/*
  The console's design system. The palette is Netcare's, read from live CSS
  (docs/brand/netcare-ci.md §1.2/§1.4): navy carries the chrome and the
  headings, aqua is the one interactive accent, and the greys lean cool to
  sit with them. Semantic colours (good / warning / critical) are separate
  from the accent so a state never looks like a button.

  Layout is an app shell: a navy rail on the left, one content column with a
  standard page header, and the call monitor docked on the right. Every
  control comes from the small set below (.btn, .icon-btn, .field, .pill,
  .panel) so the six views read as one product.
*/
:root {
  /* brand */
  --navy: #1d3443;
  --navy-deep: #16293a;
  --navy-soft: #26445a;
  --accent: #3da9d1;
  --accent-strong: #2a90b8;
  --accent-soft: #eaf5fa;
  --accent-soft-2: #d8eef6;
  --gold: #d5bfac;

  /* neutrals, cool-biased */
  --ground: #f2f5f7;
  --surface: #ffffff;
  --surface-2: #f7f9fa;
  --hair: #e3e8ec;
  --line: #cfd6db;
  --line-strong: #b8c2c9;
  --fg: #1d3443;
  --fg-2: #4a5964;
  --muted: #6b7a85;
  --faint: #93a0a9;

  /* rail */
  --rail-bg: var(--navy);
  --rail-fg: #d6e2ea;
  --rail-fg-strong: #ffffff;
  --rail-muted: #8aa3b3;
  --rail-hover: rgba(255, 255, 255, 0.07);
  --rail-active: rgba(61, 169, 209, 0.22);
  --rail-hair: rgba(255, 255, 255, 0.09);

  /* semantic */
  --good: #1a7f37;
  --good-soft: #e6f4ea;
  --warn: #9a6200;
  --warn-soft: #fff4e0;
  --warn-line: #f0d39a;
  --crit: #c8302b;
  --crit-soft: #fdecec;
  --crit-line: #f1b3b3;

  --focus: 0 0 0 3px rgba(61, 169, 209, 0.35);
  --shadow-1: 0 1px 2px rgba(29, 52, 67, 0.06);
  --shadow-2: 0 4px 16px rgba(29, 52, 67, 0.10);
  --radius: 10px;
  --radius-sm: 6px;
  --rail-w: 248px;
  --rail-w-min: 64px;
  --monitor-w: 420px;
  --pad: 24px;
  --gap: 16px;
  --font: 'Open Sans', 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---- base ------------------------------------------------------------------ */
* { box-sizing: border-box; }
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--fg);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: none; box-shadow: var(--focus); }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; font-weight: 600; color: var(--navy); }
h1 { font-size: 22px; line-height: 1.25; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-variant-numeric: tabular-nums; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ---- app shell -------------------------------------------------------------- */
.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) auto;
  transition: grid-template-columns 160ms ease;
}
body.rail-collapsed .app { grid-template-columns: var(--rail-w-min) minmax(0, 1fr) auto; }
.main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- rail ------------------------------------------------------------------ */
.rail {
  background: var(--rail-bg);
  color: var(--rail-fg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 12px 10px;
  gap: 4px;
}
.rail-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 4px 4px 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }
.brand-mark {
  display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; flex: 0 0 auto;
  background: var(--accent); color: #fff;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.brand-name { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; color: var(--rail-fg-strong); }
.brand-sub { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--rail-muted); }
.brand-light .brand-name { color: var(--navy); }
.brand-light .brand-sub { color: var(--muted); }
.rail-toggle {
  border: 0; background: transparent; color: var(--rail-muted); width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: grid; place-items: center; flex: 0 0 auto;
}
.rail-toggle:hover { background: var(--rail-hover); color: var(--rail-fg-strong); }
.nav-group { display: flex; flex-direction: column; gap: 2px; padding-top: 10px; }
.nav-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--rail-muted);
  padding: 0 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 0; background: transparent; color: var(--rail-fg);
  padding: 9px 12px; border-radius: 8px; font-weight: 600; font-size: 14px; line-height: 1.2;
  position: relative;
}
.nav-item svg { width: 19px; height: 19px; color: var(--rail-muted); }
.nav-item:hover { background: var(--rail-hover); color: var(--rail-fg-strong); }
.nav-item:hover svg { color: var(--rail-fg-strong); }
.nav-item[aria-current="page"] { background: var(--rail-active); color: var(--rail-fg-strong); }
.nav-item[aria-current="page"] svg { color: var(--accent); }
.nav-item[aria-current="page"]::before {
  content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.count {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; font-size: 11px; font-weight: 700;
  background: var(--accent); color: #fff; display: inline-grid; place-items: center; font-variant-numeric: tabular-nums;
}
.rail-foot { margin-top: auto; border-top: 1px solid var(--rail-hair); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.who { display: flex; align-items: center; gap: 10px; padding: 6px 8px 8px; min-width: 0; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  background: var(--navy-soft); color: #fff; font-size: 12px; font-weight: 700; text-transform: uppercase;
  border: 1px solid var(--rail-hair);
}
.who-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.who-name { font-size: 13px; font-weight: 600; color: var(--rail-fg-strong); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-role { font-size: 11px; color: var(--rail-muted); text-transform: capitalize; }

/* Collapsed: icons only, labels in the title tooltip. */
body.rail-collapsed .rail { padding-left: 8px; padding-right: 8px; }
body.rail-collapsed .rail-top { flex-direction: column; padding-bottom: 8px; gap: 8px; }
body.rail-collapsed .brand-text, body.rail-collapsed .nav-text, body.rail-collapsed .nav-label,
body.rail-collapsed .who-text, body.rail-collapsed .count { display: none; }
body.rail-collapsed .nav-item { justify-content: center; padding: 10px 0; }
body.rail-collapsed .nav-item[aria-current="page"]::before { left: -8px; }
body.rail-collapsed .nav-group { padding-top: 6px; }
body.rail-collapsed .who { justify-content: center; padding: 6px 0 8px; }
body.rail-collapsed .nav-item .count { display: block; position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }

/* ---- banner ------------------------------------------------------------------ */
.banner {
  flex: 0 0 auto; margin: 16px var(--pad) 0; padding: 10px 14px 10px 40px; border-radius: var(--radius-sm);
  background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); font-size: 13px; position: relative;
}
.banner::before {
  content: ""; position: absolute; left: 14px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cline x1='12' y1='11' x2='12' y2='16'/%3E%3Cline x1='12' y1='8' x2='12' y2='8.01'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cline x1='12' y1='11' x2='12' y2='16'/%3E%3Cline x1='12' y1='8' x2='12' y2='8.01'/%3E%3C/svg%3E") center / contain no-repeat;
}
.banner.error { background: var(--crit-soft); color: var(--crit); border-color: var(--crit-line); }

/* ---- sign-in ------------------------------------------------------------------ */
.signin {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px;
  background: var(--ground);
  background-image: radial-gradient(1200px 600px at 50% -10%, var(--accent-soft) 0%, transparent 60%);
}
.signin-card {
  width: min(400px, 100%); background: var(--surface); border: 1px solid var(--hair);
  border-radius: 14px; box-shadow: var(--shadow-2);
  padding: 28px; display: flex; flex-direction: column; gap: 12px;
}
.signin-card .brand { margin-bottom: 10px; }
.signin-card .brand-mark { background: var(--navy); }
.signin-card h1 { font-size: 22px; }
.signin-card .muted { margin-bottom: 6px; }
.signin-card .btn { margin-top: 4px; }

/* ---- controls ------------------------------------------------------------------ */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--navy);
  height: 34px; padding: 0 14px; border-radius: 8px; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; white-space: nowrap;
  box-shadow: var(--shadow-1); transition: background 120ms ease, border-color 120ms ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-2); border-color: var(--line-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--crit); }
