/* Steward. One typeface, two weights, color only for state. */
@font-face {
  font-family: "Inter";
  src: url("/static/fonts/inter-variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --bg: #fbfbfa;
  --bg-raised: #ffffff;
  --bg-muted: #f1f1ee;
  --ink: #1b1b1a;
  --ink-soft: #6b6b67;
  --line: #e4e4df;
  --line-strong: #c9c9c2;
  --accent: #2857c4;
  --ok: #1f7a3f;
  --ok-bg: #e4f3e9;
  --warn: #9a6100;
  --warn-bg: #fdf1dc;
  --alert: #b3261e;
  --alert-bg: #fbe5e3;
  --info-bg: #e8eefb;
  --row: 44px;
  --radius: 6px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141414;
    --bg-raised: #1c1c1c;
    --bg-muted: #222222;
    --ink: #ececea;
    --ink-soft: #9a9a95;
    --line: #2c2c2c;
    --line-strong: #444;
    --accent: #7ea2ff;
    --ok: #6fcf8f;
    --ok-bg: #16301f;
    --warn: #f0b24f;
    --warn-bg: #3a2a0d;
    --alert: #ff7b72;
    --alert-bg: #3f1a17;
    --info-bg: #1d2740;
  }
}
:root[data-theme="dark"] {
  --bg: #141414;
  --bg-raised: #1c1c1c;
  --bg-muted: #222222;
  --ink: #ececea;
  --ink-soft: #9a9a95;
  --line: #2c2c2c;
  --line-strong: #444;
  --accent: #7ea2ff;
  --ok: #6fcf8f;
  --ok-bg: #16301f;
  --warn: #f0b24f;
  --warn-bg: #3a2a0d;
  --alert: #ff7b72;
  --alert-bg: #3f1a17;
  --info-bg: #1d2740;
}

* { box-sizing: border-box; }
html { font-family: var(--font); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); margin: 28px 0 10px; }
h2 .small { text-transform: none; letter-spacing: 0; font-weight: 400; }
p { margin: 0 0 10px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.error { color: var(--alert); font-size: 13px; }
.note { color: var(--ok); font-size: 13px; }
.reason { color: var(--warn); font-size: 13px; margin-top: 2px; }
.warn { color: var(--warn); }

/* header */
.top { display: flex; align-items: center; gap: 24px; padding: 0 24px; height: 52px; border-bottom: 1px solid var(--line); background: var(--bg-raised); }
.brand { font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.top nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.top nav a { color: var(--ink-soft); padding: 6px 10px; border-radius: var(--radius); white-space: nowrap; }
.top nav a:hover { color: var(--ink); background: var(--bg-muted); text-decoration: none; }
.top nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn-bg); color: var(--warn); font-size: 12px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.top-right { display: flex; gap: 6px; align-items: center; }
.top-right form { margin: 0; }

.banner { padding: 10px 24px; border-bottom: 1px solid var(--line); }
.banner-alert { background: var(--alert-bg); color: var(--alert); }
.banner .muted { color: inherit; opacity: 0.8; }
.flash { padding: 8px 24px; background: var(--info-bg); border-bottom: 1px solid var(--line); font-size: 14px; }
.flash-error { background: var(--alert-bg); color: var(--alert); }

/* layout */
.page { max-width: 1240px; margin: 0 auto; padding: 24px 24px 64px; }
.page.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 0; flex-basis: 100%; }
.section { margin-bottom: 8px; }
.section h2:first-child { margin-top: 8px; }
.line { line-height: 2; }
.line .num { font-weight: 600; }
.inline { display: inline; }

