:root {
  --bg: #141210;
  --panel: #1e1a16;
  --panel-2: #26211b;
  --ink: #f3ead9;
  --muted: #b8ab90;
  --gold: #e8b34b;
  --line: #3a332a;
  --green: #57b06a;
  --amber: #e8a23a;
  --red: #e05d4f;
  /* House palette is black / cream / gold (HBSD branding, Oct 28 2026).
     The "responded" accent is a pale gold — no off-palette blues. */
  --blue: #d8b36a;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.45;
}
main { max-width: 1200px; margin: 0 auto; padding: 1rem; }
h1 { font-size: 1.35rem; } h2 { font-size: 1.2rem; margin: .4rem 0; } h3 { font-size: 1rem; margin: .3rem 0 .6rem; }
.muted { color: var(--muted); } .small { font-size: .82rem; } .error { color: var(--red); }
a { color: var(--gold); }

/* top bar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem 1rem; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; gap: .7rem; align-items: center; }
.brand-badge { width: 44px; height: 44px; border-radius: 50%; }
.brand-name { font-weight: 700; letter-spacing: .02em; }
.brand-sub { font-size: .75rem; color: var(--muted); }
.topbar-right { display: flex; gap: .6rem; align-items: center; }
.conn { color: var(--green); font-size: .8rem; }
.conn.stale { color: var(--red); }
.user-chip { background: var(--panel-2); border: 1px solid var(--line); border-radius: 999px; padding: .25rem .7rem; font-size: .82rem; }
.mock-banner {
  background: #4a3512; color: #ffd98a; text-align: center;
  padding: .45rem 1rem; font-size: .85rem; border-bottom: 1px solid var(--amber);
}

/* buttons & inputs */
.btn {
  background: var(--gold); color: #1a1408; border: 0; border-radius: 8px;
  padding: .5rem 1rem; font-weight: 600; cursor: pointer; font-size: .9rem;
  text-decoration: none; display: inline-block;
}
.btn:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-google { background: #fff; color: #222; }
.btn-small { padding: .3rem .6rem; font-size: .8rem; border-radius: 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
input, select, textarea {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 6px; padding: .45rem .55rem; font-size: .9rem; width: 100%;
}
label { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; color: var(--muted); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

/* cards & layout */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 1rem; margin: .8rem 0;
}
.signin { max-width: 30rem; margin: 3rem auto; text-align: left; }
.signin .btn-google { margin-top: .6rem; }
.dev-signin { margin-top: 1rem; display: flex; flex-direction: column; gap: .6rem; }
.tabs { display: flex; gap: .5rem; margin-top: .6rem; }
.tab {
  background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  border-bottom: 0; border-radius: 10px 10px 0 0; padding: .55rem 1.1rem; cursor: pointer; font-size: .95rem;
}
.tab.active { background: var(--panel); color: var(--gold); font-weight: 700; }
.pill { background: var(--gold); color: #1a1408; border-radius: 999px; padding: 0 .45rem; font-size: .75rem; font-weight: 700; }

/* board */
.board-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .5rem; }
.counts { font-size: .9rem; color: var(--muted); }
.counts strong { color: var(--ink); }
.counts .risk { color: var(--amber); font-weight: 700; }
.counts .breach { color: var(--red); font-weight: 700; }
.filters { display: flex; gap: .7rem; flex-wrap: wrap; align-items: end; }
.filters label { min-width: 8.5rem; }
.filters label.grow { flex: 1; min-width: 12rem; }
.table-wrap { padding: 0; overflow-x: auto; }
table.board { width: 100%; border-collapse: collapse; min-width: 880px; }
table.board th, table.board td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.board th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
table.board tbody tr { cursor: pointer; }
table.board tbody tr:hover { background: var(--panel-2); }
table.board tbody tr.flash { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #4a3a14; } to { background: transparent; } }
td.summary { max-width: 22rem; }
td.nowrap, th.nowrap { white-space: nowrap; }
.empty { padding: 1rem; }

/* chips & SLA states */
.chip { display: inline-block; border-radius: 999px; padding: .1rem .55rem; font-size: .75rem; font-weight: 600; border: 1px solid var(--line); }
.chip-p2 { background: #4a241f; color: #ff9d8f; border-color: #7a3a30; }
.chip-p3 { background: #35301f; color: #e6cf9a; border-color: #6b5a2e; }
.chip-p1 { background: #5a1f1f; color: #ffb3a7; border-color: #a33; }
.chip-source { background: #2e2a22; color: #cfc4a5; border-color: #5a5142; }
.chip-human { background: #6b3a00; color: #ffd28f; border-color: #a86e00; }
.chip-incident { background: #3a2b4d; color: #cdb2f0; border-color: #6a4d99; }
.chip-status { background: var(--panel-2); color: var(--ink); }
/* escalation path (HBSD, Oct 28 2026) — house gold only: outline at
   Level 1, solid gold at Level 2 so Jim's items can't be missed. */
.chip-esc1 { background: #3a2f14; color: var(--gold); border-color: var(--gold); }
.chip-esc2 { background: var(--gold); color: #1a1408; border-color: var(--gold); font-weight: 700; }
.counts .escn { color: var(--gold); font-weight: 700; }
.wl-nums .escn { color: var(--gold); font-weight: 600; }
.qchip.escchip { border-color: var(--gold); }
.chip-failed { background: #4a241f; color: #ff9d8f; border-color: var(--red); }
.chip-notified { background: #1f3a26; color: #9fd8ab; border-color: var(--green); }
.sla { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.sla-green { color: var(--green); }
.sla-amber { color: var(--amber); }
.sla-red { color: var(--red); }
.sla-responded { color: var(--blue); font-weight: 600; }
.sla-closed { color: var(--muted); font-weight: 600; }
.sla-sub { display: block; font-size: .7rem; font-weight: 400; color: var(--muted); }
/* status bar + on hold (HBSD, Oct 28 2026) — house gold marks the
   held state and the bar's current state. */
.chip-hold { background: #3a2f14; color: var(--gold); border-color: var(--gold); }
.sla-held { color: var(--gold); font-weight: 700; letter-spacing: .05em; }
.status-bar { display: flex; flex-wrap: wrap; gap: .4rem; margin: .35rem 0 .2rem; }
.sbtn { padding: .5rem .85rem; border-radius: 999px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font-weight: 600; font-size: .9rem; cursor: pointer; }
.sbtn.active { background: var(--gold); color: #1a1408; border-color: var(--gold); cursor: default; }
.sbtn[disabled] { opacity: .4; cursor: not-allowed; }
.sbtn:not(.active):not([disabled]):hover { filter: brightness(1.12); }

/* workload */
.workload-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .7rem; }
.wl-card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; }
.wl-card .wl-name { font-weight: 700; }
.wl-card .wl-role { font-size: .75rem; color: var(--muted); }
.wl-card .wl-nums { margin-top: .35rem; font-size: .85rem; }
.wl-off { opacity: .65; }

/* detail */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
@media (max-width: 820px) { .detail-grid { grid-template-columns: 1fr; } }
.detail-grid .card { margin: 0; }
.detail-wrap { display: flex; flex-direction: column; gap: .8rem; margin-top: .8rem; }
.kv { display: grid; grid-template-columns: 8.5rem 1fr; gap: .25rem .8rem; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.transcript { display: flex; flex-direction: column; gap: .5rem; max-height: 22rem; overflow-y: auto; }
.msg { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; background: var(--panel-2); }
.msg .msg-head { font-size: .72rem; color: var(--muted); margin-bottom: .2rem; }
.msg.customer { border-left: 3px solid var(--gold); }
.msg.woody { border-left: 3px solid var(--blue); }
.events { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.events li { padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.events li:last-child { border-bottom: 0; }
.events .ev-kind { font-weight: 700; }
.banner-failed {
  background: #4a241f; border: 1px solid var(--red); color: #ffc9c2;
  border-radius: 10px; padding: .8rem 1rem; display: flex;
  justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.decision-form, .contact-form, .assign-row { display: flex; flex-direction: column; gap: .6rem; }
.assign-row { flex-direction: row; flex-wrap: wrap; align-items: end; }
.assign-row label { flex: 1; min-width: 10rem; }
.radio-row { display: flex; gap: 1rem; align-items: center; }
.radio-row label { flex-direction: row; align-items: center; gap: .35rem; color: var(--ink); font-size: .9rem; }
.radio-row input { width: auto; }
.notice { border: 1px dashed var(--amber); border-radius: 8px; padding: .7rem .9rem; color: #ffd98a; font-size: .9rem; }
.foot { text-align: center; padding: 1.5rem 1rem 2rem; }

/* queues (HBSD, Oct 28 2026) */
.queue-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin: .8rem 0 0; }
.qchip {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: 999px; padding: .55rem 1rem; cursor: pointer; font-size: .92rem;
  min-height: 44px; font-weight: 600;
}
.qchip:hover { border-color: var(--gold); }
.qchip.active { background: var(--gold); color: #1a1408; border-color: var(--gold); }
.qchip .qchip-n { font-weight: 700; }
.qchip .qchip-t { opacity: .65; font-weight: 400; }

/* clickable workload cards */
.wl-click { cursor: pointer; }
.wl-click:hover, .wl-click:focus-visible { border-color: var(--gold); outline: none; }
.wl-active { border-color: var(--gold); box-shadow: 0 0 0 1px var(--gold) inset; }

/* notes in the history timeline */
.events li.ev-note { background: #2b2517; border-radius: 6px; padding: .35rem .5rem; }

/* knowledge base */
.kb-grid { display: grid; grid-template-columns: 20rem 1fr; gap: .8rem; align-items: start; }
@media (max-width: 820px) { .kb-grid { grid-template-columns: 1fr; } }
.kb-list-card { margin: .8rem 0; }
.kb-item {
  display: block; width: 100%; text-align: left; background: transparent; color: var(--ink);
  border: 0; border-bottom: 1px solid var(--line); padding: .6rem .3rem; cursor: pointer;
  min-height: 44px;
}
.kb-item:last-child { border-bottom: 0; }
.kb-item:hover, .kb-item.active { background: var(--panel-2); }
.kb-item-title { display: block; font-weight: 600; }
.kb-item-tags { display: block; font-size: .75rem; color: var(--muted); margin-top: .15rem; }
.kb-form label { margin-bottom: .6rem; }

/* reports */
.rep-table { width: 100%; border-collapse: collapse; }
.rep-table th, .rep-table td { padding: .35rem .5rem; text-align: left; border-bottom: 1px solid var(--line); }
.rep-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.rep-table td:last-child, .rep-table th:last-child { text-align: right; }
.vol-row { display: flex; align-items: center; gap: .6rem; margin: .3rem 0; font-size: .85rem; }
.vol-day { min-width: 6.2rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.vol-bar { display: inline-block; height: .8rem; background: var(--gold); border-radius: 4px; min-width: 2px; }
.vol-n { white-space: nowrap; }

/* customers */
.notice-card { border-style: dashed; border-color: var(--amber); }
.cust-table { min-width: 640px; }
.cust-ticket { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; margin: .5rem 0; cursor: pointer; background: var(--panel-2); }
.cust-ticket:hover { border-color: var(--gold); }

/* text containment (HBSD, Oct 28 2026 — Jim: "make sure the text
   stays inside the forms instead of bleeding out like it did").
   Every string wraps or breaks INSIDE its card/form; nothing widens
   the page. `overflow-x: clip` on the page is only the last-resort
   guard (clip, not hidden, so the sticky topbar keeps working) —
   the real fixes are the wrap rules below. The wide board table
   still scrolls inside its own .table-wrap on purpose; that is
   contained scrolling, not page-level bleed. */
html, body { overflow-x: clip; }
img { max-width: 100%; }

/* header: brand may shrink, the right cluster wraps under it on
   narrow screens instead of the Sign out button clipping off-edge */
.topbar { flex-wrap: wrap; row-gap: .4rem; }
.brand { min-width: 0; flex: 1 1 auto; }
.brand-name, .brand-sub { overflow-wrap: break-word; }
.topbar-right { flex-wrap: wrap; justify-content: flex-end; }
.user-chip { white-space: nowrap; }

/* tab row: all five tabs stay visible — wrap, never clip */
.tabs { flex-wrap: wrap; }

/* ticket detail: the deadline / on-hold line is a sentence, not a
   cell value — it wraps inside the card. Board cells keep .sla
   nowrap; they live in the contained-scrolling table. */
[data-detail-countdown] { white-space: normal; }

/* value cells and raw customer text: break long unbroken strings
   (emails, order codes, URLs) instead of pushing out of the card */
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.msg, .events li, .cust-ticket, #kb-reader p { overflow-wrap: anywhere; }
.card h2, .card h3, .notice, .counts, .kb-item-title, .kb-item-tags,
.wl-name, .wl-nums, td.summary, .foot { overflow-wrap: break-word; }
.chip { max-width: 100%; overflow-wrap: break-word; }
.btn, .sbtn { max-width: 100%; overflow-wrap: anywhere; }