.btn.danger:hover { background: var(--crit-soft); border-color: var(--crit-line); }
.btn.danger.armed, .mbtn.end.armed { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn:disabled { opacity: 0.5; cursor: default; box-shadow: none; }
.btn.small { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.lg { height: 42px; padding: 0 22px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; height: 38px; }
.icon-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--navy); width: 32px; height: 32px;
  border-radius: 8px; display: inline-grid; place-items: center;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.on-dark { border-color: transparent; background: rgba(255, 255, 255, 0.12); color: #fff; }
.icon-btn.on-dark:hover { background: rgba(255, 255, 255, 0.22); }
.seg { display: inline-flex; }
.seg .icon-btn { border-radius: 0; }
.seg .icon-btn:first-child { border-radius: 8px 0 0 8px; }
.seg .icon-btn:last-child { border-radius: 0 8px 8px 0; margin-left: -1px; }

input[type="text"], input[type="search"], input[type="url"], input[type="password"], input[type="email"],
input[type="tel"], input[type="date"], input[type="number"], textarea, select {
  height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  padding: 0 10px; color: var(--fg); min-width: 0; font-size: 13px;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
input::placeholder { color: var(--faint); }
input:focus-visible, textarea:focus-visible, select:focus-visible { border-color: var(--accent); box-shadow: var(--focus); }
select {
  appearance: none; padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7a85' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 16px;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--fg-2); }
.field input { height: 38px; font-size: 14px; font-weight: 400; }
.form-error, .si-error { margin: 0; min-height: 1.4em; color: var(--crit); font-size: 13px; }
.form-error:empty { display: none; }

.pill {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 9px; border-radius: 999px; background: var(--hair); color: var(--fg-2);
  display: inline-flex; align-items: center; gap: 6px; line-height: 1.6; white-space: nowrap;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.7; }
.pill.LISTENING { background: var(--good-soft); color: var(--good); }
.pill.THINKING { background: var(--accent-soft-2); color: var(--accent-strong); }
.pill.SPEAKING { background: var(--accent); color: #fff; }
.pill.INTERRUPTED { background: var(--warn-soft); color: var(--warn); }
.pill.ENDED { background: var(--crit-soft); color: var(--crit); }
.pill.IDLE { background: var(--hair); color: var(--muted); }
.pill.lang { background: var(--surface); border: 1px solid var(--line); text-transform: none; letter-spacing: 0; font-weight: 600; color: var(--fg-2); }
.pill.lang::before { display: none; }
.badge {
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 4px; line-height: 1.6;
}
.badge.sample { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-line); }
.tag { border: 1px solid var(--line); border-radius: 4px; padding: 0 6px; font-size: 11px; font-weight: 600; color: var(--fg-2); line-height: 1.6; }
.tag.live { border-color: var(--good); color: var(--good); }
.tag.audio { border-color: var(--accent); color: var(--accent-strong); }

.panel { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.empty { color: var(--muted); padding: 40px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.empty svg { width: 28px; height: 28px; color: var(--faint); margin-bottom: 6px; }
.empty b { color: var(--fg-2); font-weight: 600; }

/* ---- page structure ------------------------------------------------------------ */
.view { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 20px var(--pad) var(--pad); gap: 16px; }
.view.scroll { overflow: auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; flex: 0 0 auto; }
.page-title { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 320px; }
.page-desc { color: var(--muted); font-size: 13px; max-width: 68ch; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-head { display: flex; flex-direction: column; gap: 2px; }
.section-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 4px; }
.section-foot .kbtns { margin-left: auto; display: flex; gap: 8px; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; flex: 0 0 auto; }
.filters .search { position: relative; flex: 1 1 220px; min-width: 160px; display: flex; align-items: center; }
.filters .search svg { position: absolute; left: 10px; width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.filters .search input { width: 100%; padding-left: 32px; }
.filters .date {
  height: 34px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  display: inline-flex; align-items: center; gap: 6px; padding: 0 4px 0 10px;
}
.filters .date span { color: var(--muted); font-size: 12px; font-weight: 600; }
.filters .date input { border: 0; height: 30px; padding: 0 4px; box-shadow: none; }
.filters .date:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.toolbar { padding: 10px 12px; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.count-note { margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---- live calls ------------------------------------------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: var(--gap); overflow: auto; align-content: start; min-height: 0; }
.cards .empty { grid-column: 1 / -1; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 56px 20px; }
.card {
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius);
  box-shadow: var(--shadow-1); padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.card.watching { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-2); }
/* A call ringing reception: the card and the nav count pulse until someone picks up. */
.card.ringing { border-color: var(--good); animation: ring-pulse 1.2s ease-in-out infinite; }
@keyframes ring-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--good-soft); } 50% { box-shadow: 0 0 0 6px var(--good-soft); } }
.count.ringing { background: var(--good); animation: kpulse 1s ease-in-out infinite; }
.pill.RINGING { background: var(--good); color: #fff; }
.pill.ONCALL { background: var(--good-soft); color: var(--good); }
.pill.MISSED { background: var(--warn-soft); color: var(--warn); }
.btn.pickup, .mbtn.pickup { background: var(--good); border-color: var(--good); color: #fff; }
.btn.pickup:hover, .mbtn.pickup:hover { filter: brightness(0.92); }
.tag.missed { border-color: var(--warn); color: var(--warn); }
.tag.handoff { border-color: var(--good); color: var(--good); }
.bubble.note.handoff { color: var(--good); font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .card.ringing, .count.ringing { animation: none; } }
.card-top { display: flex; align-items: center; gap: 10px; min-width: 0; flex-wrap: wrap; }
.card-top > div:first-child { min-width: 0; flex: 1; }
.card .caller { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .line { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .dur { margin-left: auto; font-size: 20px; font-weight: 400; font-variant-numeric: tabular-nums; color: var(--navy); letter-spacing: -0.01em; }
.card .last {
  font-size: 13px; color: var(--fg-2); background: var(--surface-2); border-radius: var(--radius-sm);
  /* The inset is a border, not padding: overflow clips at the padding edge,
     so a padded clamp lets the third line peek through. */
  border: 8px solid var(--surface-2); border-left-width: 10px; border-right-width: 10px; padding: 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.9em;
}
.card .last b { color: var(--navy); font-weight: 600; }
.card-actions { display: flex; gap: 8px; }

/* ---- call log -------------------------------------------------------------------- */
.split { flex: 1; min-height: 0; display: flex; gap: var(--gap); }
.list-pane { flex: 0 0 380px; min-width: 0; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.list-pane .filters { display: grid; grid-template-columns: 1fr 1fr; }
.list-pane .filters .search, .list-pane .filters select { grid-column: 1 / -1; }
.list-pane .filters .date { min-width: 0; }
.list-pane .filters .date input { flex: 1; min-width: 0; }
.rows { flex: 1; min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 10px; padding: 12px 14px;
  border: 0; border-bottom: 1px solid var(--hair); border-left: 3px solid transparent;
  cursor: pointer; text-align: left; width: 100%; background: transparent; color: inherit;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--surface-2); }
.row.selected { background: var(--accent-soft); border-left-color: var(--accent); }
.row .r-caller { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r-when { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .r-preview { grid-column: 1 / -1; color: var(--fg-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r-tags { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--muted); margin-top: 2px; }
.detail-pane {
  flex: 1; min-width: 0; min-height: 0; overflow: auto; background: var(--surface);
  border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow-1); display: flex; flex-direction: column;
}
.detail-pane > .empty { margin: auto; }
.detail-head { padding: 18px 22px; border-bottom: 1px solid var(--hair); display: flex; flex-direction: column; gap: 14px; }
.detail-head .title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-head .title .caller { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; min-width: 0; overflow-wrap: anywhere; }
.meta { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 16px; font-size: 13px; }
.meta div { min-width: 0; overflow-wrap: anywhere; }
.meta div span { display: block; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; margin-bottom: 2px; }
.player { padding: 12px 22px; border-bottom: 1px solid var(--hair); display: flex; align-items: center; gap: 12px; background: var(--surface-2); }
.player audio { flex: 1; height: 36px; min-width: 0; }
.player .none { color: var(--muted); font-size: 13px; }
.transcript { padding: 18px 22px; display: flex; flex-direction: column; gap: 8px; }
.bubble {
  max-width: 72%; padding: 8px 12px; border-radius: 12px; font-size: 14px; position: relative;
  border: 1px solid var(--hair); background: var(--surface); cursor: default; overflow-wrap: anywhere;
}
.bubble.user { align-self: flex-end; background: var(--accent-soft); border-color: var(--accent-soft-2); border-bottom-right-radius: 4px; }
.bubble.agent { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.bubble.seekable { cursor: pointer; }
.bubble.seekable:hover { border-color: var(--accent); }
.bubble .t { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; font-variant-numeric: tabular-nums; }
.bubble .t b { font-weight: 600; color: var(--navy); }
.bubble.partial { opacity: 0.7; font-style: italic; }
.bubble.note { align-self: center; background: transparent; border: 0; color: var(--muted); font-size: 12px; max-width: 100%; text-align: center; }
.bubble.note.interrupt { color: var(--warn); }
.bubble.note.error { color: var(--crit); }
.bubble.note.policy { color: var(--warn); font-weight: 600; }
.bubble.tool { align-self: stretch; max-width: 100%; background: var(--surface); border-style: dashed; border-color: var(--line); font-size: 12.5px; }
.bubble.tool code { font-family: var(--mono); font-size: 12px; color: var(--navy); word-break: break-word; }
.bubble.tool .out { margin-top: 3px; color: var(--muted); }
.bubble.tool.pending .out { font-style: italic; }
.bubble.tool.failed { border-color: var(--crit); }
.bubble.tool.failed .out { color: var(--crit); }

/* ---- calendar ----------------------------------------------------------------------- */
.week-label { font-weight: 600; min-width: 190px; font-variant-numeric: tabular-nums; }
.calendar {
  flex: 1; min-height: 0; overflow: auto; display: grid; gap: 12px;
  grid-template-columns: repeat(var(--days, 5), minmax(150px, 1fr));
}
.day { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow-1); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.day.today { border-color: var(--accent); }
.day-head { padding: 10px 12px; border-bottom: 1px solid var(--hair); display: flex; align-items: baseline; gap: 8px; position: sticky; top: 0; background: var(--surface); z-index: 1; }
.day.today .day-head { background: var(--accent-soft); }
.day-head b { font-size: 13px; }
.day-head span { color: var(--muted); font-size: 12px; }
.day-head .n { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--fg-2); }
.day-body { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.apt { border-left: 3px solid var(--navy); background: var(--surface-2); border-radius: 6px; padding: 7px 9px; font-size: 12px; display: grid; gap: 2px; min-width: 0; }
.apt > div { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.apt .time { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--navy); display: flex; gap: 2px 6px; align-items: center; white-space: normal; flex-wrap: wrap; }
.apt .time .st { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }
.apt .pt { font-weight: 600; font-size: 13px; }
.apt .dr, .apt .why { color: var(--fg-2); }
.apt.confirmed { border-left-color: var(--accent); }
.apt.arrived { border-left-color: var(--good); }
.apt.completed { border-left-color: var(--faint); opacity: 0.8; }
.apt.cancelled { border-left-color: var(--crit); opacity: 0.65; }
.apt.cancelled .pt { text-decoration: line-through; }
.apt.no-show { border-left-color: var(--warn); border-left-style: dashed; }
.apt .st.booked { color: var(--navy); }
.apt .st.confirmed { color: var(--accent-strong); }
.apt .st.arrived { color: var(--good); }
.apt .st.completed { color: var(--faint); }
.apt .st.cancelled { color: var(--crit); }
.apt .st.no-show { color: var(--warn); }
.day .empty { padding: 14px; font-size: 12px; }

/* ---- caller launcher ----------------------------------------------------------------- */
.caller-card { padding: 48px 24px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; max-width: 560px; }
.caller-card .muted { max-width: 44ch; }
.caller-card .btn { margin-top: 8px; }
.caller-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong); margin-bottom: 4px; }
.caller-icon svg { width: 24px; height: 24px; }

/* ---- keys ------------------------------------------------------------------------------ */
.settings-section { display: flex; flex-direction: column; gap: 14px; padding: 20px 22px; background: var(--surface); border: 1px solid var(--hair); border-radius: var(--radius); box-shadow: var(--shadow-1); flex: 0 0 auto; }
.keys-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--gap); }
.kcard { margin: 0; padding: 14px 16px 16px; border: 1px solid var(--hair); border-radius: var(--radius); background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.kcard legend { font-weight: 600; padding: 0 6px; color: var(--navy); display: flex; align-items: baseline; gap: 6px; }
.legend-sub { font-size: 11px; font-weight: 700; letter-spacing: 0.06em; color: var(--muted); }
.krow { display: grid; grid-template-columns: 96px minmax(0, 1fr); align-items: center; gap: 4px 8px; font-size: 12px; font-weight: 600; color: var(--fg-2); }
.krow input { width: 100%; }
.krow .pick-wrap + .hint, .krow .hint { grid-column: 2; font-size: 11px; font-weight: 400; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; }
.krow .hint b { font-weight: 600; color: var(--fg-2); }
.krow .hint span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; font-family: var(--mono); }
.krow .hint button { border: 0; background: transparent; color: var(--crit); font-size: 11px; padding: 0; text-decoration: underline; }
.kact { margin-top: 2px; }
.kact-btns { display: flex; align-items: center; gap: 10px; min-width: 0; }
.kstatus { font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.kstatus:not(:empty)::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--line); flex: 0 0 auto; }
.kstatus.ok { color: var(--good); } .kstatus.ok::before { background: var(--good); }
.kstatus.warn { color: var(--warn); } .kstatus.warn::before { background: var(--warn); }
.kstatus.bad { color: var(--crit); } .kstatus.bad::before { background: var(--crit); }
.kstatus.busy::before { background: var(--accent); animation: kpulse 1s ease-in-out infinite; }
@keyframes kpulse { 50% { opacity: 0.3; } }
.kdetail { font-size: 12px; line-height: 1.45; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--hair); background: var(--surface); color: var(--fg-2); }
.kdetail.bad { background: var(--crit-soft); border-color: var(--crit-line); color: var(--crit); }
.kdetail.warn { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }
.kdetail b { display: block; margin-bottom: 2px; }
.ktry { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px dashed var(--hair); }
.ktry-row { display: flex; gap: 8px; align-items: center; }
.ktry-row input { flex: 1; min-width: 0; }
.ktry-out { font-size: 13px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--hair); white-space: pre-wrap; }
.ktry-out.bad { background: var(--crit-soft); border-color: var(--crit-line); color: var(--crit); }
.ktry audio { width: 100%; height: 34px; }
.btn.rec.on { background: var(--crit); border-color: var(--crit); color: #fff; }
.kpick { width: 100%; height: 38px; }
.krow input.custom-hidden { display: none; }
.krow .pick-wrap { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.krow .tag { font-size: 10px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 1px 6px; border-radius: 4px; background: var(--accent-soft-2); color: var(--navy); }
.krow .tag.env { background: var(--surface-2); color: var(--muted); border: 1px solid var(--hair); }
.probe { display: flex; gap: 14px; font-size: 12px; font-weight: 600; letter-spacing: 0.02em; color: var(--fg-2); flex-wrap: wrap; }
.probe .svc { display: inline-flex; align-items: center; gap: 6px; }
.probe .svc i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--line); }
.probe .svc.ok i { background: var(--good); }
.probe .svc.bad i { background: var(--crit); }

/* ---- users ------------------------------------------------------------------------------- */
.user-add { padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; flex: 0 0 auto; }
.user-add-row { display: flex; flex-wrap: wrap; gap: 8px; }
.user-add-row input[type="email"] { flex: 1 1 240px; }
.user-add-row input[type="password"] { flex: 1 1 200px; }
.view-users > .panel:last-child { flex: 0 0 auto; }
.rows.users { flex: 0 1 auto; border: 0; box-shadow: none; border-top: 1px solid var(--hair); border-radius: 0; }
#view-users .panel:not(.user-add) .section-head { padding: 16px 22px 12px; }
.urow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 4px 14px; padding: 12px 22px; border-bottom: 1px solid var(--hair); align-items: center; }
.urow:last-child { border-bottom: 0; }
.urow .u-email { font-weight: 600; grid-column: 1; grid-row: 1; overflow-wrap: anywhere; }
.urow .u-role { grid-column: 2; grid-row: 1; justify-self: end; height: 30px; }
.urow .u-actions { grid-column: 3; grid-row: 1 / span 2; display: flex; gap: 6px; justify-self: end; }
.urow .u-meta { grid-column: 1 / span 2; grid-row: 2; color: var(--muted); font-size: 12px; }
.urow .u-reset { display: none; grid-column: 1 / -1; gap: 8px; align-items: center; flex-wrap: wrap; padding-top: 4px; }
.urow.resetting .u-reset { display: flex; }
.urow .u-reset input { flex: 1 1 220px; }

/* ---- monitor ------------------------------------------------------------------------------ */
.monitor {
  width: min(var(--monitor-w), 100vw); min-height: 0;
  background: var(--surface); border-left: 1px solid var(--hair); box-shadow: -6px 0 20px rgba(29, 52, 67, 0.08);
  display: flex; flex-direction: column;
}
.monitor-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; background: var(--navy); color: #fff; }
.monitor-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.m-caller { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-meta { font-size: 11px; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-clock { font-variant-numeric: tabular-nums; font-weight: 400; font-size: 18px; }
.monitor-head .pill { background: rgba(255, 255, 255, 0.16); color: #fff; }
.monitor-head .pill.LISTENING { background: rgba(58, 178, 96, 0.35); }
.monitor-head .pill.SPEAKING { background: var(--accent); }
.monitor-head .pill.ENDED { background: var(--crit); }
.m-transcript { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; background: var(--surface-2); }
.m-transcript .bubble { max-width: 88%; }
.m-transcript .bubble.agent { background: var(--surface); }
.bubble.operator, .m-transcript .bubble.operator { align-self: flex-start; background: var(--good-soft); border-color: var(--good-soft); border-bottom-left-radius: 4px; }
.m-status { margin: 0; padding: 8px 16px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--hair); min-height: 2.2em; }
.m-status.warn { color: var(--warn); }
.m-status.error { color: var(--crit); }
.monitor-foot { display: flex; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--hair); }
.mbtn {
  flex: 1; border: 1px solid var(--line); background: var(--surface); color: var(--navy);
  height: 40px; padding: 0 8px; border-radius: 8px; font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; user-select: none; white-space: nowrap;
}
.mbtn svg { width: 17px; height: 17px; }
.mbtn:hover { background: var(--surface-2); }
.mbtn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.mbtn.barge[aria-pressed="true"] { background: var(--good); border-color: var(--good); }
.mbtn.end { color: var(--crit); }
.mbtn.end:hover { background: var(--crit-soft); border-color: var(--crit-line); }
.mbtn:disabled { opacity: 0.45; cursor: default; }
.mbtn.barge.arming { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }

/* ---- responsive ---------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .list-pane { flex-basis: 320px; }
  :root { --monitor-w: 360px; }
}
@media (max-width: 960px) {
  .app { grid-template-columns: var(--rail-w-min) minmax(0, 1fr) auto; }
  .rail { padding-left: 8px; padding-right: 8px; }
  .rail-top { flex-direction: column; padding-bottom: 8px; gap: 8px; }
  .brand-text, .nav-text, .nav-label, .who-text, .rail-toggle { display: none; }
  .nav-item { justify-content: center; padding: 10px 0; }
  .nav-item[aria-current="page"]::before { left: -8px; }
  .nav-item .count { position: absolute; top: 4px; right: 4px; min-width: 16px; height: 16px; font-size: 10px; padding: 0 4px; }
  .who { justify-content: center; padding: 6px 0 8px; }
  .split { flex-direction: column; }
  .list-pane { flex: 0 0 45%; }
  .monitor { position: fixed; inset: 0 0 0 auto; z-index: 20; }
}
@media (max-width: 640px) {
  :root { --pad: 16px; }
  .view { padding-top: 16px; }
  .page-head { flex-direction: column; }
  .page-title { flex: 0 0 auto; }   /* its 320px basis is a height in a column */
  .week-label { min-width: 0; }
}

/* The provider segment on the STT and TTS cards (console.js applyProvider). */
.kprov { display: flex; min-width: 0; }
.kprov .segbtn { flex: 1 1 0; min-width: 0; padding: 4px; border-radius: 0; }
/* "OpenAI Compatible" wraps to two lines in a narrow card rather than clip. */
.kprov .segbtn.small { height: auto; min-height: 28px; white-space: normal; line-height: 1.2; }
.kprov .segbtn:first-child { border-radius: 8px 0 0 8px; }
.kprov .segbtn:last-child { border-radius: 0 8px 8px 0; margin-left: -1px; }
.kprov .segbtn[aria-pressed="true"] { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---- the appointment editor ------------------------------------------------ */
/* Cards open the editor; the day's + and the header button start a new one. */
button.apt { font: inherit; color: inherit; text-align: left; width: 100%; border-top: 0; border-right: 0; border-bottom: 0; cursor: pointer; transition: box-shadow 0.12s, background 0.12s; }
button.apt:hover { background: var(--surface); box-shadow: var(--shadow-2); }
button.apt:focus-visible { outline: none; box-shadow: var(--focus); }
.apt.flash { animation: apt-flash 1.6s ease-out 1; }
@keyframes apt-flash { 0% { box-shadow: 0 0 0 4px var(--accent); } 100% { box-shadow: 0 0 0 0 transparent; } }
.day-head .add { width: 24px; height: 24px; margin-left: 4px; }
.day-head .add svg { width: 14px; height: 14px; }

.scrim { position: fixed; inset: 0; background: rgba(15, 30, 40, 0.32); z-index: 40; }
.sheet {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw); z-index: 41;
  background: var(--surface); box-shadow: -8px 0 32px rgba(29, 52, 67, 0.18);
  display: flex; flex-direction: column; animation: sheet-in 0.18s ease-out;
}
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; border-bottom: 1px solid var(--hair); }
.sheet-title { flex: 1; min-width: 0; }
.sheet-title h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.sheet-title p { margin: 4px 0 0; font-size: 12px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 20px 24px; display: flex; flex-direction: column; gap: 18px; }
.sheet-body fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.sheet-body legend { padding: 0; margin-bottom: 10px; font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sheet-body .field select { height: 38px; font-size: 14px; font-weight: 400; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field .hint { font-weight: 400; color: var(--muted); min-height: 1em; }
.field.invalid input, .field.invalid select { border-color: var(--crit); }
.field .field-error { font-weight: 500; color: var(--crit); }
.form-error { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--crit-soft); color: var(--crit); border: 1px solid var(--crit-line); font-size: 13px; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--hair); background: var(--surface-2); }
.sheet-foot .spacer { flex: 1; }
.btn.armed:not(.danger) { background: var(--warn-soft); border-color: var(--warn-line); color: var(--warn); }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-2); font-size: 13px; max-width: min(520px, calc(100vw - 32px));
}
@media (max-width: 520px) { .field-row { grid-template-columns: 1fr; } }
@media (prefers-reduced-motion: reduce) { .sheet, .apt.flash { animation: none; } }

