/* ============================================================================
   Hiventiq Admin — shared stylesheet
   ----------------------------------------------------------------------------
   Single source of truth for the admin console's look. Linked by both
   index.html (License Admin) and support.html (Support Desk) via
   /admin/static/admin.css.

   The design tokens below mirror the public Bzz site's palette
   (web/assets/site.css — gold + black/ivory). Three themes are supported,
   toggled by adding a class to <html>: default (dark), .light, .bzz. The
   appearance cog lets each theme's colors be overridden per-browser; those
   overrides set the same CSS custom properties inline on :root.

   Keep the token values here in sync with web/assets/site.css when the brand
   palette changes. Component styles (cards, tables, pills, dialogs, etc.)
   below are admin-specific and have no marketing-site equivalent.
   ============================================================================ */

/* ── Design tokens — Dark (default) ───────────────────────────────────── */
:root {
  color-scheme: dark;
  --page-max-width: 1200px;
  --bg: #0f0f10;
  --bg-deep: #08080a;
  --bg-panel: #161618;
  --bg-panel-raised: #1c1c1f;
  --bg-input: #121214;
  --bg-hover: #232328;
  --border: #2c2c30;
  --border-dim: #1f1f22;
  --border-strong: #3d3d42;
  --text: #e6e2d6;
  --text-head: #f7f3e8;
  --text-muted: #a39e8e;
  --text-dim: #7a7669;
  --text-faint: #57544a;
  --primary: #e0a921;
  --primary-hover: #f0bd3a;
  --primary-soft: rgba(224, 169, 33, 0.14);
  --primary-glow: rgba(224, 169, 33, 0.10);
  --on-primary: #1a1408;
  --success: #6cc88a;
  --success-bg: rgba(108, 200, 138, 0.16);
  --warning: #e2b84d;
  --warning-bg: rgba(226, 184, 77, 0.16);
  --danger: #ef6b73;
  --danger-bg: rgba(239, 107, 115, 0.16);
  --focus-ring: rgba(224, 169, 33, 0.34);
}

/* ── Design tokens — Light ────────────────────────────────────────────── */
html.light, :root[data-theme='light'] {
  color-scheme: light;
  --bg: #f8f5ec;
  --bg-deep: #efe9d8;
  --bg-panel: #ffffff;
  --bg-panel-raised: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f1ecdc;
  --border: #ddd4ba;
  --border-dim: #e8e1cb;
  --border-strong: #b7ac8b;
  --text: #2a2620;
  --text-head: #15110a;
  --text-muted: #6b6453;
  --text-dim: #8a8470;
  --text-faint: #aaa491;
  --primary: #a37408;
  --primary-hover: #855e06;
  --primary-soft: rgba(163, 116, 8, 0.10);
  --primary-glow: rgba(163, 116, 8, 0.08);
  --on-primary: #fffaf0;
  --success: #1a6f3a;
  --success-bg: rgba(26, 111, 58, 0.10);
  --warning: #8a6612;
  --warning-bg: rgba(138, 102, 18, 0.10);
  --danger: #b32530;
  --danger-bg: rgba(179, 37, 48, 0.10);
  --focus-ring: rgba(163, 116, 8, 0.28);
}

/* ── Design tokens — Bzz (Unified) ────────────────────────────────────────
   The bzz desktop dashboard's warm palette, adapted to these token names.
   Cycled Moon -> Sun -> Bzz by the header theme toggle. */
html.bzz {
  color-scheme: dark;
  --bg: #1a1815;
  --bg-deep: #0f0d0a;
  --bg-panel: #27221b;
  --bg-panel-raised: #31291f;
  --bg-input: #1d1a16;
  --bg-hover: #3a3228;
  --border: #3f3a33;
  --border-dim: #2a251f;
  --border-strong: #524b41;
  --text: #f0ede8;
  --text-head: #f9f7f3;
  --text-muted: #bbb5aa;
  --text-dim: #8f8977;
  --text-faint: #7a7365;
  --primary: #d4a520;
  --primary-hover: #e8b838;
  --primary-soft: rgba(212, 165, 32, 0.16);
  --primary-glow: rgba(212, 165, 32, 0.10);
  --on-primary: #1a1408;
  --success: #5ed18f;
  --success-bg: rgba(94, 209, 143, 0.16);
  --warning: #e8c068;
  --warning-bg: rgba(232, 192, 104, 0.16);
  --danger: #f47c85;
  --danger-bg: rgba(244, 124, 133, 0.16);
  --focus-ring: rgba(212, 165, 32, 0.36);
}

