/* One System. Layout: fixed sidebar + one working column; tables scroll inside their own box. */
:root {
  --paper: #f4f7f5;
  --card: #ffffff;
  --ink: #15211d;
  --muted: #5b6b65;
  --line: #d6dfda;
  --accent: #0d6a58;
  --accent-ink: #ffffff;
  --accent-soft: #dcefe9;
  --side: #10231e;
  --side-ink: #dbe8e3;
  --side-muted: #8ea69e;
  --good: #1f7a4a; --good-bg: #dff2e6;
  --warn: #8a5a00; --warn-bg: #fbecc8;
  --bad: #a3312b;  --bad-bg: #f8dedb;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper: #0f1614; --card: #17211e; --ink: #e6efeb; --muted: #9bb0a8; --line: #2a3a35;
    --accent: #3fb79f; --accent-ink: #06231d; --accent-soft: #173a33;
    --side: #0a120f; --side-ink: #dbe8e3; --side-muted: #7f978f;
    --good: #6fd39b; --good-bg: #153524; --warn: #f0c060; --warn-bg: #3b2d0c; --bad: #f09088; --bad-bg: #40191a;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 1.7rem; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.02rem; font-weight: 650; }
p { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.break { word-break: break-all; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 0.9em; white-space: nowrap; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* shell */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }
.side { background: var(--side); color: var(--side-ink); padding: 20px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 1.1rem; letter-spacing: -0.01em; color: inherit; padding: 0 8px; }
.side .brand:hover { text-decoration: none; }
.client { display: flex; flex-direction: column; gap: 2px; padding: 10px 8px; border: 1px solid #ffffff1f; border-radius: 8px; }
.client-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--side-muted); }
.client-name { font-weight: 600; }
.client-switch { font-size: 0.82rem; color: #7fd6c2; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item { color: var(--side-ink); padding: 7px 8px; border-radius: 6px; }
.nav-item:hover { background: #ffffff14; text-decoration: none; }
.nav-item.is-active { background: #ffffff22; font-weight: 600; }
.who { margin-top: auto; padding: 10px 8px 0; border-top: 1px solid #ffffff1f; display: flex; flex-direction: column; gap: 2px; }
.who-name { color: var(--side-ink); font-weight: 600; }
.who-role { color: var(--side-muted); font-size: 0.82rem; }
.link-button { background: none; border: 0; padding: 4px 0; color: #7fd6c2; font: inherit; cursor: pointer; text-align: left; }
.main { padding: 28px 32px 60px; display: flex; flex-direction: column; gap: 20px; min-width: 0; max-width: 1240px; }
.page-head { display: flex; flex-direction: column; gap: 6px; }
.crumb { font-size: 0.88rem; }

/* building blocks */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel.flush { padding: 0; gap: 0; overflow: hidden; }
.panel.narrow { max-width: 460px; }
.pad { padding: 16px 18px 10px; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; color: inherit; }
a.tile:hover { border-color: var(--accent); text-decoration: none; }
.tile b { font-size: 1.8rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.15; }
.tile span { color: var(--muted); font-size: 0.86rem; }
.scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th, .table td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table thead th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; background: var(--paper); white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact td { padding: 7px 4px; }
.table td.num { text-align: left; }
.clip { max-width: 420px; overflow-wrap: anywhere; }
.empty { color: var(--muted); padding: 26px 14px; text-align: center; }
.pager { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; }
.pager-links { display: flex; gap: 14px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.pill-good { color: var(--good); background: var(--good-bg); }
.pill-warn { color: var(--warn); background: var(--warn-bg); }
.pill-bad { color: var(--bad); background: var(--bad-bg); }
.pill-plain { color: var(--muted); background: var(--paper); border: 1px solid var(--line); }
.note { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 6px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
.note.ok { border-left-color: var(--good); }
.note.bad { border-left-color: var(--bad); color: var(--bad); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.plain-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.transcript { display: flex; flex-direction: column; gap: 8px; max-height: 520px; overflow-y: auto; }
.turn { padding: 8px 12px; border-radius: 8px; max-width: 78ch; }
.turn b { display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.turn-agent { background: var(--accent-soft); }
.turn-lead { background: var(--paper); border: 1px solid var(--line); }

/* forms */
label { font-weight: 600; font-size: 0.88rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%; }
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }
.hint { color: var(--muted); font-size: 0.82rem; margin-top: -6px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.stack .button { align-self: flex-start; margin-top: 6px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input[type="search"] { max-width: 340px; }
.filters select { width: auto; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form select { width: auto; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; align-items: end; }
.grid-form > div { display: flex; flex-direction: column; gap: 6px; }
.button { font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 1px solid var(--accent); border-radius: 6px; padding: 8px 14px; cursor: pointer; white-space: nowrap; }
.button:hover { filter: brightness(1.08); }
.button.secondary { background: transparent; color: var(--accent); }
.button.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.client-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.client-card .button { align-self: flex-start; }

/* sign-in */
.auth-body { display: grid; place-items: center; padding: 24px 16px; min-height: 100%; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.auth-card .brand { color: var(--accent); padding: 0; }
.auth-card .stack .button { align-self: stretch; }
.auth-foot { font-size: 0.9rem; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .who { margin: 0; border: 0; padding: 0; flex-direction: row; gap: 10px; align-items: center; }
  .main { padding: 18px 16px 48px; }
}
@media (prefers-reduced-motion: no-preference) { .nav-item, .tile, .button { transition: background-color .12s, border-color .12s, filter .12s; } }

/* ---- phase 3: workspace ---- */
.head-row { flex-direction: row; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.head-row > div:first-child { display: flex; flex-direction: column; gap: 6px; }
a.button { display: inline-block; }
a.button:hover { text-decoration: none; }
.small-button { padding: 4px 10px; font-size: 0.84rem; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; background: var(--card); color: var(--ink); font-size: 0.88rem; }
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip.is-on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .num { opacity: 0.75; }
.chart { width: 100%; min-width: 520px; height: 190px; display: block; }
.chart-bar { fill: var(--accent-soft); }
.chart-bar-strong { fill: var(--accent); }
.chart-axis { stroke: var(--line); stroke-width: 1; }
.chart-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font-size: 0.84rem; }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; vertical-align: baseline; }
.key-all { background: var(--accent-soft); border: 1px solid var(--line); }
.key-strong { background: var(--accent); }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--muted); }
.steps li.is-done { color: var(--ink); }
.steps li.is-done::marker { color: var(--good); }
.steps li.is-stopped { color: var(--bad); }
.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.task-list li { display: flex; gap: 10px; align-items: flex-start; }
.task-list li.is-done b { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; align-items: start; }
.board-col { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.board-col h2 { display: flex; justify-content: space-between; }
.board-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: flex; flex-direction: column; gap: 6px; background: var(--paper); }
.month { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
.month th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px; text-align: left; background: var(--paper); border-bottom: 1px solid var(--line); }
.month td { height: 104px; vertical-align: top; padding: 6px; border: 1px solid var(--line); }
.month td.is-other { background: var(--paper); color: var(--muted); }
.month td.is-today .day-number { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 7px; }
.day-number { font-size: 0.82rem; font-weight: 600; display: inline-block; margin-bottom: 4px; }
.event { display: block; font-size: 0.78rem; border-radius: 4px; padding: 2px 6px; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.event-booking { background: var(--accent); color: var(--accent-ink); }
.event-follow_up { background: var(--accent-soft); border: 1px solid var(--line); }
a.event:hover { text-decoration: none; filter: brightness(1.08); }
input[type="file"] { padding: 6px; }
