/* ===========================================================================
   Admin Portal design system
   One visual language for every page: tokens, shell, and the component set
   (buttons, fields, tables, badges, panels, menus, modals, toasts, players).
   Pages compose these classes — nothing is styled per-page.
   =========================================================================== */

:root {
  /* brand + neutrals */
  --brand:      #c0392f;
  --brand-600:  #a72f26;
  --brand-50:   #fdf3f2;
  --bg:         #f5f6f8;
  --surface:    #ffffff;
  --surface-2:  #fafbfc;
  --ink:        #101828;
  --ink-2:      #344054;
  --muted:      #667085;
  --line:       #e4e7ec;
  --line-2:     #eff1f4;

  /* status */
  --ok:    #067647;  --ok-bg:   #ecfdf3;  --ok-line:   #abefc6;
  --warn:  #b54708;  --warn-bg: #fffaeb;  --warn-line: #fedf89;
  --bad:   #b42318;  --bad-bg:  #fef3f2;  --bad-line:  #fecdca;
  --info:  #175cd3;  --info-bg: #eff8ff;  --info-line: #b2ddff;

  /* sidebar */
  --side:      #131c2b;
  --side-2:    #1c2739;
  --side-ink:  #cdd5e0;
  --side-dim:  #8b97a8;

  --radius:    10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow:    0 4px 14px rgba(16, 24, 40, .08);
  --shadow-lg: 0 18px 44px rgba(16, 24, 40, .18);
  --sidebar-w: 244px;
  --sidebar-w-collapsed: 68px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14.5px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14.5px; }
p  { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }
svg.i { width: 18px; height: 18px; flex: 0 0 auto; stroke: currentColor;
        fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }

/* ---------- utility ---------- */
.muted    { color: var(--muted); }
.small    { font-size: 12.5px; }
.strong   { font-weight: 600; }
.mono     { font-variant-numeric: tabular-nums; }
.right    { text-align: right; }
.nowrap   { white-space: nowrap; }
.t-ok     { color: var(--ok); }
.t-warn   { color: var(--warn); }
.t-bad    { color: var(--bad); }
.hidden   { display: none !important; }
.row      { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.tight{ gap: 6px; }
.row.end  { justify-content: flex-end; }
.spacer   { flex: 1 1 auto; }
.stack    { display: flex; flex-direction: column; gap: 16px; }
.stack.sm { gap: 8px; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }

.sidebar {
  background: var(--side); color: var(--side-ink); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow: hidden;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px; padding: 16px 16px 14px;
  color: #fff; font-weight: 650; font-size: 14.5px; letter-spacing: -.01em;
  border-bottom: 1px solid rgba(255, 255, 255, .07); white-space: nowrap;
}
.sidebar .brand .mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--brand);
  display: grid; place-items: center; color: #fff; flex: 0 0 auto;
}
.sidebar nav { padding: 10px 10px 16px; overflow-y: auto; flex: 1; }
.sidebar .nav-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--side-dim);
  padding: 14px 8px 6px; font-weight: 600;
}
.sidebar a.nav {
  display: flex; align-items: center; gap: 11px; padding: 8px 10px; margin-bottom: 1px;
  border-radius: var(--radius-sm); color: var(--side-ink); font-size: 14px; text-decoration: none;
  white-space: nowrap;
}
.sidebar a.nav:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.sidebar a.nav.active { background: var(--brand); color: #fff; }
.sidebar a.nav .pill {
  margin-left: auto; background: rgba(255, 255, 255, .16); color: #fff; border-radius: 20px;
  font-size: 11px; padding: 0 7px; font-weight: 600; min-width: 20px; text-align: center;
}
.sidebar a.nav.active .pill { background: rgba(0, 0, 0, .22); }
.side-foot { padding: 10px; border-top: 1px solid rgba(255, 255, 255, .07); }
.side-foot button {
  width: 100%; justify-content: center; background: transparent; color: var(--side-dim);
  border: 1px solid rgba(255, 255, 255, .12);
}
.side-foot button:hover { background: var(--side-2); color: #fff; }

.app.collapsed .sidebar .brand span,
.app.collapsed .sidebar .nav-label,
.app.collapsed .sidebar a.nav span,
.app.collapsed .sidebar a.nav .pill,
.app.collapsed .side-foot button span { display: none; }
.app.collapsed .sidebar a.nav { justify-content: center; padding: 9px 0; }
.app.collapsed .sidebar .brand { justify-content: center; padding-left: 0; padding-right: 0; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 11px 24px; min-height: 60px;
}
.topbar .titles { min-width: 0; }
.topbar .titles h1 { font-size: 18px; line-height: 1.25; }
.topbar .titles .sub { font-size: 12.5px; color: var(--muted); }
.topbar .search { position: relative; width: 260px; }
.topbar .search svg { position: absolute; left: 10px; top: 9px; color: var(--muted); }
.topbar .search input { padding-left: 33px; }
.iconbtn {
  position: relative; width: 36px; height: 36px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  display: grid; place-items: center; cursor: pointer; padding: 0;
}
.iconbtn:hover { background: var(--surface-2); }
.iconbtn .dot {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--brand); color: #fff; font-size: 10.5px;
  font-weight: 700; display: grid; place-items: center; border: 2px solid var(--surface);
}
.whoami { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 3px 6px 3px 3px;
          border-radius: 22px; border: 1px solid transparent; }
.whoami:hover { border-color: var(--line); background: var(--surface); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-50); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: 0 0 auto;
  border: 1px solid #f4d6d3;
}
.whoami .who-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.whoami .who-role { font-size: 11.5px; color: var(--muted); line-height: 1.2; }