/* ── Page width presets — cycled by the header chip (default 1200 in :root) */
html.width-compact       { --page-max-width: 900px; }
html.width-standard      { --page-max-width: 1200px; }
html.width-standard-plus { --page-max-width: 1400px; }
html.width-wide          { --page-max-width: 1600px; }
html.width-ultra         { --page-max-width: 2000px; }

/* ── Pinned-chrome layout: header at the top, footer at the bottom, <main>
      is the only scroll container in between. ─────────────────────────── */
html, body { height: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 0; background: var(--bg); color: var(--text); display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ── Top header ───────────────────────────────────────────────────────── */
header { flex: 0 0 auto; background: var(--bg-panel); color: var(--text-head); padding: 12px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
header h1 { margin: 0; font-size: 20px; font-weight: 600; color: var(--text-head); display: flex; align-items: center; gap: 8px; }
header h1 .logo { height: 28px; width: 28px; display: inline-block; vertical-align: middle; }
header h1 .n8 { color: var(--primary); }
header h1 a { text-decoration: none; color: inherit; transition: color 0.2s ease; display: flex; align-items: center; gap: 8px; }
header h1 a:hover { color: var(--primary-hover); }
header h1 .subtitle { color: var(--text-muted); font-weight: 400; font-size: 14px; margin-left: 4px; }
header .api { font-size: 12px; color: var(--text-dim); }
header a { color: var(--primary); text-decoration: underline; }
header a:hover { color: var(--primary-hover); }
/* Legacy single-row header nav (Support Desk). */
header nav { display: flex; gap: 16px; }
header nav a { color: var(--text-muted); text-decoration: none; font-size: 13px; }
header nav a:hover { color: var(--text-head); }
header nav a.active { color: var(--text-head); border-bottom: 2px solid var(--primary); padding-bottom: 2px; }
#authState { color: var(--text); }
#authState strong { color: var(--primary); }

/* ── Theme + width chips in the top-right (mirror the bzz dashboard). ──── */
.hdr-controls { display: flex; align-items: center; gap: 8px; margin-left: 12px; }
button.theme-toggle, button.width-toggle { background: none; border: 1px solid var(--border); color: var(--text-muted); height: 28px; border-radius: 6px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; padding: 0 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; white-space: nowrap; }
button.theme-toggle { width: 28px; padding: 0; }
button.theme-toggle:hover, button.width-toggle:hover { background: none; color: var(--text-head); border-color: var(--text-muted); }
button.theme-toggle svg { width: 15px; height: 15px; }
button.theme-toggle img { width: 16px; height: 16px; }

/* ── Secondary header: breadcrumb on the left, view menus on the right. ── */
.subheader { flex: 0 0 auto; background: var(--bg-deep); border-bottom: 1px solid var(--border-dim); padding: 8px 24px; display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.subheader .crumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.subheader .crumb a { color: var(--primary); font-weight: 600; text-decoration: none; font-size: 13px; }
.subheader .crumb a:hover { color: var(--primary-hover); }
.subheader .crumb .bc-sep { color: var(--text-faint); font-size: 11px; }
.subheader .crumb .bc-current { color: var(--text-head); font-weight: 600; }
.subheader nav { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.subheader nav a { color: var(--text-muted); text-decoration: none; font-size: 13px; }
.subheader nav a:hover { color: var(--text-head); }
.subheader nav a.active { color: var(--text-head); border-bottom: 2px solid var(--primary); padding-bottom: 2px; }

/* ── Appearance cog — opens the color-override panel; sits at the end of
      the subheader nav, mirroring the bzz dashboard's Settings → Appearance. */
.cog-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 6px; display: inline-flex; align-items: center; }
.cog-btn:hover { color: var(--primary); background: var(--bg-hover); }

/* ── Color settings panel (mirrors bzz Settings → Appearance → Colors). ── */
.color-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.color-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg-input); border: 1px solid var(--border); border-radius: 6px; }
.color-row label { flex: 1; font-size: 12px; color: var(--text); }
.color-row input[type="color"] { width: 34px; height: 26px; border: 1px solid var(--border); border-radius: 4px; background: none; cursor: pointer; padding: 0; }
.color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.color-row input[type="color"]::-webkit-color-swatch { border-radius: 2px; border: none; }

/* ── Self-scrolling table body + fill-card layout ─────────────────────────
   .scroll-body caps a long table so its rows scroll internally and the
   surrounding chrome (filters above, pager below) stays visible. The column
   header sticks. .fill-card + #view.view-fill make a card fill the leftover
   viewport height so the whole page fits one screen. */
.scroll-body { max-height: 60vh; overflow-y: auto; }
.scroll-body thead th { position: sticky; top: 0; z-index: 1; background: var(--bg-panel); }
#view.view-fill { display: flex; flex-direction: column; height: 100%; }
.fill-card { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 220px; }
.fill-card .scroll-body { flex: 1 1 auto; max-height: none; min-height: 0; }
.fill-card .pager { flex: 0 0 auto; }

/* ── Main scroll region + centered content column ─────────────────────────
   <main> is the scroll container, so its scrollbar sits at the far-right
   edge of the window and only appears when the page overflows. */
main { flex: 1 1 auto; overflow-y: auto; min-height: 0; }
main > #view { max-width: var(--page-max-width); width: 100%; box-sizing: border-box; margin: 0 auto; padding: 24px; }

/* ── Footer (mirror of the public site's footer) ──────────────────────── */
footer.site-footer { flex: 0 0 auto; background: var(--bg-panel); border-top: 1px solid var(--border); padding: 10px 24px; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--text-muted); }
footer.site-footer .f-brand { display: flex; align-items: center; gap: 8px; color: var(--text-head); font-weight: 600; white-space: nowrap; }
footer.site-footer .f-brand img { height: 20px; width: 20px; }
footer.site-footer .f-tag { color: var(--text-muted); font-weight: 400; }
footer.site-footer .f-links { display: flex; gap: 24px; flex-wrap: wrap; flex: 1; justify-content: center; }
footer.site-footer .f-group { display: flex; gap: 10px; align-items: baseline; }
footer.site-footer .f-h { text-transform: uppercase; font-size: 10px; letter-spacing: 0.05em; color: var(--text-dim); }
footer.site-footer a { color: var(--text-muted); text-decoration: none; }
footer.site-footer a:hover { color: var(--primary); }
footer.site-footer .f-copy { white-space: nowrap; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.card h2 { margin: 0 0 16px; font-size: 16px; font-weight: 600; color: var(--text-head); }

/* ── Collapsible card (accordion via native <details>) ─────────────────── */
details.card > summary { list-style: none; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary .acc-caret { color: var(--text-muted); display: inline-block; }
details.card[open] > summary .acc-caret { transform: rotate(90deg); }

/* ── Form rows / fields / inputs / buttons ────────────────────────────── */
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-muted); }
input, select, textarea, button { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg-input); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--focus-ring); }
textarea { min-height: 60px; min-width: 240px; }
/* Support Desk reply/draft box — taller, monospace, full-width. */
#draftBody, textarea.reply { min-height: 140px; width: 100%; box-sizing: border-box; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
button { background: var(--primary); color: var(--on-primary); border: none; cursor: pointer; font-weight: 500; }
button:hover { background: var(--primary-hover); }
button.secondary { background: var(--bg-hover); color: var(--text); border: 1px solid var(--border); }
button.secondary:hover { background: var(--border-dim); border-color: var(--border-strong); }
button.danger { background: var(--danger); color: #fff; }
button.danger:hover { opacity: 0.9; }

/* ── Tables ───────────────────────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border-dim); vertical-align: top; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
tr:hover td { background: var(--bg-hover); }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: var(--bg-hover); }
.key { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--primary); }
th.sortable .arrow { font-size: 10px; margin-left: 4px; opacity: 0.6; }

/* Content-area links (tables, detail panes) use the brand link color instead
   of the browser default blue. Scoped to #view so it doesn't touch the
   header/subheader/footer nav, which style their own links. */
#view a { color: var(--primary); text-decoration: none; }
#view a:hover { color: var(--primary-hover); text-decoration: underline; }

/* ── Cross-tab identity chips — email ↔ machine linking ───────────────────
   emailChip()/machineChip() in index.html render these. The email-chip's
   per-tab jump links (.xlink) and the machine-id copy button (.xcopy) stay
   dim until the row is hovered, so the table reads clean at rest but every
   cell offers a one-click hop to the same person on the other tabs. */
.email-chip { display: inline-flex; align-items: center; gap: 6px; }
.email-chip .xlinks, .xlinks-inline { display: inline-flex; gap: 4px; opacity: 0; transition: opacity 0.12s; }
.xlinks-inline { margin-left: 6px; vertical-align: middle; }
tr:hover .email-chip .xlinks, tr:hover .xlinks-inline { opacity: 1; }
.xlink {
  font-size: 12px; line-height: 1; text-decoration: none;
  color: var(--text-muted); padding: 1px 3px; border-radius: 3px;
}
.xlink:hover { color: var(--primary); background: var(--bg-hover); text-decoration: none; }
.mid-chip { display: inline-flex; align-items: center; gap: 4px; }
.xcopy {
  background: none; border: none; cursor: pointer; padding: 1px 3px;
  font-size: 12px; line-height: 1; color: var(--text-muted);
  border-radius: 3px; opacity: 0; transition: opacity 0.12s;
}
tr:hover .mid-chip .xcopy { opacity: 1; }
.xcopy:hover { color: var(--primary); background: var(--bg-hover); }

/* ── Pills — license/instance states (index) ──────────────────────────────
   'active' / 'licensed' use the gold accent rather than green, per the Bzz
   palette (green is reserved; accent carries the positive state). */
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 500; }
.pill.active   { background: var(--primary-soft); color: var(--primary); }
.pill.licensed { background: var(--primary-soft); color: var(--primary); }
.pill.trial    { background: var(--bg-hover); color: var(--text-muted); }
.pill.expired  { background: var(--danger-bg); color: var(--danger); }
.pill.revoked  { background: var(--bg-deep); color: var(--text-muted); border: 1px solid var(--border); }
.pill.unbound  { background: var(--warning-bg); color: var(--warning); }
.pill.lifetime { background: var(--primary-soft); color: var(--primary); }
.pill\.18month { background: var(--primary-soft); color: var(--primary); }
.pill.monthly  { background: var(--warning-bg); color: var(--warning); }
/* Pills — support-ticket states (support) */
.pill.new             { background: var(--primary-soft); color: var(--primary); }
.pill.ai_handling     { background: var(--success-bg); color: var(--success); }
.pill.operator_review { background: var(--warning-bg); color: var(--warning); }
.pill.awaiting_customer { background: var(--bg-hover); color: var(--text-muted); }
.pill.resolved        { background: var(--bg-hover); color: var(--text-dim); }
.pill.closed          { background: var(--bg-hover); color: var(--text-dim); }
.pill.answerable      { background: var(--success-bg); color: var(--success); }
.pill.escalate_bug, .pill.escalate_billing, .pill.escalate_unknown { background: var(--warning-bg); color: var(--warning); }
.pill.refuse          { background: var(--danger-bg); color: var(--danger); }
.pill.email           { background: var(--bg-hover); color: var(--text-muted); }
.pill.in_app          { background: var(--primary-soft); color: var(--primary); }

