/* 246 HQ. Brand: Space Ink, Signal Orange, Moon White. */
:root {
  --ink: #0b0d17;
  --ink-2: #12152a;
  --ink-3: #1a1e36;
  --line: rgba(246, 245, 240, 0.09);
  --line-2: rgba(246, 245, 240, 0.16);
  --text: #f6f5f0;
  --muted: rgba(246, 245, 240, 0.62);
  --faint: rgba(246, 245, 240, 0.4);
  --orange: #f24a0c;
  --orange-soft: rgba(242, 74, 12, 0.14);
  --green: #3ecf8e;
  --amber: #f0b44c;
  --blue: #8ea2ff;
  --red: #ff6b5b;
  --radius: 12px;
  --head: 'Space Grotesk', system-ui, sans-serif;
  --body: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--ink);
  background-image: radial-gradient(rgba(246, 245, 240, 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text);
  font: 15px/1.5 var(--body);
  min-height: 100vh;
}
a { color: inherit; }
h1, h2, h3 { font-family: var(--head); letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 28px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px; }

/* Top bar */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 24px;
  padding: 12px max(16px, calc((100vw - 1200px) / 2));
  background: rgba(11, 13, 23, 0.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-family: var(--head); font-size: 17px; }
.brand svg { color: var(--orange); }
.brand b { color: var(--orange); font-weight: 600; }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); white-space: nowrap; }
.nav a:hover { color: var(--text); }
.nav a[aria-current='page'] { background: var(--ink-3); color: var(--text); }
.who { margin-left: auto; font: 12px var(--mono); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; white-space: nowrap; }

main { max-width: 1200px; margin: 0 auto; padding: 28px 16px 80px; outline: none; }

/* Layout bits */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.label { font: 11px var(--mono); text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stack { display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.two { display: grid; gap: 24px; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .two { grid-template-columns: 1fr; } }
section { margin-top: 32px; }
.page-head + section { margin-top: 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }

.card {
  background: var(--ink-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
a.card { display: block; text-decoration: none; transition: border-color 0.15s, transform 0.15s; }
a.card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.card h3 { margin-bottom: 6px; }
.card .next { color: var(--muted); margin: 6px 0 10px; font-size: 14px; }
.card.late { border-color: rgba(255, 107, 91, 0.45); }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 999px;
  font: 11px var(--mono); text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--ink-3); color: var(--muted); white-space: nowrap;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.active, .chip.part_paid { color: var(--orange); background: var(--orange-soft); }
.chip.waiting, .chip.unpaid { color: var(--amber); background: rgba(240, 180, 76, 0.12); }
.chip.planned, .chip.draft { color: var(--blue); background: rgba(142, 162, 255, 0.12); }
.chip.done, .chip.paid { color: var(--green); background: rgba(62, 207, 142, 0.12); }
.chip.late { color: var(--red); background: rgba(255, 107, 91, 0.12); }
.chip.side::before { display: none; }

/* Stat tiles */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat .value { font: 600 24px var(--head); margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .value.neg { color: var(--red); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink-2); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font: 11px var(--mono); text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); font-weight: 400; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr.link { cursor: pointer; }
tbody tr.link:hover td { background: rgba(246, 245, 240, 0.03); }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* Forms */
label.field { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 10px;
  min-height: 38px;
}
textarea { min-height: 120px; resize: vertical; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
input:focus, select:focus, textarea:focus { border-color: var(--orange); outline: none; }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.form-grid .wide { grid-column: 1 / -1; }
.error { color: var(--red); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; min-height: 38px;
  border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--ink-3); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--faint); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #ff5a1f; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Checklist */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist input[type='checkbox'] { width: 18px; height: 18px; min-height: 0; accent-color: var(--orange); }
.checklist .done span { text-decoration: line-through; color: var(--faint); }
.checklist span { flex: 1; }

/* Banners and toast */
.banner { padding: 12px 14px; border-radius: 10px; border: 1px solid; margin-bottom: 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.warn { border-color: rgba(240, 180, 76, 0.4); background: rgba(240, 180, 76, 0.08); }
.banner.bad { border-color: rgba(255, 107, 91, 0.4); background: rgba(255, 107, 91, 0.08); }
#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--ink); padding: 10px 16px; border-radius: 999px;
  font-weight: 500; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Markdown */
.md { line-height: 1.7; }
.md h1 { font-size: 26px; margin: 0 0 16px; }
.md h2 { font-size: 20px; margin: 28px 0 10px; }
.md h3 { margin: 20px 0 8px; }
.md p, .md ul, .md ol { margin: 0 0 12px; }
.md a { color: var(--orange); }
.md code { font-family: var(--mono); font-size: 13px; background: var(--ink-3); padding: 1px 5px; border-radius: 4px; }
.md pre { background: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 12px; overflow-x: auto; }
.md pre code { background: none; padding: 0; }
.md table { margin-bottom: 12px; border: 1px solid var(--line); }
.md blockquote { margin: 0 0 12px; padding-left: 12px; border-left: 3px solid var(--orange); color: var(--muted); }

/* Guide */
.guide { display: grid; gap: 24px; grid-template-columns: 240px minmax(0, 1fr); }
@media (max-width: 760px) { .guide { grid-template-columns: 1fr; } }
.guide nav { display: grid; gap: 16px; align-content: start; }
.guide nav a { display: block; padding: 5px 10px; border-radius: 6px; text-decoration: none; color: var(--muted); font-size: 14px; }
.guide nav a:hover { color: var(--text); }
.guide nav a[aria-current='page'] { background: var(--ink-3); color: var(--text); }
.editor { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.editor textarea { min-height: 60vh; }
@media (max-width: 900px) { .editor { grid-template-columns: 1fr; } .editor textarea { min-height: 40vh; } }

/* Invoice items editor */
.items td input { min-height: 34px; padding: 6px 8px; }
.items td:first-child { min-width: 200px; }
.items td.qty { width: 80px; }
.items td.price { width: 160px; }

#print-root { display: none; }

@media (max-width: 600px) {
  .top { gap: 12px; flex-wrap: wrap; }
  .who { order: 2; }
  .nav { order: 3; width: 100%; }
  h1 { font-size: 24px; }
}