main.content { padding: 22px 24px 60px; max-width: 1400px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px; justify-content: center;
  background: var(--brand); color: #fff; border: 1px solid var(--brand);
  border-radius: var(--radius-sm); padding: 8px 14px; font: inherit; font-weight: 550;
  font-size: 13.5px; cursor: pointer; white-space: nowrap; line-height: 1.25;
}
.btn:hover { background: var(--brand-600); border-color: var(--brand-600); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--ink-2); border-color: var(--line); }
.btn.secondary:hover { background: var(--surface-2); border-color: #d2d7de; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: #932015; border-color: #932015; }
.btn.sm { padding: 5px 10px; font-size: 12.5px; gap: 5px; }
.btn.icon { padding: 6px; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn.busy { position: relative; color: transparent !important; pointer-events: none; }
.btn.busy::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .45); border-top-color: #fff; animation: spin .7s linear infinite;
}
.btn.secondary.busy::after { border-color: rgba(0, 0, 0, .2); border-top-color: var(--ink-2); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- form controls ---------- */
input, select, textarea {
  font: inherit; font-size: 13.5px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50);
}
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--muted); }
textarea { min-height: 80px; resize: vertical; }
select { appearance: none; background-image:
  url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667085' stroke-width='1.7' stroke-linecap='round'><path d='M4 6.5 8 10.5 12 6.5'/></svg>");
  background-repeat: no-repeat; background-position: right 9px center; padding-right: 30px; }
