/* ══════════════════════════════════════════════════════════════
   WellPeps Pulse — dashboard styles

   Design system: Pulse Brand Style Guide v1.0. One font (the Segoe UI
   system stack, nothing to download), ink #01264C, action #005FCC, light
   only, 44px controls, 8px control radius, 12px card radius, 24px card
   padding, 4px spacing scale, 2px focus ring with a white gap, 14px minimum
   text, WCAG 2.2 AA.

   Calm status system: gray = routine, blue (info) = worth a look, green =
   healthy, amber / red ONLY for something a person must act on. No colored
   side-stripe borders and no nested cards.

   This file holds tokens, base, the app shell and the legacy tabs (Feed,
   Review desk, Urgent, Analytics, Briefs, Usage, Users, Controls).
   views.css holds the three main views (Pulse, Operator HQ, Knowledge).
   ══════════════════════════════════════════════════════════════ */

/* ── Tokens ──────────────────────────────────────────────────── */

:root {
  /* Pulse Brand Style Guide v1.0 */
  --ink:         #01264C;
  --muted:       #516C8C;
  --action:      #005FCC;
  --action-hover:#004DA6;
  --action-press:#003B80;
  --action-soft: #E8F1FC;
  --canvas:      #F4F8FB;
  --surface:     #FFFFFF;
  --input-border:#6B7F95;
  --divider:     #D9E4ED;
  --ok:          #137A53;  --ok-soft:   #E4F3EC;
  --warn:        #8A5700;  --warn-soft: #FBF1DF;
  --bad:         #B42318;  --bad-soft:  #FCEAE8;
  --brand-gradient: linear-gradient(90deg, #02CCCE 0%, #028BEA 55%, #0571EB 100%);

  /* Legacy names used by the older tabs, mapped onto the palette above */
  --navy: var(--ink);  --heading: var(--ink);
  --blue: var(--action);  --blue-hover: var(--action-hover);  --blue-deep: var(--action-press);
  --white: var(--surface);  --bg: var(--canvas);  --wellness: var(--action-soft);  --subtle: #EEF3F8;
  --border: var(--divider);  --border-strong: #C3D2DF;
  --text: var(--ink);  --text-2: var(--ink);  --text-3: var(--muted);
  --success: var(--ok);  --error: var(--bad);  --warning: var(--warn);
  --s-good: var(--ok);  --s-good-bg: var(--ok-soft);  --s-good-line: #BFE0D0;
  --s-wait: var(--action-hover);  --s-wait-bg: var(--action-soft);  --s-wait-line: #C5DBF4;
  --s-warn: var(--warn);  --s-warn-bg: var(--warn-soft);  --s-warn-line: #EBD3A2;
  --s-bad: var(--bad);  --s-bad-bg: var(--bad-soft);  --s-bad-line: #F2C3BE;
  --s-active: var(--action-hover);  --s-active-bg: var(--action-soft);  --s-active-line: #C5DBF4;
  --s-note: var(--action-hover);  --s-note-bg: var(--action-soft);  --s-note-line: #C5DBF4;

  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: var(--font);
  --sans: var(--font);
  --mono: var(--font);

  --r-sm: 8px;
  --r-btn: 8px;
  --r-md: 12px;
  --r-lg: 12px;
  --r-control: 8px;
  --gut: 24px;
  --control-h: 44px;

  --shadow-sm: none;
  --shadow: 0 4px 16px rgba(1, 38, 76, 0.10);
  --shadow-lg: 0 12px 32px rgba(1, 38, 76, 0.16);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  color-scheme: light;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
::selection { background: var(--action-soft); color: var(--ink); }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  background: var(--canvas); color: var(--ink);
  min-height: 100dvh; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { color: var(--ink); font-family: var(--font); text-wrap: balance; }
a { color: var(--action); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--action-hover); }
a:active { color: var(--action-press); }
button { font: inherit; }
:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; box-shadow: 0 0 0 2px #FFFFFF; border-radius: 4px; }
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.hidden { display: none !important; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.nowrap { white-space: nowrap; }
time { white-space: nowrap; }
.skip-link {
  position: absolute; left: 16px; top: -64px; z-index: 100; background: var(--ink); color: var(--surface);
  padding: 12px 16px; border-radius: var(--r-control); text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 8px; color: var(--surface); }

/* ── App shell: product header + three-view switch ───────────── */

.top { background: var(--surface); border-bottom: 1px solid var(--divider); padding: 12px var(--gut); }
.top-in { max-width: 1160px; margin-inline: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; }
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; color: var(--ink); flex: none; }
.brand:hover { color: var(--ink); }
.brand img { width: 48px; height: 48px; display: block; }
.brand .wordmark { font-size: 2rem; line-height: 2.5rem; font-weight: 700; letter-spacing: -.01em; color: var(--ink); }
.switch { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--canvas); border: 1px solid var(--divider); border-radius: 99px; padding: 4px; }
.switch a, .more-btn {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 99px;
  color: var(--muted); font-weight: 600; font-size: 1rem; text-decoration: none; background: none; border: 0; cursor: pointer;
}
.switch a:hover, .more-btn:hover { color: var(--ink); background: var(--action-soft); }
.switch a[aria-current="page"] { background: var(--action); color: #FFFFFF; }
.top-tools { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.more-wrap, .user-menu-wrap { position: relative; }
.more-btn { border: 1px solid var(--divider); background: var(--surface); }
.more-btn[aria-expanded="true"] { background: var(--action-soft); color: var(--ink); }
.more-btn.on-tool { border-color: var(--action); color: var(--action); }
.pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; min-width: 240px; padding: 8px;
  background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r-md); box-shadow: var(--shadow-lg);
  display: grid; gap: 2px;
}
.pop a, .pop button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 44px; padding: 0 12px;
  text-align: left; font-weight: 600; color: var(--ink); background: none; border: 0; border-radius: var(--r-control);
  text-decoration: none; cursor: pointer;
}
.pop a:hover, .pop button:hover { background: var(--action-soft); color: var(--action-hover); }
.pop a[aria-current="page"] { background: var(--action-soft); color: var(--action); }
.pop .pop-sep { height: 1px; background: var(--divider); margin: 4px 0; }
.harvey-status { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.status-dot.running { background: var(--ok); }
.status-dot.offline { background: var(--bad); }
.user-chip {
  display: flex; gap: 8px; align-items: center; min-height: 44px; color: var(--ink); font-weight: 600;
  background: none; border: 1px solid var(--divider); border-radius: var(--r-control); padding: 0 12px; cursor: pointer;
}
.user-chip:hover, .user-chip[aria-expanded="true"] { border-color: var(--action); background: var(--surface); }
.user-chip .caret { font-size: 14px; color: var(--muted); }
.user-chip .role { font-size: 14px; font-weight: 600; color: var(--action-hover); background: var(--action-soft); border-radius: 99px; padding: 0 12px; }
.refresh-btn {
  min-height: 44px; padding: 0 16px; background: var(--surface); border: 1px solid var(--action); border-radius: var(--r-control);
  color: var(--action); font-weight: 600; cursor: pointer;
}
.refresh-btn:hover { border-color: var(--action-hover); color: var(--action-hover); background: var(--action-soft); }

main { padding: 32px var(--gut) 24px; max-width: 1160px; margin: 0 auto; }
.section { display: none; }
.section.active { display: block; animation: rise .2s var(--ease); }
@keyframes rise { from { opacity: 0; } to { opacity: 1; } }
.section h1:focus { outline: none; }
.crumb-back { display: inline-block; margin-bottom: 12px; font-weight: 600; }

.site-foot { display: flex; justify-content: center; padding: 40px 16px 48px; margin: 32px var(--gut) 0; border-top: 1px solid var(--divider); }
.site-foot img { height: 28px; width: auto; display: block; }

/* ── Headings ────────────────────────────────────────────────── */

.section-head { margin-bottom: 24px; }
.section-head h1 { font-weight: 700; font-size: 2rem; line-height: 2.5rem; letter-spacing: -0.01em; }
.section-head p { color: var(--muted); margin-top: 8px; max-width: 72ch; text-wrap: pretty; }
.subhead {
  font-size: 14px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--muted); margin: 28px 0 12px;
}

