/* ============ Modern-minimal tokens (Linear / Vercel) ============ */
:root{
  --bg:      oklch(99% 0.002 240);
  --surface: oklch(100% 0 0);
  --fg:      oklch(18% 0.012 250);
  --muted:   oklch(48% 0.013 250);
  --faint:   oklch(56% 0.012 250);
  --border:  oklch(92% 0.005 250);
  --border-strong: oklch(86% 0.006 250);
  --accent:  oklch(58% 0.18 255);
  --accent-soft: oklch(96% 0.03 255);
  --ok:      oklch(58% 0.13 150);
  --ok-soft: oklch(96% 0.04 150);
  --warn:    oklch(70% 0.14 70);
  --warn-text: oklch(52% 0.13 65);
  --warn-soft: oklch(96% 0.05 75);
  --danger:  oklch(56% 0.20 25);
  --danger-soft: oklch(96% 0.05 25);
  /* AI region — a restrained indigo so AI content is visually separable and can fail alone */
  --ai-fg:   oklch(46% 0.14 285);
  --ai-tint: oklch(98.5% 0.012 285);
  --ai-border: oklch(90% 0.02 285);

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-pop: 0 6px 24px -8px oklch(20% 0.03 260 / .18), 0 1px 2px oklch(20% 0.03 260 / .06);
  --font-display: -apple-system, BlinkMacSystemFont, 'SF Pro Display', system-ui, sans-serif;
  --font-body:    -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  --font-mono:    'SF Mono', ui-monospace, 'JetBrains Mono', Menlo, monospace;
}
*{box-sizing:border-box}
html,body{margin:0}
body{
  background:var(--bg); color:var(--fg); font-family:var(--font-body);
  font-size:14px; line-height:1.5; -webkit-font-smoothing:antialiased;
  font-variant-numeric:tabular-nums;
}
h1,h2,h3,h4{font-family:var(--font-display); margin:0; letter-spacing:-.02em; font-weight:600}
a{color:inherit}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px; border-radius:4px}
button{font-family:inherit; font-size:inherit; cursor:pointer}
::placeholder{color:var(--faint)}
.mono{font-family:var(--font-mono)}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* ============ Top bar ============ */
.topbar{
  position:sticky; top:0; z-index:40; height:56px; display:flex; align-items:center; gap:22px;
  padding:0 clamp(16px,4vw,40px); background:oklch(100% 0 0 / .82); backdrop-filter:saturate(1.4) blur(12px);
  border-bottom:1px solid var(--border);
}
.brand{display:flex; align-items:center; gap:9px; font-family:var(--font-display); font-weight:650; letter-spacing:-.02em}
.brand .mark{width:24px;height:24px;border-radius:7px;display:grid;place-items:center;
  background:linear-gradient(160deg, var(--accent), oklch(52% 0.2 275)); color:#fff}
.brand .mark svg{width:14px;height:14px}
.nav{display:flex; gap:2px; margin-left:6px}
.nav a{padding:7px 12px; border-radius:8px; color:var(--muted); text-decoration:none; font-weight:500}
.nav a[aria-current="page"]{color:var(--fg); background:oklch(96% 0.004 250)}
.nav a:hover{color:var(--fg)}
.topbar .spacer{flex:1}
.who{display:flex;align-items:center;gap:9px;color:var(--muted)}
.avatar{width:28px;height:28px;border-radius:50%;background:oklch(92% 0.03 255);color:var(--accent);
  display:grid;place-items:center;font-weight:600;font-size:12px}

/* ============ Shell ============ */
.wrap{max-width:1380px; margin:0 auto; padding:clamp(16px,3vw,32px) clamp(16px,4vw,40px) 96px}
.crumb{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:12.5px;margin-bottom:14px}
.crumb a{text-decoration:none;color:var(--muted)}
.crumb a:hover{color:var(--fg)}
.crumb svg{width:13px;height:13px;opacity:.6}

/* client header */
.chead{display:flex; flex-wrap:wrap; align-items:flex-start; gap:16px 22px; margin-bottom:22px}
.chead .idblock{min-width:min(100%,340px)}
.chead h1{font-size:clamp(22px,3vw,28px); display:flex; align-items:center; gap:12px; flex-wrap:wrap}
.chead .sub{color:var(--muted); margin-top:6px; display:flex; gap:14px; flex-wrap:wrap; align-items:center}
.chead .sub b{color:var(--fg); font-weight:600}
.chead .dot{width:3px;height:3px;border-radius:50%;background:var(--border-strong)}

/* status pill */
.pill{display:inline-flex; align-items:center; gap:6px; padding:3px 10px; border-radius:999px;
  font-size:12px; font-weight:600; border:1px solid transparent; white-space:nowrap}
.pill .led{width:6px;height:6px;border-radius:50%;background:currentColor}
.pill.s-new{color:oklch(50% 0.12 255); background:var(--accent-soft); border-color:var(--ai-border)}
.pill.s-active{color:oklch(48% 0.12 200); background:oklch(96% 0.04 200)}
.pill.s-hot{color:var(--danger); background:var(--danger-soft)}
.pill.s-cold{color:var(--faint); background:oklch(96% 0.004 250)}
.pill.s-lost{color:var(--muted); background:oklch(95% 0.004 250)}
.pill.s-closed{color:var(--ok); background:var(--ok-soft)}

/* understanding badge */
.understanding{margin-left:auto; max-width:520px; flex:1 1 340px;
  border:1px solid var(--ai-border); background:var(--ai-tint); border-radius:var(--radius); padding:14px 16px}
.understanding .u-top{display:flex;align-items:center;gap:9px;margin-bottom:8px}
.u-chip{font-size:10.5px; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--ai-fg);
  display:inline-flex; align-items:center; gap:5px}
