/* =============================================================================
   ASHTON ONE — components.css
   Every reusable component, one file. Demo'd on /styleguide (MASTER_PLAN §4).
   Components consume theme.css tokens only — no literal colors below except
   shadows derived from navy.
   ========================================================================== */

/* ---------- layout primitives ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }
.grid { display: grid; gap: 16px; }
.statgrid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ---------- tab bar ---------- */
.tabbar { display: flex; gap: 26px; border-bottom: 1px solid var(--line); padding: 0 4px; }
.tabbar a {
  padding: 13px 2px 11px; font: 600 14px var(--body); color: var(--steel);
  border-bottom: 3px solid transparent; text-decoration: none;
}
.tabbar a:hover { color: var(--ink); text-decoration: none; }
.tabbar a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--amber); }

/* ---------- alert banner ---------- */
.alert-banner {
  display: flex; align-items: center; gap: 18px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--amber);
  border-radius: var(--r); padding: 16px 20px;
}
.alert-banner .count { font: 700 34px/1 var(--display); color: var(--amber-deep); min-width: 44px; text-align: center; }
.alert-banner .msg b { font-size: 16px; }
.alert-banner .msg .sub { color: var(--steel); font-size: 13px; margin-top: 2px; }
.alert-banner .cta { margin-left: auto; }

/* ---------- stat card ---------- */
.statcard {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  border-left-width: 4px; padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 3px;
}
.statcard .label { font: 600 11px var(--body); letter-spacing: .06em; text-transform: uppercase; color: var(--steel); }
.statcard .value { font: 700 27px/1.15 var(--display); color: var(--navy); font-variant-numeric: tabular-nums; }
.statcard .cap   { font-size: 12px; color: var(--steel); }
.statcard.navy  { border-left-color: var(--navy); }
.statcard.blue  { border-left-color: var(--blue); }
.statcard.ok    { border-left-color: var(--ok); }    .statcard.ok .value   { color: var(--ok-deep); }
.statcard.amber { border-left-color: var(--amber); }
.statcard.red   { border-left-color: var(--red); }
.statcard.warn  { border-left-color: var(--warn); }

/* honest trend glyphs: equal or no-comparison shows nothing */
.trend-up   { color: var(--ok-deep); font-weight: 700; }
.trend-down { color: var(--red);     font-weight: 700; }

/* ---------- panel ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.panel-h {
  display: flex; align-items: baseline; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.panel-h h3 { font-size: 16px; }
.panel-h .annot { margin-left: auto; font: 400 11px var(--mono); color: var(--steel); }
.panel-b { padding: 16px 18px; }

/* ---------- CSS bar chart (no libraries — D6) ---------- */
.barchart { display: flex; align-items: flex-end; gap: 26px; min-height: 210px; padding: 6px 8px 0; overflow-x: auto; }
.barchart .bcol { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 52px; }
.barchart .bcount { font: 600 13px var(--body); color: var(--ink); font-variant-numeric: tabular-nums; }
.barchart .bsub   { font: 600 11px var(--mono); color: var(--ok-deep); }
.barchart .bar    { width: 34px; background: var(--navy); border-radius: 3px 3px 0 0; transition: background .12s; }
.barchart .bcol:hover .bar { background: var(--blue); }
.barchart .bdate  { font: 400 11px var(--mono); color: var(--steel); margin-top: 6px; }

