/* ---------- Tokens ---------- */
:root[data-theme="dark"] {
  --bg: #101216;
  --surface: #191c22;
  --surface-2: #21252d;
  --border: #2a2e37;
  --text: #eef0f3;
  --text-muted: #8991a1;
  /* Was #5c6472 — measured at only ~2.6:1 contrast against surface/surface-2
     (WCAG AA needs 4.5:1 for normal text), which made every label, hint,
     and empty-state message hard to read against the very bright --text
     values elsewhere. Now ~4.4-4.9:1. */
  --text-faint: #828a98;
  --gold: #e3b341;
  --gold-soft: #3a331f;
  --teal: #35d0a8;
  --teal-soft: #163a32;
  --blue: #4f8cf0;
  --danger: #ea6363;
  --shadow: 0 8px 24px rgba(0,0,0,0.28);
}
:root[data-theme="light"] {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --border: #e2e4ea;
  --text: #1b1e24;
  --text-muted: #6b7280;
  /* Was #9aa1ad — same low-contrast issue as the dark theme's faint token
     (~2.5:1). Now ~4.3-4.6:1. */
  --text-faint: #70767f;
  --gold: #9a6b0f;
  --gold-soft: #fbf0d9;
  --teal: #128a6b;
  --teal-soft: #e2f7f1;
  --blue: #2f68c4;
  --danger: #c93f3f;
  --shadow: 0 8px 24px rgba(20,20,30,0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex; flex-direction: column; min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, "Segoe UI", sans-serif;
  font-size: 13.5px;
  transition: background 0.2s ease, color 0.2s ease;
}

.mono { font-family: "IBM Plex Mono", ui-monospace, monospace; }

/* ---------- Topbar ---------- */
/* Two explicit rows instead of relying on flex-wrap fallback — at real
   (narrow) sidebar widths, wrapping badge+icons as one unit still didn't
   fit and cascaded into a messy 3rd line. The agent badge (often a long
   name + tier tag) now always gets its own full-width row underneath. */
.topbar {
  display: flex; flex-direction: column; gap: 8px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark { color: var(--blue); font-size: 15px; flex-shrink: 0; }
.brand-name {
  font-family: "Space Grotesk", sans-serif; font-weight: 600;
  font-size: 15px; letter-spacing: 0.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.agent-badge {
  display: block; font-size: 12px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.agent-badge.set { color: var(--teal); border-color: color-mix(in srgb, var(--teal) 40%, transparent); }
.agent-badge.unset { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }

/* Global "don't log chats" toggle — deliberately styled to stand out only
   once ticked (danger color), so an idle unticked state doesn't compete
   for attention with the agent badge right next to it. */
.logging-pause-toggle {
  display: flex; align-items: center; gap: 6px; margin-top: 6px;
  font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none;
}
.logging-pause-toggle input { accent-color: var(--danger); width: 13px; height: 13px; cursor: pointer; }
.logging-pause-toggle.active { color: var(--danger); font-weight: 600; }

.icon-btn, .theme-toggle {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 7px; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px; transition: border-color 0.15s ease, color 0.15s ease;
}
.icon-btn:hover, .theme-toggle:hover { border-color: var(--blue); color: var(--blue); }

.theme-toggle { position: relative; }
.theme-icon { position: absolute; transition: opacity 0.15s ease, transform 0.15s ease; }
:root[data-theme="dark"] .theme-icon.sun { opacity: 0; transform: scale(0.6) rotate(45deg); }
:root[data-theme="dark"] .theme-icon.moon { opacity: 1; transform: scale(1) rotate(0); }
:root[data-theme="light"] .theme-icon.sun { opacity: 1; transform: scale(1) rotate(0); }
:root[data-theme="light"] .theme-icon.moon { opacity: 0; transform: scale(0.6) rotate(-45deg); }

/* ---------- Status ---------- */
/* Hidden by default — only errors interrupt the compact top area. Routine
   confirmations are logged silently (see Settings → Diagnostics). */
.status-bar {
  padding: 8px 16px; font-size: 12px; color: var(--text-muted);
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.status-bar.hidden { display: none; }
.status-bar.error { color: var(--danger); }
.status-bar.success { color: var(--teal); }

/* ---------- Chat list ---------- */
/* No max-width — the widget only ever shows one chat at a time now (the
   real active LiveChat conversation), so it should fill whatever width the
   sidebar actually gives it instead of capping out and leaving dead space. */
/* flex:1 so the list fills whatever height body's flex column gives it
   (viewport minus topbar/status-bar), instead of stopping short and
   leaving a gap of raw page background below the card. */
.chat-list { padding: 16px; display: flex; flex-direction: column; gap: 14px; flex: 1; }

.chat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 20px; box-shadow: var(--shadow); transition: background 0.15s ease, border-color 0.15s ease;
  /* Same reasoning as .chat-list — the card's background/border extends
     down to fill available space instead of stopping at its content's
     natural height. Collapsed cards opt out (see .chat-card.collapsed). */
  flex: 1;
}
/* Chat closed but a required field is still missing — meant to be
   impossible to miss at a glance, not just the small banner text inside. */
.chat-card.needs-attention {
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border-color: var(--danger);
  box-shadow: 0 0 0 1px var(--danger), var(--shadow);
}
.chat-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-card-head-actions { display: flex; align-items: center; gap: 8px; }
.chat-name { font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 15px; }
.chat-link {
  font-size: 11.5px; color: var(--text-faint); text-decoration: none; display: flex; align-items: center; gap: 3px;
}
.chat-link:hover { color: var(--blue); }

/* ---------- Collapsed card (default view — full detail is one click away
   via toggleExpand) ---------- */
/* Opts out of the base .chat-card's flex:1 — collapsed summary rows should
   stay compact, not stretch to fill the card list's available height (only
   an expanded card should visually fill the space). */
.chat-card.collapsed { padding: 12px 16px; flex: 0 0 auto; }
.chat-card-collapsed-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; background: none; border: none; padding: 0; margin: 0;
  font-family: inherit; text-align: left; cursor: pointer;
}
.collapsed-summary {
  font-size: 11.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.collapsed-summary.summary-neutral { color: var(--text-faint); }
.collapsed-summary.summary-pending { color: var(--blue); }
.collapsed-summary.summary-ready { color: var(--gold); }
.collapsed-summary.summary-done { color: var(--teal); }
.collapsed-summary.summary-attention { color: var(--danger); }
.collapsed-actions { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.expand-btn {
  background: none; border: 1px solid var(--border); color: var(--text-faint);
  border-radius: 6px; width: 24px; height: 24px; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.expand-btn:hover { border-color: var(--blue); color: var(--blue); }

.field-label {
  display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); margin: 14px 0 6px;
}
/* Any label carrying an "auto" badge (Brand/Amount/Claim Secret in the
   auto-grid, Telegram Chat in its toggle row) gets flex + align-items:center
   instead of relying on vertical-align:middle -- that only nudges an inline
   element to roughly the x-height midpoint of surrounding text, which reads
   as visibly off-center against all-caps label text with no x-height
   reference to align against. Flex centers it against the true line-box
   instead, in every context this label appears in. */
.field-label:has(.auto-tag) { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.auto-field .field-label { justify-content: space-between; }
.hint { text-transform: none; letter-spacing: 0; color: var(--text-faint); font-size: 11px; }
.auto-tag {
  text-transform: none; letter-spacing: 0; font-size: 10.5px; font-weight: 600; line-height: 1;
  color: var(--teal); background: var(--teal-soft); padding: 3px 7px; border-radius: 20px;
  margin-left: 5px;
}

/* ---------- Inquiry (searchable dropdown, replaces the old always-open
   tag grid — same max-2 / Feedback-pairing rule, collapsed behind search
   so the card stays short until it's actually used) ---------- */
.inquiry-select { position: relative; }
/* One unified box — chips and the search input live inside the same
   bordered container, same look as .status-display, instead of a floating
   chip row sitting above a separate input box. .inquiry-chips uses
   `display: contents` so its children (chips, or the "empty" placeholder)
   become direct flex items of .inquiry-box rather than a nested row. */
.inquiry-box {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  width: 100%; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 30px 7px 11px; cursor: text;
}
.inquiry-box:focus-within { border-color: var(--blue); }
.inquiry-chips { display: contents; }
.inquiry-search {
  flex: 1 1 70px; min-width: 70px; background: none; border: none; outline: none;
  color: var(--text); font-size: 13px; font-family: inherit; padding: 3px 0;
}
.inquiry-search::placeholder { color: var(--text-faint); opacity: 1; }
/* Matches .status-caret — signals "opens a dropdown" consistently with
   Status/Brand, even though this trigger is a search input, not a button. */
.inquiry-caret {
  position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 11px; pointer-events: none;
}
.inquiry-chips-empty { font-size: 11.5px; color: var(--text-faint); }
.inquiry-chip {
  display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600;
  padding: 4px 7px 4px 11px; border-radius: 20px; background: var(--blue); color: white;
}
.inquiry-chip-remove {
  background: none; border: none; color: white; opacity: 0.75; cursor: pointer;
  font-size: 11px; line-height: 1; padding: 2px; font-family: inherit;
}
.inquiry-chip-remove:hover { opacity: 1; }

.inquiry-dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 5px); z-index: 20;
  max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 5px; box-shadow: var(--shadow);
  /* Scroll still works with the wheel/trackpad — just no visible track/thumb,
     since the browser's default scrollbar clashes with the dark theme. */
  scrollbar-width: none;
}
.inquiry-dropdown::-webkit-scrollbar { display: none; }
.inquiry-dropdown.hidden { display: none; }
.inquiry-option {
  display: flex; align-items: center; gap: 7px; text-align: left; width: 100%;
  background: none; border: none; color: var(--text-muted); font-size: 12.5px;
  padding: 8px 10px; border-radius: 6px; cursor: pointer; font-family: inherit;
}
.inquiry-option:hover:not(.disabled) { background: var(--surface-2); color: var(--text); }
.inquiry-option.active { color: var(--blue); font-weight: 600; }
.inquiry-option.disabled { opacity: 0.35; cursor: not-allowed; }
.inquiry-option-check { width: 13px; color: var(--blue); flex-shrink: 0; }
.inquiry-option-empty { padding: 10px; font-size: 12px; color: var(--text-faint); text-align: center; }

/* ---------- Status / Brand (custom dropdowns, same look as Inquiry's —
   reuses .inquiry-option/.inquiry-option-check for the list itself). Brand
   used to be a native <select> — its own dropdown chrome, scrollbar
   included, can't be restyled via CSS in any browser, which is the whole
   reason it's a custom dropdown now instead. .brand-picker/-display/
   -dropdown are separate classes from .status-*, not just reused directly
   — several call sites do `card.querySelector(".status-dropdown")`
   expecting exactly one match per card, which a shared class would break
   now that both exist on the same card. ---------- */
.status-picker, .brand-picker { position: relative; }
.status-display, .brand-display { display: flex; align-items: center; justify-content: space-between; text-align: left; cursor: pointer; }
.status-caret { color: var(--text-faint); font-size: 11px; margin-left: 6px; }
.status-dropdown, .brand-dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 5px); z-index: 20;
  max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 5px; box-shadow: var(--shadow);
  scrollbar-width: none;
}
.status-dropdown::-webkit-scrollbar, .brand-dropdown::-webkit-scrollbar { display: none; }
.status-dropdown.hidden, .brand-dropdown.hidden { display: none; }

/* ---------- Auto-derived fields (Brand / D.O.B / Released Amount / Claim Secret) ---------- */
/* 4 fields now (was 3) — forcing them into one row squeezed "Claim Secret"
   into wrapping ("— Not / ticked") at real sidebar widths, the same
   word-breaking bug fixed once before for the 3-column layout. Wraps to
   2x2 instead once a row can't fit all 4 comfortably. */
.auto-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.auto-field {
  flex: 1 1 140px; min-width: 140px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 9px 8px;
}
.auto-value { margin-top: 4px; font-size: 12px; font-weight: 600; overflow-wrap: break-word; }
.auto-field .input { background: var(--surface); padding: 5px 7px; font-size: 12px; margin-top: 4px; }

/* ---------- D.O.B. custom calendar (replaces <input type="date"> — its
   native popup grid is OS/browser chrome with no CSS styling hook in any
   browser, which the icon-only fix couldn't get around) ---------- */
.dob-picker { position: relative; }
.dob-calendar {
  position: absolute; top: calc(100% + 5px); right: 0; z-index: 20; width: 232px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 10px; box-shadow: var(--shadow);
}
.dob-calendar.hidden { display: none; }
.dob-cal-header { display: flex; align-items: center; gap: 2px; margin-bottom: 8px; }
.dob-cal-title { flex: 1; text-align: center; font-family: "Space Grotesk", sans-serif; font-weight: 600; font-size: 12.5px; }
.dob-cal-nav {
  flex-shrink: 0; background: none; border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 6px; width: 22px; height: 22px; font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.dob-cal-nav:hover { border-color: var(--blue); color: var(--blue); }
.dob-cal-weekdays {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px;
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); text-align: center;
}
.dob-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dob-cal-day {
  background: none; border: none; color: var(--text); border-radius: 6px; cursor: pointer;
  font-size: 12px; padding: 6px 0; font-family: inherit; font-variant-numeric: tabular-nums;
}
.dob-cal-day:hover:not(.selected) { background: var(--surface-2); }
.dob-cal-day.other-month { color: var(--text-faint); }
.dob-cal-day.today { color: var(--blue); font-weight: 600; }
.dob-cal-day.selected { background: var(--blue); color: white; font-weight: 600; }
.dob-cal-footer {
  display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid var(--border);
}
.dob-cal-link { background: none; border: none; color: var(--blue); font-size: 12px; cursor: pointer; font-family: inherit; padding: 2px 4px; }
.dob-cal-link:hover { text-decoration: underline; }
.input, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); color: var(--text);
  border-radius: 8px; padding: 9px 11px; font-size: 13px; font-family: inherit;
}
/* Explicit rather than relying on the browser's default placeholder dimming
   — that default varies and doesn't necessarily match --text-faint exactly,
   which is what Status's "Select status…" placeholder-style text uses. */
