:root {
  --bg: #e7e1d6;
  --paper: #fbf8f3;
  --ink: #221e19;
  --muted: #6f675e;
  --line: #e2d8cb;
  --accent: #1f4d45;
  --accent-ink: #f7f4ee;
  --good: #1e6b45;
  --good-bg: #e5f3ea;
  --bad: #8d2e2e;
  --bad-bg: #fdeceb;
  --sidebar: #221e19;
  --sidebar-text: #f3eee6;
  --shadow: 0 12px 30px rgba(34, 30, 25, 0.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
}
a { color: var(--accent); }
h1, h2, h3, h4, .mark, .company-name { font-family: var(--serif); font-weight: 600; }
h1 { font-size: 2.1rem; margin: 0; letter-spacing: -0.03em; }
h2 { margin: 0 0 12px; font-size: 1.4rem; }
h3 { margin: 18px 0 8px; font-size: 1.05rem; }
h4 { margin: 14px 0 6px; font-size: 0.95rem; }
p { margin: 0 0 10px; }
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
aside {
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 28px 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.mark { margin: 0; letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.78rem; color: #c8b8a2; }
.company-name { margin: 6px 0 0; font-size: 1.45rem; line-height: 1.15; }
.muted, aside .muted { color: var(--muted); }
aside .muted { color: #b7aa9b; font-size: 0.9rem; }
nav { display: flex; flex-direction: column; gap: 4px; }
nav a {
  color: var(--sidebar-text);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 10px;
}
nav a.active, nav a:hover { background: rgba(255, 255, 255, 0.08); }
main { padding: 32px 40px 64px; max-width: 1180px; }
.page-head, .row-head, .actions, .line-tools, .inline-form, .filters {
  display: flex;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
}
.page-head { margin-bottom: 18px; align-items: start; }
.lede { color: var(--muted); margin-top: 6px; }
.kicker { margin: 0 0 4px; color: var(--muted); letter-spacing: 0.04em; text-transform: uppercase; font-size: 0.78rem; }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px;
  margin: 0 0 16px;
  box-shadow: var(--shadow);
}
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stats article {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.stats p, .stats span { color: var(--muted); font-size: 0.9rem; }
.stats strong { display: block; font-size: 1.45rem; font-variant-numeric: tabular-nums; margin: 4px 0; }
.button, button.button {
  background: var(--accent);
  color: var(--accent-ink);
  border: 0;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}
.button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.button.danger { background: transparent; color: var(--bad); border: 1px solid #e4c4c4; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }
.side-action { justify-content: center; margin-top: auto; }
aside .button { color: var(--sidebar-text); border-color: rgba(255,255,255,0.25); background: transparent; }
aside .button:hover { background: rgba(255,255,255,0.08); }
label { display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 10px;
  padding: 9px 11px;
  font: inherit;
  color: inherit;
}
textarea { resize: vertical; }
.year-form select, aside input { background: #2c2823; color: var(--sidebar-text); border-color: #3d3832; }
.banner { padding: 12px 14px; border-radius: 12px; margin: 0 0 16px; }
.banner.ok { background: var(--good-bg); color: #145233; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.badge { display: inline-block; border-radius: 999px; padding: 2px 8px; background: #efe2d2; font-size: 0.8rem; }
.badge.open { background: var(--good-bg); color: var(--good); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; text-align: left; }
th { font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); font-weight: 650; }
.num, .num-input { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.group th { background: #f3eee6; text-transform: none; letter-spacing: 0; font-size: 0.95rem; color: var(--ink); }
tr.total td { font-weight: 700; border-top: 2px solid var(--ink); }
tr.inactive { color: var(--muted); }
.filters, .inline-form, .form-grid, .form-stack { margin-bottom: 16px; }
.filters label, .inline-form label { min-width: 140px; }
.grow { flex: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.span-2 { grid-column: span 2; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.table-wrap { overflow-x: auto; }
.lines input, .lines select { min-width: 0; }
.icon-button {
  border: 0;
  background: transparent;
  font-size: 1.3rem;
  cursor: pointer;
  color: var(--muted);
}
.balance { font-variant-numeric: tabular-nums; margin: 0; }
.balance.ok { color: var(--good); }
.balance.bad { color: var(--bad); }
.vat-preview { margin: 8px 0 12px; padding-left: 18px; color: var(--muted); }
.file-field, .file-add { margin: 12px 0; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.sumline { display: flex; justify-content: space-between; gap: 12px; font-size: 1.05rem; margin-top: 12px; }
.neg { color: var(--bad); }
.steps { margin: 0; padding-left: 18px; }
.steps li { margin: 6px 0; }
.files { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 16px; }
.files img, .files iframe { display: block; width: 100%; max-height: 520px; margin-top: 8px; border: 1px solid var(--line); border-radius: 12px; background: white; }
.files li form { display: inline; }
.secret {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 14px;
  border-radius: 12px;
  overflow-wrap: anywhere;
}
pre {
  white-space: pre-wrap;
  background: #f3eee6;
  padding: 12px;
  border-radius: 12px;
  overflow-x: auto;
}
.endpoint-list { columns: 2; padding-left: 18px; }
.check { flex-direction: row; align-items: center; margin: 8px 0; }
.check input { width: auto; }
footer { color: var(--muted); font-size: 0.85rem; margin-top: 28px; }
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate .card { width: min(440px, 100%); margin: 0; }
.logout-form { margin: 0; }
.text-button { background: none; border: 0; color: #c8b8a2; font: inherit; cursor: pointer; padding: 8px 10px; text-align: left; }
.text-button:hover { color: white; }
.qr svg { display: block; max-width: 220px; height: auto; background: white; border-radius: 12px; margin: 8px 0; }
.codes { columns: 2; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; padding-left: 18px; }
.codes li { margin: 4px 0; break-inside: avoid; }
.actions form { margin: 0; }
td.actions, .actions { display: flex; gap: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (max-width: 980px) {
  .split, .two, .stats { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  aside { position: sticky; height: auto; z-index: 5; min-width: 0; }
  nav { flex-direction: row; overflow-x: auto; min-width: 0; }
  nav a { white-space: nowrap; }
  .side-action { margin-top: 0; }
  main { min-width: 0; overflow-x: auto; padding: 20px 16px 48px; }
  .stats, .form-grid, .two, .endpoint-list { grid-template-columns: 1fr; columns: 1; }
}
@media print {
  aside, .no-print, footer, .button, form { display: none !important; }
  .shell { display: block; }
  main { max-width: none; padding: 0; }
  body, .card { background: white; box-shadow: none; }
}
