/* Blueprint design system — a drafting sheet, not a dashboard.
   Two colors carry meaning: drafting BLUE is the plan (structure, links,
   navigation); REDLINE vermilion is markup ("this needs your attention").
   Light = warm drafting vellum + blue grid; dark = true cyanotype (Prussian
   blue, pale-cyan linework). A mono "annotation" layer letters the labels,
   sheet codes, and table headers the way a hand-lettered drawing does.
   All color/type decisions flow from these tokens. */

:root {
  color-scheme: light dark;
  /* vellum */
  --bg: #f1eee4;
  --grid-line: rgba(29, 78, 216, 0.06);
  --surface: #fbfaf5;
  --surface-2: #eae7da;
  --fg: #1a2230;
  --muted-fg: #5b6675;
  --border: #d8d3c3;
  /* the plan */
  --accent: #1d4ed8;
  --accent-fg: #ffffff;
  --accent-soft: #e3ebfd;
  --link: #1d4ed8;
  /* the markup — attention/revision */
  --redline: #cf3722;
  --redline-soft: #f7e2dd;
  --ok: #15803d;
  --ok-soft: #dcf3e3;
  --warn: #b45309;
  --warn-soft: #fdeed3;
  --danger: #cf3722;
  --danger-soft: #f7e2dd;
  --shadow: 0 1px 2px rgba(16, 34, 61, 0.06), 0 4px 12px rgba(16, 34, 61, 0.05);
  --radius: 10px;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-annot: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
}

/* Cyanotype (dark) tokens. Applied two ways: automatically when the OS asks
   for dark AND the user hasn't overridden to light, and manually when the
   in-app toggle sets data-theme="dark". The two blocks below hold identical
   values — keep them in sync. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b2545;
    --grid-line: rgba(150, 200, 255, 0.07);
    --surface: #10305c;
    --surface-2: #17427a;
    --fg: #dbe9ff;
    --muted-fg: #93b0d8;
    --border: #2b4c7e;
    --accent: #7fb0ff;
    --accent-fg: #08182f;
    --accent-soft: #1c3f70;
    --link: #a9cbff;
    --redline: #ff8a76;
    --redline-soft: #4a241f;
    --ok: #4ade80;
    --ok-soft: #12331f;
    --warn: #fbbf24;
    --warn-soft: #3a2c0d;
    --danger: #ff8a76;
    --danger-soft: #4a241f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
  }
}
:root[data-theme="dark"] {
  --bg: #0b2545;
  --grid-line: rgba(150, 200, 255, 0.07);
  --surface: #10305c;
  --surface-2: #17427a;
  --fg: #dbe9ff;
  --muted-fg: #93b0d8;
  --border: #2b4c7e;
  --accent: #7fb0ff;
  --accent-fg: #08182f;
  --accent-soft: #1c3f70;
  --link: #a9cbff;
  --redline: #ff8a76;
  --redline-soft: #4a241f;
  --ok: #4ade80;
  --ok-soft: #12331f;
  --warn: #fbbf24;
  --warn-soft: #3a2c0d;
  --danger: #ff8a76;
  --danger-soft: #4a241f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 14px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }

body {
  margin: 0;
  font-family: var(--font-body);
  line-height: 1.5;
  color: var(--fg);
  /* the drafting-paper grid */
  background:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px),
    var(--bg);
  background-size: 24px 24px, 24px 24px, auto;
}

a { color: var(--link); }

h1, h2, h3 { line-height: 1.25; }

/* Annotation layer: the mono, tracked, uppercase lettering that labels a
   drawing. An eyebrow over a section; a dimension mark under a title. */
.eyebrow {
  font-family: var(--font-annot);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--muted-fg);
  /* the label owns the gap to the thing it labels */
  margin: 0 0 0.5rem;
}

/* Drafting dimension mark: |—————| tick, rule, tick — a title/label divider.
   One recipe, shared by the page-header underline and the login card's crown;
   each caller sets only its own width and placement. */
.page-header::after, .login-form::after {
  content: "";
  height: 8px;
  border-left: 2px solid var(--accent);
  border-right: 2px solid var(--accent);
  background: linear-gradient(var(--accent), var(--accent)) left center / 100% 2px no-repeat;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- top bar + nav ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.55rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-annot);
  font-weight: 700;
  font-size: 0.98rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  text-decoration: none;
  color: var(--fg);
}
.brand svg { display: block; color: var(--accent); }