.input::placeholder { color: var(--text-faint); opacity: 1; }
.status-value.placeholder { color: var(--text-faint); }
.input:focus, select:focus { outline: none; border-color: var(--blue); }

.username-row { display: flex; gap: 8px; }
.username-row .input { flex: 1; }
.lookup-btn {
  background: var(--surface-2); border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 8px; padding: 0 16px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.lookup-btn:hover { border-color: var(--blue); color: var(--blue); }
.lookup-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Ticked when the customer never gave a username — see app.js's isUnknown
   handling. Sits right under the username row so it reads as "beside" it
   without cramming a third control into that already-tight flex row. */
.unknown-toggle {
  display: flex; align-items: center; gap: 7px; margin-top: 8px;
  font-size: 12.5px; color: var(--text-muted); cursor: pointer; user-select: none;
}
.unknown-toggle input { accent-color: var(--danger); width: 14px; height: 14px; cursor: pointer; }

/* ---------- Player info (auto-filled on match) ---------- */
.player-info {
  display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 8px;
  font-size: 12px; color: var(--text-muted);
}
.pi-label {
  text-transform: uppercase; font-size: 10px; letter-spacing: 0.05em;
  color: var(--text-faint); margin-right: 3px;
}

/* ---------- Bonus ticket ---------- */
.ticket-stack { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.ticket {
  position: relative; background: var(--gold-soft);
  border: 1px dashed color-mix(in srgb, var(--gold) 55%, transparent);
  border-radius: 10px; padding: 10px 13px; display: flex; align-items: center; gap: 10px;
  overflow: visible;
}
.ticket::before, .ticket::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface); top: 50%; transform: translateY(-50%);
}
.ticket::before { left: -7px; }
.ticket::after { right: -7px; }
.ticket-icon { font-size: 18px; color: var(--gold); }
.ticket-body { flex: 1; min-width: 0; }
.ticket-name { font-weight: 600; font-size: 13.5px; color: var(--text); }
.ticket-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.ticket-meta .amount { font-family: "IBM Plex Mono", monospace; color: var(--gold); font-weight: 600; }
.claim-btn {
  background: none; border: 1px solid var(--gold); color: var(--gold);
  border-radius: 7px; padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  white-space: nowrap;
}
.claim-btn:hover { background: var(--gold); color: var(--surface); }
.claim-btn.claimed {
  background: var(--teal); border-color: var(--teal); color: var(--surface); cursor: default;
}
/* Grace Period's second, always-clickable button next to Activate — lets
   CS give the customer another attempt the same day without needing the
   first (now-disabled/claimed) button to become clickable again. */