input[type=file] { padding: 6px; background: var(--surface-2); font-size: 12.5px; }
input[type=checkbox], input[type=radio] { width: auto; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .err  { font-size: 12px; color: var(--bad); }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--bad); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.grid.two   { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.prefix { position: relative; }
.prefix > span { position: absolute; left: 10px; top: 8px; color: var(--muted); font-size: 13.5px; }
.prefix > input { padding-left: 24px; }

/* toggle switch */
.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13.5px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 38px; height: 22px; border-radius: 11px; background: #cfd4dc; position: relative;
  transition: background .15s; flex: 0 0 auto;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .15s;
}
.switch input:checked + .track { background: var(--ok); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:disabled + .track { opacity: .5; }

/* segmented control */
.segmented { display: inline-flex; background: var(--line-2); border-radius: var(--radius-sm); padding: 3px; gap: 3px; }
.segmented button {
  border: none; background: transparent; font: inherit; font-size: 13px; font-weight: 550;
  color: var(--ink-2); padding: 6px 13px; border-radius: 5px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

/* ---------- panels ---------- */
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); margin-bottom: 18px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--line-2);
}
.panel-head .sub { font-size: 12.5px; color: var(--muted); font-weight: 400; }
.panel-body { padding: 16px; }
.panel-body.flush { padding: 0; }
.panel-foot { padding: 12px 16px; border-top: 1px solid var(--line-2); background: var(--surface-2);
              display: flex; gap: 9px; align-items: center; }

/* ---------- stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(196px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 3px;
  text-decoration: none; color: inherit;
}
a.stat:hover { border-color: #d2d7de; box-shadow: var(--shadow); text-decoration: none; }
.stat .head { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.stat .head .ic { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center;
                  background: var(--line-2); color: var(--ink-2); }
.stat .value { font-size: 25px; font-weight: 680; letter-spacing: -.02em; line-height: 1.2; }
.stat .foot { font-size: 12.5px; color: var(--muted); }
.stat.danger  { border-color: var(--bad-line);  background: var(--bad-bg); }
.stat.danger .value, .stat.danger .head { color: var(--bad); }
.stat.danger .head .ic { background: #fde3e0; color: var(--bad); }
.stat.warn    { border-color: var(--warn-line); background: var(--warn-bg); }
.stat.warn .value, .stat.warn .head { color: var(--warn); }
.stat.warn .head .ic { background: #fdf0cf; color: var(--warn); }
.stat.good .head .ic { background: var(--ok-bg); color: var(--ok); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 13.5px; }
table.data th, table.data td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data thead th {
  background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; position: sticky; top: 0; z-index: 1;
  border-bottom: 1px solid var(--line);
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--ink-2); }
table.data thead th .arrow { opacity: .45; font-size: 10px; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: none; }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data tr.unread td { background: #fbfcff; }
table.data tr.unread td:first-child { box-shadow: inset 3px 0 0 var(--info); }
.cell-main { font-weight: 550; }
.cell-sub  { font-size: 12px; color: var(--muted); }

.pager { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-top: 1px solid var(--line-2);
         font-size: 12.5px; color: var(--muted); background: var(--surface-2); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; background: var(--line-2); color: var(--ink-2);
  border: 1px solid var(--line); white-space: nowrap; line-height: 1.6;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .75; }
.badge.plain::before { display: none; }
.badge.ok   { background: var(--ok-bg);   color: var(--ok);   border-color: var(--ok-line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.bad  { background: var(--bad-bg);  color: var(--bad);  border-color: var(--bad-line); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }

/* ---------- dropdown menu ---------- */
.menu-wrap { position: relative; display: inline-block; }
.menu {
  position: fixed; z-index: 200; min-width: 208px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 5px; display: flex; flex-direction: column;
}
.menu button, .menu a {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border: none; background: none;
  font: inherit; font-size: 13.5px; color: var(--ink-2); text-align: left; cursor: pointer;
  border-radius: 6px; width: 100%; text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--line-2); color: var(--ink); text-decoration: none; }
.menu button.danger { color: var(--bad); }
.menu button.danger:hover { background: var(--bad-bg); }
.menu button:disabled { opacity: .45; cursor: not-allowed; }
.menu .sep { height: 1px; background: var(--line-2); margin: 5px 3px; }
.menu .mlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
                color: var(--muted); padding: 7px 10px 3px; font-weight: 600; }