.nav {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.1rem;
}
/* top-level items: direct links and dropdown triggers share one look */
.nav-link, .nav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--muted-fg);
  text-decoration: none;
  font: inherit;
  font-size: 0.92rem;
  padding: 0.35rem 0.6rem;
  border: 0;
  border-radius: 7px;
  background: none;
  white-space: nowrap;
  cursor: pointer;
}
.nav-link:hover, .nav-trigger:hover { color: var(--fg); background: var(--surface-2); }
.nav-link.active, .nav-trigger.active {
  color: var(--accent);
  font-weight: 600;
  background: var(--accent-soft);
}
.caret {
  width: 0; height: 0;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.65;
}

/* dropdown menus — a small drawing-set index card under each group */
.nav-group { position: relative; }
.nav-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  z-index: 60;
  display: none;
  min-width: 11rem;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.nav-menu.is-open { display: block; }
.nav-menu a {
  display: block;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  color: var(--fg);
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}
.nav-menu a:hover { background: var(--surface-2); color: var(--accent); }
.nav-menu a.active { color: var(--accent); font-weight: 600; background: var(--accent-soft); }

.nav-toggle { display: none; }

/* theme toggle — shows the mode you'll switch TO (moon in light, sun in dark) */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted-fg);
  background: none;
  border: 1px solid var(--border);
  border-radius: 999px;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
  :root:not([data-theme="light"]) .theme-toggle .icon-sun { display: inline; }
}
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: inline; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: none; }

.count-pill {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0 0.3rem;
  margin-left: 0.25rem;
  border-radius: 999px;
  background: var(--redline);
  /* accent-fg is white on the light redline, near-black on the desaturated
     dark-mode salmon — keeps the count legible in both (AA). */
  color: var(--accent-fg);
  font-family: var(--font-annot);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; }
  .nav-toggle {
    display: inline-flex;
    margin-left: auto;
    background: none;
    border: 1px solid var(--border);
    color: var(--fg);
    padding: 0.3rem 0.6rem;
  }
  .nav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.5rem 0 0.25rem;
  }
  .nav.open { display: flex; }
  .nav-link { padding: 0.55rem 0.5rem; font-size: 1rem; }
  /* dropdowns become always-open sections; the trigger is the section label */
  .nav-group { position: static; }
  .nav-trigger {
    width: 100%;
    justify-content: flex-start;
    margin: 0.6rem 0 0.1rem;
    padding: 0 0.5rem;
    font-family: var(--font-annot);
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted-fg);
    pointer-events: none;
  }
  .nav-trigger.active { background: none; color: var(--muted-fg); }
  .caret { display: none; }
  .nav-menu {
    position: static;
    display: block;
    min-width: 0;
    padding: 0 0 0 0.5rem;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .nav-menu a { font-size: 1rem; padding: 0.5rem 0.5rem; }
  .logout-form { margin-left: auto; }
}

/* ---------- layout ---------- */

.content {
  padding: 1.25rem 1rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
}

section { margin-bottom: 2rem; }

/* Page header — a title with a drafting dimension mark beneath it. */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 {
  margin: 0 0 0.2rem;
  font-size: 1.6rem;
  letter-spacing: -0.01em;
}
.page-header .lead { margin: 0; color: var(--muted-fg); max-width: 60ch; }
.page-header::after { display: block; width: 4.5rem; margin-top: 0.7rem; }

/* ---------- title block (home hero) ----------
   The corner stamp of an architectural sheet: the project title set large,
   with a boxed metadata grid (project / sheet / date / open revisions). */