/* ── Action clusters / icon buttons ───────────────────────────────────── */
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.actions button { padding: 4px 10px; font-size: 12px; }
.actions button.icon-action { padding: 4px 6px; }
.copy-btn { background: transparent; color: var(--primary); border: none; cursor: pointer; padding: 0 4px; font-size: 11px; }
.copy-btn:hover { background: var(--bg-hover); border-radius: 3px; color: var(--primary-hover); }
.icon-action { background: transparent; color: var(--text-muted); border: none; cursor: pointer; padding: 4px 6px; border-radius: 4px; line-height: 0; vertical-align: middle; }
.icon-action:hover { background: var(--bg-hover); color: var(--primary-hover); }
.icon-action.danger-icon:hover { color: var(--danger); }

/* ── Bulk-action toolbar (selectable tables) ──────────────────────────── */
.bulk-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding: 8px 12px; border-radius: 6px; background: var(--primary-soft); border: 1px solid var(--border); }

/* ── Status banner (index) ────────────────────────────────────────────── */
#status { padding: 8px 12px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; display: none; }
#status.ok    { background: var(--success-bg); color: var(--success); display: block; }
#status.error { background: var(--danger-bg); color: var(--danger); display: block; }

/* ── Dialogs ──────────────────────────────────────────────────────────── */
dialog { border: 1px solid var(--border); border-radius: 10px; padding: 24px; min-width: 420px; background: var(--bg-panel); color: var(--text); box-shadow: 0 8px 32px rgba(0,0,0,0.45); }
dialog::backdrop { background: rgba(0,0,0,0.55); }