.ticket-btns { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.claim-btn.reactivate-btn {
  border-color: var(--teal); color: var(--teal); background: none;
}
.claim-btn.reactivate-btn:hover { background: var(--teal); color: var(--surface); }
.ticket.empty {
  border-style: solid; color: var(--text-faint); font-size: 12px; justify-content: center;
  background: var(--surface-2); margin-top: 16px;
}
.ticket.locked { opacity: 0.45; }
.ticket-note {
  font-size: 10.5px; color: var(--text-faint); margin-top: 6px; text-align: center;
}

/* Special tickets (Ang Pao / Redeem Code) — red, to visually separate
   one-off/manual bonuses from the 5 regular recurring programs (gold). */
.ticket.ticket-special {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--danger) 55%, transparent);
}
.ticket.ticket-special .ticket-icon { color: var(--danger); }
.ticket-meta.code { font-size: 15px; font-weight: 700; letter-spacing: 0.04em; color: var(--danger); }
.claim-btn.special { border-color: var(--danger); color: var(--danger); }
.claim-btn.special:hover { background: var(--danger); color: white; }
.claim-btn.special.claimed { background: var(--teal); border-color: var(--teal); color: var(--surface); }
.ticket.empty::before, .ticket.empty::after { display: none; }

/* ---------- Toggle row (Telegram) ---------- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }
.toggle-row .field-label { margin: 0; }
.switch { position: relative; width: 38px; height: 21px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; cursor: pointer; transition: background 0.15s ease;
}
.slider::before {
  content: ""; position: absolute; width: 15px; height: 15px; left: 2px; top: 2px;
  background: var(--text-faint); border-radius: 50%; transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .slider { background: var(--teal-soft); border-color: var(--teal); }
.switch input:checked + .slider::before { transform: translateX(17px); background: var(--teal); }
.switch input:disabled + .slider { cursor: default; }

/* ---------- Submit ---------- */
.submit-btn {
  margin-top: 18px; width: 100%; background: var(--blue); color: white; border: none;
  padding: 11px; border-radius: 9px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: "Space Grotesk", sans-serif; letter-spacing: 0.01em;
}
.submit-btn:hover { filter: brightness(1.08); }
.submit-btn:disabled { background: var(--surface-2); color: var(--text-faint); cursor: not-allowed; }