.titleblock {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0 1.25rem;
  margin-bottom: 1.75rem;
  border: 1.5px solid var(--fg);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.tb-main { flex: 1 1 22rem; padding: 1.4rem 1.5rem; min-width: 0; }
.tb-title {
  margin: 0;
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.02;
}
.tb-lead { margin: 0.6rem 0 0; color: var(--muted-fg); max-width: 48ch; }
/* the boxed corner stamp */
.tb-stamp {
  flex: 0 0 auto;
  align-self: stretch;
  display: grid;
  grid-template-columns: repeat(2, minmax(6.5rem, 1fr));
  margin: 0;
  border-left: 1.5px solid var(--fg);
  font-family: var(--font-annot);
}
.tb-stamp > div {
  padding: 0.55rem 0.9rem;
  border-bottom: 1px solid var(--border);
}
.tb-stamp > div:nth-child(odd) { border-right: 1px solid var(--border); }
.tb-stamp > div:nth-last-child(-n+2) { border-bottom: 0; }
.tb-stamp dt {
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted-fg);
}
.tb-stamp dd {
  margin: 0.15rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.tb-stamp dd.flag { color: var(--redline); }
@media (max-width: 640px) {
  .tb-stamp { flex-basis: 100%; border-left: 0; border-top: 1.5px solid var(--fg); }
}

/* ---------- cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card h2 { font-size: 1.05rem; }
/* keynote tick: a small accent square flags each card's heading, the way a
   keyed note is bulleted on a drawing. */
.card > h2:first-child::before {
  content: "";
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.5rem;
  border-radius: 2px;
  background: var(--accent);
  vertical-align: 0.08em;
}
.card-footer { margin: 0.75rem 0 0; font-size: 0.9rem; }

/* card with an inline control cluster (e.g. Everyone/Just-mine chips) beside
   its heading */
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.card-head .chips { margin-bottom: 0; }
/* zone sub-heading inside the open-work list */
.zone-head { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; margin: 1.1rem 0 0.4rem; color: var(--muted-fg); }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}
.card-grid section { margin-bottom: 0; }

/* stat strip — dimensioned callouts. A measured number with a mono label,
   ruled off by a leader tick along the top edge. Alert = redline markup. */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.stat {
  display: block;
  text-decoration: none;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  box-shadow: var(--shadow);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.stat:hover { border-color: var(--accent); border-top-color: var(--accent); transform: translateY(-1px); }
.stat .stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat .stat-label {
  font-family: var(--font-annot);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted-fg);
}
.stat.stat-alert { border-top-color: var(--redline); }
.stat.stat-alert:hover { border-color: var(--redline); border-top-color: var(--redline); }
.stat.stat-alert .stat-value { color: var(--redline); }
.stat.stat-ok { border-top-color: var(--ok); }
.stat.stat-ok .stat-value { color: var(--ok); }

/* ---------- lists / tables ---------- */

.stack-list { list-style: none; padding: 0; margin: 0.25rem 0; }
.stack-list li { padding: 0.45rem 0; border-bottom: 1px solid var(--border); }
.stack-list li:last-child { border-bottom: 0; }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.data-table th {
  text-align: left;
  font-family: var(--font-annot);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-fg);
  background: var(--surface-2);
  padding: 0.5rem 0.7rem;
}
.data-table td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-top: 1px solid var(--border);
}
.data-table tbody tr:hover td { background: var(--surface-2); }
.data-table td.num, .data-table th.num { text-align: right; }
.data-table tbody tr.cursor-row td { background: var(--accent-soft); }

/* ---------- billing cascade (budget → committed → invoiced → paid) ----------
   Magnitude bars on one shared scale. Status palette: graphite datum for the
   plan, blue for committed-within-budget, redline for the overrun past budget,
   green for money actually paid. Every bar is direct-labeled with its dollar
   value, so identity never rests on color alone. */
.cascade { margin: 0.5rem 0 1rem; }
.cascade-verdict { margin: 0 0 0.9rem; font-size: 0.95rem; }
.cascade-verdict .badge { margin-right: 0.4rem; }
.cascade-verdict.over { color: var(--redline); }
.cascade-row {
  display: grid;
  grid-template-columns: 5.5rem 1fr auto;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.cascade-label {
  font-family: var(--font-annot);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted-fg);
}
.cascade-track {
  display: flex;
  height: 1.15rem;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.cascade-fill {
  height: 100%;
  border-radius: 0 4px 4px 0;
  min-width: 2px;
  transition: width 0.5s cubic-bezier(0.2, 0.7, 0.3, 1);
}
.fill-budget { background: var(--muted-fg); opacity: 0.65; }
.fill-committed { background: var(--accent); }
/* the overrun segment, set off from the in-budget blue by a 2px surface gap */
.fill-over { background: var(--redline); border-left: 2px solid var(--surface); }
/* only the final segment of a bar carries the rounded data-end; a mid-bar
   segment (the blue committed portion when an overrun follows) is squared */
.cascade-fill:not(:last-child) { border-radius: 0; }
.fill-invoiced { background: var(--accent); opacity: 0.7; }
.fill-paid { background: var(--ok); }
.cascade-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg);
}
.cascade-value.over { color: var(--redline); }
/* the precise per-kind table, tucked behind a disclosure */
.figures { margin-top: 0.35rem; }
.figures > summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--muted-fg);
  padding: 0.2rem 0;
}
.figures > summary:hover { color: var(--accent); }