/* tables */
table.data { width: 100%; border-collapse: collapse; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
table.data th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--bg-muted); }
table.data th.num { text-align: right; }
table.data td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; height: var(--row); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: color-mix(in srgb, var(--bg-muted) 60%, transparent); }
table.data.compact td { height: auto; padding: 7px 12px; }
table.data tr.settled td { color: var(--ink-soft); }
table.data tr.settled a { color: var(--ink-soft); }
table.queue td:nth-child(3) { width: 48%; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline; margin: 0; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.actions form { margin: 0; display: inline; }
.sender { font-weight: 500; }

/* badges and pills */
.badge, .pill, .auth { display: inline-block; font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 10px; line-height: 18px; white-space: nowrap; }
.badge { background: var(--bg-muted); color: var(--ink-soft); }
.badge.st-queued { background: var(--warn-bg); color: var(--warn); }
.badge.st-processed, .badge.st-resolved, .badge.st-acknowledged { background: var(--ok-bg); color: var(--ok); }
.badge.st-blocked { background: var(--alert-bg); color: var(--alert); }
.badge.sev-info { background: var(--info-bg); color: var(--accent); }
.badge.sev-warn { background: var(--warn-bg); color: var(--warn); }
.badge.sev-alert { background: var(--alert-bg); color: var(--alert); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--alert-bg); color: var(--alert); }
.pill.off { background: var(--bg-muted); color: var(--ink-soft); }
.auth { font-weight: 500; padding: 0 5px; }
.auth.ok { color: var(--ok); background: var(--ok-bg); }
.auth.bad { color: var(--alert); background: var(--alert-bg); }

/* definition lists */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0 0 12px; }
dl.kv dt { color: var(--ink-soft); }
dl.kv dd { margin: 0; }

/* findings */
ul.findings { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 8px; }
.finding { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px; }
.finding.settled { opacity: 0.6; }
.finding-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.finding .prose { margin: 6px 0 4px; }
.finding .actions { margin-top: 8px; }
.finding .actions form.inline { display: inline-flex; gap: 6px; align-items: center; }
.finding .actions select { width: auto; padding: 3px 8px; font-size: 13px; }

/* buttons & forms */
button, .btn, .btn-small, .btn-quiet { font: inherit; }
.btn, .btn-small { display: inline-block; border: 1px solid var(--line-strong); background: var(--bg-raised); color: var(--ink); border-radius: var(--radius); padding: 7px 14px; cursor: pointer; font-weight: 500; line-height: 1.2; }
.btn-small { padding: 4px 10px; font-size: 13px; }
.btn:hover, .btn-small:hover { border-color: var(--ink-soft); text-decoration: none; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn-quiet:hover { background: var(--bg-muted); color: var(--ink); border-color: transparent; }
.btn-danger { color: var(--alert); }
.btn-danger:hover { border-color: var(--alert); }
button.btn-quiet { border: 1px solid transparent; border-radius: var(--radius); padding: 4px 10px; cursor: pointer; font-size: 13px; }
.stack { display: grid; gap: 14px; max-width: 720px; }
.stack label { display: grid; gap: 4px; font-weight: 500; }
.stack label .small { font-weight: 400; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.row .grow { grid-column: span 1; }
input[type="text"], input[type="search"], input[type="password"], input[type="email"], input[type="number"], select, textarea {
  font: inherit; padding: 7px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--bg-raised); color: var(--ink); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); outline-offset: 1px; border-color: var(--accent); }
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters input, .filters select { width: auto; padding: 5px 9px; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 14px 12px; display: grid; gap: 8px; margin: 0; }
legend { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); padding: 0 6px; }
label.check { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: baseline; font-weight: 500; }
label.check .small, label.check .error { grid-column: 2; }
label.check input { margin: 0; }
label.check.scan .warn { display: none; }
label.check.scan:has(input:checked) .warn { display: block; }
label.check.danger { color: var(--alert); }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }
form.inline button { vertical-align: baseline; }

/* prose */
.prose { max-width: 68ch; }
.prose h1 { font-size: 24px; margin-top: 0; }
.prose h2 { font-size: 15px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 24px 0 8px; }
.prose ul { padding-left: 20px; }
.prose li { margin: 2px 0; }
.prose code { font-family: ui-monospace, Menlo, monospace; font-size: 13px; background: var(--bg-muted); padding: 1px 4px; border-radius: 3px; }
.prose pre { background: var(--bg-muted); padding: 10px 12px; border-radius: var(--radius); overflow-x: auto; }
.prose.small { font-size: 13px; }
.prose.small p { margin: 0 0 6px; }
pre.body { white-space: pre-wrap; word-break: break-word; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; max-width: 80ch; font: inherit; font-size: 14px; }

/* empty states */
.empty { border: 1px dashed var(--line-strong); border-radius: var(--radius); padding: 28px 24px; text-align: center; max-width: 560px; margin: 24px auto; }
.empty p:last-child { margin-bottom: 0; }



