/* Savod Call Analyzer — design system (no framework).
   Tokens → base → layout → components → pages → responsive. Light + dark (system preference, overridable with the header toggle). */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f1f4f8;
  --surface-3: #e6ebf1;
  --border: #dfe5ec;
  --border-strong: #c4cdd8;
  --text: #0e1726;
  --text-2: #334155;
  --muted: #556274;

  --primary: #0f766e;
  --primary-hover: #0d5f59;
  --primary-soft: #e1f2ef;
  --primary-text: #0b6b63;
  --on-primary: #ffffff;

  --success: #15803d;  --success-soft: #dcf5e4;
  --warning: #a16207;  --warning-soft: #fdf1c7;
  --danger: #b42318;   --danger-soft: #fde4e1;
  --info: #1d4ed8;     --info-soft: #dfe9fd;
  --violet: #6d28d9;   --violet-soft: #ece5fd;
  --neutral: #4b5869;  --neutral-soft: #edf0f4;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, 0.06);
  --shadow: 0 1px 3px rgba(15, 27, 45, 0.08), 0 4px 14px rgba(15, 27, 45, 0.05);
  --ring: 0 0 0 3px rgba(15, 118, 110, 0.25);

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 58px;
  color-scheme: light;
}

/* Dark theme: explicit choice (data-theme="dark") or the system preference unless "light" was chosen. */
:root[data-theme="dark"] {
  --bg: #090e14;
  --surface: #131b26;
  --surface-2: #1a2430;
  --surface-3: #233140;
  --border: #273443;
  --border-strong: #3b4b5e;
  --text: #e8eef5;
  --text-2: #c5d0dc;
  --muted: #97a6b8;

  --primary: #25a294;
  --primary-hover: #2fb3a4;
  --primary-soft: rgba(37, 162, 148, 0.16);
  --primary-text: #62d6c7;
  --on-primary: #03201c;

  --success: #6fdc95;  --success-soft: rgba(52, 199, 105, 0.16);
  --warning: #f2c55c;  --warning-soft: rgba(234, 179, 8, 0.16);
  --danger: #ff8f84;   --danger-soft: rgba(239, 68, 68, 0.17);
  --info: #8db4ff;     --info-soft: rgba(59, 130, 246, 0.17);
  --violet: #c1a6ff;   --violet-soft: rgba(139, 92, 246, 0.18);
  --neutral: #b4c0cf;  --neutral-soft: rgba(148, 163, 184, 0.14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.25);
  --ring: 0 0 0 3px rgba(43, 179, 163, 0.35);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090e14;
    --surface: #131b26;
    --surface-2: #1a2430;
    --surface-3: #233140;
    --border: #273443;
    --border-strong: #3b4b5e;
    --text: #e8eef5;
    --text-2: #c5d0dc;
    --muted: #97a6b8;

    --primary: #25a294;
    --primary-hover: #2fb3a4;
    --primary-soft: rgba(37, 162, 148, 0.16);
    --primary-text: #62d6c7;
    --on-primary: #03201c;

    --success: #6fdc95;  --success-soft: rgba(52, 199, 105, 0.16);
    --warning: #f2c55c;  --warning-soft: rgba(234, 179, 8, 0.16);
    --danger: #ff8f84;   --danger-soft: rgba(239, 68, 68, 0.17);
    --info: #8db4ff;     --info-soft: rgba(59, 130, 246, 0.17);
    --violet: #c1a6ff;   --violet-soft: rgba(139, 92, 246, 0.18);
    --neutral: #b4c0cf;  --neutral-soft: rgba(148, 163, 184, 0.14);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 6px 18px rgba(0, 0, 0, 0.25);
    --ring: 0 0 0 3px rgba(43, 179, 163, 0.35);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 14.5px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--primary-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 0.6em; }