/* ---------- badges ---------- */

.badge {
  display: inline-block;
  padding: 0.12rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted-fg);
  font-family: var(--font-annot);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge-warn { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.badge-amber { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.badge-ok { background: var(--ok-soft); border-color: transparent; color: var(--ok); }
.badge-info { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* ---------- forms + buttons ---------- */

button, .btn {
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  padding: 0.4rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { border-color: var(--accent); color: var(--accent); }
button[type="submit"], .btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 600;
}
button[type="submit"]:hover, .btn-primary:hover {
  color: var(--accent-fg);
  filter: brightness(1.1);
}
button:disabled { opacity: 0.55; cursor: wait; }
button.quiet, .stack-list button, .data-table button {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted-fg);
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  font-size: 0.85rem;
}
button.quiet:hover, .stack-list button:hover, .data-table button:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Row of status-change buttons under an estimate card (accept/reject/…). */
.inline-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; align-items: baseline; }

/* Vertical single-column form (form.as_p) — e.g. add change order. */
.stacked-form { max-width: 32rem; }
.stacked-form p { margin: 0 0 0.9rem; }
.stacked-form label { display: block; margin-bottom: 0.25rem; color: var(--muted-fg); }
.stacked-form input, .stacked-form select, .stacked-form textarea { width: 100%; }
.stacked-form input[type="checkbox"] { width: auto; }

input[type="text"], input[type="password"], input[type="date"], input[type="number"],
input[type="file"], select, textarea {
  font: inherit;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

label { font-size: 0.9rem; }

.filters, .quick-add {
  display: flex;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* Quick-add's optional three-point estimate: a tight labelled cluster of
   narrow day inputs so best/likely/worst read as one unit, not three stray
   boxes. */
.est-group { display: flex; align-items: center; gap: 0.3rem; }
.est-group .est-label { font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.est-group input[type="number"] { width: 4.5rem; }

/* Typed-note capture: a full-width textarea over its options, not a row. */
.capture-note {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  align-items: start;
}
.capture-note textarea { width: 100%; resize: vertical; }
.capture-note select { align-self: stretch; max-width: 22rem; }

/* ---------- review inbox ---------- */

.chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
/* Chips render as either <button> (JS filters) or <a class="btn"> (nav-link
   filters, e.g. the digest history scope bar) — style both the same. */
.chips button, .chips .btn {
  border-radius: 999px;
  padding: 0.2rem 0.75rem;
  font-size: 0.85rem;
}
.chips button.chip-active, .chips .chip-active {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.filtered-out { display: none !important; }

.group-header { display: flex; align-items: center; gap: 0.6rem; }
.group-header .group-title { flex: 1; min-width: 0; }
.group-header .group-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.group-header .group-actions button { font-size: 0.8rem; padding: 0.2rem 0.6rem; }

/* Low-confidence proposals earn an amber left-edge so the eye lands on the
   rows that actually need scrutiny — keyed off the data-confidence the JS
   already sets, so no extra markup. */
[data-row][data-confidence="low"] td:first-child {
  box-shadow: inset 3px 0 0 var(--warn);
}

/* keyboard hints in the review lead — small drafting keycaps */
kbd {
  font-family: var(--font-annot);
  font-size: 0.78em;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface-2);
  color: var(--fg);
  white-space: nowrap;
}

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

.kanban { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 0.5rem; }
.kanban-column {
  flex: 0 0 230px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-top: 3px solid var(--muted-fg);
  border-radius: var(--radius);
  padding: 0.6rem;
}
/* status-keyed column accent: attention states run redline, motion blue,
   done green — the same semantic palette as everywhere else. Keys track
   tasks.models Task.STATUS_CHOICES; an unlisted status just keeps the default
   graphite border-top (no breakage). */
.kanban-column.col-blocked, .kanban-column.col-waiting_on_other { border-top-color: var(--redline); }
.kanban-column.col-in_progress { border-top-color: var(--accent); }
.kanban-column.col-done { border-top-color: var(--ok); }
.kanban-column.col-cancelled { border-top-color: var(--border); }
.kanban-column h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
  margin: 0.1rem 0.2rem 0.6rem;
  font-family: var(--font-annot);
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted-fg);
}
.kanban-count {
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 0.45rem;
  font-size: 0.72rem;
  color: var(--muted-fg);
}
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  margin-bottom: 0.5rem;
  box-shadow: var(--shadow);
}
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card.dragging { opacity: 0.45; cursor: grabbing; }
/* drop target: a drafting-style dashed berth, inset so it doesn't fight the
   status-colored border-top. */
.kanban-column.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.board-hint { margin: -0.25rem 0 0.75rem; font-size: 0.85rem; }
.kanban-card strong { font-size: 0.95rem; }
.kanban-meta { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.35rem; }
.kanban-flags { margin-top: 0.4rem; }
.kanban-empty { color: var(--muted-fg); text-align: center; margin: 0.5rem 0; opacity: 0.5; }

/* ---------- misc ---------- */

.muted { color: var(--muted-fg); font-size: 0.9em; }

/* The plain-English gloss under a relation triple in the review inbox — a
   readable translation of the jargon, so it's normal text, not muted chrome. */
.review-gloss { font-style: italic; color: var(--fg); }

.empty {
  color: var(--muted-fg);
  padding: 0.75rem 0.25rem;
}

.raw-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
}

