:root {
  --bg: #f6f6f3; --surface: #fff; --text: #1d1f1c; --muted: #6b6f68; --line: #e2e3de;
  --accent: #2f6b3a; --accent-text: #fff; --danger: #b3261e; --warn: #9a6400; --ok: #2f6b3a;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161815; --surface: #1f221e; --text: #e8e9e5; --muted: #9a9e96; --line: #33372f;
    --accent: #7fbf87; --accent-text: #10210f; --danger: #f2948c; --warn: #e5b55c; --ok: #7fbf87;
  }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--accent); }
.top { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 600; color: var(--text); text-decoration: none; }
nav { display: flex; gap: 16px; flex: 1; }
nav a { color: var(--muted); text-decoration: none; }
nav a[aria-current="page"] { color: var(--text); font-weight: 600; }
.logout { display: flex; gap: 12px; align-items: center; color: var(--muted); margin: 0; }
main { max-width: 1040px; margin: 0 auto; padding: 16px; }
h1 { font-size: 24px; margin: 8px 0 16px; }
h2 { font-size: 17px; margin: 28px 0 8px; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; display: block; overflow-x: auto; }
thead, tbody { display: table; width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); flex: 1; }
input, select, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
button, .button { font: inherit; background: var(--accent); color: var(--accent-text); border: 0; border-radius: 6px; padding: 9px 16px; cursor: pointer; text-decoration: none; display: inline-block; }
button.link { background: none; color: var(--accent); padding: 0; }
.form { display: flex; flex-direction: column; gap: 14px; max-width: 560px; }
.form button { align-self: flex-start; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.upload { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; text-decoration: none; color: var(--muted); display: flex; flex-direction: column; }
.stat .num { font-size: 24px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small, small { font-size: 12px; }
.error { color: var(--danger); }
.notice { background: var(--surface); border-left: 3px solid var(--accent); padding: 8px 12px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; border: 1px solid currentColor; white-space: nowrap; }
.badge.paid, .badge.processed { color: var(--ok); }
.badge.overdue, .badge.failed { color: var(--danger); }
.badge.partial, .badge.processing { color: var(--warn); }
.badge.awaiting, .badge.uploaded { color: var(--muted); }
code { font-size: 13px; }
body.center { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 20px; margin: 0; }
.filters { margin: 20px 0 12px; display: flex; gap: 12px; }
.filters label { flex: 0 0 auto; }
tr.internal td { color: var(--muted); }
.tx td { font-size: 14px; }
.budget tr.section th { background: var(--bg); color: var(--text); font-size: 13px; text-transform: none; letter-spacing: 0; padding-top: 14px; }
.budget tr.subtotal td { font-weight: 600; }
.budget tr.total td { font-weight: 700; font-size: 15px; border-top: 2px solid var(--line); }
.pct { font-size: 11px; color: var(--muted); margin-left: 4px; }
td.over { color: var(--danger); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0; align-items: flex-end; }
.chips a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; text-decoration: none; color: var(--muted); background: var(--surface); }
.chips a[aria-current="page"] { color: var(--accent-text); background: var(--accent); border-color: var(--accent); }
a.plain { color: inherit; text-decoration: none; }
.num-lg { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }
.num-lg.pos { color: var(--ok); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.button.secondary { background: none; color: var(--accent); border: 1px solid var(--line); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.tx tr[data-tx] { transition: background .15s; }
.tx tr.drop-target, .dropzone.drop-target, [data-tx].drop-target .dropzone { background: color-mix(in srgb, var(--accent) 14%, transparent); outline: 2px dashed var(--accent); outline-offset: -2px; }
.tx tr.saved { background: color-mix(in srgb, var(--ok) 12%, transparent); }
.tx tr.uploading { opacity: .6; }
select.cat { max-width: 220px; padding: 4px 6px; font-size: 13px; }
.rule-offer { margin-top: 4px; }
button.link.small { font-size: 12px; text-align: left; }
.files { display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 4px; }
.file { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 1px 2px 1px 6px; max-width: 260px; }
.file a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file a::before { content: "📎 "; }
.detach { background: none; color: var(--muted); padding: 0 5px; font-size: 14px; line-height: 1; }
.detach:hover { color: var(--danger); }
.clip { background: none; color: var(--muted); padding: 4px; border-radius: 6px; }
.clip:hover { color: var(--accent); background: var(--bg); }
button.clip.link { color: var(--accent); padding: 0; }
.dropzone { border: 1px dashed var(--line); border-radius: 8px; padding: 12px; }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 10; width: min(92vw, 460px); }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
.toast.error { background: var(--danger); color: #fff; }
.warn { color: var(--warn); }
