/* Clara web UI: design tokens + shared components (ported from the approved prototype). Loaded after Bootstrap 5.3.
   Fonts are local files under vendor/fonts: nothing is fetched from a CDN at runtime. */
@font-face { font-family: 'Atkinson Hyperlegible Next'; font-style: normal; font-weight: 400; font-display: swap; src: url('../vendor/fonts/atkinson-hyperlegible-next-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible Next'; font-style: normal; font-weight: 500; font-display: swap; src: url('../vendor/fonts/atkinson-hyperlegible-next-latin-500-normal.woff2') format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible Next'; font-style: normal; font-weight: 600; font-display: swap; src: url('../vendor/fonts/atkinson-hyperlegible-next-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Atkinson Hyperlegible Next'; font-style: normal; font-weight: 700; font-display: swap; src: url('../vendor/fonts/atkinson-hyperlegible-next-latin-700-normal.woff2') format('woff2'); }
/* Variable: weight 200-900 and the optical-size axis (the browser picks the size automatically). */
@font-face { font-family: 'Source Serif 4'; font-style: normal; font-weight: 200 900; font-display: swap; src: url('../vendor/fonts/source-serif-4-latin-opsz-normal.woff2') format('woff2'); }


:root {
  --clara-cobalt: #2448c6;      /* Clara's hair: the one brand colour */
  --clara-cobalt-dark: #1a3596;
  --clara-wash: #edf1fc;        /* selected / hover backgrounds */
  --clara-ink: #1b2437;         /* text */
  --clara-muted: #5f6b80;       /* labels, meta */
  --clara-line: #dde2eb;        /* borders */
  --clara-page: #f5f7fa;        /* page background (cool, not cream) */
  --clara-amber: #a86400;  --clara-amber-wash: #fff4dc;   /* pending / private note */
  --clara-green: #1d7a4d;  --clara-green-wash: #e3f4ea;
  --clara-red: #b3362b;    --clara-red-wash: #fbe7e4;

  --bs-body-font-family: 'Atkinson Hyperlegible Next', system-ui, sans-serif;
  --bs-body-font-size: 0.875rem;  /* 14px UI text: cards, tables, buttons */
  --bs-body-color: var(--clara-ink);
  --bs-body-bg: var(--clara-page);
  --bs-border-color: var(--clara-line);
  --bs-link-color-rgb: 36, 72, 198;
  --bs-link-hover-color-rgb: 26, 53, 150;
}

body { line-height: 1.45; }

/* Buttons: brand primary, quiet secondary */
.btn { font-weight: 600; border-radius: 6px; }
.btn-primary { --bs-btn-bg: var(--clara-cobalt); --bs-btn-border-color: var(--clara-cobalt);
  --bs-btn-hover-bg: var(--clara-cobalt-dark); --bs-btn-hover-border-color: var(--clara-cobalt-dark);
  --bs-btn-active-bg: var(--clara-cobalt-dark); }
.btn-quiet { --bs-btn-color: var(--clara-ink); --bs-btn-bg: #fff; --bs-btn-border-color: var(--clara-line);
  --bs-btn-hover-bg: var(--clara-wash); --bs-btn-hover-border-color: #c4cde0; }
.btn:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--clara-cobalt); outline-offset: 2px; box-shadow: none; }

/* ---------- Top bar ---------- */
.topbar { background: #fff; border-bottom: 1px solid var(--clara-line); height: 56px; position: sticky; top: 0; z-index: 20; }
.topbar .inner { max-width: 1400px; margin: 0 auto; height: 100%; padding: 0 24px; display: flex; align-items: center; gap: 32px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--clara-ink); }
.brand img { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; box-shadow: 0 0 0 2px #fff, 0 0 0 3.5px var(--clara-cobalt); }
.brand span { font-weight: 700; font-size: 1.125rem; letter-spacing: -0.01em; color: var(--clara-cobalt); }
.topnav { display: flex; gap: 4px; height: 100%; }
.topnav a { display: flex; align-items: center; gap: 6px; padding: 0 12px; height: 100%; color: var(--clara-muted); text-decoration: none; font-weight: 500; border-bottom: 2px solid transparent; }
.topnav a:hover { color: var(--clara-ink); }
.topnav a.active { color: var(--clara-ink); border-bottom-color: var(--clara-cobalt); font-weight: 600; }
.topnav .count { font-size: 0.75rem; font-weight: 700; background: var(--clara-amber-wash); color: var(--clara-amber); border-radius: 10px; padding: 1px 7px; }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: 12px; color: var(--clara-muted); }
.topbar .user strong { color: var(--clara-ink); font-weight: 600; }

.page { max-width: 1400px; margin: 0 auto; padding: 24px; }

/* ---------- Type roles ---------- */
.label { font-size: 0.8125rem; color: var(--clara-muted); }           /* 13px small muted labels, sentence case */
.value { font-size: 0.875rem; color: var(--clara-ink); }              /* 14px card values */
.section-title { font-size: 1rem; font-weight: 700; margin: 0 0 12px; } /* 16px section headings */
.page-title { font-size: 1.375rem; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
.reading { font-size: 1.0625rem; line-height: 1.65; max-width: 70ch; } /* 17px long text: assessment */
.reading p { margin: 0 0 0.85em; }

/* Outgoing text = a "sheet" in serif, so drafts never look like UI */
.sheet { background: #fff; border: 1px solid var(--clara-line); border-radius: 8px; overflow: hidden; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--clara-line); background: #fbfcfe; }
.sheet-head .kind { font-weight: 700; font-size: 0.8125rem; padding: 2px 8px; border-radius: 4px; }
.kind-note { background: var(--clara-amber-wash); color: var(--clara-amber); }
.kind-email { background: var(--clara-wash); color: var(--clara-cobalt); }
.sheet-meta { padding: 10px 20px; border-bottom: 1px solid var(--clara-line); display: grid; grid-template-columns: 64px 1fr; gap: 4px 12px; font-size: 0.875rem; }
.sheet-meta dt { color: var(--clara-muted); font-weight: 400; }
.sheet-meta dd { margin: 0; }
.sheet-body { padding: 20px 24px 24px; font-family: 'Source Serif 4', Georgia, serif; font-size: 1.0625rem; line-height: 1.7; max-width: 72ch; }
.sheet-body p { margin: 0 0 0.9em; }
.sheet-note .sheet-body { border-left: 4px solid #f0c674; }

/* ---------- Status badges (soft pills; colour = meaning) ---------- */
.badge-s { display: inline-flex; align-items: center; gap: 5px; font-size: 0.75rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.badge-s::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.s-pending { background: var(--clara-amber-wash); color: var(--clara-amber); }
.s-delivered { background: var(--clara-green-wash); color: var(--clara-green); }
.s-fyi, .s-noaction { background: #eef0f4; color: var(--clara-muted); }
.s-working { background: var(--clara-wash); color: var(--clara-cobalt); }
.s-failed { background: var(--clara-red-wash); color: var(--clara-red); }
/* Confidence (js/confidence-badge.js): high green, medium yellow, low grey */
.conf-high { background: var(--clara-green-wash); color: var(--clara-green); }
.conf-medium { background: #fdf2c0; color: #6b5200; }
.conf-low { background: #eef0f4; color: var(--clara-muted); }

/* ---------- Panels ---------- */
.panel { background: #fff; border: 1px solid var(--clara-line); border-radius: 8px; }
.panel-body { padding: 20px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px 24px; }
.facts div > .label { display: block; margin-bottom: 2px; }

/* Plan steps: a real sequence, so numbered */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 12px 0; border-top: 1px solid var(--clara-line); }
.steps li:first-child { border-top: 0; }
.steps .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; background: var(--clara-wash); color: var(--clara-cobalt); }
.steps .skipped { color: var(--clara-muted); text-decoration: line-through; }
.steps .why { font-size: 0.8125rem; color: var(--clara-muted); margin-top: 2px; }
.steps li.selected { background: var(--clara-wash); margin: 0 -12px; padding: 12px; border-radius: 6px; border-top-color: transparent; }

/* ---------- Tables ---------- */
.table-clara { --bs-table-bg: #fff; margin: 0; font-size: 0.875rem; }
.table-clara thead th { font-size: 0.8125rem; font-weight: 600; color: var(--clara-muted); background: #fbfcfe; border-bottom: 1px solid var(--clara-line); padding: 10px 12px; white-space: nowrap; }
.table-clara td { padding: 11px 12px; vertical-align: top; border-color: #edf0f5; }
.table-clara tbody tr:hover td { background: #f8faff; cursor: pointer; }
.table-clara .num { text-align: right; font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 600; }
.cell-sub { color: var(--clara-muted); font-size: 0.8125rem; margin-top: 2px; max-width: 60ch; }


@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

[x-cloak] { display: none !important; }

/* ---------- Ticket header (shared by the three ticket variants) ---------- */
.crumb { font-size: 0.8125rem; color: var(--clara-muted); margin-bottom: 6px; }
.crumb a { color: var(--clara-muted); }
.ticket-head { display: flex; gap: 24px; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; }
.ticket-head .subject { font-size: 1rem; color: var(--clara-muted); margin: 4px 0 10px; max-width: 80ch; }
.ticket-head .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.ticket-head .links { display: flex; gap: 8px; flex-shrink: 0; }
.factstrip { display: flex; flex-wrap: wrap; gap: 8px 32px; padding: 12px 0; border-top: 1px solid var(--clara-line); border-bottom: 1px solid var(--clara-line); margin-bottom: 24px; }
.factstrip .label { display: block; }
.headline { font-size: 1.1875rem; font-weight: 700; line-height: 1.4; max-width: 62ch; margin: 0 0 12px; }
.dl-clara { display: grid; grid-template-columns: 160px 1fr; gap: 10px 20px; margin: 0; max-width: 90ch; }
.dl-clara dt { font-weight: 400; color: var(--clara-muted); font-size: 0.875rem; padding-top: 2px; }
.dl-clara dd { margin: 0; font-size: 1rem; line-height: 1.55; }

/* ---------- Dashboards (Satisfaction, AI costs): segmented filters + summary strip ---------- */
.seg { display: inline-flex; border: 1px solid var(--clara-line); border-radius: 6px; overflow: hidden; background: #fff; }
.seg button { border: 0; background: transparent; padding: 5px 12px; font-weight: 500; color: var(--clara-muted); }
.seg button + button { border-left: 1px solid var(--clara-line); }
.seg button.on { background: var(--clara-wash); color: var(--clara-cobalt); font-weight: 600; }
.summary { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin-bottom: 24px; }
.summary > div { padding: 16px 20px; border-left: 1px solid var(--clara-line); }
.summary > div:first-child { border-left: 0; }
.summary .big { font-size: 1.5rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.summary .big small { font-size: 0.875rem; font-weight: 400; color: var(--clara-muted); }
.legend { display: flex; gap: 16px; font-size: 0.8125rem; color: var(--clara-muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }

/* A section whose data is being fetched again: still readable, clearly in motion. */
.is-loading { opacity: .6; transition: opacity .15s; }

/* The one-line filter row of the dashboards (Satisfaction, AI costs). */
.filters { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-bottom: 20px; }

/* ---------- Shell (js/shell.js): standby banner, toasts, held-writes notice ---------- */
.standby { background: var(--clara-amber-wash); color: var(--clara-amber); border-bottom: 1px solid #f0d9a4; padding: 8px 24px; text-align: center; font-weight: 600; }
.toast-area { position: fixed; right: 16px; bottom: 16px; z-index: 1080; display: flex; flex-direction: column; gap: 8px; width: min(420px, calc(100vw - 32px)); }
.toast-clara { background: #fff; border: 1px solid var(--clara-line); border-left: 4px solid var(--clara-red); border-radius: 6px; padding: 10px 12px 10px 14px; box-shadow: 0 4px 16px rgba(27, 36, 55, .18); display: flex; gap: 10px; align-items: flex-start; }
.toast-clara.kind-warning { border-left-color: var(--clara-amber); }
.toast-clara.kind-success { border-left-color: var(--clara-green); }
.toast-clara.kind-info { border-left-color: var(--clara-cobalt); }
.toast-clara .text { flex: 1; overflow-wrap: anywhere; }
.toast-clara .act { color: var(--clara-cobalt); font-weight: 600; padding: 0 6px; }
.toast-clara button { border: 0; background: none; color: var(--clara-muted); padding: 0 2px; line-height: 1; }
/* Approval hold (js/live.js): Clara re-assessed while you were reading, so the buttons that send stay off until you say you have read it. */
.hold-note { display: flex; gap: 12px; align-items: center; background: var(--clara-green-wash); border: 1px solid #b9dfc9; border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; }
.clara-shell { display: contents; } /* the shell's wrapper must not box the sticky top bar in */

/* A follow-up's relative time (js/followup-tip.js): a button whose title and click show the exact time. */
.tip-btn { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; }
.tip-btn:hover { text-decoration: underline; }
.tip-btn.overdue { color: var(--clara-red); font-weight: 600; }
.tip-exact { display: block; margin-top: 2px; }
.tip-exact[hidden] { display: none; }
.help { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; }
