:root {
  --bg: #f7f7f5; --panel: #fff; --ink: #1d1d1b; --muted: #6b6b66; --line: #e3e2dd;
  --accent: #8a3b12; --ok: #1f7a3a; --ok-bg: #e5f3e8; --watch: #8a6100; --watch-bg: #fbf1d6;
  --act: #b3261e; --act-bg: #fbe4e2; --closed: #555; --closed-bg: #ececec;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); }
.top { background: var(--panel); border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex;
       flex-wrap: wrap; gap: 8px 24px; align-items: center; position: sticky; top: 0; z-index: 5; }
.brand { font-weight: 650; } .brand span { font-weight: 400; color: var(--muted); margin-left: 6px; }
nav { display: flex; flex-wrap: wrap; gap: 4px; }
nav a { padding: 4px 10px; border-radius: 6px; color: var(--ink); text-decoration: none; }
nav a.active { background: var(--accent); color: #fff; }
nav a.later { color: #aaa; }
main { max-width: 1200px; margin: 0 auto; padding: 20px; }
h1 { font-size: 22px; margin: 4px 0 6px; } h2 { font-size: 16px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin: 14px 0; }
.card h2 { margin-top: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 0 16px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
table.kv th { width: 160px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip.ok { color: var(--ok); background: var(--ok-bg); }
.chip.watch { color: var(--watch); background: var(--watch-bg); }
.chip.act { color: var(--act); background: var(--act-bg); }
.chip.closed { color: var(--closed); background: var(--closed-bg); }
.drop { display: flex; gap: 12px; align-items: stretch; flex-wrap: wrap; margin: 14px 0; }
.drop label { flex: 1 1 400px; display: flex; flex-direction: column; gap: 4px; justify-content: center;
              border: 2px dashed #c9c7bf; border-radius: 10px; padding: 26px; background: var(--panel); cursor: pointer; }
.drop label.over { border-color: var(--accent); background: #fff6f0; }
.drop input[type=file] { position: absolute; left: -9999px; }
button, .button { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px;
                  font-size: 14px; cursor: pointer; text-decoration: none; display: inline-block; }

/* ---- phase 2 ---- */
.top .right { margin-left: auto; display: flex; gap: 12px; align-items: center; }
.asof { display: flex; gap: 6px; align-items: center; font-size: 13px; }
.asof input { font: inherit; padding: 2px 4px; }
button.link { background: none; color: var(--muted); padding: 0; font-size: 13px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 6px 0 14px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 12px 0; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stat span { display: block; color: var(--muted); font-size: 12px; }
.stat strong { font-size: 26px; font-variant-numeric: tabular-nums; }
.stat.bad strong { color: var(--act); } .stat.good strong { color: var(--ok); }
.filters { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0; }
.filters select { font: inherit; padding: 3px 6px; }
.note { background: #fbf8ef; border: 1px solid #efe6c9; border-radius: 8px; padding: 8px 12px; font-size: 13px; }
.scroll { overflow-x: auto; }
table.units td, table.units th { white-space: nowrap; }
.zero { color: #c8c6be; } .neg, .neg a { color: var(--act); }
td a { color: inherit; }
.chip.urgent { outline: 2px solid var(--act); }
.urgent-text { color: var(--act); font-weight: 700; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.pills a { border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px; text-decoration: none; color: var(--ink); background: var(--panel); }
.pills a.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.inline-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-top: 10px; }
.inline-form label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 2px; }
.inline-form input { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; }
.card.alert { border-color: #f0c4bf; background: #fff8f7; }
.login { max-width: 360px; margin: 60px auto; }
.login form { display: flex; flex-direction: column; gap: 12px; }
.login label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.login input { font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; }
details summary { cursor: pointer; }
@media (max-width: 640px) { main { padding: 12px 16px; } .top .right { margin-left: 0; } }

/* ---- phase 3 ---- */
.small { font-size: 12px; }
button.secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--line); padding: 5px 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.stack input, .stack select, .stack textarea, #case-text { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); }
#case-text { width: 100%; margin-bottom: 8px; }
.stat a { color: inherit; text-decoration: none; }

.chip { white-space: nowrap; }
.nowrap { white-space: nowrap; }
.mono { white-space: nowrap; }

/* ---- phase 5 ---- */
.hero { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(280px, 1.4fr); gap: 20px; align-items: center; }
.hero span { color: var(--muted); font-size: 13px; }
.hero strong { display: block; font-size: 56px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.hero.bad strong { color: var(--act); } .hero.good strong { color: var(--ok); }
.inline-form.tight { margin: 0; gap: 4px; flex-wrap: nowrap; }
.inline-form.tight input { padding: 3px 6px; }
.inline-form.tight button { padding: 4px 10px; font-size: 12px; }
@media (max-width: 640px) { .hero { grid-template-columns: 1fr; } .hero strong { font-size: 44px; } }

/* ---- phase 6 ---- */
.titlebar { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.export { font-size: 13px; color: var(--muted); }
textarea.code { width: 100%; font: 12px/1.5 ui-monospace, Menlo, monospace; padding: 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fcfcfa; }
.row-actions { display: flex; gap: 10px; margin-top: 8px; }