/* ── Cards, buttons, badges ─────────────────────────────────── */

.card {
  background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r-md);
  padding: 24px; margin-bottom: 16px;
}
.card h2 { font-weight: 600; font-size: 1.25rem; line-height: 1.75rem; margin-bottom: 16px; }
.card .lede { color: var(--muted); margin: -8px 0 16px; max-width: 66ch; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--control-h); font: 600 1rem/1.5rem var(--font); padding: 0 16px; border-radius: var(--r-control);
  border: 1px solid transparent; cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--divider); border-color: var(--divider); color: var(--muted); cursor: not-allowed; }
.btn-primary { background: var(--action); border-color: var(--action); color: #FFFFFF; }
.btn-primary:hover:not(:disabled) { background: var(--action-hover); border-color: var(--action-hover); color: #FFFFFF; }
.btn-primary:active:not(:disabled) { background: var(--action-press); border-color: var(--action-press); }
.btn-secondary { background: var(--surface); border-color: var(--action); color: var(--action); }
.btn-secondary:hover:not(:disabled) { background: var(--action-soft); color: var(--action-hover); border-color: var(--action-hover); }
.btn-secondary:active:not(:disabled) { color: var(--action-press); border-color: var(--action-press); }
.btn-ghost { background: none; color: var(--action); border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn-ghost:hover:not(:disabled) { background: var(--action-soft); color: var(--action-hover); text-decoration: underline; }
.btn-danger { background: var(--surface); border-color: var(--bad); color: var(--bad); }
.btn-danger:hover:not(:disabled) { background: var(--bad-soft); }
/* Local demo mode only (PULSE_DEMO_SANDBOX / DEMO config). */
.btn-demo { background: var(--warn-soft); border-color: var(--s-warn-line); color: var(--warn); }
.btn-demo:hover:not(:disabled) { background: #F6E4BF; }
.demo-config-banner, .demo-sandbox-banner { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center;
  padding: 8px 16px; text-align: center; }
.demo-config-banner { background: var(--warn-soft); color: var(--warn); border-bottom: 1px solid var(--s-warn-line); }
.demo-sandbox-banner { background: var(--action-soft); color: var(--action-hover); border-bottom: 1px solid var(--s-wait-line); }
.demo-sandbox-banner a { color: var(--action-hover); font-weight: 600; }
.btn-sm { min-height: 44px; padding: 0 16px; font-size: 1rem; }
.btn-group { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

kbd {
  font-family: var(--font); font-size: 14px; padding: 0 6px;
  border: 1px solid var(--input-border); border-radius: 4px; background: var(--surface); color: var(--ink);
}

/* Status chips: text + icon, never color alone. Gray = routine, blue = worth a look, green = healthy,
   amber / red only when a person must act. */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 14px; font-weight: 600; line-height: 20px;
  padding: 2px 12px; border-radius: 99px; border: 1px solid transparent; white-space: nowrap;
}
.badge.t-idle    { background: var(--surface); color: var(--muted); border-color: var(--divider); font-weight: 500; }
.badge.t-active  { background: var(--action-soft); color: var(--action-hover); border-color: var(--s-active-line); }
.badge.t-active::before, .badge.t-waiting::before, .badge.t-note::before { content: "\2139"; }
.badge.t-waiting { background: var(--action-soft); color: var(--action-hover); border-color: var(--s-wait-line); }
.badge.t-note    { background: var(--action-soft); color: var(--action-hover); border-color: var(--s-note-line); }
.badge.t-good    { background: var(--ok-soft); color: var(--ok); border-color: var(--s-good-line); }
.badge.t-good::before { content: "\2713"; }
.badge.t-warn    { background: var(--warn-soft); color: var(--warn); border-color: var(--s-warn-line); }
.badge.t-warn::before { content: "!"; font-weight: 700; }
.badge.t-bad     { background: var(--bad-soft); color: var(--bad); border-color: var(--s-bad-line); }
.badge.t-bad::before { content: "\00D7"; font-weight: 700; }

.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.tag-row.tight { margin: 0; gap: 4px; }
.tag {
  font-size: 14px; line-height: 20px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--divider); border-radius: 99px; padding: 2px 12px; white-space: nowrap;
}
.tag .k { color: var(--muted); margin-right: 6px; }
.chip { color: var(--muted); font-size: 14px; }
.chip b { color: var(--ink); font-weight: 600; }
.breakdown { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-bottom: 16px; }

/* Platform: icon + name */
.pf { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.pf-icon { width: 16px; height: 16px; flex: none; color: var(--ink); }

/* "Why is this urgent" */
.why {
  display: flex; gap: 12px; align-items: baseline;
  margin: 12px 0; padding: 12px 16px; border-radius: var(--r-control);
  background: var(--canvas); border: 1px solid var(--divider); color: var(--ink);
}
.why-src { flex: none; font-size: 14px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.why-text { min-width: 0; overflow-wrap: anywhere; }

/* ── Urgent ──────────────────────────────────────────────────── */

.ucards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 520px), 1fr)); gap: 16px; }
.ucard {
  display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r-md); padding: 24px;
}
.ucard.bad { border-color: var(--s-bad-line); }
.ucard:target { box-shadow: 0 0 0 3px var(--action-soft); }
.ucard-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ucard-id { color: var(--muted); font-variant-numeric: tabular-nums; }
.ucard-sla { margin-left: auto; display: inline-flex; gap: 8px; align-items: center; }
.ucard-title { font-weight: 600; font-size: 1.25rem; line-height: 1.75rem; margin-top: 12px; }
.ucard-subject { font-weight: 600; margin-top: 4px; }
.ucard-quote {
  margin: 8px 0 0; color: var(--muted);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
  overflow-wrap: anywhere;
}
.ucard .why { margin: 12px 0 0; }
.ucard-meta { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 12px; color: var(--muted); }
.ucard-meta .author { color: var(--ink); }
.ucard-meta .owner b { color: var(--ink); font-weight: 600; }
.owner-missing { cursor: help; }
.ucard-actions {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--divider);
}
.ucard-actions [data-action="ack"] { margin-left: auto; }
.countdown { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); white-space: nowrap; }
.countdown.late { color: var(--bad); }
.paged { white-space: nowrap; }