/* nav profile menu & popovers */
details.menu { position: relative; }
details.menu > summary { list-style: none; cursor: pointer; }
details.menu > summary::-webkit-details-marker { display: none; }
details.menu .menu-body { position: absolute; right: 0; top: calc(100% + 4px); min-width: 180px; background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 8px 24px rgba(0,0,0,0.12); padding: 6px; display: grid; gap: 2px; z-index: 20; }
details.menu .menu-body a, details.menu .menu-body button { display: block; width: 100%; text-align: left; padding: 6px 10px; border-radius: var(--radius); color: var(--ink); background: none; border: 0; font: inherit; cursor: pointer; }
details.menu .menu-body a:hover, details.menu .menu-body button:hover { background: var(--bg-muted); text-decoration: none; }
details.menu .menu-body form { margin: 0; }
details.profile > summary { padding: 4px 10px; }
h3 { font-size: 14px; font-weight: 600; margin: 18px 0 8px; }
h3 .small { font-weight: 400; margin-left: 4px; }

/* metrics */
table.metrics { max-width: 560px; }
table.metrics td:first-child { color: var(--ink-soft); }
table.metrics td.num { font-weight: 500; }

/* tasks */
.quick-add { display: flex; gap: 8px; margin: 0 0 20px; }
.quick-add input[type="text"] { flex: 1; }
.quick-add .due-input { flex: 0 0 200px; }
ul.tasks { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 2px; }
.task { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: var(--radius); background: var(--bg-raised); border: 1px solid var(--line); }
.task.settled { opacity: 0.6; }
.task.settled .task-title { text-decoration: line-through; }
.task-main { flex: 1; min-width: 0; }
.task-meta { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.check-btn { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--line-strong); background: var(--bg-raised); cursor: pointer; margin-top: 2px; padding: 0; }
.check-btn:hover { border-color: var(--ok); }
.check-btn.is-done { background: var(--ok); border-color: var(--ok); }
.due { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.due.today { color: var(--accent); font-weight: 600; }
.due.overdue { color: var(--alert); font-weight: 600; }
.stack-tight { display: grid; gap: 2px; }
.done-list { margin-top: 20px; }
.done-list summary { cursor: pointer; }

/* finance */
.row-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0 16px; }
.row-form input, .row-form select { width: auto; flex: 1 1 140px; }
.row-form input.short { flex: 0 1 110px; }
.add-form { margin: 8px 0 16px; }
.add-form summary { cursor: pointer; display: inline-block; list-style: none; }
.add-form summary::-webkit-details-marker { display: none; }
.file-btn { cursor: pointer; position: relative; overflow: hidden; display: inline-block; }
.file-btn input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.amount-in { color: var(--ok); }
tr.attention td { background: color-mix(in srgb, var(--warn-bg) 50%, transparent); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.map-grid label { display: grid; gap: 4px; font-size: 13px; }
.mapping { max-width: 1000px; }

/* message outcomes */
.badge.oc-filed, .badge.oc-scanned, .badge.oc-tasks, .badge.oc-events, .badge.oc-transactions { background: var(--ok-bg); color: var(--ok); }
.badge.oc-purged { background: var(--bg-muted); color: var(--ink-soft); }
.badge.oc-blocked, .badge.oc-failed { background: var(--alert-bg); color: var(--alert); }
.badge.oc-needs-you { background: var(--warn-bg); color: var(--warn); }
table.messages td:nth-child(3) { max-width: 360px; }

/* KPI row */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.kpi { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 10px; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--ink-soft); font-weight: 500; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-value { font-size: 28px; font-weight: 600; line-height: 1.15; margin-top: 4px; letter-spacing: -0.02em; font-variant-numeric: normal; }
.kpi-delta { font-size: 12px; color: var(--ink-soft); margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-delta.up { color: var(--ok); }
.kpi.money .kpi-value { font-size: 24px; }
.kpi .kpi-sub { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }
.kpi-value.neg { color: var(--alert); }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  html { font-size: 15px; }
  .top { padding: 0 14px; gap: 10px; height: 48px; position: sticky; top: 0; z-index: 30; }
  .top nav { display: none; }
  .page { padding: 14px 14px 88px; }
  .page-head { gap: 8px; }
  .page-head .actions { width: 100%; }
  h1 { font-size: 20px; }
  .row { grid-template-columns: 1fr; }
  .filters { width: 100%; }
  .filters input, .filters select { flex: 1 1 120px; width: auto; }
  .quick-add { flex-wrap: wrap; }
  .quick-add .due-input { flex: 1 1 140px; }
  .row-form input, .row-form select { flex: 1 1 100%; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dt { margin-top: 8px; }
  td.actions { white-space: normal; text-align: left; }
  .btn-small { padding: 7px 12px; min-height: 36px; }
  button.btn-quiet { min-height: 36px; }
  .flash, .banner { padding: 8px 14px; }

  /* bottom tab bar */
  .tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-around; background: var(--bg-raised); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 30; }
  .tabbar a { flex: 1; text-align: center; font-size: 12px; color: var(--ink-soft); padding: 6px 2px; border-radius: var(--radius); position: relative; }
  .tabbar a[aria-current="page"] { color: var(--ink); font-weight: 600; }
  .tabbar .count { position: absolute; top: 0; right: 8%; }

  /* stacked tables: each row becomes a block, cells labeled from data-label */
  table.data.stackable, table.data.stackable tbody, table.data.stackable tr, table.data.stackable td { display: block; width: 100%; }
  table.data.stackable thead { display: none; }
  table.data.stackable tr { padding: 10px 12px; border-bottom: 1px solid var(--line); }
  table.data.stackable tr:last-child { border-bottom: 0; }
  table.data.stackable td { height: auto; border: 0; padding: 2px 0; text-align: left; }
  table.data.stackable td.num { text-align: left; }
  table.data.stackable td:empty { display: none; }
  table.data.stackable td[data-label]::before { content: attr(data-label); display: inline-block; min-width: 76px; color: var(--ink-soft); font-size: 12px; margin-right: 6px; }
  table.data.stackable td.actions { padding-top: 6px; }
  table.data.stackable td.actions::before { display: none; }
  table.messages td:nth-child(3) { max-width: none; }
  table.queue td:nth-child(3) { width: auto; }
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-wrap table.data { min-width: 560px; }
  .kpis { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-value { font-size: 24px; }
  details.menu .menu-body { right: 0; }
}
@media (min-width: 721px) { .tabbar { display: none; } }

.edit-account { min-width: 240px; }
.edit-account input, .edit-account select { width: 100%; margin-bottom: 4px; }
@media (max-width: 720px) {
  table.data.stackable td.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
  table.data.stackable td.actions form, table.data.stackable td.actions details { display: inline-block; }
  .kpi-label { white-space: normal; }
}

.cat-summary { cursor: pointer; border-bottom: 1px dashed var(--line-strong); }
table.categories { max-width: 520px; }

#calendar { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; margin-bottom: 16px; --fc-border-color: var(--line); --fc-page-bg-color: var(--bg-raised); --fc-neutral-bg-color: var(--bg-muted); --fc-today-bg-color: color-mix(in srgb, var(--accent) 10%, transparent); --fc-event-bg-color: var(--accent); --fc-event-border-color: var(--accent); --fc-button-bg-color: var(--bg-muted); --fc-button-border-color: var(--line-strong); --fc-button-text-color: var(--ink); --fc-button-active-bg-color: var(--accent); --fc-button-active-border-color: var(--accent); --fc-button-hover-bg-color: var(--line-strong); --fc-button-hover-border-color: var(--line-strong); --fc-list-event-hover-bg-color: var(--bg-muted); }
#calendar .fc { font-size: 13px; }
#calendar .fc .fc-toolbar-title { font-size: 16px; font-weight: 600; }
#calendar .fc .fc-button { font: inherit; font-size: 13px; padding: 4px 10px; text-transform: none; box-shadow: none; }
#calendar .fc-task { background: var(--bg-muted); border-color: var(--line-strong); color: var(--ink); }
#calendar .fc-task .fc-event-title { color: var(--ink); }
#calendar a { color: inherit; }
.feed-url { word-break: break-all; user-select: all; background: var(--bg-muted); padding: 6px 10px; border-radius: var(--radius); }
.rule-test { margin: 0 0 14px; }
.rule-test input { flex: 1 1 320px; }
.rule-test-result { flex-basis: 100%; font-size: 14px; }
