@font-face {
  font-family: "Geist";
  src: url("/fonts/geist.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("/fonts/geist-mono.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* One warm-neutral gray family; one brand colour (set per platform / organisation). */
:root {
  --brand: #1F3A5F;
  --brand-ink: #FFFFFF;
  --brand-weak: color-mix(in srgb, var(--brand) 9%, #FFFFFF);
  --brand-soft: color-mix(in srgb, var(--brand) 18%, #FFFFFF);
  --brand-strong: color-mix(in srgb, var(--brand) 82%, #000000);

  --canvas: #F6F5F2;
  --surface: #FFFFFF;
  --sunken: #F1F0EC;
  --hover: #EEEDE8;
  --ink: #1B1B19;
  --ink-2: #44433F;
  --muted: #6B6A64;
  --faint: #9C9A92;
  --line: #E7E5DF;
  --line-strong: #D5D2C9;

  --ok: #2F6B4F;      --ok-bg: #E8F1EB;
  --warn: #8A5A12;    --warn-bg: #F6EEDD;
  --danger: #A63D32;  --danger-bg: #F7E6E3;
  --info: #2D5A86;    --info-bg: #E7EEF5;
  --neutral: #5F5D57; --neutral-bg: #EEEDE8;

  --r-lg: 10px;
  --r: 8px;
  --r-sm: 6px;
  --shadow-sm: 0 1px 2px rgba(40, 36, 28, .05);
  --shadow-lg: 0 18px 48px -12px rgba(40, 36, 28, .28), 0 2px 6px rgba(40, 36, 28, .06);
  --ring: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent);
  --ease: cubic-bezier(.2, .7, .2, 1);

  --font: "Geist", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --z-side: 30; --z-top: 20; --z-modal: 50; --z-toast: 60;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
html { scroll-behavior: smooth; }
body {
  font: 14px/1.5 var(--font);
  font-feature-settings: "ss01", "cv11";
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--brand); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1 { font-size: 21px; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 14px; font-weight: 600; }
p { margin: 0; text-wrap: pretty; }
code { font-family: var(--mono); }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
::selection { background: var(--brand-soft); }

.skip { position: absolute; left: 12px; top: -48px; z-index: 100; background: var(--ink); color: #fff; padding: 8px 12px; border-radius: var(--r-sm); transition: top .15s; }
.skip:focus { top: 12px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; z-index: var(--z-side);
}
.brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 16px; }
.brand-logo { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; background: var(--surface); flex: none; }
.brand-monogram {
  width: 34px; height: 34px; border-radius: 8px; flex: none;
  display: inline-grid; place-items: center;
  background: var(--brand); color: var(--brand-ink);
  font-weight: 650; font-size: 13px; letter-spacing: .02em;
}
.brand-logo.lg, .brand-monogram.lg { width: 48px; height: 48px; border-radius: 11px; font-size: 17px; }
.brand-text { min-width: 0; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -0.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; }
.nav-label { font-size: 12px; font-weight: 500; color: var(--faint); padding: 16px 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--ink-2); font-weight: 500; position: relative;
  transition: background .15s var(--ease), color .15s var(--ease);
}
.nav a:hover { background: var(--sunken); color: var(--ink); text-decoration: none; }
.nav a.active { background: var(--brand-weak); color: var(--brand-strong); }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); }
.nav svg { width: 17px; height: 17px; flex: none; }

.side-foot { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 16px; border-top: 1px solid var(--line); }
.avatar {
  width: 32px; height: 32px; border-radius: 8px; flex: none; display: inline-grid; place-items: center;
  background: var(--sunken); color: var(--ink-2); font-size: 12px; font-weight: 600;
}
.who { min-width: 0; flex: 1; }
.who-name { font-weight: 550; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-role { font-size: 12px; color: var(--muted); }
.side-foot .links { display: flex; gap: 2px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 10px 32px;
  background: color-mix(in srgb, var(--canvas) 88%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: var(--z-top);
}
.topbar .spacer { flex: 1; }
.icon-btn.menu-btn { display: none; }
.topbar.bare { display: none; }
.org-pick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.org-pick select { min-width: 220px; }
.conn { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); }
.conn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.conn.on .dot { background: #3C8A5F; box-shadow: 0 0 0 3px rgba(60, 138, 95, .16); }
.conn.off { color: var(--danger); }
.conn.off .dot { background: var(--danger); }
.scrim { display: none; }
.content { padding: 28px 32px 64px; max-width: 1600px; width: 100%; }

.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head .grow { flex: 1; min-width: 260px; }
.page-head p { margin-top: 6px; color: var(--muted); max-width: 68ch; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--ink); }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--line); }
.card-head h2 { flex: 1; }
.card-head a { font-size: 13px; font-weight: 500; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid, .metrics + .grid, .metrics + .card, .grid + .metrics, .card + .metrics { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid > .card { margin-top: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.split { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }

/* Key figures sit in one strip instead of four floating cards. */
.metrics {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
}
.metric { padding: 18px 22px 20px; min-width: 0; }
.metric + .metric { border-left: 1px solid var(--line); }
.metric .label { font-size: 13px; color: var(--muted); font-weight: 500; }
.metric .value { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.metric .sub { font-size: 12.5px; color: var(--faint); margin-top: 6px; }

/* ---------- forms ---------- */
label.field, .field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 13px; color: var(--ink-2); }
.hint, label.field .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 7px 10px; min-height: 36px; min-width: 0;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: color-mix(in srgb, var(--line-strong) 60%, var(--ink-2)); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: var(--ring); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; min-height: 0; accent-color: var(--brand); padding: 0; }
input[type=color].color-swatch { width: 44px; height: 36px; padding: 3px; cursor: pointer; }
input[type=search] { padding-left: 32px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239C9A92' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E") no-repeat 10px center / 15px; }
select { padding-right: 28px; appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B6A64' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 9px center / 14px; }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 9px; font-weight: 450; cursor: pointer; color: var(--ink); }
.days { display: flex; gap: 6px; flex-wrap: wrap; }
.days label {
  display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 6px 11px; cursor: pointer; font-weight: 500; color: var(--ink-2); transition: background .15s, border-color .15s;
}
.days label:has(input:checked) { border-color: var(--brand); background: var(--brand-weak); color: var(--brand-strong); }
.section { padding: 20px 22px 22px; border-top: 1px solid var(--line); }
.section:first-child { border-top: 0; }
.section > h2 { margin-bottom: 14px; }
.section-title { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.section-title .num { font-family: var(--mono); font-size: 12px; color: var(--faint); font-weight: 500; }
.section-title .num::after { content: " /"; }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > input, .inline > select { flex: 1; }
.inline > input[type=color], .inline > input[type=checkbox], .inline > input[type=radio] { flex: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 550; font-size: 13.5px; letter-spacing: -0.005em;
  border-radius: var(--r-sm); padding: 0 14px; min-height: 36px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: background .15s var(--ease), border-color .15s var(--ease), color .15s, transform .08s, box-shadow .15s;
}
.btn:hover { background: var(--sunken); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, .icon-btn:focus-visible, .nav a:focus-visible, .tabs button:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); box-shadow: 0 1px 2px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn.primary:hover { background: var(--brand-strong); border-color: var(--brand-strong); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 35%, var(--line-strong)); }
.btn.solid-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.solid-danger:hover { background: color-mix(in srgb, var(--danger) 85%, #000); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--hover); color: var(--ink); }
.btn.sm { min-height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn.block { width: 100%; min-height: 40px; }
.icon-btn {
  border: 0; background: transparent; cursor: pointer; padding: 6px; border-radius: var(--r-sm); color: var(--muted);
  display: inline-grid; place-items: center; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); text-decoration: none; }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12.5px; color: var(--muted); font-weight: 500; white-space: nowrap; background: transparent; padding-top: 10px; padding-bottom: 10px; }
thead tr { background: color-mix(in srgb, var(--sunken) 55%, var(--surface)); }
tbody tr { transition: background .12s; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr:hover { background: color-mix(in srgb, var(--sunken) 60%, var(--surface)); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td b { font-weight: 550; }
.empty { padding: 44px 24px 48px; text-align: center; color: var(--muted); max-width: 520px; margin: 0 auto; }
.empty h3 { color: var(--ink); margin-bottom: 6px; font-size: 15px; }
.empty .btn { margin-top: 16px; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.filters { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); align-items: center; }
.filters input[type=search] { flex: 1; min-width: 200px; }

/* ---------- badges, keys, progress ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 5px;
  font-size: 12px; font-weight: 550; line-height: 18px; background: var(--neutral-bg); color: var(--neutral); white-space: nowrap;
}
.badge.running::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.6s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
.badge.running, .badge.completed-call, .badge.done, .badge.active, .badge.online { background: var(--ok-bg); color: var(--ok); }
.badge.scheduled, .badge.dialing, .badge.answered, .badge.retry { background: var(--info-bg); color: var(--info); }
.badge.paused, .badge.no_answer, .badge.busy, .badge.pending { background: var(--warn-bg); color: var(--warn); }
.badge.stopped, .badge.failed, .badge.suspended, .badge.disabled, .badge.offline, .badge.dnc { background: var(--danger-bg); color: var(--danger); }
.badge.completed, .badge.draft, .badge.cancelled, .badge.unknown { background: var(--neutral-bg); color: var(--neutral); }
.key {
  display: inline-grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px;
  border-radius: 6px; border: 1px solid var(--line-strong); background: var(--surface);
  font: 600 13px var(--mono); box-shadow: 0 1px 0 var(--line-strong); color: var(--ink);
}

.progress { height: 6px; background: var(--sunken); border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .5s var(--ease); }
.progress-row { display: flex; align-items: center; gap: 10px; min-width: 140px; }
.progress-row .progress { flex: 1; }
.progress-row small { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; font-size: 12.5px; }

.bars { display: flex; flex-direction: column; gap: 14px; }
.bar-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) 72px; gap: 14px; align-items: center; }
.bar-row .name { font-weight: 550; margin-bottom: 6px; display: flex; justify-content: space-between; gap: 8px; }
.bar-row .name span { color: var(--faint); font-weight: 400; font-size: 12.5px; }
.bar-row .count { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.bar-row .count small { display: block; color: var(--muted); font-weight: 400; font-size: 12px; }

.chart { display: flex; align-items: flex-end; gap: 14px; height: 180px; padding: 10px 2px 0; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.chart .stack { width: 100%; max-width: 40px; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.chart .b-all { background: var(--brand-soft); border-radius: 4px 4px 1px 1px; width: 100%; position: relative; min-height: 2px; overflow: hidden; }
.chart .b-ans { background: var(--brand); position: absolute; bottom: 0; left: 0; right: 0; }
.chart .day { font-size: 12px; color: var(--muted); white-space: nowrap; }
.chart .val { font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); min-height: 16px; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: 0; }
.legend .lg-all { background: var(--brand-soft); }
.legend .lg-ans { background: var(--brand); }

/* ---------- ivr editor ---------- */
.ivr-table td { padding: 8px 8px; }
.ivr-table select, .ivr-table input { width: 100%; }
.ivr-table td:first-child { width: 84px; }
.flow {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted);
  padding: 11px 14px; background: var(--sunken); border-radius: var(--r);
}
.flow b { color: var(--ink); font-weight: 550; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 12px; }
.tabs button {
  background: none; border: 0; padding: 13px 10px 11px; font: inherit; font-weight: 550; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; border-radius: 4px 4px 0 0; transition: color .15s;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--brand); }
.tabs.rounds { overflow-x: auto; border-bottom: 0; }
.tabs.rounds button { white-space: nowrap; }

/* ---------- modal, toast, notices ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(27, 27, 25, .38); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: var(--z-modal); padding: 16px; animation: fade .15s ease-out;
}
.modal {
  background: var(--surface); border-radius: var(--r-lg); width: min(620px, 100%); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: rise .2s var(--ease);
}
.modal.wide { width: min(880px, 100%); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.modal-head h2 { flex: 1; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; background: color-mix(in srgb, var(--sunken) 45%, var(--surface)); border-radius: 0 0 var(--r-lg) var(--r-lg); }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: var(--z-toast); }
.toast {
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r); box-shadow: var(--shadow-lg);
  max-width: 400px; font-size: 13.5px; animation: rise .2s var(--ease); border-left: 3px solid transparent;
}
.toast.error { border-left-color: #E07A6E; }
.toast.ok { border-left-color: #6FBF95; }
.notice { padding: 11px 14px; border-radius: var(--r); font-size: 13.5px; background: var(--info-bg); color: #24486B; }
.notice.warn { background: var(--warn-bg); color: #6E4810; }
.notice.ok { background: var(--ok-bg); color: #245540; }
.notice.error { background: var(--danger-bg); color: #86302A; }
.secret { font-family: var(--mono); font-size: 13px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px 8px; user-select: all; word-break: break-all; }
.kv { display: grid; grid-template-columns: 170px 1fr; gap: 10px 16px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* ---------- skeleton ---------- */
.skeleton { display: flex; flex-direction: column; gap: 12px; }
.sk { border-radius: var(--r); background: linear-gradient(90deg, var(--sunken) 0%, var(--hover) 50%, var(--sunken) 100%); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
.sk-title { width: 220px; height: 26px; }
.sk-line { width: 380px; max-width: 80%; height: 14px; margin-bottom: 10px; }
.sk-strip { height: 104px; border-radius: var(--r-lg); }
.sk-block { height: 280px; border-radius: var(--r-lg); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- sign in ---------- */
.auth {
  min-height: 100dvh; display: grid; grid-template-rows: 1fr auto;
  background:
    radial-gradient(1200px 520px at 50% -10%, color-mix(in srgb, var(--brand) 9%, transparent), transparent 70%),
    var(--canvas);
}
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-card {
  width: min(400px, 100%); display: grid; gap: 16px; padding: 32px 30px 30px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.auth-head { display: grid; gap: 8px; justify-items: start; margin-bottom: 4px; }
.auth-head .brand-logo, .auth-head .brand-monogram { margin-bottom: 8px; }
.auth-head h1 { font-size: 22px; }
.auth-head p { color: var(--muted); }
.auth-foot { text-align: center; padding: 18px; font-size: 12.5px; color: var(--faint); }

/* ---------- branding page ---------- */
.logo-box { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.logo-box > img { width: 72px; height: 72px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.logo-box > .brand-monogram.lg { width: 72px; height: 72px; font-size: 22px; border-radius: 12px; }
.logo-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.logo-actions .hint { flex-basis: 100%; }
.brand-preview { display: grid; grid-template-columns: 170px 1fr; min-height: 180px; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--canvas); }
.preview-side { background: var(--surface); border-right: 1px solid var(--line); padding: 14px; display: flex; gap: 9px; align-items: flex-start; }
.preview-side .brand-logo, .preview-side .brand-monogram { width: 28px; height: 28px; font-size: 11px; border-radius: 7px; }
.preview-side .brand-name { font-size: 13px; }
.preview-side .brand-sub { font-size: 11.5px; }
.preview-body { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.preview-line { height: 12px; border-radius: 4px; background: var(--hover); width: 80%; }
.preview-line.short { width: 50%; }
.preview-btn { align-self: flex-start; margin-top: 8px; padding: 7px 12px; border-radius: var(--r-sm); font-weight: 550; font-size: 13px; }

audio { height: 34px; max-width: 260px; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(3) { border-left: 0; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--line); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: 264px; transform: translateX(-100%); visibility: hidden; transition: transform .22s var(--ease), visibility .22s; }
  .shell.nav-open .side { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  .topbar.bare { display: flex; }
  .shell.nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(27, 27, 25, .3); z-index: calc(var(--z-side) - 1); }
  .icon-btn.menu-btn { display: inline-grid; }
  .topbar { padding: 8px 16px; }
  .content { padding: 20px 16px 48px; }
  .g2, .g3, .form-grid { grid-template-columns: 1fr; }
  .org-pick select { min-width: 0; max-width: 170px; }
  .org-pick span { display: none; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .page-head { align-items: flex-start; }
  .brand-preview { grid-template-columns: 1fr; }
  .preview-side { border-right: 0; border-bottom: 1px solid var(--line); }
}
@media (max-width: 520px) {
  .metric .value { font-size: 24px; }
  .metric { padding: 14px 16px; }
  h1 { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- overview (dashboard) ---------- */
.dash { display: flex; flex-direction: column; gap: 14px; }
.dash-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 4px; }
.eyebrow { font-size: 12.5px; color: var(--muted); font-weight: 500; margin-bottom: 4px; }
.segmented { display: inline-flex; padding: 2px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r-sm); }
.segmented button {
  font: inherit; font-size: 13px; font-weight: 550; color: var(--muted); background: transparent; border: 0;
  padding: 5px 12px; border-radius: 5px; cursor: pointer; transition: background .15s, color .15s;
}
.segmented button:hover { color: var(--ink); }
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(40, 36, 28, .08), 0 0 0 1px var(--line); }
.segmented button:focus-visible { outline: none; box-shadow: var(--ring); }

.statusbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 0;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  font-size: 13px; color: var(--muted);
}
.sb-item { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; white-space: nowrap; }
.sb-item + .sb-item { border-left: 1px solid var(--line); }
.sb-item b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.sb-spacer { flex: 1; }
.sb-spacer + .sb-item { border-left: 0; }
.sb-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.sb-item.ok { color: var(--ok); font-weight: 550; }
.sb-item.ok .sb-dot { background: #3C8A5F; box-shadow: 0 0 0 3px rgba(60, 138, 95, .16); }
.sb-item.bad { color: var(--danger); font-weight: 550; }
.sb-item.bad .sb-dot { background: var(--danger); }
.meter { display: inline-block; width: 64px; height: 5px; border-radius: 9px; background: var(--sunken); overflow: hidden; margin-left: 4px; }
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: 9px; }
.meter-row { display: inline-flex; align-items: center; gap: 10px; }
.meter-row .meter { margin: 0; width: 90px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.kpi { padding: 14px 18px 16px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: 13px; font-weight: 500; color: var(--muted); }
.kpi-value { font-size: 26px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 2px; }
.kpi-foot { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12.5px; margin-top: 6px; }
.spark { width: 96px; height: 28px; flex: none; overflow: visible; }
.spark-area { fill: var(--brand-weak); }
.spark-line { fill: none; stroke: var(--brand); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.spark-dot { fill: var(--brand); }
.delta { font-weight: 550; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--danger); }
.delta.flat { color: var(--faint); font-weight: 450; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(280px, 1fr); gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); min-width: 0; }
.panel-head { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.panel-head h2 { font-size: 14px; }
.panel-head .faint { font-size: 12.5px; }
.panel-head a { font-size: 13px; font-weight: 500; }
.panel-head .grow { flex: 1; }
.panel-body { padding: 14px 16px 16px; }
.chart-body { padding: 10px 12px 6px 4px; }

.volume { width: 100%; height: auto; display: block; }
.volume .gridline { stroke: var(--line); stroke-dasharray: 2 4; }
.volume .axis { stroke: var(--line-strong); }
.volume .tick { font: 11px var(--font); fill: var(--faint); font-variant-numeric: tabular-nums; }
.volume .bar-all { fill: var(--brand-soft); }
.volume .bar-ans { fill: var(--brand); }
.volume .bar:hover .bar-all { fill: color-mix(in srgb, var(--brand) 30%, #fff); }

.stackbar { display: flex; height: 10px; border-radius: 3px; overflow: hidden; background: var(--sunken); gap: 2px; }
.stackbar span { display: block; height: 100%; }
.o-ans { background: var(--brand); }
.o-na { background: #D3B677; }
.o-busy { background: #A9906C; }
.o-fail { background: #C77D72; }
.outcomes { display: grid; grid-template-columns: 1fr auto; gap: 9px 12px; margin: 16px 0 18px; font-size: 13.5px; }
.outcomes dt { display: flex; align-items: center; gap: 9px; color: var(--ink-2); }
.outcomes dt i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.outcomes dd { margin: 0; display: flex; gap: 10px; justify-content: flex-end; font-variant-numeric: tabular-nums; }
.outcomes dd span { color: var(--faint); min-width: 44px; text-align: right; }
.subhead { font-size: 12.5px; font-weight: 500; color: var(--muted); padding-top: 14px; border-top: 1px solid var(--line); margin-bottom: 10px; }
.keylist { display: flex; flex-wrap: wrap; gap: 8px; }
.keychip { display: inline-flex; align-items: center; gap: 8px; padding: 3px 10px 3px 3px; border: 1px solid var(--line); border-radius: 8px; font-weight: 600; font-variant-numeric: tabular-nums; }

table.dense th, table.dense td { padding: 9px 16px; }
table.dense .progress-row { min-width: 120px; }

@media (max-width: 1100px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(3) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .sb-item { padding: 8px 12px; }
  .sb-item + .sb-item { border-left: 0; }
  .sb-spacer { display: none; }
  .kpis { grid-template-columns: 1fr; }
  .kpi + .kpi { border-left: 0; border-top: 1px solid var(--line); }
  .spark { width: 80px; }
}

.locked { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: default; }
.locked svg { width: 14px; height: 14px; }