/* ── Tables ──────────────────────────────────────────────────── */

.table-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm); overflow: auto;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 14px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--divider);
  white-space: nowrap; position: sticky; top: 0; background: var(--white);
}
th.num { text-align: right; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--canvas); }
tbody tr.clickable { cursor: pointer; }
td.mention-cell { color: var(--navy); min-width: 240px; max-width: 560px; }
td.phrase { font-size: 1rem; color: var(--ink); }
.pager { display: flex; gap: 10px; align-items: center; margin-top: 12px; font-size: 14px; color: var(--text-3); }

/* ── Review desk ─────────────────────────────────────────────── */

.desk { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.desk-list {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); overflow: hidden auto; max-height: 680px;
}
.desk-group {
  font-size: 14px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3);
  padding: 10px 14px 6px; background: var(--bg); border-bottom: 1px solid var(--border);
}
.desk-item { padding: 12px 16px; border-bottom: 1px solid var(--divider); cursor: pointer; }
.desk-item:last-child { border-bottom: none; }
.desk-item:hover { background: var(--bg); }
.desk-item.active { background: var(--action-soft); }
.desk-item.active .sub { color: var(--ink); }
.desk-item .to { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 500; color: var(--navy); }
.desk-item .to > span:not(.badge) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.desk-item .to .badge { margin-left: auto; }
.desk-item .sub { font-size: 14px; color: var(--text-3); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.desk-pane, .drawer { --pane-pad: 28px; }
.desk-pane {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 26px var(--pane-pad);
}
.to-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; font-size: 14px; color: var(--text-3); }
.subject {
  font-family: var(--serif); font-weight: 600; font-size: 22px; line-height: 1.25;
  letter-spacing: -0.01em; color: var(--navy); margin: 12px 0 10px; overflow-wrap: anywhere;
}
.body {
  font-size: 14.5px; line-height: 1.7; white-space: pre-wrap; max-width: 70ch; color: var(--text);
  padding: 14px 16px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md);
  overflow-wrap: anywhere;
}
.post-link { margin-top: 8px; font-size: 14px; }
.reasoning { font-size: 14px; margin-top: 4px; }
.reasoning .k { color: var(--text-3); margin-right: 6px; }
.desk-block { margin-top: 22px; }
.desk-block > .subhead { margin: 0 0 8px; }
.editor { min-height: 160px; resize: vertical; line-height: 1.6; font-size: 14px; }
.desk-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.desk-actions select.form-input { width: auto; max-width: 260px; }
.claim-chip {
  display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 14px;
  border: 1px solid var(--border-strong); border-radius: 99px; padding: 2px 5px 2px 10px; cursor: help;
}
.claim-chip.pending { border-style: dashed; color: var(--s-wait); border-color: var(--s-wait-line); }
.claim-chip.ok { color: var(--s-good); border-color: var(--s-good-line); background: var(--s-good-bg); }
.claim-chip button { border: none; background: none; color: var(--text-3); cursor: pointer; font-size: 14px; padding: 0 4px; }
.claim-add { display: flex; gap: 8px; margin-top: 10px; }
.claim-add select { flex: 1; min-width: 0; }
.hit-list, .blockers { margin: 8px 0 0 18px; font-size: 14px; color: var(--text); }
.blockers { color: var(--s-bad); }
.kbd-hint { font-size: 14px; color: var(--text-3); margin-top: 12px; }