/* ---------- donut (single inline SVG; ring drawn via stroke-dasharray) ---------- */
.donutwrap { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.donut { width: 132px; height: 132px; }
.donut .track { stroke: var(--line); }
.donut .ring  { stroke: var(--ok); stroke-linecap: butt; transform: rotate(-90deg); transform-origin: 50% 50%; }
.donut text.pct { font: 700 22px var(--display); fill: var(--navy); }
.donut text.plabel { font: 400 9px var(--body); fill: var(--steel); }
.donut-legend { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.donut-legend .row { display: flex; gap: 10px; align-items: baseline; }
.donut-legend .k { color: var(--ink); min-width: 110px; }
.donut-legend .v { font: 600 14px var(--mono); color: var(--ink); }

/* ---------- table ---------- */
.tbl-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tbl thead th {
  background: var(--cream); color: var(--steel); text-align: left;
  font: 600 11px var(--body); letter-spacing: .06em; text-transform: uppercase;
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl tbody td { padding: 0 12px; height: 44px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tbody tr:hover { background: var(--cream); }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.tbl td.emph { font-weight: 600; }

/* callability dot — never color-only: pair with its window label */
.calldot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: 1px; }
.calldot.prime { background: var(--ok); }
.calldot.biz   { background: var(--steel-line); }
.calldot.off   { background: transparent; border: 1.5px solid var(--steel-line); }

/* ---------- chips ---------- */
.chip {
  display: inline-block; padding: 2.5px 9px; border-radius: 999px;
  font: 600 11px var(--body); white-space: nowrap;
}
.chip.ok    { background: var(--ok-tint);    color: var(--ok-deep); }
.chip.amber { background: var(--amber-tint); color: var(--amber-deep); }
.chip.blue  { background: var(--blue-tint);  color: var(--blue); }
.chip.red   { background: var(--red-tint);   color: var(--red); }
.chip.warn  { background: var(--warn-tint);  color: var(--warn); }
.chip.mut   { background: var(--cream);      color: var(--steel); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
  border-radius: var(--r); padding: 9px 18px; font: 600 14px var(--body);
  border: 1px solid transparent; transition: filter .12s, background .12s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-outline { background: var(--surface); color: var(--ink); border-color: var(--steel-line); }
.btn-outline:hover { background: var(--cream); }
.btn-danger { background: var(--surface); color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: var(--red-tint); }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 9px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font: 600 12px var(--body); color: var(--steel); }
.field input, .field select, .field textarea {
  font: 400 14px var(--body); color: var(--ink);
  background: var(--surface); border: 1px solid var(--steel-line); border-radius: 9px; padding: 8px 11px;
}
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
.field.error input { border-color: var(--red); }
.field .help  { font-size: 12px; color: var(--steel); }
.field.error .help { color: var(--red); background: var(--red-tint); border-radius: 6px; padding: 5px 9px; }

/* ---------- drawer ---------- */
.drawer {
  width: 440px; max-width: 92vw; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
  display: flex; flex-direction: column; max-height: 82vh;
}
.drawer-h { padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.drawer-h h3 { font-size: 17px; margin-bottom: 6px; }
.drawer-b { padding: 8px 18px 14px; overflow-y: auto; }
.drawer-sec { padding: 11px 0; border-bottom: 1px solid var(--line); }
.drawer-sec:last-child { border-bottom: 0; }
.drawer-sec .sec-t { font: 600 11px var(--body); letter-spacing: .06em; text-transform: uppercase; color: var(--steel); margin-bottom: 7px; }
.kv { display: grid; grid-template-columns: 118px 1fr; gap: 4px 12px; font-size: 13.5px; }
.kv .k { color: var(--steel); }
.kv .v.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
/* click-to-copy fields: the whole value is a copy target; the ⧉ glyph hints on hover */
.kv .v.copyable { cursor: pointer; border-radius: 4px; margin: -1px -4px; padding: 1px 4px; transition: background .1s; }
.kv .v.copyable:hover { background: var(--blue-tint, rgba(11,37,69,.06)); }
.kv .v .copy-ic { opacity: 0; color: var(--steel); font-size: 11px; }
.kv .v.copyable:hover .copy-ic { opacity: .7; }
.drawer-h h3:hover { text-decoration: underline dotted; }
.drawer-f { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: center; background: var(--cream); border-radius: 0 0 var(--r) var(--r); }
.bigphone { font: 600 17px var(--mono); }

/* AI summary block — a reading aid, never the record (plan E4/F8) */
.ai-note { background: var(--blue-tint); border-radius: 9px; padding: 10px 13px; font-size: 13px; color: var(--ink); }
.ai-note .tag { font: 600 10px var(--body); letter-spacing: .07em; color: var(--blue); text-transform: uppercase; margin-right: 7px; }

/* ---------- toast ---------- */
.toast {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--ok);
  border-radius: 10px; padding: 11px 16px; box-shadow: var(--shadow); font-size: 13.5px;
}
.toast.err  { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }

/* ---------- skeleton loading ---------- */
.skel { border-radius: 8px; background: linear-gradient(90deg, var(--cream) 25%, var(--line) 45%, var(--cream) 65%); background-size: 300% 100%; animation: skel 1.1s infinite linear; }
@keyframes skel { from { background-position: 120% 0; } to { background-position: -60% 0; } }

/* ---------- empty state ---------- */
.empty { text-align: center; padding: 34px 20px; color: var(--steel); }
.empty b { color: var(--ink); display: block; margin-bottom: 4px; font-size: 15px; }

/* ---------- app shell: left sidebar + top bar (lib/nav.tsx Shell) ---------- */
.appshell { display: flex; min-height: 100vh; }
.appshell .skiplink {
  position: absolute; left: -9999px; top: 0; z-index: 300; background: var(--navy); color: #fff;
  padding: 9px 16px; border-radius: 0 0 var(--r) 0; text-decoration: none; font: 600 13px var(--body);
}
.appshell .skiplink:focus { left: 0; }

.siderail {
  /* explicit edges only — the `inset` shorthand + width over-constrains in some engines */
  position: fixed; top: 0; bottom: 0; left: 0; width: 224px; z-index: 90;
  display: flex; flex-direction: column; background: var(--navy); color: #fff;
}
.rail-min .siderail { width: 60px; }
.rail-brand { display: flex; align-items: center; gap: 10px; padding: 15px 16px 13px; }
.rb-mark {
  flex: none; width: 28px; height: 28px; border-radius: 8px; background: var(--amber); color: var(--navy);
  display: grid; place-items: center; font: 800 15px var(--display, var(--body));
}
.rb-name { font: 700 16px var(--display, var(--body)); color: #fff; letter-spacing: .01em; white-space: nowrap; }
.rb-name b { color: var(--amber); font-weight: 700; }
.rail-nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; }
.rail-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 9px;
  color: rgba(255,255,255,.72); text-decoration: none; font: 500 13.5px var(--body); white-space: nowrap;
}
.rail-nav a svg { flex: none; opacity: .85; }
.rail-nav a:hover { background: rgba(255,255,255,.10); color: #fff; }
.rail-nav a.active { background: rgba(255,255,255,.16); color: #fff; box-shadow: inset 3px 0 0 var(--amber); }
.rail-foot { display: flex; flex-direction: column; gap: 2px; padding: 10px; border-top: 1px solid rgba(255,255,255,.12); }
.rail-toggle, .rail-signout {
  display: flex; align-items: center; gap: 11px; padding: 8px 11px; border-radius: 9px; cursor: pointer;
  color: rgba(255,255,255,.62); background: none; border: none; text-decoration: none;
  font: 500 13px var(--body); white-space: nowrap; text-align: left;
}
.rail-toggle:hover, .rail-signout:hover { background: rgba(255,255,255,.10); color: #fff; }
.rail-min .rail-lbl, .rail-min .rb-name { display: none; }
.rail-min .rail-brand { justify-content: center; padding-left: 0; padding-right: 0; }
.rail-min .rail-nav a, .rail-min .rail-toggle, .rail-min .rail-signout { justify-content: center; padding-left: 0; padding-right: 0; }

.shellmain { flex: 1; margin-left: 224px; min-width: 0; }
.rail-min .shellmain { margin-left: 60px; }
.shelltop {
  position: sticky; top: 0; z-index: 80; display: flex; align-items: center; gap: 14px;
  background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 22px; height: 52px;
}
.shell-title { margin: 0; font: 650 16.5px var(--display, var(--body)); color: var(--navy); }
.shell-who { margin-left: auto; font-size: 13px; color: var(--steel); }
.shellwrap { max-width: 1240px; margin: 0 auto; padding: 18px 22px 40px; }
@media (max-width: 700px) { .shellwrap { padding: 14px 12px 32px; } .shelltop { padding: 0 12px; } }

.sessionbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 16px;
}
.sessionbar.live { background: var(--ok-tint); border-color: var(--ok); }
.sessionbar .stat { font-size: 13px; color: var(--steel); }
.sessionbar .stat b { color: var(--ink); font-family: var(--mono); }
.sessionbar .timer { font: 600 15px var(--mono); color: var(--ok-deep); }

/* ---------- outbox indicator (loss-prevention visible — charter) ---------- */
.outbox { display: inline-flex; gap: 7px; align-items: center; font-size: 12.5px; color: var(--amber-deep); background: var(--amber-tint); border-radius: 999px; padding: 4px 11px; }
.outbox.synced { color: var(--ok-deep); background: var(--ok-tint); }

/* ---------- floating dial panel + pop-out dialer (lib/dialpanel, src/dialer) ---------- */
.dialpanel {
  position: fixed; right: 18px; bottom: 18px; z-index: 150; width: 320px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 12px 34px rgba(11,37,69,.20); overflow: hidden;
}
.dp-head, .pd-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px;
  background: var(--navy); color: #fff; font: 600 13px var(--body);
}
.dp-dot { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--steel-line); }
.dp-dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(12,122,69,.28); }
.dp-count { margin-left: auto; font-size: 12px; color: rgba(255,255,255,.75); font-variant-numeric: tabular-nums; }
.dp-icon {
  background: none; border: none; color: rgba(255,255,255,.8); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 3px 5px; border-radius: 6px;
}
.dp-icon:hover { background: rgba(255,255,255,.14); color: #fff; }
.dp-body { padding: 12px; }
.dp-empty, .pd-empty { color: var(--steel); font-size: 13px; padding: 14px 4px; text-align: center; }
.dp-lead, .pd-lead { text-align: center; padding: 4px 0 12px; }
.dp-co { font: 650 15px var(--display, var(--body)); color: var(--navy); }
.dp-meta { font-size: 12px; color: var(--steel); margin-top: 1px; }
.dp-phone { display: block; margin-top: 6px; font: 600 15px var(--mono, monospace); color: var(--blue); text-decoration: none; }
.dp-actions { display: flex; align-items: center; gap: 8px; }
.dp-call { flex: 1; }
.dp-req { font: 600 11px var(--body); letter-spacing: .05em; text-transform: uppercase; color: var(--amber-deep); margin-bottom: 7px; text-align: center; }
.dp-outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.dp-outcomes .btn { justify-content: flex-start; font-size: 12px; padding: 7px 9px; text-align: left; }
.dp-hot {
  display: inline-grid; place-items: center; width: 16px; height: 16px; margin-right: 7px;
  border-radius: 4px; background: var(--cream); color: var(--steel); font: 600 10px var(--mono, monospace);
}
.dp-note { width: 100%; margin-top: 7px; }
.dp-foot { padding: 8px 12px; border-top: 1px solid var(--line); font-size: 11.5px; color: var(--steel); background: var(--cream); }
.dialpill {
  position: fixed; right: 18px; bottom: 18px; z-index: 150; display: flex; align-items: center; gap: 8px;
  padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  box-shadow: 0 8px 22px rgba(11,37,69,.18); cursor: pointer;
  font: 600 13px var(--body); color: var(--navy); font-variant-numeric: tabular-nums;
}
.dialpill:hover { background: var(--cream); }

/* the pop-out window is the same panel filling its own small window */
.popbody { background: var(--bg); margin: 0; }
.popdialer { display: flex; flex-direction: column; min-height: 100vh; background: var(--surface); }
.popdialer .pd-lead { padding: 18px 12px 14px; }
.popdialer .dp-actions, .popdialer .dp-dispo { padding: 0 14px; }
.popdialer .dp-foot { margin-top: auto; }