ul { margin: 0; padding-left: 1.2em; }
li + li { margin-top: 4px; }
code { font-family: var(--mono); font-size: 0.9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
.icon-sm { width: 15px; height: 15px; }

/* ---------- layout ---------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}
.app-header .inner { max-width: 1320px; margin: 0 auto; height: 100%; padding: 0 20px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff; font-weight: 800; font-size: 16px;
  box-shadow: var(--shadow-sm);
}
.brand small { display: block; font-weight: 500; font-size: 11.5px; color: var(--muted); margin-top: -2px; }
.top-nav { display: flex; gap: 4px; flex: 1; }
.top-nav a {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px;
  color: var(--text-2); font-weight: 550;
}
.top-nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.top-nav a.active { background: var(--primary-soft); color: var(--primary-text); }
.header-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.theme-toggle { width: 36px; height: 36px; padding: 0; border-radius: 10px; background: transparent; color: var(--text-2); border: 1px solid var(--border); }
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle .icon { width: 18px; height: 18px; }
.theme-toggle .i-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .i-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .i-sun { display: block; }
  :root:not([data-theme="light"]) .theme-toggle .i-moon { display: none; }
}
.auth-theme { position: fixed; top: 14px; right: 14px; }

main.container { max-width: 1320px; margin: 0 auto; padding: 20px 20px 40px; }
.app-footer { max-width: 1320px; margin: 0 auto; padding: 8px 20px 28px; color: var(--muted); font-size: 12px; }

.bottom-nav { display: none; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 550; margin-bottom: 10px; }
.back-link:hover { color: var(--text); text-decoration: none; }
.detail-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.detail-top .back-link { margin-bottom: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 16px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-body { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head h2 { display: flex; align-items: center; gap: 8px; }
.card-head .hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.card + .card { margin-top: 16px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---------- forms ---------- */
label, .label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field { display: block; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input:not([type]), select, textarea {
  width: 100%; height: 38px; padding: 0 11px;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 8px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; padding: 10px 11px; line-height: 1.5; resize: vertical; }
select { appearance: none; padding-right: 32px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7a8f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 550; color: var(--text); cursor: pointer; margin: 0; }
.switch input { appearance: none; width: 40px; height: 22px; border-radius: 999px; background: var(--surface-3); position: relative; cursor: pointer; transition: background .15s; flex: none; border: 1px solid var(--border-strong); }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s; }
.switch input:checked { background: var(--primary); border-color: var(--primary); }
.switch input:checked::after { transform: translateX(18px); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 34px; }

/* ---------- buttons ---------- */
.btn, button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer;
  background: var(--primary); color: var(--on-primary);
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover, button:hover { background: var(--primary-hover); text-decoration: none; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn-icon { width: 38px; padding: 0; }
.link-button { background: none; border: 0; height: auto; padding: 0; color: var(--primary-text); font-weight: 550; }
.link-button:hover { background: none; text-decoration: underline; }
.inline-form { display: inline; margin: 0; }
button[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- badges & pills ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: var(--neutral-soft); color: var(--neutral);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-success { background: var(--success-soft); color: var(--success); }
.b-warning { background: var(--warning-soft); color: var(--warning); }
.b-danger { background: var(--danger-soft); color: var(--danger); }
.b-info { background: var(--info-soft); color: var(--info); }
.b-violet { background: var(--violet-soft); color: var(--violet); }
.b-primary { background: var(--primary-soft); color: var(--primary-text); }
.cat-sotuv { background: var(--info-soft); color: var(--info); }
.cat-oquvchi { background: var(--violet-soft); color: var(--violet); }
.cat-hamkasb, .cat-boshqa { background: var(--neutral-soft); color: var(--neutral); }

.score {
  display: inline-grid; place-items: center; min-width: 40px; height: 26px; padding: 0 7px;
  border-radius: 7px; font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
}
.score-low { background: var(--danger-soft); color: var(--danger); }
.score-mid { background: var(--warning-soft); color: var(--warning); }
.score-high { background: var(--success-soft); color: var(--success); }
.score-none { color: var(--muted); }

.dir { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; }
.dir-in { background: var(--success-soft); color: var(--success); }
.dir-out { background: var(--info-soft); color: var(--info); }
.dir .icon { width: 15px; height: 15px; stroke-width: 2.4; }

.live { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 0 rgba(21, 128, 61, .5); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(21, 128, 61, .45); } 70% { box-shadow: 0 0 0 7px rgba(21, 128, 61, 0); } 100% { box-shadow: 0 0 0 0 rgba(21, 128, 61, 0); } }

/* ---------- notices ---------- */
.notice { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--radius); margin: 0 0 16px; font-size: 13.5px; border: 1px solid transparent; }
.notice .icon { margin-top: 1px; }
.notice.ok { background: var(--success-soft); color: var(--success); }
.notice.warn { background: var(--warning-soft); color: var(--warning); }
.notice.error { background: var(--danger-soft); color: var(--danger); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice a { color: inherit; font-weight: 700; text-decoration: underline; }

/* ---------- segmented & chips ---------- */
.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; flex-wrap: wrap; }
.segmented a { padding: 6px 12px; border-radius: 7px; color: var(--text-2); font-weight: 600; font-size: 13px; white-space: nowrap; }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-weight: 600; font-size: 13px; white-space: nowrap;
}
.chip:hover { text-decoration: none; border-color: var(--primary); color: var(--text); }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.chip.removable { background: var(--primary-soft); color: var(--primary-text); border-color: transparent; }
.chip.removable .icon { width: 14px; height: 14px; }