.timeline { border-left: 2px solid var(--border); margin: 6px 0 0 4px; padding-left: 16px; }
.timeline .ev { position: relative; padding: 6px 0; font-size: 14px; }
.timeline .ev::before {
  content: ''; position: absolute; left: -22px; top: 12px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--white); border: 2px solid var(--blue);
}
.timeline .ev .when { font-size: 14px; color: var(--text-3); margin-right: 8px; }
.timeline .ev .what { font-weight: 600; color: var(--navy); }
.timeline .ev .who { font-size: 14px; color: var(--text-3); margin-left: 8px; }
.timeline .ev .note { color: var(--text); margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); z-index: 50;
  background: var(--white); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
  overflow-y: auto; padding: 22px var(--pane-pad) 64px;
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.drawer-id { font-size: 14px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.esc-row { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 14px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.esc-row:last-child { border-bottom: none; }
.esc-row > span:first-child { font-weight: 600; color: var(--navy); }

/* ── Forms ───────────────────────────────────────────────────── */

.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.form-input {
  width: 100%; min-height: 44px; padding: 10px 12px; font: 400 1rem var(--font); color: var(--ink);
  background: var(--surface); border: 1px solid var(--input-border); border-radius: var(--r-control);
  transition: border-color .15s, box-shadow .15s;
}
.form-input:focus-visible { outline: 2px solid var(--action); outline-offset: 2px; box-shadow: 0 0 0 2px #FFFFFF; }
textarea.form-input { min-height: 120px; }
.form-input::placeholder { color: var(--text-3); }
.form-input[readonly] { background: var(--canvas); }
.form-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 140px; }
#feed-filters { margin-bottom: 8px; }

.test-result { font-size: 14px; margin-top: 12px; padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid transparent; }
.test-result.success { background: var(--s-good-bg); color: var(--s-good); border-color: var(--s-good-line); }
.test-result.error   { background: var(--s-bad-bg);  color: var(--s-bad);  border-color: var(--s-bad-line); }

/* ── Usage & Controls ────────────────────────────────────────── */

.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 16px 20px;
}
.stat-card .label { font-size: 14px; color: var(--text-3); margin-bottom: 6px; }
.stat-card .value { font-family: var(--serif); font-weight: 700; font-size: 28px; color: var(--navy); line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-card .breakdown { margin: 10px 0 0; gap: 4px 12px; }

.progress-wrap { margin-bottom: 18px; }
.progress-label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 7px; }
.progress-label .pct { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--navy); }
.progress-label .text { color: var(--text-3); }
.progress-bar { height: 6px; background: var(--subtle); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width .5s var(--ease); }
.progress-fill.green { background: var(--success); }
.progress-fill.yellow { background: var(--warning); }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 7px; font-size: 14px; }
.bar-day { width: 84px; flex-shrink: 0; color: var(--text-3); font-variant-numeric: tabular-nums; }
.bar-label { width: 140px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--navy); }
.bar-track { flex: 1; background: var(--subtle); border-radius: 99px; height: 10px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; background: var(--blue); }
.bar-val { width: 150px; text-align: right; font-variant-numeric: tabular-nums; }

