/* Bunkerchain design system.
 *
 * Copied verbatim from ai-support-agent's console (app.css) on 2026-09-21 so
 * the two consoles look like one product. Copied rather than reimplemented
 * deliberately: a second hand-written stylesheet drifts from the first within
 * weeks, and "same theme" then stops being true.
 *
 * Keep IHS-specific rules in ihs.css, NOT here, so this file can be refreshed
 * from upstream by overwriting it.
 */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f0f3f7;
  --border: #e2e7ee;
  --text: #16202b;
  --text-muted: #667487;
  --primary: #0b5cab;
  --primary-ink: #ffffff;
  --primary-soft: #e8f1fb;
  --success: #1a7f4b;
  --success-soft: #e6f6ec;
  --warn: #9a6a00;
  --warn-soft: #fdf4dd;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 32, 43, 0.06), 0 4px 16px rgba(16, 32, 43, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141b;
    --surface: #161d26;
    --surface-2: #1c2530;
    --border: #26313d;
    --text: #e6ecf3;
    --text-muted: #9aa7b6;
    --primary: #4b9fe6;
    --primary-ink: #06121f;
    --primary-soft: #14293d;
    --success: #4cc98a;
    --success-soft: #123123;
    --warn: #e0b64a;
    --warn-soft: #322a12;
    --danger: #f0857a;
    --danger-soft: #3a1e1b;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

/* [228] A <select> sizes itself to its longest <option>/<optgroup label> and never shrinks
   on its own, so one long label scrolls the whole DOCUMENT sideways on a phone — the same
   cause as [211]'s conversation picker, hit again on Settings' AI-model list (labels carry
   the endpoint name plus "· NOT served · reads photos"). Capped here so the next picker
   someone adds inherits the fix. Selects that deliberately opt out re-declare max-width. */
