/* Essos operator portal mockups. Palette and type taken from essos.com's own stylesheet (read 2026-11-18):
   cream #F5F1E5 page, warm off-white #F3EEE3 / #EBE4D1 surfaces, near-black #171715 ink, gold #DCC27B accent,
   serif display face (PS Times on essos.com; Instrument Serif stands in) over a grotesk body (ABC Repro; Inter stands in). */
@import url("https://fonts.googleapis.com/css2?family=Instrument+Serif&family=Inter:wght@400;500;600&display=swap");

:root {
  --cream: #f5f1e5;
  --paper: #fbf9f3;
  --sand: #f3eee3;
  --sand-2: #ebe4d1;
  --line: #ddd7c9;
  --muted: #8d897d;
  --muted-2: #46443f;
  --ink: #171715;
  --gold: #dcc27b;
  --gold-soft: #efe0b5;
  --red: #b4432f;
  --red-soft: #f5dcd3;
  --amber: #a86a12;
  --amber-soft: #f6e6c4;
  --green: #3d6b47;
  --green-soft: #dde8d9;
  --blue: #2f5d8a;
  --blue-soft: #dce6ef;
  --serif: "Instrument Serif", "PS Times", Times, serif;
  --sans: "Inter", "ABC Repro", system-ui, -apple-system, sans-serif;
  --radius: 10px;
  --page-gutter: 32px;
  --thread-gutter: var(--page-gutter);
  --phone-nav-height: calc(56px + env(safe-area-inset-bottom));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--sans); color: var(--ink); background: var(--cream); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 24px; }