/* ── Collapsible sections ─────────────────────────────────────────────── */
details.collapse > summary { cursor: pointer; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; padding: 4px 0; user-select: none; }
details.collapse > summary:hover { color: var(--text-head); }
details > summary { cursor: pointer; color: var(--text-muted); font-size: 12px; padding: 4px 0; }

/* ── Stat tiles ───────────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.tile .n { font-size: 24px; font-weight: 600; color: var(--text-head); }
.tile .l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }

/* ── Downloads view: collapsible left stat rail + fill events panel ───────
   The rail stacks its tiles vertically down the left; a small caret pinned to
   the top-right corner of the rail collapses it so the events table takes the
   full width. The whole layout fills the viewport height (no page scroll) —
   the events table scrolls internally via .scroll-body. */
.dl-layout { position: relative; display: flex; gap: 16px; align-items: stretch; flex: 1 1 auto; min-height: 0; }
.dl-rail { flex: 0 0 160px; display: flex; flex-direction: column; margin-bottom: 0; padding: 14px; overflow-y: auto; transition: flex-basis 0.15s ease, opacity 0.15s ease; }
.dl-rail-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 12px; }
.dl-rail-head h2 { font-size: 14px; }
.dl-days { padding: 2px 4px; font-size: 11px; }
.dl-tiles { display: flex; flex-direction: column; gap: 8px; }
.dl-tiles .tile { padding: 8px 12px; }
.dl-tiles .tile .n { font-size: 20px; }
.dl-tiles .tile .l { font-size: 10px; }
.dl-rail-links { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.dl-chart-link { background: var(--bg-hover); border: 1px solid var(--border); color: var(--text-muted); text-align: left; padding: 7px 9px; font-size: 11px; letter-spacing: 0.02em; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.dl-chart-link:hover { color: var(--text-head); border-color: var(--border-strong); background: var(--border-dim); }

/* Caret toggle is a sibling of the two panels (not nested in the rail), so it
   lives on the layout's own stacking context and is never clipped. It's a
   circle sitting in the gap between the rail and the events card, straddling
   the right-hand edge of that gap — half over the events card, half in the
   gap. The rail is 180px wide, so its right border sits at x=180; center the
   26px circle on that seam (left: 180 − 13 = 167px) so the rail's right edge
   bisects the circle. Collapsed, the rail width is 0 and the gap closes, so the
   events edge is at x=0 (left: −13px). */
.dl-rail-toggle { position: absolute; top: 16px; left: 175px; z-index: 10; width: 26px; height: 26px; display: flex; align-items: center; justify-content: center; background: var(--bg); border: 1px solid var(--border-strong); color: var(--primary); cursor: pointer; padding: 0; border-radius: 50%; font-size: 12px; line-height: 1; box-shadow: 0 1px 4px rgba(0,0,0,0.45); transition: left 0.15s ease; }
.dl-rail-toggle:hover { color: var(--primary-hover); border-color: var(--primary); }

.dl-events { flex: 1 1 auto; min-width: 0; margin-bottom: 0; }

/* Download-events table columns: keep dates/IP/last-activity on one line, cap
   the subject so a long SHA token can't blow the row width, and center the
   numeric tallies. */
.dl-events td.nowrap, .dl-events th.nowrap { white-space: nowrap; }
.dl-events td.dl-subject { max-width: 360px; }
.dl-events td.dl-subject .dl-subject-val { display: inline-block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom; }
.dl-events td.num, .dl-events th.num { text-align: center; }

/* Collapsed: the rail shrinks away; the toggle slides to the events div's left
   edge (seam now at x=0), still straddling it — half over the events panel. */
.dl-layout.rail-collapsed { gap: 0; }
.dl-layout.rail-collapsed .dl-rail { flex-basis: 0; width: 0; padding: 0; border: none; opacity: 0; overflow: hidden; }
.dl-layout.rail-collapsed .dl-rail-toggle { left: -13px; }

/* ── Detail panes / misc ──────────────────────────────────────────────── */
.back { color: var(--primary); text-decoration: none; font-size: 13px; }
.back:hover { text-decoration: underline; color: var(--primary-hover); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--text); }
.warn { background: var(--warning-bg); border-left: 3px solid var(--warning); padding: 8px 12px; margin: 12px 0; font-size: 13px; color: var(--text); }
pre.details { white-space: pre-wrap; word-break: break-all; font-size: 11px; background: var(--bg-input); border: 1px solid var(--border-dim); padding: 6px 8px; border-radius: 4px; margin: 0; color: var(--text); }
.pubref { font-family: ui-monospace, Menlo, monospace; }
.muted { color: var(--text-muted); font-size: 12px; }
.empty { color: var(--text-dim); font-style: italic; padding: 24px; text-align: center; }

/* ── Pager ────────────────────────────────────────────────────────────── */
.pager { display: flex; gap: 8px; align-items: center; padding: 12px 0 0; font-size: 12px; color: var(--text-muted); }
.pager button { padding: 4px 10px; font-size: 12px; }
.pager .spacer { flex: 1; }

/* ── Support Desk: ticket meta + message threads + draft box ───────────── */
.meta { display: grid; grid-template-columns: 160px 1fr; gap: 6px 16px; font-size: 13px; }
.meta dt { color: var(--text-muted); }
.meta dd { margin: 0; }
.msg { border-left: 3px solid var(--border); padding: 10px 14px; margin-bottom: 12px; background: var(--bg-input); border-radius: 4px; }
.msg.customer { border-left-color: var(--primary); }
.msg.ai       { border-left-color: var(--success); }
.msg.operator { border-left-color: var(--warning); }
.msg.system   { border-left-color: var(--text-dim); }
.msg .hdr { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; display: flex; justify-content: space-between; }
.msg .hdr .who { color: var(--text-head); font-weight: 600; text-transform: none; letter-spacing: 0; }
.msg .body { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.draft-box { border: 1px solid var(--warning); background: var(--warning-bg); border-radius: 6px; padding: 14px; margin: 16px 0; }
.draft-box h3 { margin: 0 0 10px; font-size: 14px; color: var(--text-head); }
.draft-box .flags { font-size: 11px; color: var(--text-muted); margin: 8px 0; font-family: ui-monospace, Menlo, monospace; white-space: pre-wrap; }
.draft-box .actions { display: flex; gap: 8px; margin-top: 10px; }

/* ── Toasts ───────────────────────────────────────────────────────────── */
.toast { position: fixed; bottom: 20px; right: 20px; max-width: 480px; padding: 12px 16px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.4); font-size: 13px; display: flex; gap: 12px; align-items: flex-start; z-index: 1000; }
.toast.ok { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.toast.error { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }
.toast .x { background: transparent; color: inherit; border: none; cursor: pointer; padding: 0 4px; font-size: 16px; line-height: 1; opacity: 0.6; }
.toast .x:hover { opacity: 1; background: rgba(255,255,255,0.06); border-radius: 3px; }
