/* ==========================================================================
   Joy Travel CRM — design system

   Chart colours come from a validated data-visualisation palette: the booking
   pipeline uses a single-hue ordinal blue ramp (checked for monotone lightness,
   visible step gaps and contrast against the white card surface), and workload
   bars use one hue with the agent's colour carried by a dot beside the label
   rather than by the bar. Text never wears a data colour.
   ========================================================================== */

:root {
  /* Neutral ink ramp (one scale used app-wide, charts included) */
  --ink-900: #111827;
  --ink-700: #374151;
  --ink-600: #4b5563;
  --ink-500: #6b7280;
  --ink-400: #9ca3af;

  /* Surfaces */
  --rail: #111827;
  --rail-hover: #1f2937;
  --plane: #f7f8fa;
  --surface: #ffffff;
  --surface-sunken: #f9fafb;

  /* Lines */
  --line: #e5e7eb;
  --line-soft: #f1f3f5;

  /* Accent */
  --accent: #2a78d6;
  --accent-hover: #1c5cab;
  --accent-wash: #eff6ff;

  /* Status (reserved — never reused as a series colour) */
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --good-wash: #ecfdf3;
  --warning-wash: #fffbeb;
  --critical-wash: #fef2f2;

  /* Booking pipeline — validated ordinal ramp, light → dark */
  --stage-1: #86b6ef;
  --stage-2: #5598e7;
  --stage-3: #2a78d6;
  --stage-4: #1c5cab;
  --stage-5: #104281;
  --stage-exit: #cbd5e1; /* cancelled: an exit, not a step in the progression */

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-card: 0 1px 2px rgba(17, 24, 39, 0.04), 0 1px 3px rgba(17, 24, 39, 0.06);
  --shadow-pop: 0 10px 30px rgba(17, 24, 39, 0.14);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  color: var(--ink-900);
  background: var(--plane);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.muted { color: var(--ink-500); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.tiny.err { color: var(--critical); }
.nowrap { white-space: nowrap; }
.hint { font-weight: 400; color: var(--ink-500); font-size: 11px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
a { color: var(--accent); }

/* ============================================================ app shell === */

.shell { display: grid; grid-template-columns: 68px 1fr; height: 100vh; }

.rail {
  background: var(--rail);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 0 12px;
  gap: 6px;
}
.rail-logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: #fff; padding: 4px; box-sizing: border-box;
  display: grid; place-items: center;
  margin-bottom: 12px; flex-shrink: 0;
}
.rail-logo img { width: 100%; height: auto; display: block; }
.auth-logo { width: 120px; height: auto; flex-shrink: 0; }
.rail-item {
  position: relative;
  width: 44px; height: 44px; border-radius: 10px;
  display: grid; place-items: center;
  color: #9aa4b2; text-decoration: none;
  background: none; border: none; cursor: pointer;
  transition: background 0.13s, color 0.13s;
}
.rail-item:hover { background: var(--rail-hover); color: #e5e7eb; }
.rail-item.active { background: var(--accent); color: white; }
.rail-item svg { width: 20px; height: 20px; }
.rail-item .rail-badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 9px; background: var(--critical); color: white;
  font-size: 10px; font-weight: 700; display: grid; place-items: center;
  border: 2px solid var(--rail);
}
.rail-tip {
  position: absolute; left: 54px; top: 50%; transform: translateY(-50%);
  background: var(--ink-900); color: white; padding: 5px 9px; border-radius: 6px;
  font-size: 12px; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity 0.12s; z-index: 60; box-shadow: var(--shadow-pop);
}
.rail-item:hover .rail-tip { opacity: 1; }
.rail-spacer { flex: 1; }

.main { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 0 20px; height: 56px; flex-shrink: 0;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 16px; }
.topbar .sub { font-size: 12px; color: var(--ink-500); margin-top: 1px; }
/* Title and whoami never squash; whatever sits between them (the inbox's
   saved-view strip) takes the remaining width. */
.topbar-title, .topbar-right { flex-shrink: 0; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.whoami { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.whoami .role { font-size: 11px; color: var(--ink-500); }

/* ================================================================ avatar === */

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  font-size: 12px; font-weight: 600; letter-spacing: 0.02em;
  color: white; user-select: none;
}
.avatar.sm { width: 26px; height: 26px; font-size: 10px; }
.avatar.xs { width: 18px; height: 18px; font-size: 8px; }
.avatar.lg { width: 44px; height: 44px; font-size: 15px; }

/* =============================================================== buttons === */

.btn {
  background: var(--accent); color: white; border: none;
  padding: 8px 15px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: background 0.13s, opacity 0.13s;
}
.btn:hover { background: var(--accent-hover); }
a.btn { text-decoration: none; display: inline-block; }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--ink-700); border: 1px solid var(--line); }
.btn.secondary:hover { background: var(--surface-sunken); }
.btn.danger { background: var(--critical); }
.btn.danger:hover { filter: brightness(0.92); }
.btn.tiny { padding: 4px 9px; font-size: 12px; border-radius: 6px; }
.btn.block { width: 100%; }

/* ================================================================= forms === */

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-600); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font-size: 13px; font-family: inherit; background: var(--surface); color: var(--ink-900);
  transition: border-color 0.13s, box-shadow 0.13s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42, 120, 214, 0.13);
}
input:disabled { background: var(--surface-sunken); color: var(--ink-500); }
select { cursor: pointer; }
.two-up { display: flex; gap: 7px; }

/* ================================================================= chips === */

.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; white-space: nowrap;
}
/* Conversation status chips are coloured inline from each status's own colour
   (see chipStyle() in shell.js), since statuses are user-defined. These three
   remain as generic tone classes for fixed states like an agent being active. */
