
:root {
  --ok: oklch(0.648 0.15 160);
  --warn: oklch(0.735 0.16 66);
  --bad: var(--color-destructive, oklch(0.577 0.245 27.325));
}

body {
  background: var(--color-background);
  color: var(--color-foreground);
  font-family: var(--font-sans, ui-sans-serif, system-ui, sans-serif);
  margin: 0;
  -webkit-text-size-adjust: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-card);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand { font-weight: 700; letter-spacing: -0.02em; }
.topbar nav {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  /* flex child: without this the nav's own overflow never engages and the
     whole topbar pushes the page wider than the viewport */
  min-width: 0;
}
.topbar nav::-webkit-scrollbar { display: none; }
.topbar nav a {
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md, 0.5rem);
  color: var(--color-muted-foreground);
  text-decoration: none;
  font-size: 0.875rem;
  white-space: nowrap;
}
.topbar nav a:hover { background: var(--color-muted); color: var(--color-foreground); }
.topbar nav a[aria-current='page'] { background: var(--color-muted); color: var(--color-foreground); font-weight: 550; }
.topbar .who { font-size: 0.8rem; color: var(--color-muted-foreground); white-space: nowrap; }

.container { max-width: 64rem; margin: 0 auto; padding: 1rem; display: grid; gap: 1rem; }
/* Grid/flex children refuse to shrink below content width by default; without
   this, a wide table pushes the whole page wide instead of scrolling inside
   its own container — the body must never scroll horizontally. */
.container > *, .grid-2 > *, .card > * { min-width: 0; }
.card { min-width: 0; }

h1 { font-size: 1.25rem; letter-spacing: -0.02em; margin: 0; }
h2 { font-size: 1rem; margin: 0; }

.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--color-muted-foreground); }
.small { font-size: 0.8rem; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }

/* dashboard tiles */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 0.75rem; }
.tile {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl, 0.75rem);
  background: var(--color-card);
  padding: 0.75rem 0.9rem;
  display: grid;
  gap: 0.15rem;
}
.tile .label { font-size: 0.75rem; color: var(--color-muted-foreground); }
.tile .value { font-size: 1.15rem; font-weight: 650; letter-spacing: -0.01em; }
.tile .sub { font-size: 0.72rem; color: var(--color-muted-foreground); }
.tile.alert { border-color: color-mix(in oklab, var(--bad) 45%, var(--color-border)); }
.tile.alert .value { color: var(--bad); }

/* cards (basecoat .card provides the chrome; these lay out our content) */
.card { padding: 0.9rem 1rem; display: grid; gap: 0.6rem; }
.card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; padding: 0; border: 0; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 48rem) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* provenance pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  color: var(--color-muted-foreground);
  background: var(--color-muted);
}
.pill.ai {
  background: color-mix(in oklab, var(--color-primary) 12%, var(--color-muted));
  border-color: color-mix(in oklab, var(--color-primary) 35%, var(--color-border));
  color: var(--color-foreground);
}

/* progress bars */
.bar { height: 0.45rem; border-radius: 999px; background: var(--color-muted); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 999px; background: var(--color-primary); }
.bar > span.full { background: var(--ok); }

/* tables */
.table-container { overflow-x: auto; border: 1px solid var(--color-border); border-radius: var(--radius-lg, 0.6rem); background: var(--color-card); }
table.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
table.table th, table.table td { padding: 0.5rem 0.75rem; text-align: left; }
table.table th { color: var(--color-muted-foreground); font-weight: 500; font-size: 0.78rem; border-bottom: 1px solid var(--color-border); }
table.table tbody tr + tr td { border-top: 1px solid var(--color-border); }
table.table td.num, table.table th.num { text-align: right; }

/* projection matrix */
.matrix td, .matrix th { white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child {
  position: sticky; left: 0; background: var(--color-card); z-index: 1;
}
.matrix .milestone { color: var(--ok); font-weight: 600; }
.matrix .breach { color: var(--bad); font-weight: 600; }

/* diff cells */
.diff-old { color: var(--color-muted-foreground); text-decoration: line-through; margin-right: 0.35rem; }
.diff-new { font-weight: 600; }

/* inline forms */
form.inline { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
form.stack { display: grid; gap: 0.5rem; }
.input, .select { min-width: 0; }
input.input.amount { max-width: 9rem; text-align: right; font-variant-numeric: tabular-nums; }
input.input.month { max-width: 8.5rem; }

/* balance tap-to-edit */
button.balance-btn {
  all: unset; cursor: pointer; font-variant-numeric: tabular-nums;
  padding: 0.25rem 0.5rem; margin: -0.25rem -0.5rem; border-radius: 0.4rem;
  font-weight: 600;
}
button.balance-btn:hover { background: var(--color-muted); }
button.balance-btn:focus-visible { outline: 2px solid var(--color-ring); }

/* notes rendered next to a swapped row */
.note { font-size: 0.8rem; padding: 0.35rem 0.5rem; border-radius: 0.4rem; }
.note.ok { color: var(--ok); }
.note.err { color: var(--bad); }
.note.muted { color: var(--color-muted-foreground); }

/* findings */
.finding { display: flex; gap: 0.5rem; align-items: baseline; font-size: 0.85rem; }
.finding .badge { flex-shrink: 0; }

/* proposals */
.proposal-head { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.rationale {
  border-left: 3px solid var(--color-border);
  padding: 0.1rem 0 0.1rem 0.75rem;
  color: var(--color-foreground);
  font-size: 0.9rem;
}
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* log */
.log-detail { font-size: 0.78rem; color: var(--color-muted-foreground); max-width: 28rem; overflow-wrap: anywhere; }

/* login */
.login-wrap { min-height: 70vh; display: grid; place-items: center; }
.login-card { width: min(22rem, 92vw); }

@media (max-width: 40rem) {
  .container { padding: 0.75rem; }
  .tile .value { font-size: 1.05rem; }
}