/* ---------- toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .search { flex: 1 1 260px; max-width: 420px; }
.filter-panel { margin-bottom: 14px; }
.filter-panel > summary { list-style: none; }
.filter-panel > summary::-webkit-details-marker { display: none; }
.filter-panel[open] > summary { background: var(--surface-2); }
.filter-panel .panel { margin-top: 10px; padding: 16px; }
.active-filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 10px; }
.kpi {
  display: block; position: relative; padding: 14px 16px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-sm); color: var(--text);
}
a.kpi:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }
.kpi .k-label { font-size: 12.5px; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 1px; }
.kpi .k-dot { width: 8px; height: 8px; border-radius: 3px; }
.hidden-note { font-size: 12.5px; color: var(--muted); margin: 0 0 14px; display: flex; gap: 6px; align-items: flex-start; }
.hidden-note .icon { margin-top: 1px; }

/* ---------- call list ---------- */
.calls { overflow: hidden; }
.call-row {
  display: grid;
  grid-template-columns: 30px 92px minmax(120px, 1.1fr) 148px 54px 100px 50px 150px minmax(160px, 2.2fr);
  column-gap: 14px; align-items: center;
  padding: 11px 18px; border-bottom: 1px solid var(--border); color: var(--text);
}
.call-row:last-child { border-bottom: 0; }
.call-row > *, .c-meta > * { grid-row: 1; }
a.call-row:hover { background: var(--surface-2); text-decoration: none; }
a.call-row:focus-visible { box-shadow: inset 0 0 0 2px var(--primary); border-radius: 0; }
.call-row.head { padding-top: 10px; padding-bottom: 10px; background: var(--surface-2); font-size: 12px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.call-row.head a { color: var(--muted); }
.call-row.head a.sorted { color: var(--text); }
.call-row.head > * { color: var(--muted); font-size: 12px; font-weight: 650; }
.c-meta { display: contents; }
.c-dir { grid-column: 1; }
.c-time { grid-column: 2; font-variant-numeric: tabular-nums; color: var(--text-2); }
.c-time b { color: var(--text); font-weight: 650; }
.c-op { grid-column: 3; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-client { grid-column: 4; font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; }
.c-dur { grid-column: 5; font-variant-numeric: tabular-nums; color: var(--text-2); }
.c-cat { grid-column: 6; }
.c-score { grid-column: 7; }
.c-res { grid-column: 8; min-width: 0; }
.c-sum { grid-column: 9; color: var(--text-2); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.c-meta .sep { display: none; }
.c-res { overflow: hidden; }
.c-res .badge { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; }
.c-res .badge .dot { display: inline-block; margin-right: 5px; vertical-align: 1px; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .icon { width: 36px; height: 36px; stroke-width: 1.5; margin-bottom: 8px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ---------- call detail ---------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 16px; align-items: start; }
.call-hero { display: flex; gap: 14px; align-items: flex-start; }
.call-hero .dir { width: 44px; height: 44px; border-radius: 12px; }
.call-hero .dir .icon { width: 22px; height: 22px; }
.call-hero h1 { font-size: 19px; }
.call-hero .sub { color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px 18px; margin: 16px 0 0; }
.meta-grid dt { font-size: 12px; color: var(--muted); font-weight: 600; }
.meta-grid dd { margin: 2px 0 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.player { width: 100%; margin-top: 16px; height: 40px; }
.score-hero { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.ring {
  --p: 0; --c: var(--primary);
  width: 92px; height: 92px; border-radius: 50%; flex: none;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-3) 0);
  display: grid; place-items: center;
}
.ring::before { content: ""; grid-area: 1 / 1; width: 74px; height: 74px; border-radius: 50%; background: var(--surface); }
.ring span { grid-area: 1 / 1; position: relative; font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.ring small { display: block; font-size: 11px; color: var(--muted); text-align: center; font-weight: 600; margin-top: -4px; }
.ring.low { --c: var(--danger); } .ring.mid { --c: var(--warning); } .ring.high { --c: var(--success); }
.score-facts { display: grid; gap: 6px; }
.score-facts .row { gap: 6px; }
.criteria { display: grid; gap: 14px; margin-top: 4px; }
.crit-top { display: flex; align-items: baseline; gap: 10px; }
.crit-name { font-weight: 650; }
.crit-weight { font-size: 12px; color: var(--muted); }
.crit-val { margin-left: auto; font-weight: 750; font-variant-numeric: tabular-nums; }
.bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 6px 0 5px; }
.bar > i { display: block; height: 100%; border-radius: inherit; background: var(--primary); }
.bar.low > i { background: var(--danger); } .bar.mid > i { background: var(--warning); } .bar.high > i { background: var(--success); }
.crit-comment { font-size: 13px; color: var(--text-2); }
.callouts { display: grid; gap: 10px; }
.callout { border-radius: var(--radius); padding: 12px 14px; border-left: 3px solid; }
.callout h3 { font-size: 13px; margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.callout ul { font-size: 13.5px; }
.callout.good { background: var(--success-soft); border-color: var(--success); }
.callout.bad { background: var(--warning-soft); border-color: var(--warning); }
.callout.tip { background: var(--info-soft); border-color: var(--info); }
.callout.good h3 { color: var(--success); } .callout.bad h3 { color: var(--warning); } .callout.tip h3 { color: var(--info); }
.callout li { color: var(--text); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chat { display: flex; flex-direction: column; gap: 8px; }
.bubble { max-width: 80%; padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.bubble .who { display: flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 700; margin-bottom: 2px; color: var(--muted); }
.bubble .ts { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--primary-text); background: none; border: 0; padding: 0; height: auto; font-size: 11.5px; cursor: pointer; }
.bubble .ts:hover { text-decoration: underline; background: none; }
.bubble.op { align-self: flex-start; background: var(--primary-soft); border-bottom-left-radius: 4px; }
.bubble.client { align-self: flex-end; background: var(--surface-2); border-bottom-right-radius: 4px; }
.bubble.other { align-self: center; background: var(--warning-soft); }
.actions { display: grid; gap: 8px; }
.actions form { margin: 0; }
.actions .btn, .actions button { width: 100%; justify-content: flex-start; }
.history { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.history th, .history td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.history th { color: var(--muted); font-weight: 600; }

details > summary { cursor: pointer; }
details.disclosure > summary { list-style: none; display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-2); padding: 12px 20px; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: ""; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-left: auto; transition: transform .15s; }
details.disclosure[open] > summary::after { transform: rotate(-135deg); }

/* ---------- settings / prompts ---------- */
.subnav {
  position: sticky; top: var(--header-h); z-index: 20; display: flex; gap: 4px; overflow-x: auto;
  padding: 10px 0; margin: -10px 0 14px; background: var(--bg); scrollbar-width: none;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a { padding: 7px 12px; border-radius: 8px; color: var(--text-2); font-weight: 600; font-size: 13px; white-space: nowrap; border: 1px solid var(--border); background: var(--surface); }
.subnav a:hover { text-decoration: none; border-color: var(--border-strong); color: var(--text); }
section[id] { scroll-margin-top: calc(var(--header-h) + 60px); }
.status-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.status-item { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.status-item .s-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.status-item .s-value { margin-top: 3px; font-weight: 650; display: flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; }
.state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.state-dot.ok { background: var(--success); } .state-dot.bad { background: var(--danger); } .state-dot.warn { background: var(--warning); }
.list-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.list-table th, .list-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.list-table th { font-size: 12px; color: var(--muted); font-weight: 600; }
.list-table tr:last-child td { border-bottom: 0; }
textarea.prompt { font-family: var(--mono); font-size: 12.5px; min-height: 380px; }
pre.result { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; max-height: 420px; overflow: auto; background: var(--surface-2); padding: 12px; border-radius: var(--radius); margin: 8px 0 0; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 50% -10%, var(--primary-soft), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card .brand { justify-content: center; margin-bottom: 18px; font-size: 17px; }
.auth-card .brand-mark { width: 40px; height: 40px; font-size: 19px; border-radius: 11px; }
.auth-card h1 { font-size: 19px; text-align: center; }
.auth-card .sub { text-align: center; color: var(--muted); margin: 4px 0 18px; }
.auth-card .field + .field { margin-top: 12px; }
.auth-card button { width: 100%; margin-top: 18px; height: 42px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .call-row { grid-template-columns: 30px 86px minmax(110px, 1fr) 140px 50px 96px 48px 140px; }
  .c-sum { display: none; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-grid { grid-template-columns: minmax(0, 1fr) 320px; }
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .app-header .inner { padding: 0 14px; }
  .top-nav, .header-actions .logout-label { display: none; }
  main.container { padding: 14px 12px calc(84px + env(safe-area-inset-bottom)); }
  .app-footer { display: none; }
  .bottom-nav {
    display: grid; grid-template-columns: repeat(3, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--border); padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: 10px; color: var(--muted); font-size: 11.5px; font-weight: 600; }
  .bottom-nav a .icon { width: 21px; height: 21px; }
  .bottom-nav a.active { color: var(--primary-text); background: var(--primary-soft); }
  .bottom-nav a:hover { text-decoration: none; }
  h1 { font-size: 20px; }
  .page-head { margin-bottom: 12px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 11px 12px; }
  .kpi .k-value { font-size: 22px; }
  .kpis .kpi:first-child { grid-column: span 2; }
  .toolbar .search { max-width: none; flex-basis: 100%; }
  .segmented { width: 100%; display: grid; grid-template-columns: repeat(5, 1fr); }
  .segmented a { text-align: center; padding: 7px 4px; }
  .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
  .call-row.head { display: none; }
  .call-row {
    grid-template-columns: 30px minmax(0, 1fr) auto; grid-template-areas: "dir op score" "dir meta meta" "dir sum sum";
    row-gap: 3px; padding: 12px 14px; align-items: start;
  }
  .c-dir { grid-area: dir; margin-top: 1px; }
  .c-op { grid-area: op; align-self: center; }
  .c-score { grid-area: score; justify-self: end; }
  .c-meta { grid-area: meta; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-size: 13px; }
  .c-meta > * { grid-column: auto; }
  .c-meta .sep { display: inline; color: var(--border-strong); }
  .c-sum { grid-area: sum; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: normal; font-size: 13px; margin-top: 3px; }
  .c-cat:empty, .c-res:empty { display: none; }
  .pager { padding: 10px 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .bubble { max-width: 92%; }
  .chip-bar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -12px; margin-right: -12px; padding: 2px 12px; }
  .chip-bar::-webkit-scrollbar { display: none; }
  .chip-bar .chips { flex-wrap: nowrap; }
  .chip-bar .chip { white-space: nowrap; }
  .chip-bar .spacer { display: none; }
  .chip-bar .filter-panel { order: -1; margin: 0; flex: none; }
  .kpis { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; margin-left: -12px; margin-right: -12px; padding: 2px 12px 4px; }
  .kpis::-webkit-scrollbar { display: none; }
  .kpis .kpi { flex: 0 0 152px; scroll-snap-align: start; }
  .call-hero { flex-wrap: wrap; }
  .call-hero h1 { font-size: 17px; }
  .call-hero > #call-status { flex-basis: 100%; }
  .card-head { flex-wrap: wrap; row-gap: 4px; }
  .subnav { margin-left: -12px; margin-right: -12px; padding-left: 12px; padding-right: 12px; }
}

/* detail layout stacks (mobile reorders cards) */
.detail-main, .detail-aside { display: grid; gap: 16px; align-content: start; min-width: 0; }
.detail-grid .card + .card { margin-top: 0; }
@media (max-width: 900px) {
  .detail-grid { gap: 14px; }
  .detail-main, .detail-aside { display: contents; }
  .o-hero { order: 1; } .o-score { order: 2; } .o-summary { order: 3; } .o-transcript { order: 4; } .o-clients { order: 5; } .o-actions { order: 6; } .o-history { order: 7; }
}

/* settings helpers */
.group-title { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 10px; }
.inline-add { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-add > input, .inline-add > .field { flex: 1 1 200px; }
.inline-add > .field { max-width: 200px; }
.inline-add > button { flex: none; }
.card-foot .htmx-indicator { align-items: center; gap: 6px; }
.prompt-stage .card-body { display: grid; gap: 12px; }
.version-list { width: 100%; }

/* transcript editing */
.bubble { position: relative; }
.bubble .edit-btn { margin-left: auto; background: none; border: 0; height: auto; padding: 2px; color: var(--muted); opacity: .55; cursor: pointer; }
.bubble .edit-btn:hover { background: none; opacity: 1; color: var(--primary-text); }
.bubble .edit-btn .icon { width: 14px; height: 14px; }
.bubble .edited-mark { font-size: 10.5px; font-weight: 600; color: var(--violet); background: var(--violet-soft); padding: 0 6px; border-radius: 999px; cursor: help; }
.bubble.edited { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--violet) 35%, transparent); }
.bubble .edit-form { display: none; margin-top: 6px; }
.bubble.editing { max-width: 100%; width: 100%; }
.bubble.editing .b-text { display: none; }
.bubble.editing .edit-form { display: grid; gap: 8px; }
.bubble .edit-form select { width: auto; max-width: 160px; height: 32px; }
.bubble .edit-form textarea { min-height: 70px; background: var(--surface); }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; font-size: 12.5px; color: var(--text-2); margin: 0; cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--primary); }
@media (hover: none) { .bubble .edit-btn { opacity: .8; } }
.bubble[id] { scroll-margin-top: calc(var(--header-h) + 24px); }

/* departments */
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.dept-grid .card + .card { margin-top: 0; }
a.dept-card { color: var(--text); transition: border-color .15s, box-shadow .15s; }
a.dept-card:hover { text-decoration: none; border-color: var(--border-strong); box-shadow: var(--shadow); }
.dept-stats { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.dept-stats b { color: var(--text); font-size: 15px; }
.lines-table input, .lines-table select, .users-table input, .users-table select { height: 34px; min-width: 120px; }
.user-chip.active { background: var(--primary-soft); color: var(--primary-text); }
.dept-chips { margin-bottom: 10px; }

/* integrations */
.integ { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; background: var(--surface); }
.integ-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.integ-head h3 { font-size: 15px; }
.integ-foot { display: flex; align-items: center; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 14px; }
.integ-foot > .small:first-child { margin-right: auto; }

/* add-line form: one aligned row (stacked on phones) */
.line-add { display: grid; grid-template-columns: 180px minmax(0, 1fr) minmax(0, 1fr) auto; gap: 6px 12px; align-items: end; }
.line-add .field { min-width: 0; }
.line-add .btn { height: 38px; }
.line-add .line-help { grid-column: 2 / -1; font-size: 12px; color: var(--muted); }
@media (max-width: 760px) {
  .line-add { grid-template-columns: 1fr; }
  .line-add > div:nth-of-type(1) { order: 1; }
  .line-add > div:nth-of-type(2) { order: 2; }
  .line-add .line-help { grid-column: 1; order: 3; margin-top: -4px; }
  .line-add > div:nth-of-type(3) { order: 4; }
  .line-add .btn { order: 5; width: 100%; justify-content: center; }
}

/* finance */
.fin-toolbar { display: flex; gap: 10px 14px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.fin-kpis .kpi .k-value { font-size: 24px; }
.money { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; font-variant-numeric: tabular-nums; white-space: nowrap; }
.money b { font-weight: 650; }
.money small { font-size: 11.5px; color: var(--muted); font-weight: 500; }
.status-item .money { align-items: flex-start; }
.status-item .money small { font-size: 12px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.fin-table { font-variant-numeric: tabular-nums; }
.fin-table th, .fin-table td { vertical-align: middle; white-space: nowrap; }
.fin-table td:first-child { white-space: normal; min-width: 150px; }
.fin-table .r { text-align: right; }
.fin-table tfoot td { border-top: 2px solid var(--border-strong); border-bottom: 0; background: var(--surface-2); }
.fin-table .share { min-width: 110px; }
.fin-table .share .bar { margin: 0 0 2px; height: 6px; }
.budget { margin-top: 14px; }
.budget-top { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.budget .bar { height: 9px; }
.fin-chart { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.fin-col { flex: 1 1 0; min-width: 3px; height: 100%; display: flex; align-items: flex-end; border-radius: 4px 4px 0 0; cursor: default; }
.fin-col i { display: block; width: 100%; background: var(--primary); border-radius: 4px 4px 0 0; opacity: .85; }
.fin-col:hover i, .fin-col:focus i { opacity: 1; background: var(--primary-hover); }
.fin-col:hover, .fin-col:focus { background: var(--surface-2); }
.fin-axis { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; }
.fin-grid { margin-top: 16px; }
.fin-grid .card + .card { margin-top: 0; }
.fin-grid > .card { min-width: 0; }
.fin-grid + .card { margin-top: 16px; }
.fin-kv { grid-template-columns: 130px 1fr; }
.fin-kv dd { color: var(--text-2); }
.fin-method { margin-top: 16px; }
.fin-method ul { color: var(--text-2); }
@media (max-width: 760px) {
  .fin-toolbar .segmented { grid-template-columns: repeat(3, 1fr); }
  .fin-toolbar .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -12px; padding: 2px 12px; width: calc(100% + 24px); }
  .fin-toolbar .chips::-webkit-scrollbar { display: none; }
  .fin-toolbar .chip { white-space: nowrap; }
  .fin-kpis .kpi { flex-basis: 170px; }
  .fin-chart { height: 120px; gap: 2px; }
  .fin-kv { grid-template-columns: 1fr; gap: 2px; }
  .fin-kv dd { margin-bottom: 8px; }
}

/* client history (call page aside) */
.client-hist { display: grid; max-height: 520px; overflow-y: auto; }
.ch-item { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--border); color: var(--text); }
.ch-item:last-child { border-bottom: 0; }
.ch-item:hover { background: var(--surface-2); text-decoration: none; }
.ch-item.same-day { box-shadow: inset 3px 0 0 var(--info); }
.ch-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; }
.ch-top .score { height: 22px; min-width: 34px; font-size: 12px; }
.ch-meta { font-size: 12.5px; color: var(--muted); margin-top: 1px; }
.ch-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.ch-tags .badge { font-size: 11px; }
.ch-sum { font-size: 12.5px; color: var(--text-2); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.context-note { margin: 0; }
.context-note a { font-weight: 600; }

/* transcript: move a line to the other speaker */
.bubble .who-actions { margin-left: auto; display: inline-flex; align-items: center; gap: 2px; }
.bubble .who-actions .edit-btn { margin-left: 0; }
.bubble .move-btn { background: none; border: 0; height: auto; padding: 2px 3px; border-radius: 6px; color: var(--muted); opacity: .6; cursor: pointer; line-height: 0; }
.bubble .move-btn:hover, .bubble .move-btn:focus-visible { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-text); opacity: 1; }
.bubble .move-btn .icon { width: 15px; height: 15px; }
.bubble.htmx-request { opacity: .55; transition: opacity .15s; }
.reeval-note { align-items: center; margin: 0 0 12px; }
.reeval-note > div { flex: 1; }
.reeval-note form { margin: 0; }
.transcript-foot { justify-content: flex-start; }
@media (hover: none) { .bubble .move-btn { opacity: .85; } }
@media (max-width: 760px) {
  .reeval-note { flex-wrap: wrap; }
  .reeval-note > div { flex: 1 1 calc(100% - 30px); }
  .reeval-note form, .reeval-note .btn { width: 100%; justify-content: center; }
}

/* call player: floats while the transcript is read (see call_detail.html) */
.player-wrap { display: flex; align-items: center; gap: 6px; }
.player-close { display: none; flex: none; width: 30px; height: 30px; padding: 0; border-radius: 50%; background: none; border: 0; color: var(--muted); cursor: pointer; place-items: center; }
.player-close:hover { background: var(--surface-2); color: var(--text); }
.player-wrap.floating {
  position: fixed; z-index: 25; top: calc(var(--header-h) + 8px); left: var(--pf-left); width: var(--pf-width);
  padding: 4px 6px 4px 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow); animation: player-in .15s ease-out;
}
.player-wrap.floating .player { margin-top: 0; flex: 1; min-width: 0; }
.player-wrap.floating .player-close { display: grid; }
@keyframes player-in { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 760px) {
  .player-wrap.floating { top: auto; bottom: calc(70px + env(safe-area-inset-bottom)); left: 10px; width: auto; right: 10px; }
  @keyframes player-in { from { opacity: 0; transform: translateY(6px); } }
}
@media (prefers-reduced-motion: reduce) { .player-wrap.floating { animation: none; } }

/* =====================================================================================================
   2026 refresh — self-hosted Inter, type ramp, WCAG 2.2 focus/contrast, calmer dark mode, touch targets.
   Placed last so it refines the components above without rewriting them.
   ===================================================================================================== */
@font-face { font-family: "Inter"; font-style: normal; font-weight: 400; font-display: swap; src: url("/static/fonts/Inter-Regular.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 500; font-display: swap; src: url("/static/fonts/Inter-Medium.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/Inter-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Inter"; font-style: normal; font-weight: 700 800; font-display: swap; src: url("/static/fonts/Inter-Bold.woff2") format("woff2"); }
@font-face { font-family: "Inter Display"; font-style: normal; font-weight: 600; font-display: swap; src: url("/static/fonts/InterDisplay-SemiBold.woff2") format("woff2"); }
@font-face { font-family: "Inter Display"; font-style: normal; font-weight: 700 800; font-display: swap; src: url("/static/fonts/InterDisplay-Bold.woff2") format("woff2"); }

:root {
  --font-display: "Inter Display", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --input-border: #8592a3;   /* 3.2:1 on surface (WCAG 1.4.11) */
  --focus: #0f766e;          /* 5.5:1 */
  --radius-sm: 8px; --radius: 12px; --radius-lg: 16px;
  --shadow-card: 0 1px 2px rgba(15, 27, 45, 0.05), 0 2px 8px -2px rgba(15, 27, 45, 0.06);
  --ease: cubic-bezier(.2, .7, .2, 1);
}
:root[data-theme="dark"] { --input-border: #5f7188; --focus: #62d6c7; --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.02), 0 8px 24px -12px rgba(0, 0, 0, 0.6); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --input-border: #5f7188; --focus: #62d6c7; --shadow-card: 0 0 0 1px rgba(255, 255, 255, 0.02), 0 8px 24px -12px rgba(0, 0, 0, 0.6); }
}

body {
  font-feature-settings: "cv11", "ss01";
  letter-spacing: -0.006em;
  background:
    radial-gradient(900px 320px at 12% -120px, color-mix(in srgb, var(--primary) 9%, transparent), transparent 70%),
    var(--bg);
}
h1, .kpi .k-value, .ring span { font-family: var(--font-display); }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.024em; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.page-head { margin-bottom: 20px; }
.page-head .sub { font-size: 14px; margin-top: 6px; }

/* focus: visible 2px outline (WCAG 2.4.13 focus appearance) */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: none; border-radius: var(--radius-sm); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline-offset: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 20%, transparent); }
.skip-link { position: absolute; left: 12px; top: -48px; z-index: 100; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.skip-link:focus { top: 10px; }

/* forms: 3:1 borders, comfortable radius */
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input:not([type]), select, textarea {
  border-color: var(--input-border); border-radius: 10px;
}
.switch input { border-color: var(--input-border); background: var(--surface-3); }
.switch input::after { box-shadow: 0 1px 2px rgba(0, 0, 0, .25); }

/* buttons */
.btn, button { border-radius: 10px; font-weight: 600; transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease), box-shadow .15s var(--ease), transform .1s var(--ease); }
.btn:not(.btn-secondary):not(.btn-ghost):not(.btn-danger) { box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 1px 2px rgba(15, 27, 45, .12); }
.btn:active, button:active { transform: translateY(1px); }
.btn-secondary { border-color: var(--border-strong); }

/* surfaces */
.card, .kpi { border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.card-head { padding: 16px 20px; }
.kpi { padding: 16px 18px; }
.kpi .k-value { font-size: 28px; font-weight: 700; letter-spacing: -0.025em; }
.kpis { gap: 14px; }
.top-nav a { border-radius: 10px; font-weight: 550; }
.top-nav a.active { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary) 22%, transparent); }
.brand-mark { border-radius: 10px; }

/* tables: centred rows, generous padding */
.list-table th, .list-table td { vertical-align: middle; padding: 11px 12px; }
.list-table th { text-transform: uppercase; letter-spacing: .04em; font-size: 11.5px; }

/* call direction: neutral (the arrow carries the meaning; colour stays for status/score) */
.dir-in, .dir-out { background: var(--surface-2); color: var(--text-2); }

/* transcript actions: 28px targets at full contrast, 40px on touch */
.bubble .move-btn, .bubble .edit-btn { width: 28px; height: 28px; padding: 0; display: inline-grid; place-items: center; border-radius: 8px; opacity: 1; color: var(--muted); }
.bubble .move-btn:hover, .bubble .edit-btn:hover { background: color-mix(in srgb, var(--primary) 12%, transparent); color: var(--primary-text); }
@media (pointer: coarse) { .bubble .move-btn, .bubble .edit-btn { width: 40px; height: 40px; } }

/* call page: coaching first */
.coach-first { margin-bottom: 14px; }

/* finance chart: slimmer bars with gridlines */
.fin-chart { gap: 6px; background: repeating-linear-gradient(to top, transparent 0, transparent calc(25% - 1px), var(--border) calc(25% - 1px), var(--border) 25%); }
.fin-col { max-width: 34px; margin: 0 auto; }
.fin-col i { border-radius: 6px 6px 2px 2px; opacity: 1; background: linear-gradient(to top, var(--primary), color-mix(in srgb, var(--primary) 70%, #fff)); }
.fin-table a.dept-link { color: var(--text); font-weight: 650; }
.fin-table a.dept-link:hover { color: var(--primary-text); }

/* mobile: no iOS zoom on focus, larger headings rhythm, KPI scroller inset */
@media (max-width: 760px) {
  input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input:not([type]), select, textarea { font-size: 16px; }
  h1 { font-size: 24px; }
  .kpis { scroll-padding-inline: 12px; }
  .kpi .k-value { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* transcript line currently being played */
.bubble { transition: box-shadow .2s var(--ease), background-color .2s var(--ease); }
.bubble.speaking { box-shadow: 0 0 0 2px var(--focus), 0 6px 18px -8px color-mix(in srgb, var(--focus) 60%, transparent); }
.bubble.speaking .who > span:first-of-type::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--focus); vertical-align: 1px; animation: speaking-pulse 1.2s ease-in-out infinite; }
@keyframes speaking-pulse { 50% { opacity: .35; } }