/* Nia Configuration */
.nia-view { padding-bottom: 0; }
.nia-view > .page-head, .nia-view > .nia-alert { max-width: 1100px; width: 100%; }
.nia-form { display: flex; flex-direction: column; gap: 16px; max-width: 1100px; width: 100%; }
.nia-card { gap: 12px; }
.nia-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.nia-card-head h2 { font-size: 15px; }
.nia-card-head p { font-size: 12.5px; margin-top: 2px; max-width: 72ch; }
.nia-chip { align-self: center; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--hair); background: var(--surface-2); color: var(--fg-2); }
.nia-chip.console { background: var(--accent-soft); border-color: var(--accent-soft-2); color: var(--accent-strong); }
.nia-chip.file { background: var(--warn-soft); color: var(--warn); }
.nia-alert { background: var(--crit-soft); color: var(--crit); border-radius: 8px; padding: 10px 14px; font-size: 13px; max-width: 1100px; }
.nia-text { width: 100%; height: auto; min-height: 64px; padding: 10px 12px; line-height: 1.5; font-family: inherit; font-size: 13px; resize: vertical; }
#nia-intro { font-size: 14px; min-height: 56px; }
.nia-intro-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 12px; }
.nia-listen { display: flex; align-items: center; gap: 8px; }
.nia-listen audio { height: 30px; max-width: 260px; }
.nia-status:empty { display: none; }
.nia-status { font-size: 12px; color: var(--crit); }