select { max-width: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- top nav ---- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.7rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.brand {
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.brand-logo { width: 26px; height: 26px; object-fit: contain; flex: none; }
.login-logo { width: 52px; margin: 0 auto 0.6rem; display: block; }
.nav { display: flex; gap: 0.25rem; margin-left: 0.5rem; flex-wrap: wrap; }
.nav a {
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
}
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.spacer { flex: 1; }
.who { display: flex; align-items: center; gap: 0.6rem; color: var(--text-muted); font-size: 0.85rem; }
.inline { display: inline; }

/* ---- layout ---- */
main { max-width: 880px; margin: 1.75rem auto; padding: 0 1.25rem; }

/* desktop (>700px): the topbar becomes a left side nav and the content uses the full
   width ([056]). Markup unchanged — mobile keeps the topbar + hamburger. */
@media (min-width: 701px) {
  body:has(.topbar) { display: grid; grid-template-columns: 225px minmax(0, 1fr); min-height: 100vh; }
  .topbar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    flex-direction: column; align-items: stretch; gap: 0.5rem;
    padding: 1rem 0.75rem; border-right: 1px solid var(--border); border-bottom: none;
  }
  .brand { padding: 0 0.45rem 0.5rem; align-items: flex-start; }
  .brand-name { line-height: 1.3; font-size: 0.95rem; }
  .nav { flex-direction: column; margin-left: 0; gap: 0.15rem; }
  .nav a { padding: 0.5rem 0.7rem; border-radius: var(--radius-sm); font-size: 0.92rem; }
  .who {
    flex-direction: column; align-items: stretch; gap: 0.45rem;
    padding: 0.6rem 0.45rem 0; border-top: 1px solid var(--border);
    overflow-wrap: anywhere; font-size: 0.8rem;
  }
  /* [180] fluid content column — no fixed cap, use the whole viewport width */
  body:has(.topbar) main { grid-column: 2; max-width: none; margin: 1.5rem 0; padding: 0 2rem; }
}
h1 { font-size: 1.5rem; letter-spacing: -0.02em; margin: 0 0 0.25rem; }
h2 { font-size: 1rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; margin: 1.5rem 0 0.6rem; }
.hint { color: var(--text-muted); font-size: 0.9rem; margin-top: 0; max-width: 105ch; } /* [180] prose line-length cap in the fluid column */
.backlink { color: var(--text-muted); font-size: 0.85rem; }
.empty { color: var(--text-muted); padding: 1.5rem; text-align: center; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---- cards ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem;
  margin: 0.75rem 0;
}

/* ---- buttons ---- */
button, .btn {
  font: inherit;
  font-weight: 600;
  padding: 0.5rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
  cursor: pointer;
  transition: filter 0.15s ease;
}
button:hover { filter: brightness(1.06); }
button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
button.danger { background: var(--surface); color: var(--danger); border-color: var(--danger-soft); }
button.danger:hover { background: var(--danger-soft); }

/* ---- forms ---- */
form { margin: 0; }
label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.3rem; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%;
  padding: 0.55rem 0.7rem;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
input:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
textarea { resize: vertical; min-height: 3rem; }
/* with JS, textareas auto-grow to fit content (console.js) — hide the scrollbar and the
   now-redundant resize handle; without JS the manual vertical resize stays */
html.js textarea { overflow: hidden; resize: none; }

/* ---- login ---- */
.login-wrap { min-height: 70vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 360px; }
.login-card .field { margin-bottom: 0.9rem; }
.login-card button { width: 100%; }

/* ---- alerts ---- */
.alert { border-radius: var(--radius-sm); padding: 0.6rem 0.85rem; margin: 0.75rem 0; font-size: 0.9rem; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.success { background: var(--success-soft); color: var(--success); }
.kb-io summary { cursor: pointer; font-weight: 600; color: var(--primary); }
.kb-io-body { margin-top: 1rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 640px) { .kb-io-body { grid-template-columns: 1fr; gap: 1.5rem; } }
/* [229] min-width:0 — `1fr` is `minmax(auto, 1fr)`, and that `auto` minimum resolves to the
   ITEM's min-content size, which here is set by the <input type="file"> (its selector button
   plus "No file chosen"). So the track was forced wider than the phone and the page scrolled,
   single-column breakpoint or not. Same flex/grid automatic-minimum trap as [228]. */
.kb-io-col { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start;
  min-width: 0;
  padding: 0.9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.kb-io-h { margin: 0; font-size: 0.95rem; }
.kb-io .hint { margin: 0; }
.kb-import { display: flex; flex-direction: column; gap: 0.75rem; align-items: flex-start; width: 100%; }
/* [229] width, not max-width — the asymmetry is the whole point. A percentage `width`
   resolves to ZERO when intrinsic contributions are computed, so it lowers this input's
   min-content contribution and the track can shrink. A percentage `max-width` resolves to
   `none` there, so it never lowered anything; it only capped the used width afterwards, by
   which point the track had already been widened to the UA's file-widget size (measured:
   Chrome sizes the widget 303px flat, no matter the container or the filename).
   Belt and braces with .kb-io-col's min-width:0 above — each alone removes the overflow
   (measured at 320px: +27px → 0 with either), both because they defend different engines'
   widget widths. */
.kb-file { font-size: 0.82rem; width: 100%; }
.kb-file::file-selector-button {
  font: inherit; padding: 0.35rem 0.7rem; margin-right: 0.6rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--primary-soft); color: var(--primary); }
.kb-import-modes { display: flex; flex-direction: column; gap: 0.4rem; }
.kb-import-modes label { display: flex; align-items: baseline; gap: 0.4rem; cursor: pointer; font-size: 0.9rem; }
.kb-mode-name { font-weight: 600; }
.kb-mode-hint { color: var(--text-muted); font-size: 0.8rem; }

/* ---- badges ---- */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.badge.sent, .badge.on, .badge.enabled { background: var(--success-soft); color: var(--success); }
.badge.suppressed, .badge.observe { background: var(--warn-soft); color: var(--warn); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }
.badge.customer { background: var(--surface-2); color: var(--text-muted); }
.badge.employee { background: var(--primary-soft); color: var(--primary); }

/* ---- conversations list ---- */
.list { display: flex; flex-direction: column; gap: 0.5rem; }
.row-link {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.85rem 1rem; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.row-link:hover { border-color: var(--primary); text-decoration: none; }
.row-link .cid { font-weight: 600; color: var(--text); }
.row-link small { color: var(--text-muted); }
/* conversation rows: a main link (name/time/preview) + a side (AI status + auto-reply toggle,
   [096]). The toggle is interactive so it sits OUTSIDE the link, not nested in it. */
.convo-row { gap: 0.75rem; }
.convo-main {
  display: flex; flex: 1; min-width: 0; align-items: center; justify-content: space-between;
  flex-wrap: wrap; row-gap: 0.15rem; column-gap: 0.75rem;
}
.convo-main:hover { text-decoration: none; }
.convo-row .preview {
  flex-basis: 100%; font-size: 0.82rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.convo-side { display: flex; align-items: center; gap: 0.6rem; flex: none; }

/* AI engagement status badge (list rows + conversation header, [096]) */
.ai-status {
  display: inline-flex; align-items: center; gap: 0.3rem; white-space: nowrap;
  font-size: 0.72rem; font-weight: 600; padding: 0.2rem 0.55rem; border-radius: 999px;
  margin-top: 0.3rem;
}
.ai-status.active  { background: var(--success-soft); color: var(--success); }
.ai-status.observe { background: var(--surface-2); color: var(--text-muted); }
.ai-status.paused  { background: var(--warn-soft); color: var(--warn); }
.ai-status.off     { background: var(--surface-2); color: var(--text-muted); }
.toggle-inline { display: inline-flex; align-items: center; gap: 0.4rem; margin: 0; }
/* [156] the bar holds the dialog trigger + hint directly (no form since the checkbox dialog);
   [163] flex on the bar itself so button + hint align and wrap on small screens. */
.broadcast-bar { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin: 0.5rem 0 1rem; }
.file-head { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.6rem; }
.file-row { align-items: center; gap: 0.6rem; }  /* [107] agent-file row: name + meta + edit/remove */
.file-name-input { width: 100%; box-sizing: border-box; }  /* [110] create-file field fills its column */

@media (max-width: 700px) {
  /* [163] mobile: the row must WRAP for the side (status + toggle) to stack below the
     name/preview — width:100% alone never wrapped because .row-link is nowrap by default. */
  .convo-row { flex-wrap: wrap; }
  .convo-side { width: 100%; justify-content: space-between; }
  /* [211] the [204] per-row product picker overflowed the viewport: a <select> never
     shrinks below its intrinsic width (longest option label), so give it its own
     full-width row and let it flex — same fix as the chat header's picker ([207]). */
  .convo-side { flex-wrap: wrap; row-gap: 0.5rem; }
  .convo-side form:has(select[name="application"]) {
    /* min-width:0 — the FORM is a flex item too; its default min-width:auto blocked the
       shrink, leaving the select at intrinsic width poking past the card ([212] revisit) */
    flex-basis: 100%; display: flex; min-width: 0;
  }
  .convo-side select[name="application"] { flex: 1; min-width: 0; }
  /* long JIDs/names must break, not push the row wider than the screen */
  .row-link .cid { min-width: 0; overflow-wrap: anywhere; }
  /* (search-bar wrap rules live in the later ≤700px block shared with the KB page) */
}

/* ---- conversation thread (WhatsApp-style chat, [053]) ---- */
:root {
  --wa-bg: #efe7dc;             /* chat wallpaper */
  --wa-in: #ffffff;             /* incoming bubble */
  --wa-out: #d9fdd3;            /* outgoing (agent) bubble */
  --wa-sep: rgba(255, 255, 255, 0.9);
}
@media (prefers-color-scheme: dark) {
  :root {
    --wa-bg: #0b141a;
    --wa-in: #202c33;
    --wa-out: #005c4b;
    --wa-sep: rgba(32, 44, 51, 0.92);
  }
}
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.chat-head h1 { margin-bottom: 0.1rem; }
/* [207] The conversation view is a fixed-height app screen: the header, banner and tools
   sit above a .chat pane that scrolls INTERNALLY, so nothing needs to be sticky and the
   page never grows with the transcript. (Replaces the old sticky chat-head + JS-pinned
   takeover banner, whose measured offsets overlapped and misrendered on long chats.) */
body:has(.chat-page) { height: 100dvh; overflow: hidden; }
body:has(.chat-page) main {
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.chat-page { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.chat-page .takeover-banner { position: static; }  /* always visible above the pane */
@media (min-width: 701px) {
  .chat-head { border-bottom: 1px solid var(--border); padding: 0.5rem 0; }
}
@media (max-width: 700px) {
  /* the mobile topbar shares the column: body becomes the flex root */
  body:has(.chat-page) { display: flex; flex-direction: column; }
  body:has(.chat-page) main { flex: 1; width: 100%; margin: 0.6rem auto; }
}
.chat-tools { display: flex; align-items: center; gap: 0.9rem; }
.poll-label { display: flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin: 0; }
.poll-label select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.3rem 0.4rem;
}
.chat {
  display: flex; flex-direction: column;
  background: var(--wa-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem 0.9rem 1rem; margin-top: 0.75rem;
  /* [207] the scrolling pane; min-height:0 lets flex actually shrink it to fit */
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
/* [158] "Load older messages" pager pinned at the top of a long chat. */
.load-more { align-self: center; margin: 0.15rem 0 0.35rem; }
.load-more a {
  display: inline-block; font-size: 0.78rem; text-decoration: none; color: var(--primary);
  background: var(--card); border: 1px solid var(--border); border-radius: 999px;
  padding: 0.25rem 0.85rem;
}
.load-more a:hover { background: var(--bg); }
.day-sep { text-align: center; margin: 0.7rem 0 0.3rem; }
.day-sep span {
  display: inline-block; background: var(--wa-sep); color: var(--text-muted);
  font-size: 0.72rem; padding: 0.25rem 0.7rem; border-radius: 8px; box-shadow: var(--shadow);
}
.bubble {
  /* [180] px cap so bubbles stay readable in the fluid full-width column (WhatsApp-Web-style) */
  position: relative; max-width: min(72%, 720px); width: fit-content;
  padding: 0.45rem 0.65rem 0.35rem; border-radius: 10px; margin: 0.22rem 0;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.12);
}
.bubble p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-media { display: block; max-width: min(260px, 100%); height: auto; border-radius: 8px; margin-bottom: 0.25rem; }
.bubble .sender { display: block; font-size: 0.74rem; font-weight: 600; color: var(--primary); margin-bottom: 0.1rem; }
.bubble .sender-num { font-weight: 400; font-size: 0.68rem; color: var(--text-muted); margin-left: 0.25rem; }
.bubble .sender-tag {
  font-weight: 600; font-size: 0.62rem; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--warn); border: 1px solid var(--warn); border-radius: 999px;
  padding: 0 0.35rem; margin-left: 0.3rem; vertical-align: 1px;
}
/* deterministic per-sender name colors, like WhatsApp group chats */
.sender.sc0 { color: #d81b60; }
.sender.sc1 { color: #7b1fa2; }
.sender.sc2 { color: #1976d2; }
.sender.sc3 { color: #00897b; }
.sender.sc4 { color: #e65100; }
.sender.sc5 { color: #5d4037; }
.sender.sc6 { color: #c2185b; }
.sender.sc7 { color: #2e7d32; }
@media (prefers-color-scheme: dark) {
  /* lighter variants — the light-mode swatches lack contrast on dark bubbles */
  .sender.sc0 { color: #f48fb1; }
  .sender.sc1 { color: #ce93d8; }
  .sender.sc2 { color: #90caf9; }
  .sender.sc3 { color: #80cbc4; }
  .sender.sc4 { color: #ffb74d; }
  .sender.sc5 { color: #bcaaa4; }
  .sender.sc6 { color: #f8bbd0; }
  .sender.sc7 { color: #a5d6a7; }
}
.bubble .stamp {
  display: block; text-align: right; font-size: 0.66rem; color: var(--text-muted);
  margin-top: 0.15rem; white-space: nowrap;
}
.bubble.customer { background: var(--wa-in); border-top-left-radius: 2px; align-self: flex-start; }
.bubble.employee { background: var(--wa-in); border-top-left-radius: 2px; align-self: flex-start; }
.bubble.agent { background: var(--wa-out); border-top-right-radius: 2px; align-self: flex-end; }
.bubble.agent .sender { color: var(--text-muted); font-weight: 500; }
/* [155] Flash a deep-linked message (KB gap "Open chat") so staff spot where the gap surfaced. */
.bubble.flash { animation: bubble-flash 2s ease-out; }
@keyframes bubble-flash {
  0%, 25% { box-shadow: 0 0 0 3px var(--primary); }
  100% { box-shadow: 0 0 0 3px transparent; }
}
.tick { margin-left: 0.3rem; font-size: 0.66rem; }
.tick.sent { color: #53bdeb; letter-spacing: -0.08em; }
.tick.suppressed { color: var(--warn); font-weight: 600; }
.tick.failed { color: var(--danger); font-weight: 600; }
.bubble.agent.suppressed { opacity: 0.75; border: 1px dashed var(--warn); }
/* [214] Assistant page: staff speak from the left (like a customer bubble), agent right */
.bubble.staff-msg { background: var(--wa-in); border-top-left-radius: 2px; align-self: flex-start; }
.bubble .when { display: block; text-align: right; font-size: 0.68rem; color: var(--text-muted); margin-top: 0.15rem; }
/* [231] Chat-app composer. Three boxes that used to sit in a row as equals (textarea, a
   bordered clip button, a rectangular Send) are now one rounded pill holding the clip and
   the text field, plus a round send button beside it — the shape people already know from
   WhatsApp. The palette stays the console's own; only the geometry is borrowed. */
.assistant-compose { display: flex; gap: 0.5rem; margin-top: 0.75rem; align-items: flex-end; }
.composer-pill {
  /* min-width:0 — the pill is a flex item wrapping a textarea, and a flex item's automatic
     minimum is content-sized: without this it refuses to shrink on a phone (six prior bugs,
     see [229]). */
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: 0.2rem;
  padding: 0.2rem; background: var(--surface);
  border: 1px solid var(--border); border-radius: 1.4rem;
}
/* the whole pill takes the focus ring, so the borderless textarea inside still reads as
   focused — that cue was previously the textarea's own outline */
.composer-pill:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.composer-row { display: flex; align-items: flex-end; gap: 0.1rem; min-width: 0; }
.assistant-compose textarea {
  flex: 1; min-width: 0;
  margin: 0; padding: 0.5rem 0.5rem 0.5rem 0.15rem;
  /* dvh, not vh: with a phone keyboard open, vh still measures the LARGE viewport, so the
     cap would be ~40% of a screen the user cannot fully see. */
  min-height: 2.1rem; max-height: 40vh; max-height: 40dvh;
  border: none; border-radius: 0; background: transparent;
}
.assistant-compose textarea:focus { outline: none; }
/* autosize sets an inline height from scrollHeight and `html.js textarea` hides the
   scrollbar, so past the cap a long paste would be CLIPPED with no way to scroll to it —
   wheel and touch both dead. Restore scrolling for this one field, and keep `resize: none`
   scoped to the JS case so a no-JS composer still has its drag handle. */
html.js .assistant-compose textarea { overflow-y: auto; resize: none; }
.cmp-icon { width: 1.25rem; height: 1.25rem; display: block; flex: none; }
/* [224] Attach-a-screenshot control: the native file input is visually replaced by the
   clip label (still focusable + keyboard-activatable, since the input stays in the DOM).
   [231] now a round icon button seated inside the pill rather than a bordered box. */
.assistant-attach {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 2.15rem; height: 2.15rem; margin: 0; padding: 0; cursor: pointer;
  border: none; border-radius: 50%; background: transparent; color: var(--text-muted);
}
.assistant-attach:hover { background: var(--surface-2); color: var(--text); }
.assistant-attach:focus-within { outline: 2px solid var(--primary); outline-offset: -2px; }
.assistant-attach input[type="file"] { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
/* the chosen filename rides INSIDE the pill; :empty keeps it out of the layout until the
   picker fills it in, so the composer doesn't jump before a file is chosen */
.attach-name {
  font-size: 0.72rem; color: var(--text-muted);
  padding: 0.15rem 0.6rem 0; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attach-name:empty { display: none; }
.assistant-compose .send-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 2.75rem; height: 2.75rem; padding: 0;
  border: none; border-radius: 50%;
  background: var(--primary); color: var(--primary-ink);
}
.assistant-compose .send-btn:disabled { opacity: 0.6; cursor: default; filter: none; }
/* [231] busy state is a CLASS, not a text swap: this button's label is an <svg>, and
   assigning textContent (the old data-busy-label mechanism) would delete the icon. */
.assistant-compose .send-btn.is-busy .cmp-icon { animation: send-busy 1s ease-in-out infinite; }
@keyframes send-busy { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .assistant-compose .send-btn.is-busy .cmp-icon { animation: none; opacity: 0.5; }
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* [216] the in-flight turn's placeholder bubble */
.bubble.thinking p { color: var(--text-muted); font-style: italic; }
.bubble.thinking { animation: thinking-pulse 1.6s ease-in-out infinite; }
@keyframes thinking-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.bubble.agent.failed { border: 1px solid var(--danger); }
.sys-note {
  align-self: center; max-width: 86%; text-align: center;
  background: var(--wa-sep); border-radius: 8px; box-shadow: var(--shadow);
  padding: 0.35rem 0.7rem; margin: 0.45rem 0; font-size: 0.74rem; color: var(--text-muted);
}
.sys-note .sys-label { display: block; font-weight: 600; }
.sys-note .sys-text { display: block; margin-top: 0.15rem; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---- editor rows / tables ---- */
.kb-row, .roster-row, .group-row {
  display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 0.75rem 0.9rem; margin: 0.5rem 0; box-shadow: var(--shadow);
}
.kb-row textarea { flex: 1; min-width: 240px; }
.kb-row { align-items: stretch; }
.kb-row .kb-edit { flex: 1; display: flex; gap: 0.5rem; align-items: center; }
/* [232] the passage's action pair, kept together in one container */
.kb-actions { display: flex; gap: 0.5rem; align-items: center; flex: none; }
.kb-actions form { display: flex; align-items: center; }

/* [056] read mode: text as text; the edit form appears only after "Edit" (JS).
   Without JS the view row is hidden and the always-on edit form remains (old behavior). */
.kb-view { flex: 1; display: flex; gap: 0.7rem; align-items: center; min-width: 0; }
.kb-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; flex: 1; }
.kb-cat {
  white-space: nowrap; font-size: 0.72rem; font-weight: 600; color: var(--text-muted);
  background: var(--surface-2); border-radius: 999px; padding: 0.2rem 0.6rem;
}
/* [243] A passage the nightly learner published with no one reviewing it. Warn-coloured
   rather than neutral: the chip is the only warning staff get that this text went live
   unapproved, and it has to read differently from the category and product chips beside it. */
.kb-cat.kb-learned { color: var(--warn); background: var(--warn-soft); }
html:not(.js) .kb-view { display: none; }
html:not(.js) [data-cancel-edit] { display: none; } /* inert without JS — hide it */
/* [232] Edit left .kb-view, so it is no longer hidden along with it — without JS the button
   does nothing (it only toggles a class), so hide it the same way Cancel is hidden. */
html:not(.js) .kb-edit-btn { display: none; }
html.js .kb-row .kb-edit { display: none; }
html.js .kb-row.editing .kb-edit { display: flex; }
html.js .kb-row.editing .kb-view { display: none; }
/* while editing, Save/Cancel are the controls — a second "Edit" would be a no-op */
html.js .kb-row.editing .kb-edit-btn { display: none; }
.roster-row .email, .group-row .gid { font-weight: 600; min-width: 180px; word-break: break-all; }
.roster-row { align-items: end; }
.roster-row .email { align-self: center; }
.roster-row label { display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem; margin: 0; }
.roster-row button { margin-bottom: 2px; }
.group-row label { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; }

/* ---- toggle switch ---- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; transition: 0.2s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: 0.2s; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.switch input:checked + .slider { background: var(--success); border-color: var(--success); }
.switch input:checked + .slider::before { transform: translateX(18px); }

.count { color: var(--text-muted); font-weight: 400; font-size: 1rem; }

/* ---- KB search + pager ---- */
.kb-search { display: flex; gap: 0.5rem; align-items: center; margin: 1rem 0 0.5rem; }
/* category selects ([051]): shared look in add form, search filter, and row editors */
.kb-search select, .kb-add-actions select, .kb-edit-actions select {
  padding: 0.5rem 0.6rem; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); max-width: 220px;
}
.kb-add-actions, .kb-edit-actions { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.6rem; }
.kb-edit-actions { margin-top: 0; }
.kb-search input[type="search"] { flex: 1; max-width: 420px; padding: 0.55rem 0.7rem; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.btn-link { align-self: center; font-size: 0.9rem; }
.pager { display: flex; justify-content: space-between; align-items: center; margin: 1rem 0; }
.pager-status { color: var(--text-muted); font-size: 0.85rem; }
.jid { color: var(--text-muted); font-weight: 400; font-size: 0.75rem; }

/* ---- agent control center ([067]): QR pairing + master switch ---- */
/* [228] No min-width:0 here on purpose: #wa-msg only ever holds one of four fixed sentences
   (console.js), all of which fit a phone. If a JID, hostname or raw error body is ever put
   in it, this row becomes the next horizontal-overflow bug — add `min-width: 0` then. */
.wa-status { display: flex; align-items: center; gap: 0.5rem; }
.wa-qr { width: 240px; height: 240px; max-width: 100%; margin-top: 0.6rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; padding: 8px; }
/* [209] the unlink button sits under the status/QR with its explainer beside it */
.wa-logout { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-top: 0.9rem; }
.wa-logout .hint { margin: 0; }
/* [210] Support API key card */
.api-key-row { margin: 0.5rem 0; }
.api-key-row input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }
.api-key-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.6rem; }
.master-switch { display: flex; align-items: center; gap: 0.7rem; }
.switch-label { font-size: 0.95rem; }
.settings-table th { width: 42%; text-align: left; color: var(--text-muted); font-weight: 600; }
.settings-table td { word-break: break-all; }

/* ---- agent settings + prompt audit ---- */
.alert.saved { background: var(--success-soft); color: var(--success); }
.agent-form label { margin-top: 0.9rem; }
.agent-form .hint { margin: 0.1rem 0 0.35rem; }
.prompt-details { margin-top: 0.45rem; }
.prompt-details summary { cursor: pointer; font-size: 0.78rem; color: var(--text-muted); }
.prompt-details pre {
  white-space: pre-wrap; word-break: break-word; font-size: 0.75rem;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.6rem; max-height: 320px; overflow-y: auto;
}

/* ---- gateway health + roster periods ---- */
/* [228] wrap + min-width:0: the status line carries a HOSTNAME
   (llm.bunkerchain.io/qwen3.8-27b/v1 and, before [236], a far longer EC2 name), one token wider
   than a phone. A flex item's default min-width:auto refuses to shrink below that, so the
   card pushed the page sideways instead of wrapping. */
.gw-card { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.55rem 0.9rem; margin: 0.5rem 0 1rem; box-shadow: var(--shadow); }
.gw-card small { color: var(--text-muted); min-width: 0; overflow-wrap: anywhere; }
.period-add { display: flex; gap: 0.75rem; align-items: end; flex-wrap: wrap; }
.period-add label { margin: 0; }
.period-row span { font-size: 0.92rem; }
select, input[type="datetime-local"] { padding: 0.5rem 0.6rem; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* Modal dialogs (roster add-user / duty / reset-password / remove, [102]). Native <dialog>:
   JS opens via showModal(); Escape + Cancel close. Without JS the forms render inline (the
   trigger buttons hide) so the page still works — progressive enhancement. */
.roster-toolbar { margin: 0.25rem 0 1rem; }
.modal {
  border: none; padding: 0; max-width: 30rem; width: calc(100% - 2rem);
  background: var(--surface); color: var(--text);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.modal::backdrop { background: rgba(16, 32, 43, 0.5); }
.modal-form { display: flex; flex-direction: column; gap: 0.7rem; padding: 1.25rem; margin: 0; }
.modal-form h3 { margin: 0 0 0.25rem; }
.modal-form label { margin: 0; }
.modal-form input, .modal-form select, .modal-form textarea {
  display: block; width: 100%; margin-top: 0.25rem; box-sizing: border-box;
}
/* [107]/[109] file-edit modal: near-full-screen so a whole file is comfortable to edit.
   Fixed height with internal scroll (not content-autosized — see data-noautosize). */
.modal.modal-wide { width: calc(100vw - 2rem); max-width: 1600px; }
.modal-wide .modal-form textarea { height: 74vh; overflow: auto; resize: vertical; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 0.4rem; }
/* [156] Recipient checkbox list in the broadcast / intro send dialogs. */
.check-list {
  display: flex; flex-direction: column; gap: 0.15rem;
  max-height: 40vh; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem;
}
.check-row {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.3rem 0.4rem; border-radius: 6px; cursor: pointer;
}
.check-row:hover { background: var(--bg); }
.modal-form .check-row input[type="checkbox"] {
  display: inline-block; width: auto; margin: 0; flex-shrink: 0;
}
/* No-JS fallback: show the dialog inline (a trigger can't open it without JS). */
html:not(.js) .modal {
  display: block; max-width: none; width: auto; box-shadow: none;
  border: 1px solid var(--border); margin-bottom: 1rem;
}
html:not(.js) [data-open], html:not(.js) [data-close] { display: none; }

/* ---- on-duty banner + performance ---- */
.duty-banner { display: flex; gap: 0.6rem; align-items: center; background: var(--success-soft); border: 1px solid var(--success-soft); color: var(--success); border-radius: var(--radius); padding: 0.55rem 0.9rem; margin: 0.5rem 0; font-size: 0.92rem; }
.duty-banner--warn { background: var(--warn-soft); color: var(--warn); border-color: var(--warn-soft); }
/* Sticky so the "Let the AI reply again" button stays reachable even though the chat
   auto-scrolls to the newest message on open ([092] — otherwise the banner is stranded at
   the top, off-screen). Default top:0 is correct for the desktop layout (topbar is a left
   sidebar, so the content column starts at the viewport top) and for the no-JS case (which
   doesn't auto-scroll). console.js overrides `top` to the topbar height on the MOBILE layout,
   where the topbar is a horizontal bar above the content. */
.takeover-banner { position: sticky; top: 0; z-index: 11; display: flex; flex-wrap: wrap; gap: 0.6rem 0.9rem; align-items: center; justify-content: space-between; background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn-soft); border-radius: var(--radius); padding: 0.55rem 0.9rem; margin: 0.5rem 0; font-size: 0.92rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; margin: 0.75rem 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 0.8rem 1rem; }
.stat .num { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.stat .lbl { color: var(--text-muted); font-size: 0.8rem; }
table.perf { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table.perf th, table.perf td { text-align: left; padding: 0.6rem 0.9rem; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
table.perf th { color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.perf tr:last-child td { border-bottom: none; }
/* [181] explicit column sizing: .col-fit hugs its text (width:1% + nowrap makes the auto
   table layout shrink it to content), .col-grow columns share the remaining width */
table.perf .col-fit { width: 1%; white-space: nowrap; }
table.perf td.col-grow { overflow-wrap: anywhere; }

/* hamburger: hidden on desktop; shown on mobile only when JS is active
   (no JS → the nav falls back to the scrollable pill row) */
.nav-toggle { display: none; }
.nav-logout { display: none; } /* [212] menu-resident session controls — mobile only */

/* ================= mobile (<= 700px) ================= */
@media (max-width: 700px) {
  /* topbar: brand row + horizontally scrollable nav */
  .topbar { flex-wrap: wrap; gap: 0.5rem; padding: 0.55rem 0.8rem; }
  .brand { font-size: 0.95rem; }
  /* mobile: the logo mark IS the brand — the full name is too long for the bar */
  .brand-name { display: none; }
  .brand-logo { width: 30px; height: 30px; }
  /* [212] the session controls move into the menu — the topbar cluster crowded the header */
  .who { display: none; }
  .nav-logout {
    display: flex; align-items: center; justify-content: space-between; gap: 0.6rem;
    border-top: 1px solid var(--border); margin-top: 0.3rem; padding: 0.6rem 0.6rem 0.2rem;
  }
  .nav-logout .nav-who {
    color: var(--text-muted); font-size: 0.85rem; min-width: 0; overflow-wrap: anywhere;
  }
  .nav-logout button { padding: 0.35rem 0.8rem; }
  .nav {
    order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; margin-left: 0;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }

  /* with JS: collapse the nav behind a hamburger (☰ left of the brand) */
  html.js .nav-toggle {
    display: flex; align-items: center; justify-content: center;
    order: -1; width: 44px; min-height: 44px; padding: 0;
    background: transparent; color: var(--text); border: none; box-shadow: none;
    font-size: 22px !important; /* must beat the mobile button 16px !important below */
    position: relative; cursor: pointer;
  }
  html.js .nav { display: none; }
  html.js .topbar.nav-open .nav {
    display: flex; flex-direction: column; gap: 0;
    overflow: visible; padding: 0.25rem 0 0.4rem;
    border-top: 1px solid var(--border); margin-top: 0.25rem;
  }
  html.js .topbar.nav-open .nav a {
    border-radius: var(--radius-sm); padding: 0.7rem 0.6rem; font-size: 1rem;
  }

  main { margin: 1rem auto; padding: 0 0.8rem; }
  h1 { font-size: 1.25rem; }

  /* inputs: 16px prevents iOS focus zoom; bigger touch targets */
  input, textarea, select, button { font-size: 16px !important; }
  button { min-height: 44px; }
  /* [231] the clip is a <label>, so the rule above never reaches it — size it to the same
     touch target the rest of the console holds itself to (it measured 34px otherwise). */
  .assistant-attach { width: 2.75rem; height: 2.75rem; }
  .switch { transform: scale(1.1); }

  /* editor/roster/group rows stack vertically */
  .kb-row, .roster-row, .group-row { flex-direction: column; align-items: stretch; }
  .kb-row .kb-edit { flex-direction: column; align-items: stretch; }
  html:not(.js) .kb-row textarea { min-height: 7rem; } /* JS autosizes instead */
  /* column layout: flex:1 would make height a (vertical) flex basis and defeat autosize */
  .kb-row textarea { flex: none; }
  /* read mode stacks: full-width text, then category + Edit on one line */
  .kb-view { flex-wrap: wrap; }
  .kb-view .kb-text { flex-basis: 100%; }
  .kb-edit-actions, .kb-add-actions { flex-direction: column; align-items: stretch; }
  .kb-search select, .kb-add-actions select, .kb-edit-actions select { max-width: none; }
  /* [232] Edit + Delete share one full-width row and split it evenly, so they read as the
     pair they are and each gets a real touch target. min-width:0 because a flex item's
     automatic minimum is its content width — `flex: 1` alone would not divide the row
     evenly once a label is wider than its share (the trap behind [211]/[228]/[229]). */
  /* GRID, not flex: two flex items with identical `flex: 1 1 0` still resolved unevenly here
     (measured 143px vs 112px at 320px). `minmax(0, 1fr)` splits the row exactly in half by
     construction — the 0 floor matters, since a bare `1fr` is `minmax(auto, 1fr)` and that
     auto minimum is content-sized (the trap behind [211]/[228]/[229]). */
  .kb-actions { flex: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kb-actions button { width: 100%; }
  /* Edit is hidden in both of these, so Delete takes the whole row rather than half of it
     with an empty track beside it. The no-JS case needs saying explicitly: the grid lays out
     two tracks whether or not one child is display:none. */
  .kb-row.editing .kb-actions,
  html:not(.js) .kb-actions { grid-template-columns: minmax(0, 1fr); }
  .roster-row .email, .group-row .gid { min-width: 0; word-break: break-all; }
  .roster-row label { width: 100%; }
  .roster-row input, .roster-row select { width: 100%; }
  .group-row { flex-direction: row; flex-wrap: wrap; align-items: center; }

  /* duty add-period form stacks */
  .period-add { flex-direction: column; align-items: stretch; }
  .period-add select, .period-add input { width: 100%; }
  .period-row { flex-direction: row; flex-wrap: wrap; align-items: center; }


  /* chat bubbles use more width */
  .bubble { max-width: 94%; }

  /* [207] the header tools wrap instead of overflowing; long selects and the JID shrink */
  .chat-head > div { min-width: 0; }
  .chat-head .hint { overflow-wrap: anywhere; }
  .chat-tools { flex-wrap: wrap; gap: 0.5rem; width: 100%; }
  .chat-tools form { max-width: 100%; }
  /* the application picker gets its own full-width row so its label isn't clipped */
  .chat-tools form:has(select[name="application"]) {
    flex-basis: 100%; display: flex; align-items: center; gap: 0.4rem;
  }
  .chat-tools select[name="application"] { flex: 1; min-width: 0; }
  .poll-label { min-width: 0; }
  .poll-label select { min-width: 0; max-width: 58vw; }

  /* stats + tables */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
  .stat .num { font-size: 1.25rem; }
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.perf { min-width: 480px; }
  /* [228] ...but the deployment table is two columns of label/value, not a data grid —
     480px made it scroll inside its box for no reason. Let it fit and wrap instead. */
  table.perf.settings-table { min-width: 0; }

  /* [228] the tuning form's dropdowns are full-width fields like its text inputs; without
     this the AI-model list sets its own intrinsic width from the longest option. */
  .agent-form select { width: 100%; }

  /* KB search stacks */
  .kb-search { flex-wrap: wrap; }
  .kb-search input[type="search"] { max-width: none; flex-basis: 100%; }

  /* pager stays usable */
  .pager a { padding: 0.5rem 0.75rem; }
}

/* [123] side-by-side numeric pair (broadcast min/max) */
.field-pair { display: flex; gap: 0.5rem; }
/* [228] min-width:0 — a text input's flex minimum is its ~20ch preferred width, so
   `flex: 1` alone could not shrink these two below ~410px and the pair scrolled Settings
   sideways on a 393px phone (≈328px of content width). Same mechanism as .gw-card below
   and [212]'s conversation picker: `flex: 1` is floored by min-width:auto, not by 0. */
.field-pair input { flex: 1; min-width: 0; }

/* [137] Team & Duty Roster redesign — cards instead of flat flex rows */
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin: 1.5rem 0 0.5rem;
}
.section-head h2 { margin: 0; }
.section-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.section-actions form { margin: 0; }

.user-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 0.9rem; }
.user-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.8rem;
}
.user-id { display: flex; align-items: center; gap: 0.7rem; }
.avatar {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 1.05rem;
  background: var(--primary-soft); color: var(--primary);
}
.user-meta { display: flex; flex-direction: column; min-width: 0; }
.user-name { font-weight: 600; display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.user-sub { color: var(--text-muted); font-size: 0.85rem; word-break: break-all; }
.user-edit { display: flex; flex-wrap: wrap; gap: 0.6rem 0.8rem; margin: 0; align-items: end; }
.user-edit label { display: flex; flex-direction: column; gap: 0.2rem; margin: 0; font-size: 0.8rem; color: var(--text-muted); flex: 1 1 120px; }
.user-edit input, .user-edit select { width: 100%; }
.user-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; width: 100%; margin-top: 0.2rem; }
.user-actions button { margin: 0; }

/* [141] Duty calendar — month grid rendered by console.js (hidden without JS) */
.duty-calendar {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 0.8rem; margin: 0.5rem 0 1rem;
}
.cal-head { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.6rem; }
.cal-title { font-weight: 600; margin-right: auto; }
.cal-nav { padding: 0.25rem 0.65rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-wd { text-align: center; font-size: 0.72rem; font-weight: 700; color: var(--text-muted); padding: 0.1rem 0; }
.cal-day {
  min-height: 4.4rem; min-width: 0; background: var(--surface-2); border-radius: var(--radius-sm);
  padding: 0.25rem 0.3rem; display: flex; flex-direction: column; gap: 2px; overflow: hidden;
}
.cal-out { opacity: 0.45; }
.cal-today { outline: 2px solid var(--primary); outline-offset: -2px; }
.cal-num { font-size: 0.75rem; color: var(--text-muted); }
.cal-today .cal-num { color: var(--primary); font-weight: 700; }
.cal-chip {
  font-size: 0.72rem; line-height: 1.3; border-radius: 4px; padding: 0 0.3rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* "on duty now": bold + outer ring on the cell background, not color-only and visible
   on every chip color in both themes */
.cal-chip.cal-live { font-weight: 700; outline: 2px solid var(--success); outline-offset: 1px; }
/* six distinguishable per-person colors that hold up in both themes */
.cal-c0 { background: var(--primary-soft); color: var(--primary); }
.cal-c1 { background: var(--success-soft); color: var(--success); }
.cal-c2 { background: var(--warn-soft); color: var(--warn); }
.cal-c3 { background: var(--danger-soft); color: var(--danger); }
.cal-c4 { background: var(--surface); color: var(--text); box-shadow: inset 0 0 0 1px var(--border); }
.cal-c5 { background: var(--text-muted); color: var(--surface); }
@media (max-width: 640px) {
  .cal-day { min-height: 3.2rem; }
  .cal-chip { font-size: 0.62rem; }
}

.duty-list { display: flex; flex-direction: column; gap: 0.55rem; }
.duty-card {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 0.7rem 1rem;
}
.duty-card.is-active { border-color: var(--success); background: var(--success-soft); }
.duty-who { display: flex; align-items: center; gap: 0.5rem; min-width: 160px; }
.duty-name { font-weight: 600; }
.duty-when { display: flex; align-items: center; gap: 0.5rem; color: var(--text-muted); font-size: 0.9rem; }
.duty-arrow { opacity: 0.6; }
.duty-card form { margin: 0 0 0 auto; }

@media (max-width: 640px) {
  .user-grid { grid-template-columns: 1fr; }
  .duty-card { align-items: stretch; }
  .duty-card form { margin: 0; }
}

/* [144] Performance page redesign — hero rate + KPI tiles + 14-day stacked-bar trend.
   Series colors are a CVD-validated categorical trio (blue/aqua/yellow), stepped per
   mode; identity never rides on color alone (legend, tooltips, table view). */
:root {
  --viz-replies: #2a78d6;
  --viz-clarify: #1baf7a;
  --viz-escalate: #eda100;
  --viz-grid: #e7ebf1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --viz-replies: #3987e5;
    --viz-clarify: #199e70;
    --viz-escalate: #c98500;
    --viz-grid: #222c38;
  }
}
.viz-replies { background: var(--viz-replies); }
.viz-clarify { background: var(--viz-clarify); }
.viz-escalate { background: var(--viz-escalate); }

.perf-week { display: grid; grid-template-columns: 300px 1fr; gap: 0.75rem; margin: 0.75rem 0; align-items: stretch; }
.perf-hero { display: flex; flex-direction: column; justify-content: center; gap: 0.4rem; }
.perf-hero-num { font-size: 3rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.perf-meter { height: 8px; border-radius: 999px; background: var(--primary-soft); overflow: hidden; }
.perf-meter-fill { height: 100%; border-radius: 999px; background: var(--primary); }
.perf-tiles { margin: 0; align-content: stretch; }
.delta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.15rem; }
.delta.up-good { color: var(--success); }
.delta.down-bad { color: var(--danger); }

.viz-key {
  display: inline-block; width: 10px; height: 10px; border-radius: 3px;
  margin-right: 0.35rem; vertical-align: -1px;
}
.viz-card { padding: 1.1rem 1.25rem; overflow: visible; }
.viz-legend { display: flex; gap: 1.1rem; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 1rem; }
.viz-plot { position: relative; height: 170px; margin-left: 36px; }
.viz-gridline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--viz-grid); }
.viz-gridline-base { border-top-color: var(--border); }
.viz-gridline span {
  position: absolute; right: calc(100% + 8px); top: -0.6em;
  font-size: 0.7rem; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.viz-cols { position: absolute; inset: 0; display: flex; align-items: stretch; }
.viz-col {
  position: relative; flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.viz-col:hover, .viz-col:focus-visible { background: var(--surface-2); outline: none; }
.viz-bar { width: min(60%, 22px); height: 100%; display: flex; flex-direction: column-reverse; gap: 2px; }
.viz-seg { flex: none; min-height: 3px; }
.viz-seg:last-child { border-radius: 4px 4px 0 0; }
.viz-tip {
  display: none; position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  z-index: 6; white-space: nowrap; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 0.5rem 0.7rem; font-size: 0.78rem; color: var(--text-muted);
}
.viz-col:hover .viz-tip, .viz-col:focus-visible .viz-tip { display: block; }
.viz-col:nth-child(-n+3) .viz-tip { left: 0; transform: none; }
.viz-col:nth-last-child(-n+3) .viz-tip { left: auto; right: 0; transform: none; }
.viz-tip-day { font-weight: 600; color: var(--text); margin-bottom: 0.25rem; }
.viz-tip-row { display: flex; align-items: center; gap: 0.35rem; }
.viz-tip-row strong { color: var(--text); font-variant-numeric: tabular-nums; }
.viz-axis { display: flex; margin: 0.35rem 0 0 36px; }
.viz-axis span {
  flex: 1; min-width: 0; text-align: center;
  font-size: 0.68rem; color: var(--text-muted); font-variant-numeric: tabular-nums;
}
.viz-table { margin-top: 1rem; }
.viz-table summary { cursor: pointer; font-size: 0.8rem; color: var(--text-muted); }
.viz-table .table-scroll { margin-top: 0.6rem; }

@media (max-width: 700px) {
  .perf-week { grid-template-columns: 1fr; }
  .perf-hero-num { font-size: 2.4rem; }
  .viz-plot { height: 140px; margin-left: 30px; }
  .viz-axis { margin-left: 30px; }
  .viz-axis span:nth-child(even) { visibility: hidden; }
}

/* [259] Tables. Added here rather than in a page-specific block because the IHS console
   copies this file verbatim as the shared theme — its table rules and these are the same
   rules, and two hand-written copies drift within weeks. `.table-wrap` is what keeps a wide
   table from making the whole PAGE scroll sideways on a phone. */
/* SCOPED to .table-wrap on purpose. Bare `table`/`td` selectors here reach every table in
   the console, and `white-space: nowrap` beat rules that exist for good reasons: the audit
   log's `td.col-grow { overflow-wrap: anywhere }` ([181], Actor/Action columns) and
   `.settings-table td { word-break: break-all }` for long deployment URLs. The IHS console
   hit the same collision and had to opt out with `.docs td { white-space: normal }`;
   scoping costs nothing and means nobody downstream needs that escape hatch. */
.table-wrap { overflow-x: auto; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table-wrap th,
.table-wrap td {
  text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border);
}
.table-wrap th {
  color: var(--text-muted); font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap;
}
.table-wrap td { white-space: nowrap; }
.table-wrap td.empty { color: var(--text-muted); text-align: center; padding: 1.2rem; }
/* Actions hug the right edge and never wrap mid-row. */
.table-wrap td.row-actions { text-align: right; white-space: nowrap; }
.table-wrap td.row-actions button { margin-left: 0.3rem; }

/* API keys page — the issue form and the one-time key panel. Same source and
   the same reason as the .table-wrap block above: this layout is shared by
   ai-support-agent, ihs-search and messaging-platform, and two hand-written
   copies drift within weeks. */
   now, not like another readonly field you can come back to. */
.new-key {
  background: var(--warn-soft); color: var(--warn);
  border: 1px solid var(--warn); border-radius: var(--radius);
  padding: 0.9rem 1rem; margin: 0.8rem 0;
}
.new-key input { width: 100%; font-family: ui-monospace, Menlo, monospace; margin: 0.4rem 0; }
.new-key .hint { color: inherit; opacity: 0.85; }
.key-new { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; margin: 0.6rem 0 0.2rem; }
.key-new label { display: block; font-size: 0.82rem; color: var(--text-muted); margin-bottom: 0.2rem; }
.key-new input[type="text"] { min-width: 0; flex: 1 1 260px; }