.logged-badge {
  display: flex; align-items: center; gap: 6px; margin-top: 18px;
  background: var(--teal-soft); color: var(--teal); font-size: 12.5px; font-weight: 600;
  padding: 9px 12px; border-radius: 9px;
}
/* Distinct from the normal (teal) logged state — nothing was actually
   written to Lark, so this shouldn't read as a success confirmation. */
.logged-badge.unknown { background: var(--surface-2); color: var(--text-muted); }

/* Shown while a chat is still open — recording is deferred until it closes. */
.record-pending-hint {
  margin-top: 18px; font-size: 11.5px; color: var(--text-faint); text-align: center;
  padding: 9px; border: 1px dashed var(--border); border-radius: 9px;
}

/* Shown when a chat closed but required fields weren't filled in — the
   agent needs to complete them and click Record to Lark Base manually. */
.record-error-banner {
  /* Solid --surface (not a red tint) so it reads as a distinct detail panel
     against the now-red .needs-attention card, rather than blending into it. */
  margin-top: 18px; font-size: 11.5px; color: var(--danger); line-height: 1.5;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  border-radius: 9px; padding: 9px 12px;
}

.empty-state {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 40px 20px; text-align: center; color: var(--text-faint); font-size: 13px;
}

/* ---------- Settings overlay (full-screen) ---------- */
.settings-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: var(--bg); display: flex; align-items: center; justify-content: center;
}
.settings-panel {
  width: 100%; max-width: 420px; padding: 32px 24px; text-align: center;
}
.settings-head {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-family: "Space Grotesk", sans-serif; font-size: 18px; font-weight: 700;
  color: var(--text); margin-bottom: 12px;
}
.settings-close {
  position: absolute; top: 16px; right: 16px;
  background: none; border: 1px solid var(--border); color: var(--text-muted);
  border-radius: 6px; width: 28px; height: 28px; cursor: pointer; font-size: 14px;
}
.settings-close:hover { border-color: var(--text); color: var(--text); }
.settings-hint {
  color: var(--text-muted); font-size: 13px; margin-bottom: 20px; line-height: 1.5;
}
.settings-select {
  width: 100%; padding: 12px 14px; font-size: 15px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  font-family: "Inter", sans-serif; appearance: auto; cursor: pointer;
}
.settings-select:focus { border-color: var(--blue); outline: none; }
.settings-text {
  width: 100%; padding: 12px 14px; font-size: 15px; border-radius: 8px;
}