.control-panel { display: grid; grid-template-columns: 1fr 1.4fr; gap: 16px; }
.status-big { display: flex; align-items: center; gap: 11px; margin-bottom: 10px; }
.status-big .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border-strong); }
.status-big .dot.running { background: var(--success); }
.status-big .label { font-family: var(--serif); font-weight: 600; font-size: 20px; color: var(--navy); }
.status-big .label.running { color: var(--success); }
.status-meta { font-size: 14px; color: var(--text-3); margin-bottom: 16px; min-height: 16px; }
.log-viewer {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 12px 14px;
  font-family: var(--mono); font-size: 14px; line-height: 1.6; color: var(--text); height: 340px; overflow-y: auto; white-space: pre-wrap;
}

/* ── Dialogs & passwords ─────────────────────────────────────── */

dialog.modal {
  width: min(460px, calc(100% - 32px)); margin: auto; padding: 0; border: 1px solid var(--border);
  border-radius: var(--r-lg); background: var(--white); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.modal::backdrop { background: rgba(1, 38, 76, 0.45); }
.modal-body { padding: 24px 26px 22px; }
.modal-body h2 { font-weight: 600; font-size: 1.5rem; line-height: 2rem; color: var(--ink); margin-bottom: 8px; }
.modal-body .lede { font-size: 14px; color: var(--text); margin-bottom: 18px; line-height: 1.55; overflow-wrap: anywhere; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; flex-wrap: wrap; }
.form-hint { font-size: 14px; color: var(--text-3); line-height: 1.5; margin-top: 4px; }
.form-error {
  font-size: 14px; margin-top: 12px; padding: 9px 12px; border-radius: var(--r-sm);
  background: var(--s-bad-bg); color: var(--s-bad); border: 1px solid var(--s-bad-line);
}
.pw-field { position: relative; }
.pw-field .form-input { padding-right: 72px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%); min-height: 36px; padding: 0 12px;
  font: 500 14px var(--sans); color: var(--blue); background: none; border: none; border-radius: var(--r-sm); cursor: pointer;
}
.pw-toggle:hover { background: var(--wellness); color: var(--blue-hover); }
.btn-group.tight { margin-top: 0; align-items: center; }
.form-check label { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--text); cursor: pointer; }
.form-check input { width: 20px; height: 20px; accent-color: var(--action); }
.form-row .form-group.form-check { flex: 0 1 auto; align-self: center; margin-bottom: 14px; }
td.row-actions { white-space: nowrap; text-align: right; }
td.row-actions .btn + .btn { margin-left: 6px; }
/* Forced change: nothing but the dialog (and its Sign out) until it's done. */
body.pw-forced .top-tools, body.pw-forced .switch, body.pw-forced main, body.pw-forced .site-foot { display: none; }

/* ── Empty states & toasts ───────────────────────────────────── */