.nia-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.nia-tile { border: 1px solid var(--hair); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: var(--surface); transition: border-color 120ms ease, background 120ms ease; }
.nia-tile.custom { border-color: var(--accent-soft-2); background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface)); }
.nia-tile.bad { border-color: var(--crit); }
.nia-tile-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 34px; }
.nia-tile-top label { font-size: 13px; font-weight: 600; color: var(--fg); }
.nia-num { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); overflow: hidden; flex: 0 0 auto; }
.nia-num:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.nia-num input { border: 0 !important; box-shadow: none !important; width: 78px; text-align: right; height: 32px; padding: 0 8px; font-variant-numeric: tabular-nums; background: transparent; }
.nia-unit { padding: 0 10px 0 2px; font-size: 12px; color: var(--muted); }
.nia-help { font-size: 12px; line-height: 1.45; }
.nia-tile-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 11.5px; min-height: 18px; }
.nia-field-error { font-size: 12px; color: var(--crit); }
.nia-field-error:empty { display: none; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent-strong); font: inherit; font-weight: 600; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.linkbtn[hidden] { display: none; }

.nia-switch { appearance: none; -webkit-appearance: none; width: 38px; height: 22px; border-radius: 999px; background: var(--line-strong); position: relative; cursor: pointer; transition: background 140ms ease; flex: 0 0 auto; margin: 0; }
.nia-switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform 140ms ease; }
.nia-switch:checked { background: var(--accent); }
.nia-switch:checked::after { transform: translateX(16px); }
.nia-switch:focus-visible { outline: none; box-shadow: var(--focus); }