.u-chip svg{width:12px;height:12px}
.u-state{margin-left:auto; font-size:11.5px; font-weight:600; display:inline-flex; align-items:center; gap:6px;
  padding:2px 9px; border-radius:999px; border:1px solid var(--ai-border); color:var(--ai-fg); background:var(--surface)}
.u-state .led{width:6px;height:6px;border-radius:50%;background:var(--ok)}
.u-state[data-state="updating"]{color:var(--warn-text)}
.u-state[data-state="updating"] .led{background:var(--warn); animation:pulse 1s infinite}
@keyframes pulse{0%,100%{opacity:1}50%{opacity:.3}}
.u-text{color:oklch(30% 0.02 285); font-size:13px; line-height:1.55}
.understanding[data-state="updating"] .u-text{color:var(--faint)}

/* ============ Layout grid ============ */
.grid{display:grid; grid-template-columns:minmax(0,1fr) 420px; gap:22px; align-items:start}
@media (max-width:1080px){ .grid{grid-template-columns:1fr} }
.col-ai{position:sticky; top:76px}
@media (max-width:1080px){ .col-ai{position:static} }

/* ============ Panels ============ */
.panel{background:var(--surface); border:1px solid var(--border); border-radius:var(--radius); margin-bottom:18px}
.panel > header{display:flex; align-items:center; gap:10px; padding:14px 18px; border-bottom:1px solid var(--border)}
.panel > header h2{font-size:14.5px; font-weight:600}
.panel > header .ico{width:26px;height:26px;border-radius:7px;display:grid;place-items:center;
  background:oklch(96% 0.01 250); color:var(--muted)}
.panel > header .ico svg{width:15px;height:15px}
.panel > header .count{font-size:11.5px;color:var(--muted);font-weight:600;background:oklch(96% 0.004 250);
  padding:2px 8px;border-radius:999px}
.panel .body{padding:18px}
.panel .fact-note{margin-left:auto; font-size:11px; color:var(--faint); display:inline-flex; align-items:center; gap:5px}
.panel .fact-note svg{width:12px;height:12px}