.chip.open { background: var(--good-wash); color: #067306; }
.chip.pending { background: var(--warning-wash); color: #92600a; }
.chip.resolved { background: var(--surface-sunken); color: var(--ink-500); }
.chip.unassigned { background: var(--critical-wash); color: #a52121; }
/* Inbox list: the owner avatar / "unassigned" chip opens an inline assignee
   picker without opening the thread (app.js quickAssign). */
.conv-owner { display: inline-flex; align-items: center; cursor: pointer; border-radius: 20px; }
.conv-owner:hover { box-shadow: 0 0 0 2px var(--accent-wash); }
.quick-assign { font-size: 11.5px; padding: 2px 6px; height: 24px; max-width: 150px; }
.chip.reply { background: var(--critical-wash); color: #a52121; }
.chip.phone { background: #ecfeff; color: #0e7490; }
.chip.test-data { background: #f3e8ff; color: #7c3aed; letter-spacing: 0.04em; }
.chip.vendor { background: #fff1e6; color: #b45309; }
.kind-select { font-size: 12px; padding: 4px 6px; flex-shrink: 0; }
.chip.due { background: var(--critical-wash); color: #a52121; }
.chip.snoozed { background: #eef2ff; color: #4338ca; }
/* Quote follow-up tool (quotes.js): the case's open quote, red once the
   client has been quiet long enough that it is due a chase. */
.chip.quote { background: var(--warning-wash); color: #92600a; }
/* Invoices (stripe.js): amber while open, red past due, green paid, grey void. */
.chip.invoice { background: var(--warning-wash); color: #92600a; }
.chip.invoice.overdue { background: var(--critical-wash); color: #a52121; }
.chip.invoice.paid { background: #e7f6ec; color: #1f7a3a; }
.chip.invoice.void { background: var(--surface-sunken); color: var(--ink-500); text-decoration: line-through; }
.invoice-row { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.invoice-row:last-child { border-bottom: none; }
.invoice-main { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.invoice-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.invoice-modal { width: min(620px, calc(100vw - 32px)); }
.invoice-line { display: flex; gap: 6px; align-items: center; margin-bottom: 6px; }
.invoice-line .invoice-desc { flex: 1; min-width: 0; }
.invoice-line .invoice-amount { width: 110px; text-align: right; }
.invoice-meta { display: flex; gap: 12px; align-items: flex-start; }
.invoice-meta .field { margin-bottom: 0; }
.invoice-total { text-align: right; }
.small.danger { color: #a52121; }
.invoice-tickets { color: var(--ink-600); }
.ticket-line .ticket-pax { flex: 1; min-width: 0; }
.ticket-line .ticket-num { width: 190px; }
.ok-note { color: #1f7a3a; }
.chip.quote.due { background: var(--critical-wash); color: #a52121; }
.quote-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap;
  margin-top: 8px; padding: 6px 10px; border-radius: 8px; font-size: 12.5px;
  background: var(--warning-wash); color: #92600a;
}
.quote-bar.due { background: var(--critical-wash); color: #a52121; }
.quote-bar a { color: inherit; text-decoration: underline; text-underline-offset: 2px; margin-left: 4px; }
.quote-bar-text { min-width: 0; }
.quote-bar-actions { display: inline-flex; gap: 6px; align-items: center; flex-shrink: 0; }
.quote-bar-actions select { width: auto; font-size: 12px; padding: 4px 6px; }
.quote-book-opt { display: flex; flex-direction: column; gap: 6px; }
.quote-book-row { display: flex; gap: 8px; }
.quote-book-row input { flex: 1; min-width: 0; }
.quote-book-or { text-align: center; font-size: 12px; color: var(--ink-500); }
.msg-row.quote-flash .bubble-wrap { outline: 2px solid #f59e0b; outline-offset: 2px; border-radius: 12px; }
/* Returning client handed back to their last agent for a limited claim window. */
.chip.dibs { background: var(--warning-wash); color: #92600a; }
.chip.collab-overflow { background: var(--surface-sunken); color: var(--ink-500); font-weight: 700; }
.owner-chip svg { width: 10px; height: 10px; }

.label-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 20px; border: 1px solid;
}
.chip-x {
  border: none; background: none; cursor: pointer; padding: 0;
  font-size: 14px; line-height: 1; color: inherit; opacity: 0.55;
}
.chip-x:hover { opacity: 1; }
.label-add {
  width: auto; padding: 2px 7px; font-size: 11px; border-radius: 20px;
  border: 1px dashed var(--line); color: var(--ink-500); background: var(--surface);
}

/* PNR box at the right end of the chat's label row (app.js pnrBoxHtml) — an
   input dressed as a chip; dashed while empty, solid once a ref is recorded. */
.pnr-box { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; }
.pnr-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-500); }
.pnr-input {
  width: 104px; padding: 2px 9px; font-size: 12px; font-weight: 600;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.06em; text-transform: uppercase;
  border-radius: 20px; border: 1px dashed var(--line); background: var(--surface); color: var(--ink-600);
}
.pnr-input::placeholder { text-transform: none; letter-spacing: 0; font-family: inherit; font-weight: 500; color: var(--ink-500); }
.pnr-input.set { border-style: solid; }
/* SegWatch verdict colours on the PNR, in the list chip and the header box.
   Three looks that read apart at a glance, not only by hue: ticketed is green
   with a tick, not-yet-ticketed is bright yellow with an hourglass, cancelled
   is red and struck through. */
.chip.pnr.sw-ticketed, .pnr-chip.sw-ticketed { background: var(--good-wash); color: #067306; border-color: #86efac; }
.chip.pnr.sw-ticketed::before { content: "✓ "; }
.chip.pnr.sw-unticketed, .pnr-chip.sw-unticketed { background: #fef08a; color: #713f12; border-color: #eab308; font-weight: 700; }
.chip.pnr.sw-unticketed::before { content: "⏳ "; }
.chip.pnr.sw-cancelled, .pnr-chip.sw-cancelled { background: #fecaca; color: #991b1b; border-color: #ef4444; text-decoration: line-through; text-decoration-thickness: 2px; }
.chip.pnr.sw-cancelled::before { content: "✕ "; text-decoration: none; display: inline-block; }
.pnr-input:focus { border-style: solid; border-color: var(--accent); outline: none; }
.pnr-done { width: 13px; height: 13px; margin: 0 2px 0 0; cursor: pointer; accent-color: var(--accent); }
.pnr-cleared-note { white-space: nowrap; }
.pnr-copy { border: none; background: none; cursor: pointer; padding: 0 2px; font-size: 13px; line-height: 1; color: var(--ink-500); }
.pnr-copy:hover { color: var(--accent); }
/* Several PNRs on one case: each is a chip (input + copy + remove) and the
   dashed "add" input waits at the end of the row. */
.pnr-box { flex-wrap: wrap; row-gap: 4px; }
/* A recorded PNR is one bubble: the done checkbox, the editable code, copy
   and × all sit inside the pill, and the SegWatch tone colours the pill. */
.pnr-chip { display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px 1px 6px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); color: var(--ink-600); }
.pnr-chip .pnr-input { width: 84px; padding: 1px 4px; border: none; background: transparent; color: inherit; font-weight: inherit; border-radius: 0; }
.pnr-chip .pnr-input:focus { border: none; box-shadow: inset 0 -2px 0 var(--accent); }
.pnr-chip:focus-within { border-color: var(--accent); }
.pnr-chip.sw-cancelled .pnr-input { text-decoration: line-through; text-decoration-thickness: 2px; }
.pnr-chip .pnr-copy, .pnr-chip .pnr-remove { color: inherit; opacity: 0.6; }
.pnr-chip .pnr-copy:hover, .pnr-chip .pnr-remove:hover { opacity: 1; }
.pnr-chip .pnr-done { accent-color: currentColor; }
.pnr-remove { border: none; background: none; cursor: pointer; padding: 0 2px; font-size: 14px; line-height: 1; color: var(--ink-400); }
.pnr-remove:hover { color: var(--critical); }
.pnr-input.pnr-add { width: 78px; }
.pnr-input.pnr-add:focus { width: 104px; }
.pnr-label.quote-label { margin-left: 10px; }
.pnr-input.quote-add { width: 82px; }
.segwatch-one + .segwatch-one { border-top: 1px dashed var(--line); }
.chip.pnr {
  background: var(--surface-sunken); color: var(--ink-600);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.05em;
}

.stage-pill {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.stage-new { background: #eef4fd; color: #1c5cab; }
.stage-quoted { background: var(--warning-wash); color: #92600a; }
.stage-confirmed { background: var(--accent-wash); color: #1c5cab; }
.stage-booked { background: var(--good-wash); color: #067306; }
.stage-completed { background: #f0fdfa; color: #0f766e; }
.stage-cancelled { background: var(--surface-sunken); color: var(--ink-500); }

/* ================================================================= inbox === */

.inbox { display: grid; grid-template-columns: 330px 1fr 340px; flex: 1; overflow: hidden; min-height: 0; }
.col { display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border-right: 1px solid var(--line); min-width: 0; }
.col:last-child { border-right: none; border-left: 1px solid var(--line); }
.col-scroll { overflow-y: auto; flex: 1; min-height: 0; }

.search-wrap { padding: 12px 12px 8px; display: flex; gap: 6px; align-items: center; }
.search-wrap .search-input { flex: 1; min-width: 0; }
.new-chat-btn { padding: 6px 10px; font-size: 12px; white-space: nowrap; flex-shrink: 0; }

/* "New message" dialog (app.js openNewChat) */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 200; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh;
}
.modal {
  background: var(--surface); border-radius: var(--radius); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  width: min(460px, calc(100vw - 32px)); padding: 18px 18px 14px; display: flex; flex-direction: column; gap: 10px;
}
.modal h3 { font-size: 15px; margin: 0; }
.modal .sub { font-size: 12px; color: var(--ink-500); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.contact-results { max-height: 220px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.contact-result {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; cursor: pointer; font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.contact-result:last-child { border-bottom: none; }
.contact-result:hover, .contact-result.active { background: var(--accent-wash); }
.contact-result .num { color: var(--ink-500); font-size: 12px; margin-left: auto; white-space: nowrap; }
.contact-result .open-tag { font-size: 10.5px; font-weight: 700; color: #067306; background: var(--good-wash); padding: 1px 6px; border-radius: 10px; }
.contact-results .empty-inner { padding: 14px; font-size: 12.5px; color: var(--ink-500); text-align: center; }
.import-help { margin: 8px 0 12px; font-size: 12.5px; color: var(--ink-600); }
.import-help summary { cursor: pointer; font-weight: 600; }
.import-help ol { margin: 8px 0 6px 18px; padding: 0; line-height: 1.6; }
.import-help code { background: var(--surface-sunken); padding: 0 4px; border-radius: 3px; }
.search-input { padding-left: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%239ca3af' stroke-width='2'%3E%3Cpath stroke-linecap='round' d='m21 21-4.3-4.3M19 11a8 8 0 1 1-16 0 8 8 0 0 1 16 0Z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: 9px center; background-size: 15px; }

/* Saved-view pills (spec 2.3). One row in the top bar; if the window is too
   narrow for all of them it scrolls sideways rather than wrapping — the strip
   used to wrap to four rows inside the list column and ate a fifth of it. */
.views-strip {
  display: flex; flex-wrap: nowrap; gap: 5px; align-items: center;
  flex: 1; min-width: 0; overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
  /* Fade the trailing edge when there's more to scroll to. */
  mask-image: linear-gradient(to right, black calc(100% - 18px), transparent);
}
.views-strip::-webkit-scrollbar { display: none; }
.view-pill {
  display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0; white-space: nowrap;
  padding: 3px 9px; font-size: 11.5px; font-weight: 600; font-family: inherit;
  border-radius: 20px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-600); cursor: pointer; transition: background 0.13s, color 0.13s, border-color 0.13s;
}
.view-pill:hover { background: var(--surface-sunken); }
.view-pill.active { background: var(--accent-wash); color: var(--accent-hover); border-color: var(--accent); }
/* Admin "quiet view" toggle (app.js): while on, opening a thread sends no
   presence, so agents don't see "… is viewing" / "… is typing". */
.quiet-pill { margin-right: 14px; }
.quiet-pill.active { background: var(--warning-wash); color: #92600a; border-color: var(--warning); }
.view-count {
  font-size: 10px; font-weight: 700; min-width: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--surface-sunken); color: var(--ink-500);
  display: inline-grid; place-items: center; line-height: 16px;
}
.view-count.hot { background: var(--critical-wash); color: #a52121; }
.view-pill.active .view-count { background: var(--accent); color: white; }

.filter-bar { display: flex; gap: 6px; padding: 0 12px 8px; }
.filter-bar select { padding: 5px 7px; font-size: 12px; min-width: 0; flex: 1; }

.conv-list { list-style: none; margin: 0; padding: 0; }
.conv-item {
  display: flex; gap: 10px; padding: 11px 13px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer; border-left: 3px solid transparent;
  transition: background 0.11s;
}
.conv-item:hover { background: var(--surface-sunken); }
.conv-item.active { background: var(--accent-wash); border-left-color: var(--accent); }
.conv-main { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.conv-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { font-size: 11px; color: var(--ink-400); flex-shrink: 0; }
.conv-preview {
  font-size: 12.5px; color: var(--ink-500); margin-top: 2px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-item.needs-reply .conv-preview { color: var(--ink-700); font-weight: 500; }
/* Unread reads like WhatsApp: bold name, green time, green count pill */
.conv-item.needs-reply .conv-name { font-weight: 700; }
.conv-item.needs-reply .conv-time { color: #1fa855; font-weight: 600; }
.conv-preview-row { display: flex; align-items: center; gap: 6px; }
.conv-preview-row .conv-preview { flex: 1; min-width: 0; margin-top: 2px; }
.unread-pill {
  background: #25d366; color: white; flex-shrink: 0;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 10px;
  font-size: 10.5px; font-weight: 700; display: grid; place-items: center;
}
/* Team "mark as unread" (app.js markUnread): WhatsApp's green dot, in the
   same slot as the unread count; the name goes bold like a needs-reply row. */
.unread-dot { width: 10px; height: 10px; border-radius: 50%; background: #25d366; flex-shrink: 0; }
.conv-item.marked-unread .conv-name { font-weight: 700; }
.conv-item.marked-unread .conv-preview { color: var(--ink-700); font-weight: 500; }
.conv-meta { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 6px; }

/* 24h reply-window triage dot (conversation list) */
.window-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.window-dot.open { background: var(--good); }
.window-dot.amber { background: var(--warning); }
.window-dot.closed { background: var(--ink-400); }

/* ================================================================== chat === */

/* Two calm rows: who this is (name, number, case, reply window, close) and
   then the controls. The identity row never wraps — long names ellipsise —
   so the controls can't squeeze the name into a column of single words. */
.chat-head { padding: 10px 16px 9px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.chat-head-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.chat-who { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1 1 auto; }
.chat-who-text { min-width: 0; }
.chat-who h2 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-who .sub { font-size: 12px; color: var(--ink-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-head-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; margin-left: auto; }
.chat-controls { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-top: 8px; }
/* Phone-only one-line case summary (app.js caseSummaryHtml); desktop never shows it */
.case-summary {
  display: none; align-items: center; gap: 6px; width: 100%; margin-top: 6px; padding: 2px 0;
  background: none; border: none; font-family: inherit; cursor: pointer; text-align: left;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.case-summary::-webkit-scrollbar { display: none; }
.case-summary .chip, .case-summary .label-chip { flex-shrink: 0; }
.case-caret { margin-left: auto; padding-left: 6px; color: var(--ink-400); font-size: 13px; flex-shrink: 0; }
.chat-controls select { width: auto; font-size: 12px; padding: 6px 8px; }
.mark-unread-btn { margin-left: auto; font-size: 12px; padding: 6px 10px; }

/* Presence — "Rivky is typing…" in the thread header (spec 1.5) */
.presence-line { color: var(--accent); font-weight: 600; }
/* …and on inbox rows: avatar + "viewing" / "typing…" for anyone else in the thread */
.chip.viewing { background: var(--accent-wash); color: var(--accent-hover); gap: 5px; padding-left: 3px; }
.chip.viewing.typing { background: var(--good-wash); color: #067306; }

/* 24h reply-window badge (thread header) */
.window-badge {
  display: inline-flex; align-items: center; flex-shrink: 0;
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; white-space: nowrap;
}
.window-badge.open { background: var(--good-wash); color: #067306; }
.window-badge.amber { background: var(--warning-wash); color: #92600a; }
.window-badge.closed { background: var(--surface-sunken); color: var(--ink-500); }

.label-strip {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 16px; border-bottom: 1px solid var(--line); background: var(--surface-sunken); flex-shrink: 0;
}
.label-strip.tight { padding: 0; border: none; background: none; }

/* Column layout + margin-top:auto on the inner wrapper anchors a short thread to
   the bottom, the way a chat should read, without breaking scroll when it's long. */
.thread { flex: 1; overflow-y: auto; padding: 18px 18px 8px; background: var(--plane); min-height: 0; display: flex; flex-direction: column; }
.thread-inner { margin-top: auto; }
.day-sep { display: flex; align-items: center; gap: 10px; margin: 14px 0 12px; }
.day-sep::before, .day-sep::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.day-sep span { font-size: 11px; color: var(--ink-400); font-weight: 500; }

/* Case boundary — a heavier marker than a day separator, since it's a bigger
   break in the (still continuous) chat log. */
.case-sep { display: flex; align-items: center; gap: 10px; margin: 20px 0 14px; }
.case-sep::before, .case-sep::after { content: ""; height: 1px; background: var(--accent); opacity: 0.25; flex: 1; }
.case-sep span {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--accent-hover); background: var(--accent-wash); padding: 3px 10px; border-radius: 20px;
}

.chip.case-chip { background: var(--surface-sunken); color: var(--ink-600); font-variant-numeric: tabular-nums; }

.merge-banner {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 16px; font-size: 12px; color: #92600a;
  background: var(--warning-wash); border-bottom: 1px solid #fde68a; flex-shrink: 0;
}
.merge-banner select { width: auto; font-size: 12px; padding: 4px 7px; }

.stale-banner {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 8px 16px; font-size: 12.5px; color: #92600a;
  background: var(--warning-wash); border-bottom: 1px solid #fde68a; flex-shrink: 0;
}
.stale-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stale-line a { color: #92600a; text-decoration: underline; text-underline-offset: 2px; }
.stale-line a:hover { color: #6b4703; }
.stale-detail summary { cursor: pointer; list-style: none; }
.stale-detail summary::-webkit-details-marker { display: none; }
.stale-detail summary::before { content: '▸ '; }
.stale-detail[open] summary::before { content: '▾ '; }
.stale-group { margin: 6px 0 0 14px; }
.stale-group + .stale-group { margin-top: 4px; }
.stale-dismiss {
  border: none; background: transparent; color: #92600a; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 2px 4px; flex-shrink: 0;
}
.stale-dismiss:hover { color: #6b4703; }
/* Bell in the top bar: the work banners draw into its dropdown (shell.js
   BANNERS_IN_BELL) and keep their chrome; the count is how many are there. */
.notif-wrap { position: relative; }
.notif-bell {
  position: relative; width: 34px; height: 34px; border-radius: 50%; border: none;
  background: transparent; color: var(--ink-500); cursor: pointer; display: grid; place-items: center;
}
.notif-bell:hover, .notif-bell.open { background: var(--line); color: var(--ink-900); }
.notif-bell svg { width: 20px; height: 20px; }
.notif-count {
  position: absolute; top: 2px; right: 1px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--critical); color: white; font-size: 10px; font-weight: 700;
  display: grid; place-items: center; border: 2px solid var(--surface);
}
.notif-panel {
  position: absolute; top: 40px; right: 0; width: min(420px, calc(100vw - 24px)); max-height: 70vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15); z-index: 60;
}
.notif-head { padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--ink-500); border-bottom: 1px solid var(--line); }
.notif-empty { padding: 18px 14px; font-size: 13px; color: var(--ink-500); }
.notif-panel .stale-banner { border-bottom: 1px solid var(--line); }
.notif-panel > div > :last-child .stale-banner { border-bottom: none; }
.notif-panel .stale-line { white-space: normal; }

/* Disk-headroom banner (shell.js) shares the stale-banner chrome; 90%+ goes red. */
.stale-banner.disk.critical { color: #a52121; background: var(--critical-wash); border-bottom-color: #fecaca; }
.stale-banner.disk.critical .stale-dismiss { color: #a52121; }

/* ------------------------------------------------------------ kanban board */

.board-filter-bar { padding: 10px 16px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.board-filter-bar select { width: auto; font-size: 12.5px; padding: 5px 8px; }

.board-scroll {
  flex: 1; overflow-x: auto; overflow-y: hidden;
  display: flex; gap: 12px; padding: 14px 16px; align-items: flex-start;
}

.board-col {
  flex: 0 0 260px; display: flex; flex-direction: column;
  background: var(--surface-sunken); border-radius: 10px; max-height: 100%;
}
.board-col-head {
  display: flex; align-items: center; gap: 7px; padding: 10px 12px;
  border-top: 3px solid var(--ink-400); border-radius: 10px 10px 0 0;
  font-weight: 600; font-size: 12.5px; color: var(--ink-700);
}
.board-col-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.board-col-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-col-count { color: var(--ink-400); font-weight: 500; }
.board-col-body { flex: 1; overflow-y: auto; padding: 0 8px 8px; display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.board-col-body.drag-over { background: var(--accent-wash); border-radius: 8px; }
.board-col-empty { font-size: 11.5px; color: var(--ink-400); text-align: center; padding: 14px 0; }

.board-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 10px; cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}
.board-card:active { cursor: grabbing; }
.board-card-top { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.board-card-time { margin-left: auto; }
.board-card-name { font-weight: 600; font-size: 13px; color: var(--ink-900); margin-bottom: 3px; }
.board-card-summary {
  font-size: 11.5px; color: var(--ink-500); margin-bottom: 7px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.board-card-bottom { display: flex; align-items: center; gap: 6px; }

/* Admin → Agents: the name is editable in place (admin.js renameAgent) —
   reads as plain bold text until it is focused. */
.agent-name {
  font: inherit; font-weight: 600; color: inherit; width: 100%; min-width: 120px;
  padding: 1px 4px; margin-left: -4px; border: 1px solid transparent; border-radius: 6px; background: transparent;
}
.agent-name:hover { border-color: var(--line); }
.agent-name:focus { border-color: var(--accent); background: var(--surface); outline: none; }
.case-history { margin-top: 10px; }
.case-history summary { font-size: 11.5px; font-weight: 600; color: var(--ink-500); cursor: pointer; }
.case-history-row {
  display: flex; justify-content: space-between; gap: 8px; padding: 6px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 12.5px;
}
.case-history-row:last-child { border-bottom: none; }
.case-history-row.current { font-weight: 600; }
/* Booking history rows in the Details panel (app.js bookingRowHtml). */
.booking-row { padding: 7px 0; border-bottom: 1px solid var(--line); }
.booking-row:last-child { border-bottom: none; }
.booking-row.current .booking-sub { font-weight: 600; }
.booking-row.cleared .chip.pnr { opacity: 0.55; }
.booking-main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.booking-route { font-size: 12.5px; font-weight: 600; color: var(--ink-700); }
.booking-sub { margin-top: 2px; }
.booking-sub a { color: var(--accent); text-decoration: none; }
.booking-sub a:hover { text-decoration: underline; }

.msg-row { display: flex; margin-bottom: 8px; }
.msg-row.out { justify-content: flex-end; }
.bubble-wrap { position: relative; display: inline-block; max-width: 65%; }
.bubble {
  padding: 9px 13px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.45; word-wrap: break-word; white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(17, 24, 39, 0.05);
}
.msg-row.in .bubble { background: var(--surface); border-bottom-left-radius: 5px; }
/* Outbound wears WhatsApp's light green with dark ink — the colour agents'
   eyes already parse as "mine", and blue read-ticks stay legible on it. */
.msg-row.out .bubble { background: #d9fdd3; color: #111b21; border-bottom-right-radius: 5px; }
.bubble .meta { font-size: 10px; margin-top: 4px; opacity: 0.7; }
/* The phone's automatic away message: kept in the thread, visibly not a person */
.msg-row.auto-reply .bubble { opacity: 0.72; font-size: 12px; border-style: dashed; }
.msg-row.auto-reply .bubble .auto-tag { font-weight: 600; letter-spacing: 0.02em; text-transform: uppercase; font-size: 9px; }
.msg-row.out .bubble .meta { opacity: 1; color: rgba(17, 27, 33, 0.55); }

/* Delivery ticks (WhatsApp familiarity) */
.ticks { display: inline-flex; align-items: center; gap: 3px; margin-left: 4px; color: rgba(17, 27, 33, 0.4); }
.ticks svg { width: 15px; height: 10px; }
.ticks.read { color: #53bdeb; }
.ticks.failed { color: var(--critical); font-weight: 700; }
.ticks.failed svg { width: 12px; height: 12px; }
.msg-image { display: block; max-width: 100%; max-height: 260px; border-radius: 8px; margin-bottom: 5px; cursor: zoom-in; }

/* Photo viewer (app.js openLightbox) */
#lightbox { position: fixed; inset: 0; z-index: 400; background: rgba(10, 14, 20, 0.92); display: flex; flex-direction: column; }
#lightbox[hidden] { display: none; }
.lightbox-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top)); color: #e5e7eb; font-size: 13px; }
.lightbox-caption { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-actions { display: flex; gap: 6px; flex-shrink: 0; }
.lightbox-actions .btn { background: rgba(255,255,255,0.12); color: #fff; border-color: transparent; }
.lightbox-actions .btn:hover { background: rgba(255,255,255,0.22); }
.lightbox-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 8px 16px calc(16px + env(safe-area-inset-bottom)); cursor: zoom-out; }
.lightbox-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); cursor: default; }
body.lightbox-open { overflow: hidden; }
.msg-video { display: block; max-width: 260px; max-height: 260px; border-radius: 8px; margin-bottom: 5px; background: #000; }
.msg-audio { display: block; width: 240px; margin-bottom: 5px; }
.msg-transcript { font-size: 13px; line-height: 1.4; margin: 2px 0 4px; max-width: 320px; white-space: pre-wrap; }
.msg-transcript.muted { opacity: 0.6; font-style: italic; }
/* Stickers render small and never full-width, unlike photos. */
.msg-sticker { display: block; width: 96px; height: 96px; object-fit: contain; margin-bottom: 5px; }

.doc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 11px; border-radius: 10px; margin-bottom: 5px;
  background: var(--surface-sunken); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 500; text-decoration: none; color: inherit;
}
.msg-row.out .doc-chip { background: rgba(255, 255, 255, 0.6); border-color: rgba(17, 27, 33, 0.12); color: inherit; }
.doc-size { opacity: 0.6; font-weight: 400; }

.media-notice { font-size: 12.5px; color: var(--ink-500); font-style: italic; margin-bottom: 2px; }
.media-notice.deleted { margin-bottom: 0; }
/* A file being dragged over the open thread */
#chatCol.drop-target { outline: 3px dashed var(--accent); outline-offset: -6px; }

/* Quoted replies (WhatsApp "replying to") — inside a bubble, and as the bar
   above the composer while one is being written. */
.quote {
  border-left: 3px solid var(--accent); background: rgba(17, 27, 33, 0.05); border-radius: 6px;
  padding: 5px 8px; margin-bottom: 6px; font-size: 12.5px; cursor: pointer; min-width: 0;
}
.quote:hover { background: rgba(17, 27, 33, 0.09); }
.quote-who { font-weight: 600; color: var(--accent-hover); font-size: 11.5px; }
.quote-text { color: var(--ink-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar {
  display: flex; align-items: center; gap: 10px; margin: 8px 14px 0; padding: 6px 10px;
  border-left: 3px solid var(--accent); background: var(--surface-sunken); border-radius: 6px; font-size: 12.5px;
}
.reply-bar-text { flex: 1; min-width: 0; }
/* Draft attachment (pasted / dropped) waiting above the composer */
.attach-bar {
  display: flex; align-items: center; gap: 10px; margin: 8px 14px 0; padding: 6px 10px;
  border: 1px solid var(--line); background: var(--surface-sunken); border-radius: 8px; font-size: 12.5px;
}
.attach-thumb { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.attach-file-icon { width: 56px; height: 56px; display: grid; place-items: center; font-size: 26px; background: var(--surface); border-radius: 6px; flex-shrink: 0; }
.attach-bar-text { flex: 1; min-width: 0; }
.attach-audio { height: 36px; max-width: 260px; }
.mic-btn { font-size: 15px; line-height: 1; padding: 7px 9px; }
.attach-bar.recording { border-color: #fecaca; background: var(--critical-wash); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #dc2626; flex-shrink: 0; animation: rec-pulse 1s ease-in-out infinite; }
@keyframes rec-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.bubble-wrap { position: relative; }
.bubble-reply {
  position: absolute; top: 50%; transform: translateY(-50%); border: none; cursor: pointer;
  width: 26px; height: 26px; border-radius: 50%; background: var(--surface); color: var(--ink-500);
  box-shadow: var(--shadow-card); font-size: 14px; line-height: 1; opacity: 0; transition: opacity 0.12s;
}
/* Hover actions (react + reply) sit beside the bubble, on the free side. */
.bubble-actions { position: absolute; top: 50%; transform: translateY(-50%); display: flex; gap: 4px; }
.msg-row.in .bubble-actions { left: calc(100% + 6px); }
.msg-row.out .bubble-actions { right: calc(100% + 6px); }
.bubble-actions .bubble-reply { position: static; transform: none; }
.bubble-wrap:hover .bubble-reply, .bubble-reply:focus, .bubble-wrap:focus-within .bubble-reply { opacity: 1; }
@media (hover: none) { .bubble-reply { opacity: 0.55; } }
.react-picker {
  position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 30; display: flex; gap: 2px; padding: 4px 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-pop);
}
.msg-row.out .react-picker { left: auto; right: 0; }
.react-option { border: none; background: none; cursor: pointer; font-size: 20px; line-height: 1; padding: 4px 5px; border-radius: 50%; }
.react-option:hover { background: var(--surface-sunken); transform: scale(1.15); }
.react-option.mine { background: var(--accent-wash); }
.msg-row.flash .bubble { box-shadow: 0 0 0 3px var(--accent-wash); transition: box-shadow 0.3s; }
.edited-tag { font-style: italic; }
.msg-row.out .media-notice { color: rgba(17, 27, 33, 0.6); }

.location-card, .contact-card {
  padding: 2px 0 4px; margin-bottom: 2px;
}
.location-name, .contact-name { font-weight: 600; font-size: 13.5px; }
.location-address, .contact-phone { font-size: 12.5px; opacity: 0.85; margin-top: 1px; }
.location-card .btn, .contact-card .btn { margin-top: 7px; }
.contact-card + .contact-card { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(0, 0, 0, 0.08); }

/* An emoji reaction hangs off the bubble's outer bottom corner, like the
   messaging apps this is meant to feel familiar to. */
.reaction-chip {
  position: absolute; bottom: -9px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 1px 5px; font-size: 13px; line-height: 1.3; box-shadow: var(--shadow-card);
}
.msg-row.in .reaction-chip { right: -6px; }
.msg-row.out .reaction-chip { left: -6px; }

.composer-wrap { border-top: 1px solid var(--line); flex-shrink: 0; background: var(--surface); }
.composer-mode { display: flex; gap: 6px; padding: 8px 14px 0; }
.mode-btn {
  padding: 4px 11px; font-size: 11.5px; font-weight: 600; font-family: inherit;
  border-radius: 20px; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-500); cursor: pointer; transition: background 0.13s, color 0.13s, border-color 0.13s;
}
.mode-btn.active { background: var(--accent-wash); color: var(--accent-hover); border-color: var(--accent); }
.composer { display: flex; gap: 8px; padding: 8px 14px 12px; align-items: flex-end; }
.emoji-btn { font-size: 15px; line-height: 1; padding: 7px 9px; flex-shrink: 0; }
.emoji-picker {
  position: absolute; bottom: calc(100% - 2px); left: 10px; z-index: 40;
  width: min(340px, calc(100% - 20px));
  display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 2px;
  padding: 8px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-pop);
}
.emoji-picker[hidden] { display: none; }
.emoji-cell {
  border: none; background: none; cursor: pointer; font-size: 20px; line-height: 1;
  padding: 5px 0; border-radius: 6px;
}
.emoji-cell:hover { background: var(--surface-sunken); }

.attach-btn { padding: 8px 10px; flex-shrink: 0; line-height: 0; }
.attach-btn svg { width: 16px; height: 16px; }
.composer textarea {
  resize: none; max-height: 120px; line-height: 1.4;
  /* rows=1 + JS auto-grow: starts input-height, grows with Shift+Enter newlines */
  min-height: 36px;
}

/* Canned-reply picker (spec 1.6) — floats above the composer while the draft
   is a "/shortcut". */
.composer-wrap { position: relative; }
.canned-picker {
  position: absolute; bottom: calc(100% - 2px); left: 10px; right: 10px; z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-pop); overflow: hidden;
}
.canned-item {
  display: flex; align-items: baseline; gap: 8px; padding: 8px 11px;
  cursor: pointer; border-bottom: 1px solid var(--line-soft); min-width: 0;
}
.canned-item:last-child { border-bottom: none; }
.canned-item.active, .canned-item:hover { background: var(--accent-wash); }
.canned-shortcut { font-size: 12px; font-weight: 700; color: var(--accent-hover); flex-shrink: 0; }
.canned-title { font-size: 12.5px; font-weight: 600; flex-shrink: 0; }
.canned-preview {
  font-size: 12px; color: var(--ink-500);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.composer.note-mode textarea {
  border-color: var(--warning); background: var(--warning-wash);
}
.composer.note-mode textarea:focus { box-shadow: 0 0 0 3px rgba(250, 178, 25, 0.18); }
.btn.note { background: var(--warning); color: #5a3d00; }
.btn.note:hover { filter: brightness(0.95); }
.composer-notice { padding: 0 14px 10px; font-size: 11.5px; color: var(--ink-500); }

/* Closed 24h window: a slim strip instead of a wall of fields, so the thread
   stays readable. The picker itself lives in a dialog (bar/popup styles) or a
   pull-up drawer. */
.closed-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 14px;
  background: var(--warning-wash); border-top: 1px solid #f3e2a3; font-size: 12.5px; color: #6b4703;
}
.closed-text { flex: 1 1 240px; }
.closed-actions { display: flex; gap: 6px; flex-shrink: 0; }
.closed-actions .btn { font-size: 12px; padding: 6px 10px; }
.phone-hint { padding: 8px 14px; line-height: 1.45; background: var(--surface-sunken); border-top: 1px solid var(--line); margin: 0; }
.template-picker.compact .template-vars { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; }
.template-picker.compact .template-preview { max-height: 90px; overflow-y: auto; }
.modal.template-modal { width: min(720px, 94vw); }
.choice-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; }
.choice { padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); min-width: 0; }
.choice-phone { background: var(--surface-sunken); }
.choice-title { font-weight: 700; font-size: 13px; margin-bottom: 8px; }
.template-picker.in-modal { padding: 0; }
@media (max-width: 760px) { .choice-grid { grid-template-columns: 1fr; } }

/* Approved-template picker (spec 1.3) — replaces the composer once the 24h
   window is closed. */
.template-picker { padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 8px; }
.template-picker select { font-size: 13px; }
.template-vars { display: flex; flex-direction: column; gap: 6px; }
.template-var { font-size: 12.5px; padding: 7px 9px; }
.template-preview {
  font-size: 12.5px; line-height: 1.45; color: var(--ink-700); padding: 9px 11px;
  background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius-sm);
  white-space: pre-wrap; word-wrap: break-word;
}

/* =========================================================== right panel === */

.tabs { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.tab {
  flex: 1; padding: 11px 8px; border: none; background: none; cursor: pointer;
  font-size: 12.5px; font-weight: 600; font-family: inherit; color: var(--ink-500);
  border-bottom: 2px solid transparent; transition: color 0.13s;
}
.tab:hover { color: var(--ink-700); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.section { padding: 15px 16px; border-bottom: 1px solid var(--line); }
.section h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--ink-500); margin-bottom: 11px;
}
.deal-card { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 11px; margin-bottom: 10px; }
.deal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 9px; font-size: 13px; font-weight: 600; }
.new-deal-form { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 11px; margin-top: 10px; }

/* Internal notes list (Details sidebar) — amber like the old inline note
   bubble was, so the "private, never sent" association carries over, but as
   a compact log entry rather than a chat bubble. */
.notes-list { display: flex; flex-direction: column; gap: 8px; }
.note-entry {
  background: var(--warning-wash); border: 1px solid #fde68a; border-left: 3px solid var(--warning);
  border-radius: var(--radius-sm); padding: 8px 10px;
}
.note-entry-head { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: #92600a; margin-bottom: 4px; }
.note-entry-head svg { width: 11px; height: 11px; flex-shrink: 0; }
.note-entry-head .chip-x { margin-left: auto; color: #92600a; }
.note-entry-body { font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }

/* ============================================================== timeline === */

.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.tl-item:last-child { border-bottom: none; }
.tl-dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.tl-body { flex: 1; min-width: 0; }
.tl-head { font-size: 12.5px; line-height: 1.4; }
.tl-change { font-size: 12px; margin-top: 3px; }
.tl-change .arrow { color: var(--ink-400); }
.tl-detail { font-size: 12px; color: var(--ink-500); margin-top: 3px; word-wrap: break-word; }
.tl-time { font-size: 10.5px; color: var(--ink-400); margin-top: 3px; }

/* ============================================================= dashboard === */

.page { flex: 1; overflow-y: auto; padding: 22px; min-height: 0; }
.page-wrap { max-width: 1180px; margin: 0 auto; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}
.card > h3 { font-size: 14px; margin-bottom: 3px; }
.card > .card-sub { font-size: 12px; color: var(--ink-500); margin-bottom: 15px; }

.hero-card { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.hero-figure { font-size: 52px; font-weight: 600; line-height: 1; letter-spacing: -0.02em; }
.hero-figure.attention { color: var(--critical); }
.hero-figure.calm { color: var(--good); }
.hero-text h3 { font-size: 15px; margin-bottom: 4px; }
.hero-text p { margin: 0; font-size: 13px; color: var(--ink-500); }

.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px; box-shadow: var(--shadow-card);
}
.kpi-value { font-size: 27px; font-weight: 600; line-height: 1.1; letter-spacing: -0.01em; }
.kpi-label { font-size: 12px; color: var(--ink-500); margin-top: 5px; }
.kpi.attention .kpi-value { color: var(--critical); }
a.kpi.linked { text-decoration: none; color: inherit; display: block; transition: border-color 0.13s, box-shadow 0.13s; }
a.kpi.linked:hover { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(42, 120, 214, 0.1); }

/* Deal-stage nudges (spec 2.4) */
.nudge-card { border-left: 3px solid var(--warning); }
.nudge-row {
  display: grid; grid-template-columns: 44px 1fr auto auto 90px; gap: 12px; align-items: center;
  padding: 9px 4px; border-bottom: 1px solid var(--line-soft);
  text-decoration: none; color: inherit; font-size: 13px;
}
.nudge-row:last-child { border-bottom: none; }
.nudge-row:hover { background: var(--surface-sunken); }
.nudge-days { font-weight: 700; color: #92600a; font-variant-numeric: tabular-nums; }
.nudge-who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nudge-route { color: var(--ink-500); font-size: 12px; }
.nudge-agent { color: var(--ink-500); font-size: 12px; }
.nudge-value { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* Horizontal bar chart. Bars are capped at 22px, square at the baseline with a
   4px rounded data-end, values direct-labelled at the tip so no value depends on
   reading a colour. Single series, so no legend — the row label names each mark. */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 92px 1fr auto; align-items: center; gap: 10px; }
.bar-label { font-size: 12px; color: var(--ink-600); text-align: right; }
.bar-track { background: var(--surface-sunken); border-radius: 3px; height: 22px; position: relative; overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 0 4px 4px 0; min-width: 3px;
  transition: width 0.35s ease;
}
.bar-fill.zero { background: var(--line) !important; min-width: 3px; }
.bar-value { font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 22px; text-align: right; }

.workload-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.workload-row:last-child { border-bottom: none; }
a.workload-row.linked { text-decoration: none; color: inherit; cursor: pointer; }
a.workload-row.linked:hover { background: var(--line-soft); }
.workload-reply { display: block; }
.workload-reply:hover { text-decoration: underline; }
.workload-who { display: flex; align-items: center; gap: 8px; font-size: 13px; min-width: 0; }
.agent-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ================================================================= admin === */

.admin-tabs { display: flex; background: var(--surface); border-bottom: 1px solid var(--line); padding: 0 20px; flex-shrink: 0; }
.admin-tabs .tab { flex: 0 0 auto; padding: 12px 18px; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-500); font-weight: 600;
}
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table td input, .table td select { padding: 5px 7px; font-size: 12px; }
.table td input[type="color"] { width: 42px; padding: 2px; height: 28px; }
.table tr.inactive { opacity: 0.5; }
.row-actions { display: flex; gap: 6px; white-space: nowrap; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); gap: 12px; margin-bottom: 13px; align-items: end; }
.form-grid input[type="color"], .field input[type="color"] { width: 54px; height: 34px; padding: 2px; cursor: pointer; }
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-row .field { margin: 0; min-width: 165px; }
.inline-error { background: var(--critical-wash); color: #a52121; padding: 8px 11px; border-radius: var(--radius-sm); font-size: 12px; margin-top: 11px; }

/* ================================================================= login === */

.auth-body { display: grid; place-items: center; background: var(--rail); overflow: auto; }
.auth-card {
  background: var(--surface); border-radius: 14px; padding: 32px;
  width: 100%; max-width: 400px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35); margin: 24px;
}
.auth-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.auth-brand h1 { font-size: 17px; }
.auth-brand p { margin: 3px 0 0; font-size: 12.5px; color: var(--ink-500); }
.auth-form .field { margin-bottom: 15px; }
.auth-form input { padding: 10px 11px; font-size: 14px; }
.auth-submit { width: 100%; margin-top: 6px; padding: 11px; font-size: 14px; }
.auth-error { background: var(--critical-wash); color: #a52121; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12.5px; margin-bottom: 16px; }
.google-btn {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; padding: 10px 12px; font-size: 14px; font-weight: 500;
  background: var(--surface, #fff); color: inherit; border: 1px solid var(--line, #d5d9e0);
}
.google-btn:hover { background: var(--surface-sunken, #f5f6f8); }
.auth-divider {
  display: flex; align-items: center; gap: 10px; margin: 16px 0;
  color: var(--ink-500, #7a8194); font-size: 12px;
}
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; border-top: 1px solid var(--line, #d5d9e0); }
.auth-notice { background: var(--accent-wash); color: #1c5cab; padding: 11px 12px; border-radius: var(--radius-sm); font-size: 12px; margin-bottom: 16px; line-height: 1.55; }

/* =============================================== misc / empty / tooltip === */

.empty {
  display: grid; place-items: center; height: 100%; min-height: 140px;
  color: var(--ink-500); font-size: 13px; text-align: center; padding: 24px;
}
.empty-inner { max-width: 260px; line-height: 1.6; }

.viz-tip {
  position: fixed; z-index: 200; pointer-events: none;
  background: var(--ink-900); color: white; padding: 7px 10px;
  border-radius: 6px; font-size: 12px; line-height: 1.4;
  box-shadow: var(--shadow-pop); opacity: 0; transition: opacity 0.1s;
}
.viz-tip.on { opacity: 1; }

.dev-tools { border-top: 1px solid var(--line); flex-shrink: 0; }
.dev-tools summary {
  padding: 9px 13px; font-size: 11px; font-weight: 600; color: var(--ink-500);
  cursor: pointer; list-style: none; display: flex; align-items: center; gap: 6px;
  user-select: none;
}
.dev-tools summary::-webkit-details-marker { display: none; }
.dev-tools summary::before { content: '▸'; font-size: 9px; transition: transform 0.12s; }
.dev-tools[open] summary::before { transform: rotate(90deg); }

.sim-box { padding: 12px 13px; background: var(--warning-wash); border-top: 1px solid #fde68a; max-height: 60vh; overflow-y: auto; }
.sim-box h4 { font-size: 11px; color: #92600a; margin-bottom: 8px; line-height: 1.45; font-weight: 600; }
.sim-box input { margin-bottom: 6px; font-size: 12px; padding: 6px 8px; border-color: #fde68a; }
.harness-group { margin-bottom: 12px; }
.harness-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: #92600a; margin-bottom: 6px; }
.harness-buttons { display: flex; flex-wrap: wrap; gap: 5px; }
.harness-buttons .btn { border-color: #fde68a; }

/* Raw webhook payload viewer (Admin -> WhatsApp) */
.payload {
  margin: 0; padding: 12px; background: var(--rail); color: #d1d5db;
  border-radius: var(--radius-sm); font-size: 11.5px; line-height: 1.5;
  overflow-x: auto; max-height: 320px; white-space: pre-wrap; word-break: break-word;
}
code { background: var(--surface-sunken); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
/* Admin → Daily brief: the nightly message, shown as it would read in WhatsApp */
.brief-text {
  margin: 0; padding: 14px 16px; background: var(--surface-sunken); color: var(--ink-900);
  border-radius: var(--radius-sm); font: 13px/1.55 inherit; font-family: inherit;
  white-space: pre-wrap; word-break: break-word; max-height: 520px; overflow: auto;
}
.stale-banner.disk.ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.stale-banner.disk.ok a { color: #047857; font-weight: 600; margin-left: 4px; }
/* Personal brief overlay (shell.js openMyBrief) and the admin's per-agent list */
.brief-overlay { position: fixed; inset: 0; background: rgba(17, 24, 39, 0.45); z-index: 60; display: flex; align-items: center; justify-content: center; padding: 16px; }
.brief-dialog { background: var(--surface, #fff); border-radius: var(--radius, 12px); width: min(720px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,0.25); }
.brief-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line, #e5e7eb); }
.brief-dialog .brief-text { max-height: none; overflow: auto; border-radius: 0 0 var(--radius, 12px) var(--radius, 12px); }
details.personal-brief { margin: 8px 0; }
details.personal-brief summary { cursor: pointer; }

/* ==========================================================================
   Responsive layouts (spec 1.8 "usable at tablet width" + mobile)

   Three tiers. Tablet (≤1024px): the details column becomes a slide-over so
   the thread keeps its width. Phone (≤760px): one pane at a time — list,
   thread as a full-screen layer, details above that — with the nav rail as a
   bottom bar. State lives in two body classes (chat-open, right-open) that
   only mean anything at these widths; desktop ignores them entirely.
   ========================================================================== */

/* Buttons that only exist for the smaller layouts */
.mobile-back, .details-toggle { display: none; }
.icon-btn { padding: 7px 10px; line-height: 0; flex-shrink: 0; }
.icon-btn svg { width: 16px; height: 16px; }

/* --- Small desktop / tablet landscape ------------------------------------- */
@media (max-width: 1180px) {
  .inbox { grid-template-columns: 290px 1fr 300px; }
}

/* --- Tablet ---------------------------------------------------------------- */
@media (max-width: 1024px) {
  .inbox { grid-template-columns: 300px 1fr; }

  .details-toggle { display: inline-flex; }

  /* Details column slides in from the right instead of owning permanent width */
  #rightCol {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 80;
    width: min(380px, 94vw);
    border-left: 1px solid var(--line); box-shadow: var(--shadow-pop);
    transform: translateX(102%);
    transition: transform 0.22s ease;
  }
  body.right-open #rightCol { transform: none; }

  /* Scrim behind the slide-over; clicks on it land on <body> (see app.js) */
  body.right-open::after {
    content: ""; position: fixed; inset: 0; z-index: 70;
    background: rgba(17, 24, 39, 0.35);
  }
}

/* --- Phone ------------------------------------------------------------------ */
/* Sound toggle pill, "this case only" toggle and note, Admin → Reports */
.sound-pill.off { opacity: 0.7; }
.case-only-toggle.active { background: var(--accent-wash); color: var(--accent-hover); border-color: var(--accent); }
.case-only-note { margin: 10px 14px 0; padding: 8px 12px; font-size: 12.5px; color: var(--ink-600); background: var(--surface-sunken); border: 1px dashed var(--line); border-radius: var(--radius-sm); }
.report-pick { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 12px; }
.report-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.report-filters label { display: inline-flex; align-items: center; gap: 6px; }
.report-filters input[type=date], .report-filters select, .report-filters input[type=number] { font-size: 13px; padding: 5px 7px; }
.report-find { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; }
.report-block { margin-top: 16px; }
.report-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.report-head h4 { margin: 0; font-size: 14px; }
.report-table td, .report-table th { white-space: nowrap; }
.report-table td:first-child a { font-variant-numeric: tabular-nums; }

/* Search in a chat (app.js chatSearch) */
.chat-search { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border-bottom: 1px solid var(--line); background: var(--surface-sunken); flex-shrink: 0; }
.chat-search input { flex: 1; min-width: 0; font-size: 13px; padding: 6px 9px; }
.chat-search-count { font-size: 12px; color: var(--ink-500); white-space: nowrap; font-variant-numeric: tabular-nums; }
.chat-search[hidden] { display: none; }
body.chat-searching .msg-row:not(.search-hit) { opacity: 0.35; }
.msg-row.search-hit .bubble { box-shadow: 0 0 0 2px #fcd34d; }
.msg-row.search-current .bubble { box-shadow: 0 0 0 3px var(--accent); }

/* Read-only (accounting) accounts: no reactions or quoted replies on bubbles */
body.viewer .bubble-actions, body.viewer .msg-actions { display: none !important; }

/* Pull-to-refresh pill (shell.js, touch screens) */
#ptrPill {
  position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%; transform: translate(-50%, 0);
  z-index: 200; background: var(--surface); color: var(--ink-700); border: 1px solid var(--line);
  border-radius: 999px; padding: 7px 14px; font-size: 12.5px; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12); pointer-events: none; transition: transform 0.05s linear;
}
#ptrPill.ready { background: var(--accent); color: #fff; border-color: var(--accent); }
#ptrPill[hidden] { display: none; }

@media (max-width: 760px) {
  /* Rail becomes a bottom bar; dvh tracks the real viewport when the browser
     chrome and keyboard come and go */
  .shell {
    display: flex; flex-direction: column-reverse;
    height: 100vh; height: 100dvh;
  }
  .rail {
    flex-direction: row; width: 100%; height: 56px;
    padding: 0 10px calc(env(safe-area-inset-bottom) / 2);
    justify-content: space-around; align-items: center; gap: 0;
    border-top: 1px solid var(--rail-hover); flex-shrink: 0;
  }
  .rail-logo, .rail-spacer, .rail-tip { display: none; }
  .main { flex: 1; min-height: 0; position: relative; }

  /* No room beside the title on a phone: the top bar becomes two rows, with
     the saved-view strip on its own full-width line, scrolling sideways. */
  .topbar { padding: 8px 14px; height: auto; flex-wrap: wrap; gap: 8px 12px; }
  .topbar .views-strip { order: 3; flex-basis: 100%; }

  /* One pane at a time: the list owns the page… */
  .inbox { display: flex; }
  .inbox > .col { flex: 1; border-right: none; }

  /* …and the thread slides over it, above the bottom bar */
  #chatCol {
    /* absolute inside .main (not fixed to the window): .main already ends
       where the bottom bar starts and shrinks with the browser toolbar, so
       the composer can't end up behind Safari's toolbar */
    position: absolute; inset: 0; z-index: 60;
    display: flex; transform: translateX(102%);
    transition: transform 0.22s ease;
    border-left: none;
  }
  body.chat-open #chatCol { transform: none; }

  /* Details covers the full phone width, above the thread — same anchoring */
  #rightCol { position: absolute; inset: 0; width: auto; }

  .mobile-back { display: inline-flex; }
  .close-chat { display: none; } /* the back arrow does this job on a phone */

  .chat-head { padding: 8px 10px 6px; }
  .chat-head-row { gap: 6px; }
  .chat-head-right { gap: 4px; }
  .icon-btn { padding: 6px 8px; }
  .case-only-toggle { display: none; } /* rarely needed on a phone; the name needs the room */
  .window-badge { font-size: 10.5px; padding: 2px 7px; }
  .bubble-wrap { max-width: 85%; }
  .thread { padding: 12px 12px 8px; }

  /* Form controls at 16px: below that iOS Safari zooms the whole page when a
     field is tapped and leaves it zoomed — the "everything got huge" effect.
     Padding comes down so the boxes don't grow with the type. */
  input, select, textarea { font-size: 16px; padding: 6px 9px; }
  .filter-bar { flex-wrap: wrap; }
  .filter-bar select { flex: 1 1 45%; padding: 5px 8px; }
  .search-wrap { padding: 8px 10px 6px; }
  .conv-item { padding: 11px 12px; }
  .conv-meta .chip, .conv-meta .label-chip { font-size: 10.5px; padding: 1px 7px; }

  /* The case controls fold behind the one-line summary (app.js caseSummaryHtml) */
  .case-summary { display: flex; }
  /* summary line above the controls it opens */
  .chat-head { display: flex; flex-direction: column; }
  .chat-head-row { order: 0; } .case-summary { order: 1; margin-top: 4px; } .chat-controls { order: 2; }
  #chatCol .chat-controls, #chatCol > .label-strip { display: none; }
  body.case-bar-open #chatCol .chat-controls, body.case-bar-open #chatCol > .label-strip { display: flex; }
  .chat-controls select { padding: 5px 8px; }
  .chat-controls .btn, .label-add { padding: 6px 10px; font-size: 12.5px; }

  /* Composer: tighter, the Send button no wider than it must be */
  .composer { padding: 6px 10px 8px; gap: 6px; }
  .composer textarea { min-height: 40px; }
  .composer .btn { padding: 8px 12px; }

  /* Top bar: title + pills only; the name and role are on the Settings page */
  .topbar { padding: 6px 12px; gap: 6px 10px; }
  .topbar-right { gap: 8px; }
  .whoami > div { display: none; }

  /* Banners (install nudge, personal brief, follow-ups, disk, off-site)
     sit at the bottom of the page above the bar instead of pushing the
     list down from the top; an open chat covers them. Two lines at most. */
  /* The bell's dropdown spans the screen under the top bar instead of hanging
     off the bell, which sits too far left for a right-anchored box. */
  .notif-panel { position: fixed; left: 12px; right: 12px; width: auto; max-height: 60vh; }

  #staleBannerSlot { order: 10; }
  .stale-banner { padding: 6px 12px; font-size: 12px; border-bottom: none; border-top: 1px solid #fde68a; }
  .stale-banner.disk.ok { border-top-color: #a7f3d0; }
  .stale-banner.disk.critical { border-top-color: #fecaca; }
  .stale-line { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

  /* Comfortable touch targets */
  .conv-item { padding: 13px; -webkit-touch-callout: none; user-select: none; }
  /* The emoji picker is the phone keyboard's job; the row is crowded enough */
  .composer .emoji-btn { display: none; }
  /* Installed app: no browser chrome, so keep clear of the notch/home bar */
  .rail { padding-bottom: calc(env(safe-area-inset-bottom) / 2 + 2px); }
  .view-pill { padding: 5px 11px; }
  .mode-btn { padding: 6px 13px; }

  /* Dashboard / admin pages */
  .page { padding: 14px; }
  .page-wrap { max-width: none; }
  .hero-figure { font-size: 38px; }
  .kpi-row { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 9px; }
  .kpi { padding: 12px; }
  .kpi-value { font-size: 22px; }
  .admin-tabs { overflow-x: auto; padding: 0 10px; }
  .admin-tabs .tab { padding: 12px 13px; white-space: nowrap; }
  /* Wide tables scroll inside their card instead of stretching the page */
  .card { overflow-x: auto; }
  .table { min-width: 560px; }
  .nudge-row { grid-template-columns: 40px 1fr 80px; }
  .nudge-route, .nudge-agent { display: none; }
}

/* SegWatch panel under the label row (app.js loadSegwatch): what the Sabre
   PNR mirror knows about the case's PNR. The head is a one-line summary that
   stays useful collapsed; the body is a compact itinerary + tickets readout. */
.segwatch-panel { border-bottom: 1px solid var(--line); background: var(--surface); flex-shrink: 0; max-height: 46vh; overflow-y: auto; }
.segwatch-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 16px; cursor: pointer; user-select: none;
  font-size: 12px; color: var(--ink-600);
}
.segwatch-head:hover { background: var(--surface-sunken); }
.segwatch-title { font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; color: var(--ink-500); text-transform: uppercase; }
.segwatch-caret { margin-left: auto; color: var(--ink-400); font-size: 12px; }
.segwatch-verdict { padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.segwatch-verdict.good { background: var(--good-wash); color: #067306; }
.segwatch-verdict.warn { background: var(--warning-wash); color: #92600a; }
.segwatch-verdict.bad { background: var(--critical-wash); color: #a52121; }
.segwatch-verdict.muted { background: var(--surface-sunken); color: var(--ink-500); }
.segwatch-body { padding: 4px 16px 10px; display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; }
.segwatch-facts { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.segwatch-facts:empty { display: none; }
.segwatch-fact { font-size: 12px; color: var(--ink-600); }
.segwatch-fact.bad { color: #a52121; font-weight: 600; }
.segwatch-fact.warn { color: #92600a; font-weight: 600; }
.segwatch-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.segwatch-k { font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; color: var(--ink-500); text-transform: uppercase; margin-right: 2px; }
.segwatch-pax, .segwatch-contact { font-size: 12.5px; color: var(--ink-700); }
.segwatch-table { font-size: 12px; }
.segwatch-table th { padding: 5px 6px; font-size: 10px; }
.segwatch-table td { padding: 4px 6px; white-space: nowrap; }
.segwatch-table td.mono, .segwatch-row .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: 0.04em; }
.segwatch-table .num { text-align: right; }
.segwatch-table tr.segwatch-void td { color: var(--ink-400); text-decoration: line-through; }
.segwatch-table tr.segwatch-void td:last-child { text-decoration: none; }
.segwatch-table tr.segwatch-other td { color: var(--ink-500); }
.segwatch-status { font-weight: 600; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.segwatch-status.HK, .segwatch-status.KK, .segwatch-status.TK, .segwatch-status.RR { color: #067306; }
.segwatch-status.HL, .segwatch-status.KL, .segwatch-status.HN { color: #92600a; }
.segwatch-tick { font-weight: 700; }
.segwatch-tick.yes { color: #067306; }
.segwatch-tick.no { color: #a52121; }
.segwatch-tick.na { color: var(--ink-400); }
.segwatch-asof { margin-top: 2px; }
@media (max-width: 760px) { .segwatch-panel { overflow-x: auto; } .segwatch-table { min-width: 560px; } }