.empty {
  text-align: center; padding: 48px 24px; background: var(--surface);
  border: 1px dashed var(--border-strong); border-radius: var(--r-md);
}
.empty .glyph {
  width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--blue); background: var(--wellness);
}
.empty .title { font-weight: 600; font-size: 1.25rem; line-height: 1.75rem; color: var(--ink); margin-bottom: 4px; }
.empty .copy { font-size: 14px; color: var(--text-3); line-height: 1.6; max-width: 50ch; margin: 0 auto; text-wrap: pretty; }

/* Toasts live in the #toasts live region (role=status), so they are announced. */
.toasts {
  position: fixed; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  z-index: 60; display: grid; gap: 8px; width: min(480px, calc(100% - 32px)); pointer-events: none;
}
.toast {
  padding: 12px 16px; border-radius: var(--r-control); font-weight: 600; pointer-events: auto;
  box-shadow: var(--shadow-lg); animation: toast-in .25s var(--ease);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.toast.success { background: var(--ink); color: var(--surface); }
.toast.error { background: var(--bad); color: #FFFFFF; }

/* ── Pulse tab ───────────────────────────────────────────────── */

.pulse-bar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 22px; }
.pulse-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pulse-tools .form-label { margin: 0; }
.pulse-tools .form-input { width: auto; min-width: 160px; }
.admin-only { display: inline-flex; gap: 8px; align-items: center; }
.seg { display: inline-flex; background: var(--white); border: 1px solid var(--border-strong); border-radius: 99px; padding: 3px; }
.seg button {
  background: none; border: none; color: var(--ink); font: 600 1rem var(--font);
  min-height: 40px; padding: 0 16px; border-radius: 99px; cursor: pointer;
}
.seg button:hover { color: var(--blue); }
.seg button.active { background: var(--blue); color: var(--white); }
.brief-head { margin-bottom: 22px; max-width: 80ch; }
.brief-head .to-line { gap: 8px; }
.brief-headline { font-weight: 700; font-size: 1.5rem; line-height: 1.25; margin: 12px 0; text-wrap: balance; }
.md p { font-size: 1rem; line-height: 1.65; margin-bottom: 10px; }
.md ul { margin: 0 0 10px 20px; font-size: 1rem; line-height: 1.6; }
.md b { color: var(--navy); font-weight: 600; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: 14px; margin-bottom: 24px; }
.action-card {
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 16px 18px;
}
.ac-title { font-family: var(--serif); font-weight: 600; font-size: 16px; color: var(--navy); line-height: 1.3; }
.ac-chips { margin: 8px 0; display: flex; gap: 6px; flex-wrap: wrap; }
.ac-why { font-size: 14px; line-height: 1.55; margin-bottom: 6px; }
.ac-action { font-size: 14px; line-height: 1.55; }
.ac-action b { color: var(--navy); }
.pulse-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 16px; }
.pulse-card { margin-bottom: 0; }
.delta { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta.up { color: var(--s-good); }
.delta.down { color: var(--s-bad); }
.delta.flat { color: var(--text-3); }
.mix-row { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.mix-row:last-child { border-bottom: none; }
.theme { margin-bottom: 12px; }
.theme-head { font-size: 14px; font-weight: 600; color: var(--navy); }
.quote-list { margin: 6px 0 0; padding-left: 18px; font-size: 14px; color: var(--text); }
.quote-list li { margin-bottom: 4px; }
.term-link {
  background: none; border: none; padding: 0; font: inherit; text-align: left; color: var(--blue);
  cursor: pointer;
}
.term-link:hover { color: var(--blue-hover); text-decoration: underline; text-underline-offset: 2px; }
.bank-note { font-size: 14px; margin: 0 0 12px; max-width: 80ch; }

/* ── Feed: urgent banner, filter actions ─────────────────────── */

.urgent-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 16px; padding: 10px 14px; border-radius: var(--r-md);
  background: var(--s-wait-bg); border: 1px solid var(--s-wait-line); color: #5C3A00; font-size: 14px;
}
.urgent-banner.bad { background: var(--s-bad-bg); border-color: var(--s-bad-line); color: var(--s-bad); }
.urgent-banner .ub-icon { font-size: 15px; }
.urgent-banner .ub-text b { font-weight: 600; }
.urgent-banner .ub-link { margin-left: auto; font-weight: 600; white-space: nowrap; }
.urgent-banner.bad .ub-link { color: var(--s-bad); }
.form-row .form-group.form-actions { flex: 0 0 auto; min-width: 0; display: flex; gap: 6px; }
.form-row .form-group.fg-narrow { flex: 0 1 150px; min-width: 130px; }
.btn-group.center { justify-content: center; }

/* ── Analytics ───────────────────────────────────────────────── */

.an-filters {
  display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: 14px 16px 2px; margin-bottom: 16px;
}
.an-filters .form-group { flex: 0 1 auto; min-width: 130px; }
.an-filters .form-group.form-actions { min-width: 0; }
.an-dates { display: inline-flex; align-items: center; gap: 6px; }
.an-dates .form-input { width: auto; }
.multi { position: relative; }
.multi summary { list-style: none; cursor: pointer; min-width: 170px; max-width: 240px; padding-right: 28px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; position: relative; }
.multi summary::-webkit-details-marker { display: none; }
.multi summary::after { content: '▾'; position: absolute; right: 10px; color: var(--text-3); }
.multi[open] summary { border-color: var(--blue); }
.check-list {
  position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 240px; max-height: 300px; overflow-y: auto;
  background: var(--white); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow); padding: 6px;
}
.check { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; font-size: 14px; color: var(--navy); cursor: pointer; }
.check:hover { background: var(--wellness); }
.check input { accent-color: var(--blue); }
.an-error { margin: 0 0 12px; font-size: 14px; color: var(--s-bad); }

