:root {
  --bg: #f4f1ee;
  --surface: #ffffff;
  --surface-strong: #f2f0eb;
  --ink: #111111;
  --muted: #5e5d5d;
  --line: #e5e0db;
  --accent: #c81f2f;
  --accent-ink: #ffffff;
  --secondary: #111111;
  --secondary-soft: #f7dfe1;
  --paid: #1d6f4c; --paid-bg: #dfeee6;
  --due: #a3661d; --due-bg: #f9e8c8;
  --pend: #555555; --pend-bg: #ececeb;
  --bad: #c02b2b;
  --shadow: rgba(17, 17, 17, 0.14);
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111111; --surface: #1a1a1a; --surface-strong: #202020; --ink: #f5f3f0; --muted: #b2b0ac; --line: #2d2d2d;
    --accent: #de2d38; --accent-ink: #ffffff;
    --secondary: #ffffff; --secondary-soft: rgba(222,45,56,0.12);
    --paid: #8fe0ad; --paid-bg: rgba(29,111,76,.38); --due: #f3cd7c; --due-bg: rgba(163,102,29,.45);
    --pend: #d3d1cf; --pend-bg: rgba(85,85,85,.42); --bad: #ff8c7a;
    --shadow: rgba(0, 0, 0, 0.28);
  }
}
html[data-theme="dark"] {
  --bg: #111111;
  --surface: #1a1a1a;
  --surface-strong: #202020;
  --ink: #f5f3f0;
  --muted: #b2b0ac;
  --line: #2d2d2d;
  --accent: #de2d38;
  --accent-ink: #ffffff;
  --secondary: #ffffff;
  --secondary-soft: rgba(222,45,56,0.12);
  --paid: #8fe0ad; --paid-bg: rgba(29,111,76,.38);
  --due: #f3cd7c; --due-bg: rgba(163,102,29,.45);
  --pend: #d3d1cf; --pend-bg: rgba(85,85,85,.42);
  --bad: #ff8c7a;
  --shadow: rgba(0, 0, 0, 0.28);
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #f4f1ee;
  --surface: #ffffff;
  --surface-strong: #f2f0eb;
  --ink: #111111;
  --muted: #5e5d5d;
  --line: #e5e0db;
  --accent: #c81f2f;
  --accent-ink: #ffffff;
  --secondary: #111111;
  --secondary-soft: #f7dfe1;
  --paid: #1d6f4c; --paid-bg: #dfeee6;
  --due: #a3661d; --due-bg: #f9e8c8;
  --pend: #555555; --pend-bg: #ececeb;
  --bad: #c02b2b;
  --shadow: rgba(17, 17, 17, 0.14);
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 1280px; margin: 0 auto; padding: 24px 20px 64px; }
h1 { font-size: 26px; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 20px 0 8px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.r { text-align: right; }
.num, .amt, td.r, dd, .big, .v { font-variant-numeric: tabular-nums; }

.top { display: flex; align-items: center; gap: 28px; padding: 0 20px; height: 52px;
  background: #111111; color: #ffffff; box-shadow: 0 10px 24px var(--shadow); border-bottom: 1px solid rgba(255,255,255,0.08); }
.top a { color: inherit; text-decoration: none; }
.brand { display: inline-flex; align-items: center; justify-content: center; min-width: 160px; }
.brand-logo { display: block; height: 26px; width: auto; max-width: 180px; object-fit: contain; filter: brightness(0) invert(1); }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { padding: 6px 12px; border-radius: var(--radius); opacity: .9; color: #ffffff; }
.top nav a:hover { opacity: 1; background: rgba(255,255,255,0.04); }
.top nav a[aria-current] { opacity: 1; background: rgba(255,255,255,.08); }
.top-actions { display: flex; align-items: center; gap: 12px; }
.who { display: flex; gap: 12px; align-items: center; font-size: 14px; }
.top .link { color: inherit; opacity: .8; }
.theme-shell { position: fixed; top: 18px; right: 20px; z-index: 50; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 7px 12px; border: 1px solid rgba(255,255,255,.2); border-radius: 999px; background: #111111; color: #ffffff; font-weight: 700; cursor: pointer; box-shadow: 0 10px 24px var(--shadow); }
html[data-theme="light"] .theme-toggle { background: #ffffff; color: #111111; border-color: rgba(17,17,17,.12); }
.theme-toggle:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar { margin: 0 0 10px; }

input, select, button { font: inherit; color: inherit; }
input:not([type=checkbox]), select { padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); min-width: 0; }
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn { padding: 7px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.link { background: none; border: 0; padding: 2px 4px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link.danger { color: var(--bad); }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.err { color: var(--bad); margin: 0 0 6px; font-size: 13px; }
.ok { color: var(--paid); background: var(--paid-bg); padding: 8px 12px; border-radius: var(--radius); }
p.err.top, .head + .err { margin-bottom: 12px; }

/* summary strip */
.stats { display: flex; flex-wrap: wrap; margin: 0 0 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.stats > div { flex: 1 1 140px; padding: 12px 16px; border-right: 1px solid var(--line); }
.stats > div:last-child { border-right: 0; }
.stats dt { font-size: 12.5px; color: var(--muted); }
.stats dd { margin: 2px 0 0; font-size: 19px; font-weight: 600; }
.good { color: var(--paid); } .warn { color: var(--due); }

/* jobs table */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th.r { text-align: right; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
td.stage { min-width: 150px; }
td.stage .amt { display: block; font-weight: 600; }
td.actions { white-space: nowrap; }
tr.editing td { background: color-mix(in srgb, var(--accent) 7%, var(--surface)); }
tr.editing input:not([type=checkbox]) { width: 100%; min-width: 96px; }
tr.editing td.stage input[type=date] { margin-top: 4px; }
tr.empty td { color: var(--muted); text-align: center; padding: 28px; }
tbody tr.empty:not(:only-child) { display: none; }
table.plain td, table.plain th { padding: 8px 10px; }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; }
.pill.paid { background: var(--paid-bg); color: var(--paid); }
.pill.due { background: var(--due-bg); color: var(--due); font-weight: 600; }
.pill.pending { background: var(--pend-bg); color: var(--pend); }
.htmx-request { opacity: .6; }

/* dashboard */
.hero { display: flex; flex-wrap: wrap; gap: 24px 48px; justify-content: space-between; align-items: flex-end; }
.hero p { margin: 0; }
.label { font-size: 14px; color: var(--muted); }
.big { font-size: clamp(40px, 7vw, 64px); font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; color: var(--accent); }
.side { display: flex; gap: 32px; margin: 0; }
.side dt { font-size: 13px; color: var(--muted); }
.side dd { margin: 2px 0 0; font-size: 24px; font-weight: 600; }
.chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; height: 220px; align-items: end; padding-top: 8px; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar .col { width: 100%; max-width: 44px; background: var(--accent); border-radius: 4px 4px 0 0; }
.bar .v { font-size: 11px; color: var(--muted); margin-bottom: 4px; white-space: nowrap; }
.bar .m { font-size: 12px; margin-top: 6px; color: var(--muted); }
@media (max-width: 720px) { .bar .v { display: none; } }

/* login / admin */
.login { max-width: 360px; margin: 12vh auto 0; display: grid; gap: 12px; }
.login label { display: grid; gap: 4px; font-size: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.paid-dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 20px; max-width: 360px; box-shadow: 0 8px 28px var(--shadow); }
.paid-dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.paid-dialog h3 { margin: 0 0 4px; }
.paid-dialog label { display: block; margin: 12px 0; }
.paid-dialog .dialog-actions { display: flex; gap: 8px; }