h3 { font-size: 18px; }
button { font: inherit; cursor: pointer; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }
.side { background: var(--ink); color: var(--cream); display: flex; flex-direction: column; padding: 20px 14px; gap: 4px; }
.brand { font-family: var(--serif); font-size: 28px; padding: 2px 10px 18px; letter-spacing: 0.01em; }
.brand small { display: block; font-family: var(--sans); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.nav-label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 14px 10px 6px; }
.nav a { white-space: nowrap; display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; color: #d9d3c3; }
.nav a:hover { background: #26251f; color: var(--cream); }
.nav a.active { background: #2f2e2a; color: var(--cream); }
.nav .count { margin-left: auto; background: var(--gold); color: var(--ink); font-size: 11px; font-weight: 600; border-radius: 99px; padding: 1px 7px; }
.nav .soon { margin-left: auto; font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gold); border: 1px solid #4a473d; border-radius: 99px; padding: 1px 6px; }
.side .me { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 10px; border-top: 1px solid #2f2e2a; font-size: 13px; color: #d9d3c3; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--sand-2); color: var(--ink); flex: none; }
.avatar.gold { background: var(--gold); }
.avatar.ai { background: var(--ink); color: var(--gold); font-family: var(--serif); font-size: 15px; }

.main { overflow: auto; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: 16px; padding: 22px var(--page-gutter) 14px; }
.main [data-route-focus]:focus { outline: none; }
.main [data-route-focus="keyboard"]:focus-visible { outline: 2px solid var(--green); outline-offset: 4px; }
.topbar .sub { color: var(--muted); margin-top: 4px; }
.topbar .right { margin-left: auto; display: flex; gap: 10px; align-items: center; }

/* ---------- Bits ---------- */
.btn { border: 1px solid var(--line); background: var(--paper); color: var(--ink); border-radius: 99px; padding: 7px 14px; font-weight: 500; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.btn:hover { background: #fff; }
.btn.dark { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.btn.dark:hover { background: #2f2e2a; }
.btn.gold { background: var(--gold); border-color: var(--gold); }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 600; letter-spacing: 0.02em; border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.blue { background: var(--blue-soft); color: var(--blue); }
.pill.gray { background: var(--sand-2); color: var(--muted-2); }
.pill.dark { background: var(--ink); color: var(--cream); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }

/* "Tomorrow" (P1) treatment: designed, visibly not live. */
.tomorrow { position: relative; }
.tomorrow-badge { white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--amber); background: var(--amber-soft); border: 1px dashed #d8b46a; border-radius: 99px; padding: 3px 9px; }
.tomorrow-banner { margin: 0 var(--page-gutter) 16px; padding: 12px 16px; border: 1px dashed #d8b46a; background: #fbf3df; border-radius: var(--radius); display: flex; gap: 12px; align-items: center; color: var(--muted-2); }
.dashed { border-style: dashed !important; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; padding: 0 32px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 14px; border: 0; background: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; display: flex; gap: 8px; align-items: center; }
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }
.tab .n { font-size: 11px; background: var(--sand-2); border-radius: 99px; padding: 1px 7px; color: var(--muted-2); }
.tab.active .n { background: var(--gold); color: var(--ink); }

/* ---------- Inbox rows ---------- */
.list { padding: 16px var(--page-gutter) 40px; display: flex; flex-direction: column; gap: 10px; }
.item { display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; gap: 0 16px; padding: 16px 18px 16px 0; text-decoration: none; overflow: hidden; }
.item:hover { border-color: #bcb6a7; background: #fff; }
.item .bar { border-radius: 0 4px 4px 0; }
.bar.urgent { background: var(--red); } .bar.high { background: var(--amber); } .bar.normal { background: var(--gold); } .bar.low { background: var(--line); }
.item .head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.item .who { font-weight: 600; }
.item .what { font-family: var(--serif); font-size: 20px; margin: 6px 0 8px; line-height: 1.2; }
.facts { display: grid; grid-template-columns: 112px 1fr; gap: 3px 12px; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.needs { margin-top: 10px; background: var(--sand); border-radius: 8px; padding: 9px 12px; font-size: 13px; }
.needs b { font-weight: 600; }
.needs ul { margin: 4px 0 0; padding-left: 18px; }
.item .side-meta { text-align: right; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; min-width: 120px; }
.queue-filters { display: flex; flex-wrap: wrap; gap: 8px; }
.queue-item { position: relative; }
.handoff-link { display: block; color: inherit; text-decoration: none; }
.handoff-link::after { content: ""; position: absolute; inset: 0; }
.handoff-link:focus-visible { outline-offset: 2px; }
.item-tools { display: flex; align-items: inherit; flex-wrap: wrap; gap: 8px; }
.item-tools > button, .side-meta > .queue-owner-control { position: relative; }
.queue-owner-control { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 4px 9px;
  overflow-wrap: anywhere; background: var(--paper); border: 1px solid var(--line); border-radius: 6px;
  color: inherit; font: inherit; font-size: 12px; cursor: pointer; }
.queue-owner-control:hover { border-color: var(--muted); }
.operator-summary { margin: 7px 0; overflow-wrap: anywhere; }
.operator-summary p { margin: 3px 0; }
.operator-summary strong { margin-right: 4px; }
.suggested-reply { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; margin-bottom: 5px; }
.suggested-reply [data-suggestion-status]:empty { display: none; }
.suggestion-sources { font-size: 12px; }
.suggestion-sources summary { cursor: pointer; }
.suggestion-sources ul { margin: 4px 0; padding-left: 20px; }
.demo-settings-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-settings [role="status"]:empty { display: none; }
.wait { font-variant-numeric: tabular-nums; font-weight: 600; }
.wait.red { color: var(--red); }

table.convos { width: calc(100% - 2 * var(--page-gutter)); margin: 16px var(--page-gutter) 40px; border-collapse: separate; border-spacing: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.convos th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--sand); }
.convos td { padding: 12px 14px; border-bottom: 1px solid #ebe6d8; vertical-align: middle; }
.convos tr:last-child td { border-bottom: 0; }
.convos tbody tr { cursor: pointer; }
.convos tbody tr:hover td { background: #fff; }
.convos .preview { color: var(--muted-2); max-width: 420px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filters { display: flex; gap: 8px; padding: 14px var(--page-gutter) 0; align-items: center; }
.search { border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 7px 14px; width: 280px; color: var(--muted); }

/* ---------- Conversation ---------- */
.convo { display: grid; grid-template-columns: 1fr 340px; height: 100vh; overflow: hidden; }
.thread { display: flex; flex-direction: column; min-width: 0; }
.thread-head { padding: 16px var(--thread-gutter); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; background: var(--cream); }
.thread-head .crumbs { font-size: 12px; color: var(--muted); }
.thread-head .crumbs a { text-decoration: none; }
.control { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.escalation { margin: 16px var(--thread-gutter) 0; padding: 14px 16px; border-radius: var(--radius); background: var(--red-soft); border: 1px solid #e8bfb2; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; }
.escalation .icon { width: 30px; height: 30px; border-radius: 50%; background: var(--red); color: #fff; display: grid; place-items: center; font-weight: 700; }
.escalation h3 { font-family: var(--sans); font-size: 14px; font-weight: 600; }
.escalation p { margin: 4px 0 0; font-size: 13px; color: var(--muted-2); }
.msgs { flex: 1; overflow: auto; padding: 20px var(--thread-gutter); display: flex; flex-direction: column; gap: 14px; }
.daysep { align-self: center; font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.msg { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 10px; max-width: 720px; }
.msg .meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; align-items: center; }
.msg .meta b { color: var(--ink); font-weight: 600; }
.bubble { margin-top: 3px; padding: 10px 13px; border-radius: 4px 12px 12px 12px; background: var(--paper); border: 1px solid var(--line); }
.msg.ai .bubble { background: var(--sand); }
.msg.op .bubble { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.msg.held .bubble { background: transparent; border-style: dashed; color: var(--muted-2); }
.sources { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.src { font-size: 11px; border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; background: var(--paper); color: var(--muted-2); text-decoration: none; }
.msg-actions { display: flex; gap: 6px; margin-top: 6px; }
.system-note { align-self: center; font-size: 12px; color: var(--muted-2); background: var(--sand-2); border-radius: 99px; padding: 4px 12px; }
.composer { border-top: 1px solid var(--line); padding: 14px var(--thread-gutter) 18px; background: var(--paper); }
.composer textarea { width: 100%; min-height: 66px; resize: vertical; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font: inherit; background: #fff; }
.composer .row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.context { border-left: 1px solid var(--line); background: var(--sand); overflow: auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.context section h4 { margin: 0 0 8px; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.context .box { background: var(--paper); border: 1px solid var(--line); border-radius: 8px; padding: 12px; font-size: 13px; }
.context ul { margin: 0; padding-left: 16px; }
.context li { margin: 3px 0; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 4px 10px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }

/* ---------- P1 pages ---------- */
.page { padding: 0 var(--page-gutter) 40px; display: flex; flex-direction: column; gap: 18px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.panel { padding: 18px; }
.panel h3 { margin-bottom: 4px; }
.panel .desc { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.prompt { font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; white-space: pre-wrap; color: var(--muted-2); }
.rows { display: flex; flex-direction: column; }
.rows .r { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #ebe6d8; font-size: 13px; }
.rows .r:last-child { border-bottom: 0; }
.rows .r .grow { flex: 1; min-width: 0; }
.stat { font-family: var(--serif); font-size: 40px; line-height: 1; }
.meter { height: 8px; border-radius: 99px; background: var(--sand-2); overflow: hidden; margin-top: 10px; }
.meter i { display: block; height: 100%; background: var(--green); }
.diff { font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.diff .del { background: #f8e1da; text-decoration: line-through; color: var(--red); display: block; }
.diff .add { background: #e2ecdd; color: var(--green); display: block; }
.im-focused-diff { font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; }
.im-focused-diff del { background: var(--red-soft); color: var(--red); }
.im-focused-diff ins { background: #e2ecdd; color: var(--green); text-decoration-thickness: 1px; }
.eval-progress { height: 6px; margin-block: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.eval-progress > i { display: block; height: 100%; background: var(--green); }

/* ---------- Revision 2: nav counts, filters, templates, phone frames ---------- */
.nav .count.muted-count { background: #2f2e2a; color: #d9d3c3; }
.nav .count.warn-count { background: var(--red-soft); color: var(--red); }
.chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chip { white-space: nowrap; flex: none; border: 1px solid var(--line); background: var(--paper); border-radius: 99px; padding: 5px 12px; font-size: 13px; font-weight: 500; color: var(--muted-2); display: inline-flex; gap: 6px; align-items: center; }
.chip.on { background: var(--ink); color: var(--cream); border-color: var(--ink); }
.d { width: 8px; height: 8px; border-radius: 50%; }
[hidden] { display: none !important; }
.d.urgent { background: var(--red); } .d.high { background: var(--amber); } .d.normal { background: var(--gold); } .d.low { background: var(--line); }
.why-priority { font-size: 12px; color: var(--muted); margin-top: 8px; }
.why-priority b { color: var(--muted-2); font-weight: 600; }
.templates { display: flex; flex-direction: column; gap: 6px; }
.tpl { text-align: left; border: 1px solid var(--line); background: var(--paper); border-radius: 8px; padding: 8px 10px; font-size: 12.5px; color: var(--ink); display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.tpl:hover { background: #fff; border-color: #bcb6a7; }
.tpl .go { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tpl:hover .go { color: var(--ink); }
.p2-badge { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--blue); background: var(--blue-soft); border: 1px dashed #8eaacb; border-radius: 99px; padding: 3px 9px; }
.toggle { width: 38px; height: 22px; border-radius: 99px; background: var(--line); position: relative; flex: none; border: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on { background: var(--green); }
.toggle.on::after { left: 19px; }


/* Live portal layout and controls */
:root { --muted: #6c675a; }
.app { min-width: 0; height: 100dvh; }
.side { overflow: auto; }
.side .brand small, .side .nav-label { color: #aca595; }
.main { min-width: 0; }
#screen { min-width: 0; }
.chat-screen { flex: 1; min-height: 0; }
.convo { height: 100%; grid-template-columns: minmax(0, 1fr) minmax(245px, 30%); }
.thread { min-height: 0; }
.thread-head { flex-wrap: wrap; justify-content: space-between; }
.thread-head h1, .box, .item, .bubble, .system-note, .error { overflow-wrap: anywhere; }
.control { flex-wrap: wrap; }
.context-toggle, .install-back, #mobile-nav, .install-prompt { display: none; }
.install-actions { display: flex; flex: none; align-items: center; gap: 6px; }
.install-actions button { min-height: 44px; }
#dismiss-install { min-width: 44px; font-size: 20px; justify-content: center; }
.escalation { grid-template-columns: auto 1fr; margin-top: 12px; max-height: 28dvh; overflow: auto; }
.escalation.high { background: var(--amber-soft); border-color: #decb9d; }
.escalation.normal, .escalation.low { background: var(--sand-2); border-color: var(--line); }
.inline-action { font: inherit; color: inherit; background: transparent; border: 0; padding: 2px 0; text-decoration: underline; text-underline-offset: 3px; }
.bubble, .system-note { white-space: pre-wrap; }
.transcript-frame { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; }
.msgs { min-height: 0; overscroll-behavior: contain; overflow-anchor: none; }
#transcript { display: flex; flex: none; flex-direction: column; gap: inherit; }
#new-messages { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); min-height: 44px; white-space: nowrap; }
.chat-status { flex: none; display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; background: var(--paper); border-top: 1px solid var(--line); padding: 3px var(--thread-gutter); font-size: 12px; line-height: 1.25; }
#chat-status-text, #chat-status-details > summary { display: flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 600; }
#chat-status-details { min-width: 0; flex: 1; }
#chat-status-details > summary { cursor: pointer; list-style: none; }
#chat-status-details > summary::-webkit-details-marker { display: none; }
#chat-status-details > summary::after { content: '›'; flex: none; color: var(--muted); }
#chat-status-details[open] > summary::after { transform: rotate(90deg); }
#chat-status-details.urgent > summary { color: var(--red); }
#chat-status-summary { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-status-content { max-height: 36dvh; overflow: auto; overscroll-behavior: contain; }
.chat-status-tools { display: flex; align-items: flex-start; gap: 6px 12px; flex-wrap: wrap; }
.chat-status-tools .btn { min-height: 34px; }
#chat-status-actions:empty { display: none; }
.chat-status:has(#chat-status-quick:not([hidden])) { position: relative; }
.chat-status:has(#chat-status-quick:not([hidden])) #chat-status-details > summary { padding-inline-end: 96px; }
#chat-status-quick { position: absolute; inset: 3px var(--thread-gutter) auto auto; }
#chat-status-quick .btn { min-height: 44px; white-space: nowrap; }
#handoff .escalation { margin: 0 0 6px; max-height: none; overflow: visible; }
.chat-status + .composer { border-top: 0; padding-top: 3px; }
.system-note.transcript-divider { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 3px 0; border: 0; background: transparent; text-align: center; }
.system-note.held-back-note { margin: 0; padding: 3px 0; color: var(--muted); background: transparent; text-align: center; }
.customer-reply-note { margin-block: 8px; }
.customer-reply-note p { margin: 0 0 4px; }
.customer-reply-note blockquote { margin: 0; padding-inline-start: 10px; border-inline-start: 2px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.transcript-divider span { min-width: 0; max-width: 90%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transcript-divider::before, .transcript-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.msg:focus, .system-note:focus { outline: 2px solid #7e651c; outline-offset: 4px; }
.composer .row { flex-wrap: wrap; }
.composer textarea, input, #memory-value { font-size: 16px; }
.overlay-heading + #template-list { margin-top: 8px; }
#template-list p { margin: 6px; }
.template-row { display: grid; grid-template-columns: minmax(0, 1fr) 44px; gap: 5px; }
.template-edit { justify-content: center; border-radius: 8px; font-size: 16px; padding: 5px; min-height: 44px; }
.tpl { grid-template-columns: minmax(0, 1fr) auto; white-space: normal; }
.memory-row + .memory-row, .profile-identity + .memory-row { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 8px; }
.memory-row b { display: block; }
.fact { display: block; width: 100%; min-height: 44px; padding: 0; border: 0; text-align: start; color: inherit; font: inherit; background: transparent; overflow-wrap: anywhere; }
.fact:hover { text-decoration: underline; text-underline-offset: 3px; }
dialog[data-overlay] { width: min(460px, 92vw); max-height: 90dvh; border-radius: 10px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); padding: 0; }
dialog::backdrop { background: #17171588; }
.overlay-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.overlay-heading h2 { min-width: 0; margin: 0; outline: none; }
.overlay-close { flex: none; width: 44px; height: 44px; justify-content: center; font-size: 22px; }
dialog.drawer { inset: 0 0 0 auto; margin: 0; height: 100dvh; max-height: 100dvh; width: min(340px, 88vw); border-radius: 0; }
dialog.drawer[open] { display: flex; flex-direction: column; }
.drawer > .overlay-heading { flex: none; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.drawer > .side, .drawer > .context { flex: 1; }
#drawer { width: min(280px, 88vw); }
#desktop-context { min-height: 0; display: flex; }
#desktop-context .context { width: 100%; }
dialog label { display: block; margin: 10px 0 3px; }
dialog textarea { width: 100%; min-height: 100px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; }
dialog .row { display: flex; gap: 8px; margin-top: 10px; }
#memory-error, .error, .err { color: #8e2b1c; }
.error { margin: 0; background: var(--red-soft); padding: 8px 20px; }
.updatebar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 20px; background: var(--gold-soft); }
p.what { margin-bottom: 8px; }
.item > div { min-width: 0; }
.side-meta .small { white-space: nowrap; }
.table-scroll { min-width: 0; overflow-x: auto; }
table.all-convos { table-layout: fixed; }
.all-convos th:nth-child(1) { width: 27%; }
.all-convos th:nth-child(2) { width: 150px; }
.all-convos th:nth-child(4) { width: 90px; }
.all-convos td { overflow-wrap: anywhere; }
.search { color: var(--ink); max-width: 100%; }
.topbar { align-items: flex-start; }
.topbar > :first-child, .preview-actions, .page > *, .rows .grow { min-width: 0; overflow-wrap: anywhere; }
.topbar .sub { max-width: 68ch; }
.nav .count { min-width: 5ch; text-align: center; padding-inline: 3px; }
.count, .priority-count, .wait, .stat, time, .all-convos td:last-child { font-variant-numeric: tabular-nums; }
.priority-count { min-width: 2ch; text-align: center; }
.all-convos th:last-child, .all-convos td:last-child { text-align: right; white-space: nowrap; }
.eval-results .convos { margin: 0; width: 100%; min-width: 620px; }
.eval-results .convos td:nth-child(2) { max-width: 240px; white-space: normal; overflow-wrap: anywhere; }
.eval-results .convos :is(th, td):nth-last-child(-n+2) { text-align: center; white-space: nowrap; }
.preview-actions { margin-top: 10px; }
.team-preview .bubble { white-space: normal; }
.msg .meta { flex-wrap: wrap; column-gap: 8px; row-gap: 2px; }
.msg .meta time { white-space: nowrap; }
#install-help-title:focus { outline: none; }
.topbar .right { flex-wrap: wrap; justify-content: flex-end; }
.team-preview { display: grid; grid-template-columns: minmax(0, 1fr) minmax(245px, 30%); align-items: start; }
.page > .tomorrow-banner { margin: 0; }
.page .prompt { overflow-wrap: anywhere; }
.proposal { margin-top: 18px; }
.page > .btn { align-self: flex-start; }
.notification-page, .install-page { max-width: 980px; }
#nopts { margin: 0; padding: 0; border: 0; min-inline-size: 0; display: grid; gap: 16px; justify-items: stretch; }
#nopts > button { justify-self: start; }
.notification-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 0; min-height: 44px; border-bottom: 1px solid var(--line); }
.notification-row:last-child { border: 0; }
.notification-row input { appearance: none; flex: none; width: 38px; height: 22px; border-radius: 99px; background: #b6b0a1; position: relative; cursor: pointer; }
.notification-row input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; }
.notification-row input:checked { background: var(--green); }
.notification-row input:checked::after { left: 19px; }
.notification-row input:disabled { opacity: .5; cursor: default; }
.quiet-times { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 12px; }
.quiet-times input { border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }
#nresult:empty { display: none; }
.steps { margin: 0; padding: 0; list-style: none; counter-reset: install-step; }
.steps li::before { counter-increment: install-step; content: counter(install-step); display: grid; place-items: center; width: 28px; height: 28px; margin-bottom: 8px; border-radius: 50%; color: var(--gold); background: var(--ink); }
.steps p { margin-bottom: 0; }
.loading { padding: 28px; }
.center { display: grid; place-items: center; padding: 20px; }
.center form { width: min(440px, 100%); padding: 24px; }
.center label { display: block; }
.center input { display: block; width: 100%; margin: 4px 0 14px; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.primary { background: var(--ink); color: var(--paper); border: 0; border-radius: 99px; padding: 8px 15px; }
button:disabled { cursor: default; opacity: .55; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 1100px) {
  .app { grid-template-columns: 225px minmax(0, 1fr); }
  .nav a { font-size: 13px; gap: 6px; }
  .convo { grid-template-columns: minmax(0, 1fr); position: relative; }
  .context-toggle { display: inline-flex; }
  #desktop-context { display: none; }
}
@media (max-width: 740px) {
  :root { --page-gutter: 16px; }
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .app > .side { display: none; }
  #mobile-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--paper); border-top: 1px solid var(--line); min-height: var(--phone-nav-height); padding: 2px 4px env(safe-area-inset-bottom); z-index: 6; }
  #mobile-nav a, #mobile-nav button { display: grid; grid-template-rows: 19px 15px; align-content: center; justify-items: center; align-items: center; position: relative; gap: 3px; color: var(--muted); min-height: 48px; text-decoration: none; font-size: 11px; background: none; border: 0; padding: 0 2px; }
  #mobile-nav a.active { color: var(--ink); font-weight: 600; }
  #mobile-nav .nav-title { white-space: nowrap; }
  #mobile-nav .nav-icon { font-size: 16px; line-height: 1; }
  #mobile-nav .count { position: absolute; top: 4px; left: calc(50% + 9px); display: grid; place-items: center; width: 26px; height: 15px; background: var(--gold-soft); color: var(--ink); border-radius: 99px; font-size: 9px; }
  .has-chat #mobile-nav { display: none; }
  .show-install-reminder .install-prompt { display: flex; flex: none; align-items: center; justify-content: space-between; gap: 8px; background: var(--sand-2); padding: 6px var(--page-gutter); font-weight: 600; font-size: 13px; }
  .install-phone-intro { display: none; }
  #install-entrance:not(:has(#install:not([hidden]), #install-status:not([hidden]))) { display: none; }
  .install-page .steps { grid-template-columns: 1fr; gap: 0; }
  .install-page .steps li { border: 0; background: transparent; padding: 8px 0; }
  .install-prompt > span { min-width: 0; }
  .install-back { display: inline-block; margin-bottom: 8px; }
  .main { grid-row: 1; }
  h1 { font-size: 30px; }
  .topbar { padding: 17px var(--page-gutter) 12px; gap: 8px; flex-wrap: wrap; }
  .topbar .right { margin-left: 0; }
  .list { padding-top: 10px; gap: 8px; }
  .item { grid-template-columns: 4px minmax(0, 1fr); gap: 6px 10px; padding: 11px 12px 11px 0; }
  .item .bar { grid-row: span 2; }
  .item .side-meta { align-items: center; justify-content: flex-start; flex-direction: row; flex-wrap: wrap; min-width: 0; }
  .item .what { font-size: 18px; }
  .all-convos th:nth-child(1) { width: 44%; }
  .all-convos th:nth-child(2) { width: auto; }
  .all-convos th:nth-child(3), .all-convos td:nth-child(3) { display: none; }
  .all-convos th:nth-child(4) { width: 58px; }
  table.convos { margin: 12px var(--page-gutter); width: calc(100% - 2 * var(--page-gutter)); }
  .convos td, .convos th { padding: 8px 6px; }
  .convos .pill { white-space: normal; }
  .thread-head { padding: 9px var(--thread-gutter); gap: 6px; }
  .thread-head h1 { font-size: 26px; }
  .control { margin: 0; gap: 5px; }
  .control .btn { font-size: 12px; padding: 5px 8px; }
  .escalation { margin: 6px var(--thread-gutter) 0; padding: 8px; gap: 8px; }
  .escalation .icon { width: 22px; height: 22px; }
  .msgs { padding: 12px var(--thread-gutter); gap: 9px; }
  .msg { grid-template-columns: minmax(0, 1fr); width: fit-content; max-width: 88%; }
  .msg.op { align-self: flex-end; }
  .msg > .avatar { display: none; }
  .composer { padding: 8px var(--thread-gutter) max(10px, env(safe-area-inset-bottom)); }
  .composer textarea { min-height: 45px; }
  .grid2, .grid3, .team-preview { grid-template-columns: minmax(0, 1fr); }
  .tomorrow-banner { margin: 0 var(--page-gutter) 14px; flex-wrap: wrap; }
}
@media (max-height: 550px) {
  .thread-head { padding-block: 5px; }
  .composer { padding-block: 5px; }
}

/* Insights and operator settings */
.settings-nav { margin: 0 var(--page-gutter) 16px; }
.settings-nav a, .topbar .chips a { text-decoration: none; min-height: 36px; }
.insights-page, .bookings-page, .config-page { max-width: 1240px; }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.section-heading p, .insights-page section > p { margin: 4px 0 0; }
.section-heading + p { margin-top: 12px; }
.funnel, .drill-rows, .config-list, .bookings-list { list-style: none; margin: 0; padding: 0; }
.funnel { margin-top: 12px; }
.funnel > li + li { border-top: 1px solid var(--line); }
.funnel-row { display: grid; gap: 6px; padding: 11px 0; text-decoration: none; min-width: 0; }
.funnel-row:hover .funnel-label strong { text-decoration: underline; }
.funnel-row[aria-current], .metric-card[aria-current] { outline: 2px solid var(--green); outline-offset: 2px; }
.funnel-label { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.funnel-label > span, .metric-value, .funnel-values, .booking-row time { font-variant-numeric: tabular-nums; }
.funnel-label > span { font-weight: 600; }
.funnel-track { height: 7px; background: var(--sand-2); border-radius: 20px; }
.funnel-track i { display: block; height: 100%; background: var(--green); border-radius: inherit; }
.funnel-values { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 12px; }
.funnel-drop { display: inline-block; margin: 0 0 9px; color: var(--muted-2); font-size: 12px; }
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: 10px; margin-top: 12px; }
.metric-card { min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 13px; text-decoration: none; }
.metric-card:hover { background: #fff; }
.metric-label { font-weight: 600; }
.metric-value { font-size: 24px; line-height: 1.15; font-weight: 600; }
.drill-rows { margin-top: 8px; }
.drill-rows .r { gap: 8px; flex-wrap: wrap; }
.drill-rows .drill-reason { margin: 4px 0 0; overflow-wrap: anywhere; }
.row-stage { margin-top: 5px; }
.row-stage .pill { white-space: normal; }
.config-fieldset { display: grid; gap: 12px; border: 0; margin: 0; padding: 0; min-inline-size: 0; }
.config-fieldset > p, .stage-policy p, .bookings-page > p { margin: 0; }
.config-list, .bookings-list { display: grid; gap: 8px; }
.config-row { padding: 10px 12px; }
.stage-summary { display: grid; gap: 3px; width: 100%; min-height: 44px; padding: 4px 0; text-align: left; color: inherit; font: inherit; border: 0; background: transparent; }
.stage-summary strong { font-size: 14px; }
.stage-editor { display: grid; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.config-fields { display: grid; flex: 1; gap: 8px; min-width: 0; }
.stage-fields { grid-template-columns: repeat(auto-fit, minmax(min(100%, 155px), 1fr)); align-items: end; }
.config-fields label, .stage-policy label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; min-width: 0; }
.config-fields input:not([type=checkbox]), .config-fields select, .stage-policy select { width: 100%; min-width: 0; min-height: 36px; background: white; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; font: inherit; font-size: 16px; }
.config-fields .config-check { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.config-actions, .config-footer, .booking-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.config-actions { flex: none; }
.config-action { min-width: 36px; min-height: 36px; justify-content: center; font-size: 17px; }
.config-footer { justify-content: space-between; }
.config-status:empty { display: none; }
.config-status { margin: -6px 0 0; }
.availability-policy { display: grid; gap: 6px; max-width: 440px; }
.booking-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, auto); gap: 12px; align-items: center; }
.booking-actions { justify-content: end; }

@media (max-width: 740px) {
  .topbar .chips { gap: 4px; }
  .topbar .chips a { padding-inline: 8px; }
  .metrics-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .config-actions { justify-content: flex-end; }
  .config-action { min-width: 44px; min-height: 44px; }
  .booking-row { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .booking-actions { justify-content: flex-start; }
  .settings-nav a, .topbar .chips a, .config-footer .btn { min-height: 44px; }
}

.im-page, .evals-page, .capability-groups-page { max-width: 1020px; }
.flag-reply { min-height: 32px; padding: 4px 2px; border: 0; background: transparent; color: var(--muted-2); font: inherit; font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
.im-actions, .eval-case-actions, .eval-summary-head, .eval-version-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.eval-version-picker { flex-wrap: nowrap; }
.eval-version-picker .btn { white-space: nowrap; }
.im-actions { margin-top: 8px; }
.im-form, .im-fieldset, .im-field, .eval-review-list { display: grid; gap: 12px; min-width: 0; }
.im-field { gap: 5px; font-weight: 600; }
.im-field input, .im-field textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); font: inherit; font-size: 16px; font-weight: 400; padding: 8px 10px; }
.im-field textarea { resize: vertical; }
.im-fieldset { border: 0; padding: 0; margin: 0; }
#flag-dialog .im-field > textarea { min-height: 72px; }
#flag-result:empty, .im-status:empty { display: none; }
.im-status { padding: 0 var(--page-gutter); }
.im-preline { white-space: pre-wrap; overflow-wrap: anywhere; }
.im-version-list, .capability-examples, .eval-transcript-messages { list-style: none; padding: 0; margin: 0; }
.im-version-list a { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.im-version-list a[aria-current="page"] { font-weight: 600; }
.im-disclosure, .eval-transcript { margin-top: 10px; }
.im-disclosure summary, .eval-transcript summary { cursor: pointer; padding: 6px 0; font-weight: 600; }
.im-diff-list { min-width: 0; margin-top: 10px; }
.im-diff-list .diff { margin: 6px 0 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.eval-summary { margin: 8px 0; }
.eval-blocker, .eval-error { color: var(--red); margin: 8px 0; }
.eval-category-counts { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 12px; color: var(--muted-2); margin-top: 8px; }
.eval-category { margin-top: 10px; }
.eval-result, .eval-case-review, .eval-case-summary, .capability-example { border-top: 1px solid var(--line); padding: 10px 0; }
.eval-result-head { display: flex; justify-content: space-between; gap: 10px; }
.eval-result-head strong { overflow-wrap: anywhere; }
.eval-failures { color: var(--red); padding-left: 18px; }
.eval-transcript-messages li { background: var(--sand); padding: 7px 10px; border-radius: 6px; margin-top: 6px; }
.eval-transcript-messages p { margin: 2px 0 0; white-space: pre-wrap; }
.eval-case-review > .eval-case-summary { border: 0; padding-top: 0; }
.capability-groups { display: grid; gap: 10px; }
.capability-example a { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px; }
.capability-example p { margin: 4px 0; }
/* Team agent: floating button and chat panel on every page */
.team-fab { position: fixed; right: 16px; bottom: 20px; z-index: 5; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--ink); color: var(--paper); display: grid; place-items: center; box-shadow: 0 4px 14px #0004; cursor: pointer; }
body:has(.app.has-chat) .team-fab { bottom: 168px; }
.team-panel[open] { display: flex; flex-direction: column; position: fixed; inset: auto 16px 16px auto; margin: 0; width: min(420px, calc(100vw - 32px)); height: min(640px, 82dvh); padding: 14px; }
.team-panel .overlay-heading { margin-bottom: 4px; }
.team-context { margin: 0 0 8px; overflow-wrap: anywhere; }
.team-thread-frame { position: relative; flex: 1; min-height: 0; display: flex; }
.team-thread { flex: 1; min-width: 0; overflow: auto; overscroll-behavior: contain; padding: 4px 4px 10px; }
#team-history { display: grid; gap: 12px; }
#team-new-messages { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); min-height: 44px; white-space: nowrap; }
.team-message-content { min-width: 0; }
.team-panel .msg { grid-template-columns: minmax(0, 1fr); max-width: 100%; min-width: 0; }
.team-proposal-link { display: block; margin-top: 6px; }
.team-composer textarea { width: 100%; min-height: 56px; resize: none; }
.team-composer .row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
#team-busy:empty { display: none; }
@media (max-width: 740px) {
  .team-fab { bottom: calc(var(--phone-nav-height) + 12px); }
  body:has(.app.has-chat) .team-fab { bottom: 262px; }
  .team-panel[open] { inset: auto 0 0 0; width: 100%; max-width: 100%; height: 85dvh; border-radius: 14px 14px 0 0; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .team-composer textarea { font-size: 16px; }
}
.followup-text { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; margin: 4px 0 8px; white-space: pre-wrap; overflow-wrap: anywhere; }
#journey-edit-dialog input, #journey-fast-forward-dialog select { width: 100%; min-height: 44px; padding: 7px 10px; background: white; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; font: inherit; font-size: 16px; }
.journey-field + .journey-field { border-top: 1px solid var(--line); padding-top: 6px; }
.journey-fast-forward { margin-top: 8px; }
.system-note.scheduled-followup-divider { color: var(--green); }
#followup-review p { margin: 0; }
#followup-result:empty { display: none; }
@media (max-width: 740px) {
  .flag-reply { min-height: 44px; }
  .im-actions .btn, .eval-case-actions .btn { min-height: 44px; }
}

/* Eval case rows: one expandable row per case */
.eval-case-row { border-top: 1px solid var(--line); padding: 8px 0; }
.eval-case-row > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 4px 0; min-height: 44px; }
.eval-row-first { flex-basis: 100%; }
.eval-rules ul { margin: 4px 0 10px; padding-left: 20px; }
.eval-rules-readonly { margin-top: 10px; }
.eval-case-edit select, .eval-case-edit textarea { width: 100%; font: inherit; }