.an-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.an-tile .value { font-family: var(--sans); font-weight: 600; font-size: 28px; font-variant-numeric: normal; }
.an-tile-delta { margin-top: 6px; font-size: 14px; display: flex; gap: 6px; flex-wrap: wrap; align-items: baseline; }

.an-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.an-card { margin-bottom: 0; min-width: 0; }
.an-card.wide { grid-column: 1 / -1; }
.an-card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.an-title { font-family: var(--serif); font-weight: 600; font-size: 17px; line-height: 1.3; color: var(--navy); }
.an-takeaway { font-size: 14px; color: var(--text); margin-top: 4px; max-width: 80ch; }
.an-card-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.seg.seg-sm button { padding: 4px 10px; font-size: 14px; }
.an-plot { position: relative; min-height: 60px; border-radius: var(--r-sm); }
.an-plot:focus-visible { outline-offset: 4px; }
.an-plot[tabindex] { cursor: crosshair; }
#an-plot-emerging { cursor: pointer; }
.chart-svg { display: block; max-width: none; overflow: visible; }
.chart-scroll { overflow-x: auto; }
.chart-tick { font: 400 14px var(--sans); fill: var(--text-3); font-variant-numeric: tabular-nums; }
.chart-label { font: 500 14px var(--sans); fill: var(--navy); }
.chart-value { font: 600 14px var(--sans); fill: var(--text); font-variant-numeric: tabular-nums; }
.chart-cell { font: 600 14px var(--sans); fill: var(--navy); font-variant-numeric: tabular-nums; }
.chart-cell.on-dark { fill: var(--white); }
.an-empty { display: flex; align-items: center; justify-content: center; min-height: 140px; padding: 16px;
  text-align: center; font-size: 14px; color: var(--text-3); background: var(--bg); border-radius: var(--r-md); }
.an-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 14px; color: var(--text); }
.an-legend:empty { display: none; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-key { display: inline-block; flex: none; }
.legend-key.rect { width: 10px; height: 10px; border-radius: 3px; }
.legend-key.line { width: 14px; height: 2px; border-radius: 2px; }
.legend-detail { color: var(--text-3); font-variant-numeric: tabular-nums; }
.ramp-legend { display: inline-flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 14px; }
.ramp { display: inline-flex; gap: 2px; }
.ramp span { width: 18px; height: 10px; border-radius: 2px; }
.an-table { margin-top: 4px; max-height: 420px; overflow: auto; }
.an-table table caption { text-align: left; }
.an-table tbody th { text-align: left; font: 500 14px var(--sans); color: var(--navy); text-transform: none; letter-spacing: 0;
  padding: 9px 14px; border-bottom: 1px solid var(--border); position: static; white-space: nowrap; }
.an-note { font-size: 14px; margin-top: 10px; }
.an-note:empty { display: none; }
#analytics.is-loading .an-card, #analytics.is-loading .an-tiles { opacity: .55; transition: opacity .2s; }

.an-mini { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.an-mini-tile { background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px; }
.an-mini-tile .label { font-size: 14px; color: var(--text-3); }
.an-mini-tile .value { font-size: 20px; font-weight: 600; color: var(--navy); line-height: 1.3; }
.an-mini-tile .value.bad { color: var(--s-bad); }
.an-mini-tile .sub { font-size: 14px; color: var(--s-bad); }

.spark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 200px), 1fr)); gap: 10px; }
.spark {
  display: flex; flex-direction: column; gap: 2px; text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: var(--white); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px 12px 8px;
  transition: border-color .15s, box-shadow .15s;
}
.spark:hover:not(:disabled) { border-color: var(--blue); box-shadow: var(--shadow-sm); }
.spark:disabled { cursor: default; background: var(--bg); }
.spark-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.spark-name { font-weight: 600; color: var(--navy); font-size: 14px; }
.spark-total { font-size: 14px; }
.spark-line { display: block; height: 40px; margin-top: 4px; }