/* ---------- modal ---------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .5); z-index: 300;
  display: grid; place-items: center; padding: 20px; animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 540px; max-height: 88vh; display: flex; flex-direction: column;
  animation: pop .14s ease-out;
}
.modal.wide { max-width: 860px; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.modal-head .ic { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
                  background: var(--info-bg); color: var(--info); flex: 0 0 auto; }
.modal-head .ic.danger { background: var(--bad-bg); color: var(--bad); }
.modal-head .ic.warn { background: var(--warn-bg); color: var(--warn); }
.modal-head .sub { font-size: 13px; color: var(--muted); margin-top: 3px; }
.modal-body { padding: 4px 20px 18px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-2); display: flex;
              justify-content: flex-end; gap: 9px; background: var(--surface-2);
              border-radius: 0 0 12px 12px; }

/* ---------- toasts ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 500; display: flex;
          flex-direction: column; gap: 9px; max-width: 380px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px; background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--ok); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 11px 13px; font-size: 13.5px; animation: slide .16s ease-out;
}
@keyframes slide { from { transform: translateX(14px); opacity: 0; } }
.toast .tico { color: var(--ok); }
.toast.error   { border-left-color: var(--bad); }
.toast.error .tico { color: var(--bad); }
.toast.warn    { border-left-color: var(--warn); }
.toast.warn .tico { color: var(--warn); }
.toast .tclose { margin-left: auto; background: none; border: none; cursor: pointer; color: var(--muted); padding: 0; }

/* ---------- states ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .ic { width: 46px; height: 46px; border-radius: 50%; background: var(--line-2);
             display: grid; place-items: center; margin: 0 auto 12px; color: var(--muted); }
.empty h3 { color: var(--ink-2); margin-bottom: 4px; }
.empty p { font-size: 13px; max-width: 380px; margin: 0 auto; }
.skeleton { background: linear-gradient(90deg, var(--line-2) 25%, #f6f7f9 37%, var(--line-2) 63%);
            background-size: 400% 100%; animation: shimmer 1.3s ease-in-out infinite;
            border-radius: 6px; height: 13px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.notice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border-radius: var(--radius-sm);
          font-size: 13px; border: 1px solid var(--info-line); background: var(--info-bg); color: #0f3f96; }
.notice.warn { border-color: var(--warn-line); background: var(--warn-bg); color: #7a4408; }
.notice.bad  { border-color: var(--bad-line);  background: var(--bad-bg);  color: #8c1c14; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button {
  border: none; background: none; font: inherit; font-size: 13.5px; font-weight: 550; color: var(--muted);
  padding: 9px 14px; cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs button:hover { color: var(--ink-2); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- audio ---------- */
/* superseded by .aplayer below — kept harmless for any cached markup */
.audio { display: inline-flex; align-items: center; gap: 7px; }

/* ---------- key/value list ---------- */
.kv { display: grid; grid-template-columns: minmax(120px, auto) 1fr; gap: 9px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-size: 12.5px; }
.kv dd { margin: 0; font-weight: 550; }

/* ---------- wizard steps ---------- */
.steps { display: flex; align-items: center; gap: 4px; margin-bottom: 18px; flex-wrap: wrap; }
.steps .step { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.steps .step .n { width: 24px; height: 24px; border-radius: 50%; background: var(--line-2);
                  display: grid; place-items: center; font-size: 12px; font-weight: 650; color: var(--muted); }
.steps .step.on { color: var(--ink); font-weight: 600; }
.steps .step.on .n { background: var(--brand); color: #fff; }
.steps .step.done .n { background: var(--ok-bg); color: var(--ok); }
.steps .bar { width: 26px; height: 1px; background: var(--line); margin: 0 6px; }

/* ---------- sortable rows (playlist / flow) ---------- */
.orderlist { display: flex; flex-direction: column; gap: 8px; }
.orderrow {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
}
.orderrow .pos { width: 24px; height: 24px; border-radius: 6px; background: var(--line-2);
                 display: grid; place-items: center; font-size: 12px; font-weight: 650; color: var(--ink-2); }
.orderrow.dragging { opacity: .45; }
.orderrow.over { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-50); }
.orderrow .handle { cursor: grab; color: var(--muted); display: flex; }

/* ---------- IVR mapping rows ---------- */
.mapping { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--line);
           border-radius: var(--radius-sm); background: var(--surface); }