.nia-sections { display: flex; flex-direction: column; gap: 8px; }
.nia-sec { border: 1px solid var(--hair); border-radius: 10px; background: var(--surface); }
.nia-sec[open] { border-color: var(--line); }
.nia-sec.bad { border-color: var(--crit); }
.nia-sec > summary { list-style: none; cursor: pointer; display: grid; grid-template-columns: 170px minmax(0, 1fr) auto; align-items: center; gap: 4px 14px; padding: 11px 14px; border-radius: 10px; }
.nia-sec > summary::-webkit-details-marker { display: none; }
.nia-sec > summary:hover { background: var(--surface-2); }
.nia-sec > summary:focus-visible { outline: none; box-shadow: var(--focus); }
.nia-sum-title { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; min-width: 0; }
.nia-sum-title::before { content: ""; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 120ms ease; flex: 0 0 auto; margin-right: 2px; }
.nia-sec[open] .nia-sum-title::before { transform: rotate(45deg); }
.nia-sum-title b { font-size: 13px; }
.nia-flag { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.nia-sum-help { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nia-sec[open] .nia-sum-help { white-space: normal; }
.nia-count { font-size: 11.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nia-sec.bad .nia-count { color: var(--crit); font-weight: 600; }
.nia-sec > textarea { display: block; margin: 0 14px 14px; width: calc(100% - 28px); font-size: 13px; }

.nia-bar { position: sticky; bottom: 0; z-index: 5; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: -4px; padding: 12px 0 16px; background: color-mix(in srgb, var(--ground) 94%, transparent); backdrop-filter: blur(6px); box-shadow: 0 -1px 0 var(--hair); }
.nia-bar .form-error { flex: 1 1 240px; margin: 0; }
.nia-bar .kbtns { margin-left: auto; display: flex; gap: 8px; }
.nia-dirty { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; }
.nia-dirty.on { color: var(--fg); font-weight: 600; }
.nia-dirty.on::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.nia-dirty.saved { color: var(--good); font-weight: 600; }
.nia-dirty.saved::before { content: "✓"; font-weight: 700; }

@media (max-width: 640px) {
  .nia-sec > summary { grid-template-columns: minmax(0, 1fr) auto; }
  .nia-sum-help { grid-column: 1 / -1; grid-row: 2; }
  .nia-grid { grid-template-columns: minmax(0, 1fr); }
  .nia-chip { align-self: flex-start; }
  .nia-sec > summary { padding: 10px 12px; }
  .nia-sec > textarea { margin: 0 10px 10px; width: calc(100% - 20px); }
  .nia-bar .kbtns { width: 100%; }
  .nia-bar .kbtns .btn { flex: 1; }
}
.nia-text { width: 100%; height: auto; padding: 8px 10px; line-height: 1.45; font-family: inherit; resize: vertical; }
.nia-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px 20px; margin-bottom: 8px; }
.nia-row { grid-template-columns: 1fr 96px; }
.nia-row input[type="checkbox"] { width: auto; justify-self: start; }
.nia-help { grid-column: 1 / -1; font-weight: 400; }
.nia-sec { display: block; margin-bottom: 14px; }
.nia-sec-head { display: block; font-size: 12px; margin-bottom: 4px; color: var(--fg-2); }
.nia-sec-head .muted { font-weight: 400; }
#nia-form .section-head { margin-top: 18px; }

/* ---- QA pass 2026-09-28 --------------------------------------------------- */
/* Live cards never wider than the screen (a 340px floor overflowed a phone). */
.cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
/* A long view name wraps to a second line rather than losing its end
   (only where the rail shows names at all). */
@media (min-width: 961px) {
  body:not(.rail-collapsed) .nav-text { white-space: normal; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
}
@media (max-width: 640px) {
  /* The week reads as an agenda on a phone: one day under the next, each
     as tall as its appointments. */
  .calendar { grid-template-columns: 1fr; grid-auto-rows: max-content; overflow: auto; }
  .day { overflow: visible; }
  .day-head { position: static; }
}
/* Sign-in sits over everything, the editor sheet included: a session that
   expires mid-edit must be answerable without losing the form. */
.signin { z-index: 60; }