.chart-tip {
  position: absolute; z-index: 70; pointer-events: none; max-width: 300px;
  background: var(--white); border: 1px solid var(--border-strong); border-radius: var(--r-md);
  box-shadow: var(--shadow); padding: 8px 10px; font-size: 14px;
}
.chart-tip-head { font-weight: 600; color: var(--navy); margin-bottom: 4px; }
.chart-tip-row { display: flex; align-items: center; gap: 7px; line-height: 1.6; }
.chart-tip-row b { color: var(--navy); font-weight: 600; font-variant-numeric: tabular-nums; }
.chart-tip-label { color: var(--text-3); }
.chart-tip-key { flex: none; display: inline-block; }
.chart-tip-key.line { width: 12px; height: 2px; border-radius: 2px; }
.chart-tip-key.rect { width: 9px; height: 9px; border-radius: 2px; }
.chart-tip-key.none { display: none; }

/* ── Sign-in ─────────────────────────────────────────────────── */

.login-page { background: var(--canvas); }
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card {
  width: min(400px, 100%); background: var(--white); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 32px 32px 26px;
}
.login-brand { text-align: center; margin-bottom: 24px; }
.login-brand .brand-logo { height: 64px; width: 64px; margin: 0 auto 8px; display: block; }
.login-brand h1 { font-weight: 700; font-size: 2rem; color: var(--ink); line-height: 2.5rem; }
.login-brand .tagline { font-size: 14px; margin-top: 6px; }
.login-card .btn { width: 100%; margin-top: 8px; }
.login-note { font-size: 14px; color: var(--text-3); margin-top: 16px; line-height: 1.6; }
.login-note code { font-family: var(--mono); font-size: 14px; background: var(--subtle); border-radius: 4px; padding: 1px 5px; }

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 1000px) {
  .an-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .desk { grid-template-columns: 1fr; }
  .desk-list { max-height: 240px; }
  .control-panel { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  :root { --gut: 16px; }
  .top { padding: 8px var(--gut); }
  .brand img { width: 40px; height: 40px; }
  .brand .wordmark { font-size: 1.75rem; line-height: 2rem; }
  .top-in { gap: 8px 12px; }
  .switch { width: 100%; justify-content: space-between; }
  .switch a { padding: 0 12px; flex: 1 1 auto; justify-content: center; }
  .top-tools { margin-left: 0; width: 100%; }
  .harvey-status { display: none; }
  .top-tools { gap: 8px; flex-wrap: nowrap; }
  .user-chip > span:first-child { display: none; }
  .refresh-btn { margin-left: auto; }
  main { padding-top: 24px; }
  .section-head h1 { font-size: 1.75rem; line-height: 2.25rem; }
  .desk-pane, .drawer { --pane-pad: 16px; }
  .desk-pane { padding-top: 18px; padding-bottom: 18px; }
  .ucard, .card { padding: 16px; }
  .ucard-sla { margin-left: 0; width: 100%; }
  .ucard-actions [data-action="ack"] { margin-left: 0; }
  .why { flex-direction: column; gap: 2px; }
  .bar-label { width: 90px; }
  .bar-val { width: auto; }
  td.mention-cell { min-width: 200px; }
  .an-filters { padding: 12px 12px 2px; }
  .an-filters .form-group { flex: 1 1 100%; }
  .check-list { min-width: 0; width: 100%; max-width: calc(100vw - 2 * var(--gut)); }
  .an-filters .form-group.an-custom { flex-basis: 100%; }
  .multi summary { max-width: none; }
  .an-card-head { flex-direction: column; }
  .an-card-tools { justify-content: flex-start; }
  .an-mini { grid-template-columns: minmax(0, 1fr); }
  .an-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .urgent-banner .ub-link { margin-left: 0; }
  .login-card { padding: 26px 20px 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
  html { scroll-behavior: auto; }
}

/* Replies & links card (replies.js) and the review desk's tracked-link chip */
.rp-card { margin-top: 16px; }
.rp-tables { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 16px; }
.tracked-link { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tracked-link p { flex-basis: 100%; margin: 4px 0 0; }

/* Rules of engagement block on the review desk (app.js engagementHtml). */
.protocol { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.protocol .hit-list { margin-top: 6px; }

/* Count chips on the nav (drafts waiting, urgent items) */
.nav-count {
  display: none; min-width: 24px; height: 24px; padding: 0 8px; border-radius: 99px;
  font-size: 14px; font-weight: 600; line-height: 24px; text-align: center;
  background: var(--action-soft); color: var(--action-hover);
}
.nav-count.on { display: inline-block; }
.nav-count.alert { background: var(--bad); color: #FFFFFF; }
.switch a[aria-current="page"] .nav-count { background: #FFFFFF; color: var(--action); }
.login-page .login-wrap { min-height: calc(100dvh - 132px); }
