:root {
  --ink: #1c2420;
  --forest: #17332c;
  --forest-2: #21493f;
  --paper: #f3efe6;
  --card: #fbf8f2;
  --line: #e3dacb;
  --brass: #8d6232;
  --terra: #b5523a;
  --teal: #1f6f5b;
  --ok: #1d6b45;
  --danger: #8d2f2f;
  --warn: #8a5a12;
  --muted: #5f675f;
  --shadow: 0 12px 30px rgba(28, 36, 32, 0.06);
  --font: "Outfit", "Segoe UI", sans-serif;
  --serif: "Newsreader", Georgia, serif;
  --mono: "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }

.nav-toggle { position: absolute; opacity: 0; pointer-events: none; }
.shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--forest);
  color: #f4efe4;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand { display: flex; gap: 12px; align-items: center; }
.mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: #c9864a; color: #1c2420;
  display: grid; place-items: center; font-family: var(--serif); font-weight: 650;
}
.brand strong { display: block; font-family: var(--serif); font-size: 1.25rem; font-weight: 560; letter-spacing: -0.02em; }
.brand span { color: #c9d5cf; font-size: 0.78rem; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a {
  color: #e7efe9; text-decoration: none; padding: 8px 10px; border-radius: 8px;
  font-size: 0.95rem;
}
.nav a:hover, .nav a.active { background: rgba(255,255,255,0.08); }
.sidebar footer { margin-top: auto; font-size: 0.85rem; color: #d5e0da; }
.sidebar footer form { margin-top: 8px; }
.sidebar .btn {
  color: #f4efe4;
  background: transparent;
  border-color: rgba(244, 239, 228, 0.45);
}
.who { font-weight: 600; }
.role { color: #c9d5cf; }

.burger {
  display: none; margin: 12px 16px 0;
  background: var(--forest); color: white; border: 0; border-radius: 8px; padding: 8px 12px;
}
.content { padding: 32px 36px 64px; max-width: 1180px; min-width: 0; }
.page-head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-end; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-family: var(--serif); font-weight: 560; font-size: 2.1rem; margin: 0; letter-spacing: -0.03em; }
.lede { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat, .card {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  min-width: 0; max-width: 100%;
}
.stat { padding: 16px 16px 14px; }
.stat span { display: block; color: var(--muted); font-size: 0.82rem; }
.stat strong { display: block; margin-top: 6px; font-family: var(--mono); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.card { padding: 18px; margin-bottom: 16px; }
.card h2 { margin: 0 0 12px; font-size: 1.05rem; }

.table-wrap { overflow-x: auto; max-width: 100%; }
table { width: 100%; border-collapse: collapse; font-size: 0.94rem; }
th { text-align: left; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--line); }
td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.money, .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
th.money { text-align: right; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.75rem; background: #efe6d6; color: var(--ink); }
.badge-draft { background: #efe6d6; }
.badge-review { background: #f3ddb0; color: #6d4b10; }
.badge-approved { background: #d7eee4; color: #13553a; }
.badge-locked { background: #1c332c; color: #f4efe4; }
.badge-pending { background: #f3ddb0; }
.badge-active { background: #d7eee4; color: #13553a; }
.badge-paid_off { background: #e7e4dc; }
.badge-cancelled, .badge-failed { background: #f4d6d0; color: var(--danger); }
.badge-planned { background: #efe6d6; color: var(--muted); }
.badge-ready { background: #d7eee4; color: #13553a; }

.btn, button.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 999px; border: 1px solid transparent; padding: 8px 14px; cursor: pointer;
  text-decoration: none; background: transparent; color: var(--ink);
}
.btn-primary { background: var(--forest); color: #f7f3ea; }
.btn-primary:hover { background: var(--forest-2); text-decoration: none; }
.btn-ghost { border-color: var(--line); background: white; }
.btn-danger { background: var(--terra); color: white; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inline { display: inline; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; }
.field-check { flex-direction: row; align-items: center; }
.field span { color: var(--muted); }
.control, input.control, select.control, textarea.control {
  width: 100%; border: 1px solid #d9d0c2; background: white; border-radius: 10px; padding: 9px 10px; color: var(--ink);
}
.errorlist { color: var(--danger); margin: 0; padding-left: 16px; font-size: 0.82rem; }
.alert { background: #f8e7df; border: 1px solid #efc7b8; color: #6d2c22; padding: 10px 12px; border-radius: 10px; margin-bottom: 12px; }
.alert-ok { background: #e5f4ec; border-color: #b7dfc8; color: #145338; }
.alert-warn { background: #f8efd8; border-color: #ead29a; color: #6d4b10; }
.empty { padding: 28px 8px; color: var(--muted); }

.messages { display: grid; gap: 8px; margin-bottom: 12px; }
.filters { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters input, .filters select { border: 1px solid #d9d0c2; border-radius: 10px; padding: 8px 10px; background: white; }

.slip { display: grid; grid-template-columns: 1.4fr 0.8fr; gap: 16px; }
.thp {
  background: var(--forest); color: #f7f3ea; border-radius: 14px; padding: 18px;
}
.thp span { color: #c9d5cf; }
.thp strong { display: block; font-family: var(--mono); font-size: 1.8rem; margin-top: 6px; }
.muted { color: var(--muted); }
.modules { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.module { padding: 16px; }
.login-wrap {
  min-height: 100vh; display: grid; grid-template-columns: 1.1fr 0.9fr;
}
.login-hero { background: var(--forest); color: #f4efe4; padding: 64px; display: flex; flex-direction: column; justify-content: flex-end; }
.login-hero h1 { font-family: var(--serif); font-weight: 560; font-size: 3.2rem; margin: 0 0 8px; }
.login-panel { display: grid; place-items: center; padding: 32px; }
.login-card { width: min(420px, 100%); }

.pager { display: flex; gap: 12px; margin-top: 12px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline; }

@media (max-width: 960px) {
  .burger { display: inline-block; }
  .shell { grid-template-columns: minmax(0, 1fr); }
  .content { overflow-x: hidden; }
  .sidebar { display: none; }
  .nav-toggle:checked ~ .shell .sidebar { display: flex; }
  .stats, .form-grid, .slip, .modules, .login-wrap { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 48px; }
  .login-hero { padding: 32px 20px; min-height: 220px; }
  .login-hero h1 { font-size: 2.2rem; }
}
@media print {
  .sidebar, .burger, .actions, .nav-toggle { display: none !important; }
  .shell { display: block; }
  .content { max-width: none; }
  body { background: white; }
}