.digest-editor {
  width: 100%;
  font-family: inherit;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.message {
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  margin-bottom: 0.5rem;
  background: var(--accent-soft);
  color: var(--fg);
  border: 1px solid var(--border);
}
.message-success { background: var(--ok-soft); border-color: transparent; }
.message-error, .message-warning { background: var(--danger-soft); border-color: transparent; }

/* ---------- login ---------- */

.login-wrap { display: flex; justify-content: center; padding-top: 8vh; }
.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  width: min(340px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow);
}
.login-form .brand { justify-content: center; font-size: 1.05rem; letter-spacing: 0.2em; margin-bottom: 0.25rem; }
.login-form::after { align-self: center; width: 3.5rem; order: -1; }
.login-form label { display: flex; flex-direction: column; gap: 0.25rem; color: var(--muted-fg); }
.login-form .errorlist { color: var(--danger); margin: 0; padding-left: 1.1rem; font-size: 0.9rem; }

/* ---------- chat ---------- */

.chat-entry { margin-bottom: 1rem; }
.chat-question {
  font-weight: 650;
  margin: 0 0 0.5rem;
}
.chat-question::before { content: "❯ "; color: var(--accent); }
.chat-steps { list-style: none; padding: 0 0 0 0.25rem; margin: 0 0 0.5rem; }
.chat-steps li {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted-fg);
  padding: 0.1rem 0;
}
.chat-answer { white-space: pre-wrap; margin: 0.25rem 0; }
.chat-sources { font-size: 0.9rem; }
.chat-sources a { margin-right: 0.75rem; }

/* Frappe Gantt ships light-only styles — keep its canvas on paper in both
   color schemes rather than half-theming it. */
#gantt-container {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  /* The library's default bar fill is white — ordinary (non-critical, non-
     decision, non-group) task bars would vanish against the white grid. Give
     them a visible slate-blue; the custom-class rules in gantt.html still
     override this for critical/decision/group bars. */
  --g-bar-color: #8ea3c9;
  --g-bar-border: #6f86b3;
}

.zone-list { list-style: none; padding: 0; }
.zone-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.zone-list li:last-child { border-bottom: 0; }

/* --- Photo timeline (Sprint 7) --- */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.photo-tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--fg);
}
.photo-tile img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}
.photo-caption {
  display: block;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- Graph explorer (Sprint 7) --- */
#graph-canvas {
  height: 70vh;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.graph-detail {
  margin-top: 0.75rem;
}
.graph-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.9rem;
  align-items: center;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.85rem;
  cursor: pointer;
  text-transform: capitalize;
}
.legend-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  display: inline-block;
}

/* --- Dispute dossier print styles (Sprint 7) --- */
@media print {
  .topbar, .filters, button, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
