/* CTEKS LeadGen Hub v12, Direction D "CTEKS Enterprise Hybrid": reusable component styles. Loaded after v12.css.
   Everything is driven by the existing tokens, so Light, Dark, Match my device, the four colour looks and the four header styles all keep working. */
:root { --avbg: var(--navy-800); --avfg: #fff; --seg-info2: #3FA7D6; }
:root[data-theme="dark"] { --avbg: var(--brand); --avfg: #05202F; --seg-info2: #6BC3EA; }
@media (prefers-color-scheme: dark) { :root[data-theme="auto"] { --avbg: var(--brand); --avfg: #05202F; --seg-info2: #6BC3EA; } }

/* page header */
.pagehead.v12head { grid-template-columns: minmax(0, 1fr) auto; padding-bottom: 16px; margin-bottom: 18px; }
.v12head .crumbs a { color: var(--muted); text-decoration: none; } .v12head .crumbs a:hover { color: var(--brand); text-decoration: underline; }
.v12head .titlerow { grid-column: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.v12head h1 { font-size: 28px; font-weight: 800; letter-spacing: -.02em; overflow-wrap: anywhere; }
.v12head .sub { grid-column: 1; }
.v12head .headactions { grid-column: 2; grid-row: 2 / span 2; flex-wrap: wrap; justify-content: flex-end; }
.rechead.v12rec { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 0; }
.rechead.v12rec .pagehead { flex: 1; min-width: 0; }
.avatar { background: var(--avbg); color: var(--avfg); }
.avatar.big { width: 64px; height: 64px; border-radius: 14px; font-size: 22px; font-weight: 800; display: grid; place-items: center; flex: none; margin-top: 18px; }
.avatar.sm { width: 32px; height: 32px; border-radius: 8px; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }

/* buttons */
a.btnlink { display: inline-flex; align-items: center; min-height: 36px; padding: 0 14px; border-radius: var(--r-sm); border: 1px solid var(--brand); background: var(--brand); color: #fff; font-weight: 600; text-decoration: none; font-size: 14px; }
a.btnlink.secondary { background: var(--btn2); color: var(--brand); border-color: #A9C6DC; }
a.btnlink:hover { filter: brightness(.96); }
button.small { padding: 3px 10px; min-height: 30px; font-size: 12.5px; }
@media (pointer: coarse) { button.small, a.btnlink { min-height: 44px; } }
button.unavail { opacity: .8; } .utag { margin-left: 8px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; background: var(--line-2); color: var(--muted); border-radius: 8px; padding: 1px 6px; }

/* KPI cards */
.card.metric { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.card.metric.static { cursor: default; background: var(--card); border: 1px solid var(--line); border-top: 3px solid var(--navy-700); border-radius: var(--r-md); padding: 12px 16px; box-shadow: var(--sh-1); }
.card.metric.static.attn { border-top-color: #D08A1E; } .card.metric.static.risk { border-top-color: var(--bad); } .card.metric.static.good { border-top-color: var(--ok); }
.metrics.hero { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
button.card.metric.hero { padding: 20px 22px 18px; border-top-width: 4px; }
button.card.metric.hero .v { font-size: 46px; font-weight: 800; letter-spacing: -.02em; }
button.card.metric.hero .hint { font-size: 13px; }
.card.metric.mini, button.card.metric.mini { padding: 10px 14px; }
.card.metric.mini .v { font-size: 24px; }
.stattiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stattiles.rec { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.card.metric.gauge { flex-direction: column; align-items: flex-start; }

/* charts */
.stack { width: 100%; height: 22px; display: block; }
.seg.info, .dseg.info { fill: var(--brand); stroke: var(--brand); } .seg.info2, .dseg.info2 { fill: var(--seg-info2); stroke: var(--seg-info2); }
.seg.warn, .dseg.warn { fill: #D08A1E; stroke: #D08A1E; } .seg.good, .dseg.good { fill: var(--ok); stroke: var(--ok); } .seg.bad, .dseg.bad { fill: var(--bad); stroke: var(--bad); }
.seg.review, .dseg.review { fill: var(--review); stroke: var(--review); } .seg.none { fill: var(--line); }
.seg { stroke: none; } .dseg.info, .dseg.info2, .dseg.warn, .dseg.good, .dseg.bad, .dseg.review { fill: none; }
.dtrack, .rtrack { fill: none; stroke: var(--line); }
.dcenter { font-size: 22px; font-weight: 800; fill: var(--head); }
.donutbox { display: flex; align-items: center; gap: 20px; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line-2); flex-wrap: wrap; }
.donut { width: 120px; height: 120px; flex: none; }
.donutbox h3 { margin: 0 0 6px; font-size: 14px; }
.stackbox { margin: 8px 0; }
.legend2 { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.donutbox .legend2 { flex-direction: column; gap: 4px; }
.legend2 b { color: var(--ink); margin-left: 2px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; background: var(--brand); }
.dot.info2 { background: var(--seg-info2); } .dot.warn { background: #D08A1E; } .dot.good { background: var(--ok); } .dot.bad { background: var(--bad); } .dot.review { background: var(--review); }
.ring .rval { stroke: var(--brand); } .ring.good .rval { stroke: var(--ok); } .ring.warn .rval { stroke: #D08A1E; } .ring.bad .rval { stroke: var(--bad); }
.rtext { font-size: 14px; font-weight: 700; fill: var(--ink); }
.fitcell { display: inline-flex; align-items: center; gap: 8px; }

/* panels and states */
.emptybox { border: 1px dashed var(--line); border-radius: var(--r-md); padding: 22px; text-align: center; background: var(--card); }
.emptybox p { margin: 4px 0 0; }
details.critbox, details.addco { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); padding: 0 18px 12px; margin: 0 0 16px; box-shadow: var(--sh-1); }
details.critbox > summary, details.addco > summary { padding: 14px 0; font-weight: 700; cursor: pointer; color: var(--head); font-size: 15px; }
details.critbox form.panel { border: 0; box-shadow: none; padding: 0 0 6px; background: none; }
.compcard { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md); margin-bottom: 10px; }
.pcard { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line-2); display: grid; gap: 8px; }

/* dashboard */
.worklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.worklist li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.worklist .wtext { flex: 1; }
.wcount { min-width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; background: var(--line-2); color: var(--muted); }
.wcount.on { background: var(--brand-50); color: var(--brand); }
.gatesum { display: flex; align-items: baseline; gap: 10px; margin: 4px 0 10px; flex-wrap: wrap; }
.gnum { font-size: 26px; font-weight: 800; color: var(--head); }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.steps li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.steps p { margin: 2px 0 0; }
.recright { display: grid; gap: 16px; align-content: start; }
.recright .panel { margin: 0; }

/* tables and lists */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); }
.tablewrap table { border-radius: 0; margin: 0; }
.dlist .toolspacer { flex: 1 1 8px; }
.dlist .tbtn { font-size: 12.5px; padding: 5px 10px; min-height: 32px; }
.dlist.dense td { padding: 5px 10px; font-size: 13px; } .dlist.dense th { padding: 6px 10px; } .dlist.dense .avatar.sm { width: 24px; height: 24px; font-size: 10px; border-radius: 6px; }
.cname { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.ctext { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; } .ctext small { color: var(--muted); font-size: 12px; }
.tab.mine { border-style: dashed; }
.chips2 { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 8px; }
.fchip { display: inline-flex; align-items: center; gap: 4px; background: var(--brand-50); color: var(--ink); border: 1px solid var(--line); border-radius: 999px; padding: 2px 4px 2px 12px; font-size: 12.5px; }
.fchip button { background: none; border: 0; color: var(--muted); padding: 0 8px; min-height: 26px; font-size: 16px; line-height: 1; }
.fchip button:hover:not(:disabled) { background: none; color: var(--bad); }
.saveview { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); }
.rowactions { display: inline-flex; gap: 6px; flex-wrap: wrap; }

/* master and detail */
.splitq.open, .discgrid.open { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.qdetail, .discgrid.open > #discdetail { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow: auto; }
.discmain, .qlist { min-width: 0; }
@media (max-width: 1100px) { .splitq.open, .discgrid.open { grid-template-columns: 1fr; } .qdetail, .discgrid.open > #discdetail { position: static; max-height: none; } }

/* pipeline columns by stage */
.kcol { background: var(--surface-2); border-top: 4px solid var(--brand); }
.kcol.st-info2 { border-top-color: var(--seg-info2); } .kcol.st-warn { border-top-color: #D08A1E; } .kcol.st-good { border-top-color: var(--ok); } .kcol.st-bad, .kcol.restricted { border-top-color: var(--bad); background: var(--surface-2); } .kcol.st-review { border-top-color: var(--review); }
.kcard .kmeta { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
:root[data-theme="dark"] .kcard { background: var(--card); }

/* phone bottom bar */
.tabbar { display: none; }
@media (max-width: 900px) {
  .tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--card); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom, 0px)); box-shadow: 0 -4px 14px rgba(16, 42, 67, .10); }
  body.signedout .tabbar { display: none; }
  .tabitem { display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 0; color: var(--ink-2); font-size: 11.5px; font-weight: 600; min-height: 52px; padding: 4px 2px; border-radius: var(--r-sm); }
  .tabitem:hover:not(:disabled) { background: var(--brand-50); }
  .tabitem[aria-current="page"] { color: var(--brand); } .tabitem[aria-current="page"] .ico { background: var(--brand-50); }
  .tabitem .ico { width: 44px; height: 26px; border-radius: 13px; display: grid; place-items: center; }
  .tabitem .ico svg { width: 20px; height: 20px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
  body { padding-bottom: 64px; }
  .toasts { bottom: 76px; }
  .v12head { grid-template-columns: 1fr; } .v12head .headactions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
  .v12head h1 { font-size: 24px; }
  .rechead.v12rec { flex-direction: column; gap: 0; } .avatar.big { width: 48px; height: 48px; font-size: 18px; margin-top: 8px; }
  .metrics.hero { grid-template-columns: 1fr; } button.card.metric.hero .v { font-size: 38px; }
  .stattiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .dlist .toolbar { gap: 8px; } .dlist .tbtn { flex: 1 1 auto; }
  .donutbox { justify-content: flex-start; }
  .cname { width: 100%; }
}
@media (prefers-reduced-motion: no-preference) { .card.metric, .kcard, .tab { transition: box-shadow .15s, border-color .15s, background .15s; } }

.metrics:not(.hero) { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.top button, .top .who .name { white-space: nowrap; } .topactions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; } .top .who { flex-shrink: 0; }
.gate { gap: 10px; } .gate .pill { white-space: nowrap; font-size: 11px; flex: none; }
.cmd .panel h2.tight + p { margin-top: 0; }
.discgrid.open { grid-template-columns: minmax(0, 1.8fr) minmax(320px, 1fr); }
.discmain td, .discmain th { padding-left: 8px; padding-right: 8px; }
.discmain button.linkbtn { text-align: left; }
.board { grid-auto-columns: minmax(200px, 1fr); }

/* Phone top bar: let the environment badge shrink so the bar never scrolls sideways */
@media (max-width: 900px) {
  .top { grid-template-columns: auto auto minmax(0, 1fr) auto auto; }
  #envbadge { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .top .topactions { min-width: 0; }
}

/* Outreach Command Center (simulated): meters and spacing */
.ocview .meterrow { margin: 8px 0 12px; }
.ocview .meterrow label { display: grid; gap: 4px; font-size: 13px; color: var(--ink, inherit); }
.ocview progress { width: 100%; max-width: 420px; height: 12px; accent-color: var(--brand, #005F99); }
.ocview .tabpane { margin-top: 12px; display: grid; gap: 14px; }
.ocview .probe ul { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 4px; }
.ocview details.probe > summary { min-height: 24px; padding: 4px 0; display: inline-block; cursor: pointer; }

.ocview .thread { display: grid; gap: 10px; margin: 12px 0; }
.ocview .bubble { border: 1px solid var(--line, #d0d7de); border-radius: 10px; padding: 10px 12px; max-width: 760px; background: var(--card, #fff); overflow-wrap: anywhere; }
.ocview .bubble.out { border-left: 4px solid var(--brand, #005F99); }
.ocview .bubble.in { border-left: 4px solid #1a7f37; margin-left: 24px; }
.ocview .bubble header { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 4px; }
.ocview .bubble p { margin: 6px 0 0; }
.chart .drill { cursor: pointer; }
.chart .drill:hover rect, .chart .drill:focus rect { opacity: .8; }
.chart .drill:focus { outline: none; }
.chart .drill:focus-visible text.ct { text-decoration: underline; }
.chartkey { display: flex; flex-wrap: wrap; gap: 6px 16px; list-style: none; margin: 6px 0 0; padding: 0; font-size: 13px; }
.chartkey li { display: inline-flex; align-items: center; gap: 6px; }
.chartkey .swatch { width: 12px; height: 12px; border-radius: 2px; background: var(--brand, #0b5189); display: inline-block; }
.chartkey .swatch.good { background: var(--ok, #1f8a4c); } .chartkey .swatch.bad { background: var(--bad, #c0392b); } .chartkey .swatch.warn { background: #C27A12; }
.chartbox svg.chart { max-width: 640px; }