/* per-panel status line */
.statusline{display:flex; align-items:center; gap:7px; font-size:12px; color:var(--muted); min-height:18px}
.statusline .led{width:7px;height:7px;border-radius:50%;background:var(--border-strong);flex:none}
.statusline[data-tone="ok"]{color:var(--ok)} .statusline[data-tone="ok"] .led{background:var(--ok)}
.statusline[data-tone="load"]{color:var(--muted)} .statusline[data-tone="load"] .led{background:var(--accent);animation:pulse 1s infinite}
.statusline[data-tone="err"]{color:var(--danger)} .statusline[data-tone="err"] .led{background:var(--danger)}

/* forms */
.form-grid{display:grid; grid-template-columns:repeat(2,1fr); gap:14px 16px}
@media (max-width:540px){ .form-grid{grid-template-columns:1fr} }
.field{display:flex; flex-direction:column; gap:6px}
.field.col-2{grid-column:span 2}
@media (max-width:540px){ .field.col-2{grid-column:span 1} }
.field label{font-size:12px; font-weight:600; color:var(--muted)}
.field .hint{font-size:11px; color:var(--faint); font-weight:400}
input, select, textarea{
  width:100%; padding:9px 11px; border:1px solid var(--border-strong); border-radius:var(--radius-sm);
  background:var(--surface); color:var(--fg); font-size:13.5px; font-family:inherit;
}
textarea{resize:vertical; min-height:64px; line-height:1.5}
input:hover, select:hover, textarea:hover{border-color:var(--faint)}
input:focus, select:focus, textarea:focus{outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--accent-soft)}
.two-up{display:grid; grid-template-columns:1fr 1fr; gap:10px}
.form-foot{display:flex; align-items:center; gap:12px; margin-top:18px; padding-top:16px; border-top:1px solid var(--border)}
.form-foot .statusline{margin-right:auto}

/* buttons */
.btn{display:inline-flex; align-items:center; justify-content:center; gap:7px; padding:8px 14px; border-radius:var(--radius-sm);
  border:1px solid var(--border-strong); background:var(--surface); color:var(--fg); font-weight:600; font-size:13px;
  transition:background .12s, border-color .12s}