.keycap {
  width: 38px; height: 38px; border-radius: 8px; background: var(--ink); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 16px; flex: 0 0 auto;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .25);
}
.keycap input { width: 100%; height: 100%; background: none; border: none; color: #fff;
                text-align: center; font: inherit; font-weight: 700; font-size: 16px; padding: 0; }
.keycap input:focus { box-shadow: none; }
.arrowto { color: var(--muted); flex: 0 0 auto; }

/* ---------- login ---------- */
.login-body { display: grid; place-items: center; min-height: 100vh; background: var(--side);
              background-image: radial-gradient(1000px 500px at 50% -10%, #24334a 0%, var(--side) 60%); }
.login-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
              padding: 32px; width: 384px; max-width: 92vw; }
.login-card .mark { width: 42px; height: 42px; border-radius: 11px; background: var(--brand);
                    display: grid; place-items: center; color: #fff; margin-bottom: 16px; }
.login-card h1 { font-size: 19px; margin-bottom: 4px; }
.login-card .field { margin-top: 15px; }
.login-card .btn { width: 100%; margin-top: 20px; padding: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .app { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
  .app .sidebar .brand span, .app .sidebar .nav-label,
  .app .sidebar a.nav span, .app .sidebar a.nav .pill,
  .app .side-foot button span { display: none; }
  .app .sidebar a.nav { justify-content: center; padding: 9px 0; }
  .app .sidebar .brand { justify-content: center; padding-left: 0; padding-right: 0; }
  .app.collapsed { grid-template-columns: var(--sidebar-w-collapsed) minmax(0, 1fr); }
  .topbar .search { width: 180px; }
  .whoami .who-name, .whoami .who-role { display: none; }
  main.content { padding: 18px 16px 50px; }
}
@media (max-width: 640px) {
  .topbar .search { display: none; }
  .topbar { padding: 10px 14px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dd { margin-bottom: 8px; }
}

/* ===========================================================================
   Dashboard, charts and the 2026 polish pass
   Extends the tokens above — no new palette, only refinements to rhythm,
   hierarchy and the data-visualisation layer.
   =========================================================================== */

:root {
  --ink-3:     #475467;
  --elev-1:    0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.04);
  --elev-2:    0 2px 4px -1px rgba(16,24,40,.06), 0 8px 20px -4px rgba(16,24,40,.08);
  --ring:      0 0 0 4px rgba(192,57,47,.10);
}

/* ---- typography rhythm --------------------------------------------------- */
h1 { font-size: 21px; letter-spacing: -.021em; }
h2 { font-size: 15.5px; letter-spacing: -.014em; }
.cell-main { font-weight: 560; color: var(--ink); }
.cell-sub  { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.muted.small, .small.muted { color: var(--muted); }

/* ---- panels -------------------------------------------------------------- */
.panel { box-shadow: var(--elev-1); border-radius: 12px; }
.panel-head { padding: 14px 16px; gap: 9px; align-items: center; }
.panel-head h2 { color: var(--ink); }
.panel-body { padding: 16px 16px 18px; }

/* ---- KPI tiles ----------------------------------------------------------- */
.stat-grid { gap: 14px; margin-bottom: 18px; }
.stat {
  border-radius: 12px; padding: 15px 16px 16px; gap: 9px;
  box-shadow: var(--elev-1);
  transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
}
a.stat:hover { box-shadow: var(--elev-2); transform: translateY(-1px);
               border-color: #d7dbe2; text-decoration: none; }
.stat .value { font-size: 27px; font-weight: 700; letter-spacing: -.025em; }
.stat .head { font-weight: 560; letter-spacing: .002em; }

/* ---- attention band ------------------------------------------------------ */
.attention { display: grid; gap: 10px; margin-bottom: 18px;
             grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.att {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  box-shadow: var(--elev-1); color: var(--ink);
  transition: box-shadow .16s ease, transform .16s ease;
}
.att:hover { text-decoration: none; box-shadow: var(--elev-2); transform: translateY(-1px); }
.att .ic { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
           flex: 0 0 auto; }
.att > svg.i { margin-left: auto; color: var(--muted); }
.att.bad  { border-color: var(--bad-line);  background: var(--bad-bg); }
.att.bad .ic  { background: #fde3e0; color: var(--bad); }
.att.bad .cell-main { color: var(--bad); }
.att.warn { border-color: var(--warn-line); background: var(--warn-bg); }
.att.warn .ic { background: #fdf0d0; color: var(--warn); }
.att.warn .cell-main { color: var(--warn); }

.allclear {
  display: flex; align-items: center; gap: 11px; margin-bottom: 18px;
  padding: 12px 14px; border: 1px solid var(--ok-line); border-radius: 12px;
  background: var(--ok-bg); color: var(--ok); font-size: 13.5px;
}
.allclear .muted { color: #3f7d5f; }

/* ---- charts -------------------------------------------------------------- */
.chart-panel .panel-body { padding-top: 6px; }
svg.viz { width: 100%; height: 150px; display: block; overflow: visible; }
svg.viz .vlab { font: 10.5px system-ui, sans-serif; fill: var(--muted); }
.chart-foot { margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.chart-foot b { color: var(--ink); font-weight: 620; }

.vlegend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 12px;
           font-size: 12.5px; color: var(--ink-3); }
.vlegend span { display: inline-flex; align-items: center; gap: 7px; }
.vlegend i, .sharekey i { width: 9px; height: 9px; border-radius: 3px; flex: 0 0 auto; }
.vlegend b { color: var(--ink); font-weight: 640; font-variant-numeric: tabular-nums; }

.viztip {
  position: fixed; z-index: 90; pointer-events: none; opacity: 0;
  transform: translateY(3px); transition: opacity .12s ease, transform .12s ease;
  background: #1d2939; color: #fff; border-radius: 8px; padding: 7px 10px;
  font-size: 12px; line-height: 1.5; box-shadow: var(--shadow-lg); max-width: 240px;
}
.viztip.on { opacity: 1; transform: translateY(0); }
.viztip b { display: block; font-weight: 620; }
.viztip span { display: flex; align-items: center; gap: 6px; color: #d0d5dd; }
.viztip i { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }

/* part-to-whole: one bar, direct labels (never a pie) */
.sharebar { display: flex; gap: 2px; height: 34px; margin: 6px 0 14px; }
.sharebar span:first-child { border-radius: 7px 3px 3px 7px; }
.sharebar span:last-child  { border-radius: 3px 7px 7px 3px; }
.sharebar span:only-child   { border-radius: 7px; }
.sharebar span { display: block; min-width: 4px; cursor: default; }
.sharekeys { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.sharekey { display: flex; align-items: flex-start; gap: 8px; }
.sharekey i { margin-top: 5px; }
.sharekey .cell-main { font-size: 17px; font-weight: 680; letter-spacing: -.02em; }

/* ---- tables -------------------------------------------------------------- */
table.data tbody tr { transition: background .12s ease; }
table.data tbody tr:hover { background: var(--surface-2); }

/* ---- misc components introduced by this update --------------------------- */
.quoted { display: inline; font-style: italic; color: var(--ink-3); }
.sms-preview {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 9px;
  padding: 10px 12px; font-size: 13px; line-height: 1.55; color: var(--ink-2);
  white-space: pre-wrap; word-break: break-word;
}
code.masked { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px;
              background: var(--line-2); border-radius: 6px; padding: 3px 8px; color: var(--ink-2); }
.kv-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* ---- login / verification ------------------------------------------------ */
.code-input {
  font-size: 26px; font-weight: 640; letter-spacing: .34em; text-align: center;
  font-variant-numeric: tabular-nums; padding: 12px !important;
}
.login-sub { text-align: center; margin-top: 12px; }
.linkbtn {
  background: none; border: none; padding: 4px 8px; cursor: pointer;
  color: var(--brand); font: inherit; font-size: 13px;
}
.linkbtn:hover { text-decoration: underline; }
.notice.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }

/* ---- focus visibility ---------------------------------------------------- */
:is(button, a, input, select, textarea):focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px;
}

@media (max-width: 720px) {
  .stat .value { font-size: 24px; }
  svg.viz { height: 130px; }
}

/* ---- live calls ---------------------------------------------------------- */
#livecalls .panel-head .sub { font-size: 12.5px; color: var(--muted); }
.livepulse { display: inline-flex; align-items: center; gap: 7px; font-size: 12px;
             font-weight: 600; color: var(--ok); letter-spacing: .02em; }
.livepulse i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok);
               animation: livepulse 1.8s ease-in-out infinite; }
@keyframes livepulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(6, 118, 71, .35); }
  50%      { opacity: .55; box-shadow: 0 0 0 5px rgba(6, 118, 71, 0); }
}
.livedot { color: var(--ok); font-size: 12px; font-weight: 620; white-space: nowrap; }
.live-empty { display: flex; align-items: center; justify-content: center; gap: 9px;
              padding: 20px 8px; color: var(--muted); font-size: 13px; }
.tabular { font-variant-numeric: tabular-nums; }
.avatar.anon { background: var(--line-2); color: var(--muted); }
#livecalls table.data td { padding-top: 11px; padding-bottom: 11px; }
@media (prefers-reduced-motion: reduce) { .livepulse i { animation: none; } }

/* ---- audio player -------------------------------------------------------- */
.aplayer {
  display: inline-flex; align-items: center; gap: 9px;
  min-width: 232px; max-width: 320px;
  padding: 5px 9px 5px 5px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); box-shadow: var(--elev-1);
}
.aplayer .abtn {
  width: 30px; height: 30px; flex: 0 0 auto; display: grid; place-items: center;
  border: none; border-radius: 50%; cursor: pointer;
  background: var(--brand); color: #fff; transition: background .15s ease;
}
.aplayer .abtn:hover { background: var(--brand-600); }
.aplayer .adl {
  background: transparent; color: var(--muted); width: 26px; height: 26px;
}
.aplayer .adl:hover { background: var(--line-2); color: var(--ink-2); text-decoration: none; }
.aplayer .atrack {
  flex: 1; height: 5px; border-radius: 3px; background: var(--line);
  position: relative; cursor: pointer; min-width: 60px; overflow: hidden;
}
.aplayer .afill {
  display: block; height: 100%; width: 0%; border-radius: 3px;
  background: var(--brand); transition: width .12s linear;
}
.aplayer .atime {
  font-size: 11.5px; color: var(--muted); white-space: nowrap; min-width: 68px;
  text-align: right;
}
.aplayer.playing .abtn { background: var(--brand-600); }
.aplayer.failed {
  border-color: var(--bad-line); background: var(--bad-bg);
  border-radius: 10px; max-width: 420px;
}
.aplayer.failed .abtn { background: var(--bad); }
.aplayer .atrack:has(.aerr) { height: auto; background: none; cursor: default; overflow: visible; }
.aplayer .aerr { display: block; font-size: 12px; line-height: 1.45; color: var(--bad); }

/* ---- SMS flow manager ---------------------------------------------------- */
.smsstep { display: grid; grid-template-columns: 30px 1fr; gap: 0 14px; padding-bottom: 4px; }
.smsstep + .smsstep { margin-top: 4px; }
.smsstep-n {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 650; color: var(--brand);
  background: var(--brand-50); border: 1px solid #f3d9d6;
  position: relative;
}
/* the connecting line that makes it read as one conversation */
.smsstep:not(:last-child) .smsstep-n::after {
  content: ""; position: absolute; top: 27px; left: 50%; width: 1px;
  height: calc(100% + 18px); background: var(--line);
}
.smsstep-n.start, .smsstep-n.done { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
.smsstep-body { padding-bottom: 18px; min-width: 0; }
.smsmsg { margin-top: 8px; }
.smsmsg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 5px; }
.smsbubble {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px 12px 12px 3px; padding: 9px 13px;
  font-size: 13.5px; line-height: 1.5; color: var(--ink-2);
  max-width: 62ch; white-space: pre-wrap; word-break: break-word;
}
.smsalt { margin-top: 10px; padding-left: 12px; border-left: 2px solid var(--line-2); }
.smsalt .smsbubble { background: var(--warn-bg); border-color: var(--warn-line); }
.smsnext { margin-top: 10px; font-size: 12.5px; color: var(--muted);
           display: flex; align-items: center; gap: 6px; }
.smsnext b { color: var(--ink-2); }
.smshint { margin-top: 5px; font-size: 11.5px; color: var(--muted); font-style: italic; }

/* Compact bubble for the trigger table (next update: SMS triggers). */
.smsbubble.sm { font-size: 12.5px; padding: 6px 10px; max-width: 320px; }

/* ---------- password requirement checklist -------------------------------- */
/* Shown live wherever a password is set, and generated from the SAME rule list
   the backend enforces (GET /api/password-policy), so the two cannot drift. */
.pwrules { display: grid; gap: 2px; margin-top: 4px; }
.pwrule { display: flex; align-items: center; gap: 6px; line-height: 1.5; }
.pwrule .pwmark { display: inline-block; width: 1em; text-align: center; font-weight: 700; }
.pwrule.met { color: var(--ok); }

/* ---------- verification-code card (login 2FA + password reset) -----------
   One component for both flows.  Everything sits inside .login-card: the
   resend form and the way back used to be siblings of the card inside the
   centred grid of .login-body, so each became its own grid row and drifted a
   long way below it. */
.otp-card { text-align: left; }
.otp-card .otp-sent { margin-bottom: 14px; }
.otp-card form { margin: 0; }

.otp-timer {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  background: var(--ok-bg); color: var(--ok);
  border: 1px solid var(--ok-line);
  font-size: 12.5px; font-variant-numeric: tabular-nums;
}
.otp-timer b { font-weight: 650; }
/* Under a minute: still calm, but no longer reassuring. */
.otp-timer.low { background: var(--warn-bg, #fffaeb); color: var(--warn, #b54708);
                 border-color: var(--warn-line, #fedf89); }
.otp-timer.expired { background: var(--bad-bg, #fef3f2); color: var(--bad, #b42318);
                     border-color: var(--bad-line, #fecdca); }

/* An expired code makes the input pointless; dim it so the resend link reads
   as the live action, without removing it (the server is still the authority
   and a resend re-enables everything). */
#otpform.is-expired { opacity: .55; }

.otp-card .code-input { width: 100%; }

.otp-foot {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 13px; text-align: center;
}
.otp-resend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
              justify-content: center; }

@media (max-width: 420px) {
  .login-card { padding: 24px 20px; }
  .otp-card .code-input { font-size: 22px; letter-spacing: 6px; }
}

/* ---------- prompt placeholder chips -------------------------------------- */
.ph_help { margin-top: 8px; }
.ph_help summary { cursor: pointer; }
.ph_chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.chip.ph_insert {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 3px 9px; font-size: 12px; font-family: ui-monospace, monospace;
  cursor: pointer; color: var(--ink-3);
}
.chip.ph_insert:hover { border-color: var(--brand); color: var(--brand); }
/* Already used by this prompt. */
.chip.ph_insert.on { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok); }