/* Replaces the old "dump state to console" link — a plain-language
   activity log right in Settings. Routine confirmations that don't
   interrupt the compact top bar still land here for troubleshooting. */
.settings-diagnostics { margin-top: 24px; text-align: left; }
.settings-diagnostics-head {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-faint); margin-bottom: 8px;
}
.settings-diagnostics-list {
  max-height: 160px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px;
  scrollbar-width: none;
}
.settings-diagnostics-list::-webkit-scrollbar { display: none; }
.diag-entry { font-size: 11px; color: var(--text-muted); line-height: 1.4; }
.diag-entry.diag-error { color: var(--danger); }
.diag-entry.diag-success { color: var(--teal); }
.diag-time {
  font-family: "IBM Plex Mono", monospace; color: var(--text-faint); font-size: 10px; margin-right: 6px;
}
.diag-empty { font-size: 11px; color: var(--text-faint); text-align: center; padding: 4px; }

/* ---------- Escalation Ticket (C9MYR CS-PYM) ---------- */
.escalation-slot { margin-top: 8px; }
.escalation-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.escalation-field { flex: 1 1 160px; min-width: 160px; }
.escalation-field .field-label { margin: 0 0 6px; }
.escalation-field-wide { flex-basis: 100%; }
.escalation-field-wide textarea.input { resize: vertical; min-height: 44px; }
.escalation-submit-btn { margin-top: 14px; }