.btn:hover{background:oklch(97% 0.004 250)}
.btn svg{width:15px;height:15px}
.btn.primary{background:var(--accent); border-color:var(--accent); color:#fff}
.btn.primary:hover{background:oklch(54% 0.18 255)}
.btn.danger{color:var(--danger); border-color:var(--danger-soft)}
.btn.danger:hover{background:var(--danger-soft)}
.btn.ghost{border-color:transparent; background:transparent; color:var(--muted); padding:6px 10px}
.btn.ghost:hover{background:oklch(96% 0.004 250); color:var(--fg)}
.btn.sm{padding:5px 10px; font-size:12px}
.btn:disabled{opacity:.5; cursor:not-allowed}

/* list rows (declines, follow-ups, conversations) */
.rows{display:flex; flex-direction:column; gap:10px}
.row{border:1px solid var(--border); border-radius:var(--radius-sm); padding:12px 14px; background:var(--surface)}
.row.done{opacity:.62}
.row .row-top{display:flex; align-items:center; gap:10px}
.row .row-top .rlead{font-weight:600}
.row .row-meta{color:var(--muted); font-size:12.5px; margin-top:3px}
.row .row-actions{margin-left:auto; display:flex; gap:4px; flex:none}
.tag{display:inline-flex;align-items:center;gap:5px;font-size:11px;font-weight:600;padding:2px 8px;border-radius:6px;
  background:oklch(96% 0.01 250);color:var(--muted);border:1px solid var(--border)}
.tag.unit{color:var(--accent);background:var(--accent-soft);border-color:var(--ai-border)}
.tag.cat{color:oklch(48% 0.12 200);background:oklch(96% 0.04 200);border-color:transparent}
.fp-status{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.07em}
.fp-status.pending{color:var(--warn-text)} .fp-status.done{color:var(--ok)} .fp-status.skipped{color:var(--faint)}

.empty{border:1px dashed var(--border-strong); border-radius:var(--radius-sm); padding:22px; text-align:center; color:var(--muted); font-size:13px}
.empty svg{width:22px;height:22px;opacity:.5;margin-bottom:6px;display:block;margin-inline:auto}

/* seg-control */
.seg{display:inline-flex; padding:3px; gap:2px; background:oklch(96% 0.004 250); border-radius:9px; border:1px solid var(--border)}
.seg button{padding:5px 12px; border:none; background:transparent; border-radius:7px; font-weight:600; font-size:12.5px; color:var(--muted)}
.seg button[aria-selected="true"]{background:var(--surface); color:var(--fg); box-shadow:0 1px 2px oklch(20% 0 0 / .08)}

/* import dropzone */
.drop{border:1.5px dashed var(--border-strong); border-radius:var(--radius-sm); padding:20px; text-align:center; color:var(--muted);
  background:oklch(99% 0.002 250)}
.drop.hot{border-color:var(--accent); background:var(--accent-soft)}
.drop svg{width:24px;height:24px;color:var(--faint);margin-bottom:8px}
.drop b{color:var(--fg)}
.drop .browse{color:var(--accent); font-weight:600; text-decoration:underline; cursor:pointer}

/* ============ AI column ============ */
.ai-card{background:var(--ai-tint); border:1px solid var(--ai-border); border-radius:var(--radius); overflow:hidden}
.ai-card > header{display:flex; align-items:center; gap:10px; padding:14px 18px; border-bottom:1px solid var(--ai-border)}
.ai-card > header .ai-badge{display:inline-flex; align-items:center; gap:7px; font-family:var(--font-display); font-weight:650; font-size:14.5px; color:var(--ai-fg)}
.ai-card > header .ai-badge svg{width:16px;height:16px}
.ai-status{margin-left:auto; font-size:11px; color:var(--ai-fg); display:inline-flex; align-items:center; gap:6px}
.ai-status .led{width:6px;height:6px;border-radius:50%;background:var(--ok)}
.ai-status[data-tone="err"]{color:var(--danger)} .ai-status[data-tone="err"] .led{background:var(--danger)}
.ai-status[data-tone="load"] .led{background:var(--warn);animation:pulse 1s infinite}

.ai-tabs{display:flex; gap:2px; padding:10px 14px 0}
.ai-tabs button{flex:1; padding:8px; border:none; background:transparent; font-weight:600; font-size:12.5px; color:var(--muted);
  border-bottom:2px solid transparent; border-radius:6px 6px 0 0}
.ai-tabs button[aria-selected="true"]{color:var(--ai-fg); border-bottom-color:var(--ai-fg); background:oklch(100% 0 0 / .5)}
.ai-body{padding:16px 18px 20px}
.ai-panel[hidden]{display:none}

/* degrade banner */
.degrade{display:none; align-items:center; gap:10px; padding:10px 12px; margin:0 14px 12px; border-radius:var(--radius-sm);
  background:var(--warn-soft); border:1px solid oklch(88% 0.06 75); color:oklch(40% 0.09 60); font-size:12.5px}
.degrade svg{width:15px;height:15px;flex:none}
.ai-card[data-state="failed"] .degrade{display:flex}

/* ai read blocks */
.ai-sec{margin-bottom:16px}
.ai-sec:last-child{margin-bottom:0}
.ai-sec h4{font-size:11px; text-transform:uppercase; letter-spacing:.07em; color:var(--muted); margin-bottom:7px; font-weight:700}
.ai-sec p{color:oklch(28% 0.02 285); margin:0}
.arch{display:flex; align-items:center; gap:12px; padding:12px; background:var(--surface); border:1px solid var(--ai-border); border-radius:var(--radius-sm)}
.arch .ring{--v:78; width:46px;height:46px;border-radius:50%;flex:none;display:grid;place-items:center;font-weight:700;font-size:12px;color:var(--ai-fg);
  background:conic-gradient(var(--ai-fg) calc(var(--v)*1%), var(--ai-border) 0)}
.arch .ring span{width:34px;height:34px;border-radius:50%;background:var(--surface);display:grid;place-items:center}
.arch .a-name{font-weight:650; font-family:var(--font-display)}
.arch .a-sub{color:var(--muted); font-size:12.5px; margin-top:2px}
.risk{display:flex; align-items:center; gap:12px}
.risk .bar{flex:1; height:8px; border-radius:999px; background:oklch(94% 0.01 250); overflow:hidden}
.risk .bar i{display:block; height:100%; width:64%; border-radius:999px; background:linear-gradient(90deg,var(--warn),var(--danger))}
.risk .num{font-weight:700; font-family:var(--font-mono); font-size:13px}
.chips{display:flex; flex-wrap:wrap; gap:6px}
.chips .c{font-size:12px; padding:4px 10px; border-radius:7px; background:var(--surface); border:1px solid var(--ai-border); color:oklch(30% 0.02 285)}
.chips.avoid .c{color:var(--danger); border-color:var(--danger-soft); background:var(--danger-soft)}
.chips.miss .c{color:oklch(40% 0.09 60); background:var(--warn-soft); border-color:transparent}
.nextstep{padding:12px 14px; background:var(--accent-soft); border:1px solid var(--ai-border); border-radius:var(--radius-sm);
  color:oklch(34% 0.08 275); font-weight:500}
.nextstep b{display:block; font-size:11px; text-transform:uppercase; letter-spacing:.06em; color:var(--ai-fg); margin-bottom:3px}

.confirm-row{display:flex; gap:8px; margin-top:12px}
.correct-box{margin-top:10px; display:none}
.correct-box.open{display:block}
.correct-box .note{font-size:11.5px; color:var(--muted); margin:8px 0 0}

/* replies */
.reply{border:1px solid var(--ai-border); background:var(--surface); border-radius:var(--radius-sm); padding:12px 14px; margin-bottom:10px}
.reply .r-head{display:flex; align-items:center; gap:8px; margin-bottom:8px}
.reply .style{font-size:10.5px; font-weight:700; letter-spacing:.07em; text-transform:uppercase; padding:2px 8px; border-radius:6px;
  color:var(--ai-fg); background:var(--ai-tint); border:1px solid var(--ai-border)}
.reply .r-body{color:oklch(26% 0.02 285); line-height:1.55; font-size:13.5px}
.reply .btn{margin-left:auto}
.clip-note{display:flex; align-items:center; gap:7px; font-size:11.5px; color:var(--muted); margin-top:2px; padding:8px 2px 0}
.clip-note svg{width:13px;height:13px;color:var(--ok)}

/* playbook */
.pb-badge{display:inline-flex; align-items:center; gap:6px; font-size:11px; font-weight:600; color:var(--warn-text);
  background:var(--warn-soft); padding:3px 9px; border-radius:999px; border:1px solid oklch(88% 0.06 75); margin-bottom:12px}
.pb-badge svg{width:12px;height:12px}
.pb-grid{display:grid; gap:12px}
.pb-block{background:var(--surface); border:1px solid var(--ai-border); border-radius:var(--radius-sm); padding:12px 14px}
.pb-block h5{font-size:11px; text-transform:uppercase; letter-spacing:.07em; color:var(--muted); margin:0 0 8px; font-weight:700; display:flex; align-items:center; gap:6px}
.pb-block h5 svg{width:13px;height:13px}
.pb-block ul{margin:0; padding-left:16px; color:oklch(30% 0.02 285)}
.pb-block ul li{margin:3px 0}
.pb-block.dont h5{color:var(--danger)}
.pb-block p{margin:0; color:oklch(30% 0.02 285)}

/* ============ Modal ============ */
.scrim{position:fixed; inset:0; background:oklch(20% 0.02 260 / .42); backdrop-filter:blur(2px); z-index:60;
  display:none; align-items:center; justify-content:center; padding:20px}
.scrim.open{display:flex}
.modal{background:var(--surface); border:1px solid var(--border); border-radius:14px; box-shadow:var(--shadow-pop);
  width:min(560px,100%); max-height:86vh; overflow:auto}
.modal.sm{width:min(420px,100%)}
.modal header{display:flex;align-items:center;gap:10px;padding:16px 20px;border-bottom:1px solid var(--border)}
.modal header h3{font-size:16px}
.modal header .close{margin-left:auto}
.modal .m-body{padding:20px}
.modal .m-foot{display:flex;gap:10px;justify-content:flex-end;padding:16px 20px;border-top:1px solid var(--border)}
.warn-ico{width:34px;height:34px;border-radius:9px;background:var(--danger-soft);color:var(--danger);display:grid;place-items:center;flex:none}
.warn-ico svg{width:18px;height:18px}

/* transcript */
.msg{display:flex; gap:10px; margin-bottom:12px}
.msg .who-b{width:30px;height:30px;border-radius:8px;flex:none;display:grid;place-items:center;font-size:11px;font-weight:700}
.msg.agent{flex-direction:row-reverse; text-align:right}
.msg .who-b.agent{background:var(--accent-soft);color:var(--accent)}
.msg .who-b.client{background:oklch(96% 0.04 150);color:var(--ok)}
.msg .who-b.unknown{background:oklch(95% 0.004 250);color:var(--faint)}
.msg .bubble{max-width:78%; padding:9px 12px; border-radius:12px; background:oklch(97% 0.004 250); border:1px solid var(--border)}
.msg.agent .bubble{background:var(--accent-soft); border-color:var(--ai-border)}
.msg .bubble .t{font-size:10.5px;color:var(--faint);margin-top:4px}
.media-ph{display:inline-flex;align-items:center;gap:6px;color:var(--muted);font-style:italic}

/* toast */
.toast-wrap{position:fixed; bottom:24px; left:50%; transform:translateX(-50%); z-index:80; display:flex; flex-direction:column; gap:8px; align-items:center}
.toast{background:oklch(22% 0.02 260); color:#fff; padding:10px 16px; border-radius:10px; font-size:13px; font-weight:500;
  box-shadow:var(--shadow-pop); display:flex; align-items:center; gap:9px; animation:rise .2s ease}
.toast svg{width:15px;height:15px;color:oklch(80% 0.14 150)}
@keyframes rise{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:none}}

