:root {
  --bg: #f6f5f2; --surface: #fcfcfb; --line: #e4e2dc; --line-strong: #cfccc3;
  --ink: #0b0b0b; --ink-2: #52514e; --ink-3: #7b7a74;
  --accent: #2a78d6; --accent-ink: #1c5cab; --accent-soft: #e7f1fb;
  --good: #0b7a3e; --good-soft: #e5f4e4; --warn: #9a5b00; --warn-soft: #fbf1dc;
  --bad: #b42323; --bad-soft: #fbebeb;
  --radius: 8px; --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 15px; margin: 0 0 12px; font-weight: 650; }
.sub { color: var(--ink-2); margin: 0 0 20px; }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 12.5px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* layout */
.shell { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: #1d1d1b; color: #e9e8e3; padding: 20px 12px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 700; font-size: 15px; padding: 0 10px 18px; letter-spacing: -0.01em; }
.brand small { display: block; font-weight: 450; color: #a9a79f; font-size: 12px; }
.nav a { display: flex; justify-content: space-between; align-items: center; color: #d6d4cd;
         padding: 7px 10px; border-radius: 6px; margin-bottom: 2px; }
.nav a:hover { background: #2c2c29; text-decoration: none; }
.nav a.on { background: #34342f; color: #fff; }
.nav .sep { height: 1px; background: #34342f; margin: 12px 4px; }
.pill { background: #e34948; color: #fff; border-radius: 10px; font-size: 11px; padding: 0 7px; font-weight: 600; }
.pill.grey { background: #55544f; }
.side form { position: absolute; bottom: 16px; left: 12px; right: 12px; }
.side .who { color: #a9a79f; font-size: 12px; padding: 0 10px 6px; }
.main { padding: 28px 32px 48px; max-width: 1240px; }

/* cards & grids */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
.g-main { grid-template-columns: 1.6fr 1fr; }
.stack > * + * { margin-top: 16px; }
.stat .label { color: var(--ink-2); font-size: 12.5px; }
.stat .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .foot { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.stat.alert .value { color: var(--bad); }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 12px; text-transform: uppercase;
     letter-spacing: 0.04em; padding: 8px 10px; border-bottom: 1px solid var(--line-strong); white-space: nowrap; }
td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #f8f7f4; }
.table-card { padding: 4px 8px; }
td .desc { max-width: 420px; }
td small { color: var(--ink-3); }

/* bars in tables */
.bar { height: 8px; background: var(--accent); border-radius: 0 4px 4px 0; min-width: 2px; }
.barcell { width: 40%; }

/* tags */
.tag { display: inline-block; border-radius: 4px; padding: 1px 7px; font-size: 12px; font-weight: 550;
       background: #efeee9; color: var(--ink-2); white-space: nowrap; }
.tag.open { background: var(--bad-soft); color: var(--bad); }
.tag.raised { background: var(--warn-soft); color: var(--warn); }
.tag.credited { background: var(--good-soft); color: var(--good); }
.tag.accepted { background: #efeee9; color: var(--ink-2); }
.tag.rule { background: var(--accent-soft); color: var(--accent-ink); }
.flagdot { color: var(--bad); font-weight: 700; }

/* forms */
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line-strong);
  border-radius: 6px; padding: 7px 9px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; font-weight: 550; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-weight: 600; border-radius: 6px;
       padding: 7px 14px; border: 1px solid var(--accent); background: var(--accent); color: #fff; cursor: pointer; }
.btn:hover { background: var(--accent-ink); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn.ghost:hover { background: #f3f2ee; }
.btn.danger { background: #fff; color: var(--bad); border-color: #e9b9b9; }
.btn.small { padding: 4px 10px; font-size: 13px; }
.filters { display: flex; gap: 10px; align-items: flex-end; margin-bottom: 16px; flex-wrap: wrap; }
.inline { display: inline; }

/* messages */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: var(--good-soft); border-color: #bfe0c4; color: #0b5a2e; }
.flash.error { background: var(--bad-soft); border-color: #efc6c6; color: var(--bad); }
.result { padding: 6px 0; border-bottom: 1px solid var(--line); }
.result.added::before { content: "✓ "; color: var(--good); font-weight: 700; }
.result.duplicate::before { content: "= "; color: var(--ink-3); font-weight: 700; }
.result.review::before { content: "! "; color: var(--bad); font-weight: 700; }

/* invoice */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; }
.pdf { width: 100%; height: 760px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.notes { white-space: pre-line; color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
details summary { cursor: pointer; color: var(--accent-ink); }

/* chart */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e9e8e3; stroke-width: 1; }
.chart .tick { fill: var(--ink-2); font-size: 11.5px; font-family: var(--font); }
.chart .label { fill: var(--ink-2); font-size: 11.5px; font-family: var(--font); }
.chart .band { fill: #f0efec; stroke: #cfccc3; stroke-dasharray: 3 3; }
.chart .agreed { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 6 4; }
.chart .pt:hover circle:last-of-type { r: 6; }
.legend { display: flex; gap: 16px; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }

/* login */
.login { max-width: 360px; margin: 12vh auto; }
.login .card { padding: 28px; }

.empty { color: var(--ink-3); padding: 18px 10px; text-align: center; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; } .side { position: static; height: auto; }
  .side form { position: static; margin-top: 12px; }
  .g2, .g3, .g4, .g-main { grid-template-columns: 1fr; }
  .main { padding: 20px 16px; }
}

.chart { max-height: 340px; }
td.date, td:first-child:not(.num) { white-space: nowrap; }
.chart .value { fill: var(--ink); font-size: 12.5px; font-weight: 600; font-family: var(--font); }
.combine-bar { position: sticky; top: 12px; z-index: 5; margin-bottom: 12px; border-color: var(--accent); box-shadow: 0 2px 10px rgba(0,0,0,.06); }
.combine-bar[hidden] { display: none; }
/* tags */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips.small { margin-top: 5px; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line-strong); background: #fff;
        border-radius: 999px; padding: 2px 10px; font-size: 12.5px; color: var(--ink); font: inherit; font-size: 12.5px; }
.chips.small .chip { padding: 0 8px; font-size: 11.5px; }
.chip a { color: inherit; }
.chip small { color: var(--ink-3); }
.chip button { border: 0; background: none; color: var(--ink-3); cursor: pointer; padding: 0 0 0 2px; font-size: 14px; line-height: 1; }
.chip button:hover { color: var(--bad); }
.chip.auto { border-style: dashed; color: var(--ink-2); }
.chip.suggest { border-style: dashed; color: var(--accent-ink); cursor: pointer; }
.chip.suggest:hover, a.chip:hover { background: var(--accent-soft); text-decoration: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on small { color: #e7f1fb; }
.tag.match-same { background: var(--good-soft); color: var(--good); }
.cheaper { color: var(--good); font-weight: 600; }
.dearer { color: var(--bad); font-weight: 600; }