.hr{height:1px;background:var(--border);margin:16px 0}
.disclaimer{display:flex;align-items:center;gap:8px;justify-content:center;color:var(--faint);font-size:11.5px;margin-top:26px}
.disclaimer svg{width:13px;height:13px}

/* ---- polish: press feedback, balanced headings, empty state ---- */
h1,h2,h3{text-wrap:balance}
.u-text,.ai-sec p,.reply .r-body,.pb-block p,#confirm-msg,.chead .sub{text-wrap:pretty}
.btn:active{transform:translateY(1px)}
.reply:hover{border-color:var(--faint)}
.empty{animation:rise .2s ease}

/* ---- responsive: keep the top bar breathing on small screens ---- */
@media (max-width:600px){
  .topbar{gap:12px; padding:0 16px}
  .who .avatar{margin-left:2px}
  .who > span:first-child{display:none}
  .nav a{padding:7px 9px}
  .chead .understanding{margin-left:0}
}
@media (max-width:400px){
  .two-up{grid-template-columns:1fr}
  .nav{gap:0}
}

/* ---- accessibility: honour reduced-motion for every transition/loop ---- */
@media (prefers-reduced-motion: reduce){
  *,*::before,*::after{
    animation-duration:.001ms !important;
    animation-iteration-count:1 !important;
    transition-duration:.001ms !important;
    scroll-behavior:auto !important;
  }
}

/* ---- shared: skip-to-content link (WCAG 2.4.1 Bypass Blocks) ---- */
.skip-link{position:absolute; left:8px; top:-48px; z-index:100; background:var(--surface); color:var(--fg);
  border:1px solid var(--border-strong); padding:9px 14px; border-radius:8px; font-weight:600; box-shadow:var(--shadow-pop);
  transition:top .12s ease}
.skip-link:focus{top:8px}
