/* Quartiermeister — Feldbuch
   A quartermaster's ledger: stencil type, rubber stamps, ruled lines, brass.
   Dark "Zeltlicht" by default, kraft paper when the OS asks for light. */

@font-face { font-family: "QM Stencil"; src: url("/fonts/stencil-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "QM Stencil"; src: url("/fonts/stencil-900.woff2") format("woff2"); font-weight: 900; font-display: swap; }
@font-face { font-family: "QM Body"; src: url("/fonts/barlow-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "QM Body"; src: url("/fonts/barlow-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "QM Body"; src: url("/fonts/barlow-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "QM Label"; src: url("/fonts/barlow-condensed-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "QM Label"; src: url("/fonts/barlow-condensed-600.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "QM Label"; src: url("/fonts/barlow-condensed-700.woff2") format("woff2"); font-weight: 700; font-display: swap; }
@font-face { font-family: "QM Mono"; src: url("/fonts/plex-mono-400.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "QM Mono"; src: url("/fonts/plex-mono-500.woff2") format("woff2"); font-weight: 500; font-display: swap; }

:root {
  color-scheme: dark;
  --bg: #0d100b;
  --bg-grid: rgba(212, 175, 55, 0.04);
  --band: #1a1f11;
  --band-ink: #ebe5d0;
  --sheet: #13170f;
  --panel: #181d13;
  --field: #0e120b;
  --rule: #283020;
  --rule-strong: #3a4430;
  --ink: #ebe5d0;
  --ink-2: #b1ab93;
  --ink-3: #7c7966;
  --brass: #d4af37;
  --brass-ink: #1b1505;
  --brass-soft: rgba(212, 175, 55, 0.13);
  --olive: #8d9c4c;
  --red: #e25b48;
  --green: #95b95c;
  --amber: #e3a33c;
  --focus: #f2d266;
  --steel-1: #d9dcd6;
  --steel-2: #9ea39a;
  --steel-ink: #20231c;
  --shadow: 0 1px 0 rgba(0, 0, 0, 0.35), 0 12px 32px -18px rgba(0, 0, 0, 0.7);

  --font-display: "QM Stencil", "Big Shoulders Stencil Display", Impact, sans-serif;
  --font-label: "QM Label", "Barlow Condensed", "Arial Narrow", sans-serif;
  --font-body: "QM Body", Barlow, system-ui, sans-serif;
  --font-mono: "QM Mono", "IBM Plex Mono", ui-monospace, monospace;
}

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #d6ccb1;
    --bg-grid: rgba(60, 48, 16, 0.07);
    --band: #39411f;
    --band-ink: #efe8d4;
    --sheet: #f3ecd9;
    --panel: #ebe2c9;
    --field: #fbf8ee;
    --rule: #d8cca9;
    --rule-strong: #b5a67d;
    --ink: #1e1f15;
    --ink-2: #53513e;
    --ink-3: #7f7a60;
    --brass: #8c6a0c;
    --brass-ink: #fff7df;
    --brass-soft: rgba(140, 106, 12, 0.12);
    --olive: #55611f;
    --red: #a8311e;
    --green: #3b6a21;
    --amber: #9f620b;
    --focus: #8c6a0c;
    --steel-1: #f4f5f1;
    --steel-2: #b7bbb1;
    --shadow: 0 1px 0 rgba(80, 60, 20, 0.12), 0 14px 30px -20px rgba(60, 45, 10, 0.45);
  }
}

/* ---------------------------------------------------------------- base -- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 56px 56px;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
}

a { color: inherit; }
img { display: block; }
code { font-family: var(--font-mono); font-size: 0.9em; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { white-space: nowrap; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.js .js-hide { display: none; }
.is-good { color: var(--green); }
.is-bad { color: var(--red); }

/* -------------------------------------------------------------- topbar -- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 28px;
  background: var(--band);
  color: var(--band-ink);
  border-bottom: 1px solid var(--brass);
}

.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; min-width: 0; }
.brand .crate { width: 34px; height: 34px; color: var(--brass); flex: none; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-word {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 26px;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.brand-sub {
  font-family: var(--font-label);
  font-size: 13px;
  letter-spacing: 0.06em;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 18px; }

.bot-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}
.bot-state-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); }
.bot-state.is-online .bot-state-dot { background: #9bd06a; box-shadow: 0 0 0 3px rgba(155, 208, 106, 0.18); }
.bot-state.is-offline .bot-state-dot { background: var(--red); }

.logout { margin: 0; }
.link-button {
  background: none;
  border: 0;
  padding: 4px 0;
  color: inherit;
  font: 600 13px/1 var(--font-label);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0.75;
}
.link-button:hover { opacity: 1; text-decoration: underline; }

/* Dog tag: steel, rounded, with a punched hole. */
.dogtag {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px 6px 26px;
  border-radius: 18px 10px 10px 18px;
  background:
    radial-gradient(circle at 12px 50%, var(--band) 0 5px, transparent 5.5px),
    linear-gradient(160deg, var(--steel-1), var(--steel-2) 70%, var(--steel-1));
  color: var(--steel-ink);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25), 0 1px 0 rgba(255, 255, 255, 0.08);
  min-width: 0;
}
.dogtag-avatar { width: 30px; height: 30px; border-radius: 50%; filter: grayscale(0.35) contrast(1.05); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.3); }
.dogtag-lines { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.dogtag-name {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
}
.dogtag-role, .dogtag-id { font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; opacity: 0.75; }

/* ---------------------------------------------------------------- tabs -- */

.tabs {
  display: flex;
  gap: 4px;
  max-width: 1240px;
  margin: 26px auto 0;
  padding: 0 28px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 10px 18px 9px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 3px 3px 0 0;
  color: var(--ink-2);
  text-decoration: none;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tab-no { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0; color: var(--ink-3); }
.tab:hover { color: var(--ink); background: var(--brass-soft); }
.tab.is-active {
  color: var(--ink);
  background: var(--sheet);
  border-color: var(--rule-strong);
  position: relative;
  top: 1px;
}
.tab.is-active .tab-no { color: var(--brass); }

/* --------------------------------------------------------------- sheet -- */

.sheet {
  position: relative;
  max-width: 1240px;
  margin: 0 auto;
  padding: 34px 40px 48px;
  background: var(--sheet);
  border: 1px solid var(--rule-strong);
  box-shadow: var(--shadow);
}
/* Registration marks in the corners, like a printed form. */
.sheet::before, .sheet::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-color: var(--brass);
  border-style: solid;
  opacity: 0.7;
}
.sheet::before { top: 10px; right: 10px; border-width: 1px 1px 0 0; }
.sheet::after { bottom: 10px; left: 10px; border-width: 0 0 1px 1px; }

.sheet-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  margin-bottom: 28px;
  border-bottom: 3px double var(--rule-strong);
}
.sheet-head-main { min-width: 0; }
.sheet-code {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
}
.sheet-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(38px, 5.2vw, 62px);
  line-height: 0.95;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.lede { margin: 10px 0 0; max-width: 62ch; color: var(--ink-2); }
.sheet-head-aside { flex: none; display: flex; align-items: center; gap: 12px; }

.colophon {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 14px 28px 40px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --------------------------------------------------------------- flash -- */

.flash {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 24px;
  padding: 12px 14px;
  border: 1px solid var(--rule-strong);
  border-left-width: 4px;
  background: var(--panel);
}
.flash--ok { border-left-color: var(--green); }
.flash--error { border-left-color: var(--red); }
.flash-tag {
  flex: none;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding-top: 2px;
}
.flash--ok .flash-tag { color: var(--green); }
.flash--error .flash-tag { color: var(--red); }

/* --------------------------------------------------------------- block -- */

.block { margin-top: 38px; }
.block:first-child { margin-top: 0; }
.block-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.block-code {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: none;
  border: 1.5px solid var(--brass);
  color: var(--brass);
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 17px;
}
.block-head h2 {
  margin: 0;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
}
.block-head::after { content: ""; flex: 1; height: 1px; background: var(--rule-strong); order: 2; }
.block-aside { order: 3; font-size: 14px; white-space: nowrap; }

.columns { display: grid; grid-template-columns: 1.35fr 1fr; gap: 38px 40px; margin-top: 38px; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 38px 40px; align-items: start; }
.split > .block, .columns > .block { margin-top: 0; }
.columns + .block, .split + .block { margin-top: 38px; }

/* ---------------------------------------------------------------- hero -- */

.hero { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; }

.panel {
  position: relative;
  padding: 24px 26px;
  background: var(--panel);
  border: 1px solid var(--rule-strong);
}
.eyebrow {
  margin: 0 0 12px;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.hero-figure { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 16px; }
.hero-number {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(76px, 10vw, 128px);
  line-height: 0.8;
  color: var(--brass);
}
.hero-unit { font-family: var(--font-display); font-weight: 700; font-size: 44px; color: var(--brass); margin-left: -8px; }
.hero-caption {
  flex-basis: 100%;
  margin-top: 8px;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.04em;
}

.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0 0; }
.figures div { border-top: 1px solid var(--rule-strong); padding-top: 8px; }
.figures dt, .tally dt, .strip dt, .facts dt {
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.figures dd { margin: 2px 0 0; font-size: 20px; }

.balance { margin: 0; font-family: var(--font-display); font-weight: 900; font-size: 56px; line-height: 1; }
.balance .num { font-family: var(--font-display); }
.balance-note { margin: 8px 0 18px; color: var(--ink-2); font-size: 14px; }
.tally { margin: 0; }
.tally div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px dashed var(--rule-strong); }
.tally dd { margin: 0; }

/* Segmented gauge, slanted like a magazine counter. */
.gauge { display: flex; gap: 4px; }
.gauge-seg {
  flex: 1;
  height: 22px;
  transform: skewX(-14deg);
  border: 1px solid var(--rule-strong);
  background: transparent;
}
.gauge-seg.is-full { background: var(--brass); border-color: var(--brass); }
.gauge-seg.is-part {
  border-color: var(--brass);
  background: repeating-linear-gradient(135deg, var(--brass) 0 3px, transparent 3px 6px);
}
.gauge--sm { gap: 3px; margin: -6px 0 6px; }
.gauge--sm .gauge-seg { height: 8px; }

/* -------------------------------------------------------------- stamps -- */

.stamp {
  display: inline-block;
  padding: 3px 9px 2px;
  border: 3px double currentColor;
  border-radius: 3px;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: rotate(-3deg);
  opacity: 0.92;
}
.stamp--funded, .stamp--sent, .stamp--on { color: var(--green); }
.stamp--partial, .stamp--waiting { color: var(--amber); }
.stamp--pending { color: var(--red); }
.stamp--unknown, .stamp--off { color: var(--ink-3); }
.sheet-head-aside .stamp { font-size: 17px; padding: 5px 14px 4px; transform: rotate(-5deg); }

/* -------------------------------------------------------------- ledger -- */

.ledger { list-style: none; margin: 0; padding: 0; }
.ledger-row {
  display: grid;
  grid-template-columns: auto 1fr auto 104px;
  align-items: end;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule);
}
.ledger-title { font-weight: 600; min-width: 0; }
.ledger-title small { display: block; font-weight: 400; font-size: 13px; color: var(--ink-3); }
.ledger-leader { border-bottom: 2px dotted var(--rule-strong); margin-bottom: 6px; min-width: 16px; }
.ledger-amount { font-size: 16px; }
.ledger-stamp { text-align: right; }

.receipts { list-style: none; margin: 0; padding: 0; }
.receipt {
  display: grid;
  grid-template-columns: 94px 1fr auto;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--rule-strong);
}
.receipt-date { font-family: var(--font-mono); font-size: 12px; color: var(--ink-3); padding-top: 2px; }
.receipt-who { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.receipt-who small, .receipt-amount small { display: block; font-weight: 400; font-size: 12.5px; color: var(--ink-3); }
.receipt-amount { text-align: right; }

.status-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 40px; }
.status-row {
  display: grid;
  grid-template-columns: 12px 190px 1fr;
  align-items: baseline;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--rule);
}
.status-lamp { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-3); align-self: center; }
.status-row--ok .status-lamp { background: var(--green); }
.status-row--warn .status-lamp { background: var(--amber); }
.status-label { font-family: var(--font-label); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; font-size: 14px; color: var(--ink-2); }
.status-value { min-width: 0; overflow-wrap: anywhere; }

/* --------------------------------------------------------------- strip -- */

.strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 0 0 18px;
  border: 1px solid var(--rule-strong);
  background: var(--panel);
}
.strip-cell { padding: 14px 16px; border-left: 1px solid var(--rule); }
.strip-cell:first-child { border-left: 0; }
.strip dd { margin: 4px 0 0; font-size: 21px; }
.strip .strip-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }
.strip-cell--result { background: var(--brass-soft); }

.month-nav { display: flex; align-items: center; gap: 6px; }
.month-form { display: flex; gap: 6px; margin: 0; }
.month-step {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--rule-strong);
  text-decoration: none;
  font-size: 22px;
  line-height: 1;
  color: var(--ink-2);
}
.month-step:hover { color: var(--ink); border-color: var(--brass); }

/* -------------------------------------------------------------- tables -- */

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th {
  padding: 8px 10px;
  text-align: left;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  border-bottom: 2px solid var(--rule-strong);
  white-space: nowrap;
}
.table td { padding: 11px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.table th.num, .table td.num { text-align: right; }
.table tbody tr:hover td { background: var(--brass-soft); }
.table tr.is-editing td { background: var(--panel); padding: 18px; }
.table tr.is-editing:hover td { background: var(--panel); }
.col-pos { width: 52px; color: var(--ink-3); }
.col-actions { text-align: right; white-space: nowrap; }
.col-actions form { display: inline; margin-left: 12px; }
.cell-title { font-weight: 600; }
.cell-note { display: block; font-size: 13px; color: var(--ink-3); overflow-wrap: anywhere; }
.tag {
  display: inline-block;
  margin-left: 8px;
  padding: 0 6px;
  border: 1px solid var(--brass);
  color: var(--brass);
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  vertical-align: 2px;
}
.person { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.person img { border-radius: 50%; }

/* --------------------------------------------------------------- forms -- */

.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  background: var(--field);
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  color: var(--ink);
  font: 400 15px/1.4 var(--font-body);
}
.input:focus { outline: 2px solid var(--focus); outline-offset: 1px; border-color: transparent; }
.input.mono, .input.num { font-family: var(--font-mono); font-size: 14px; }
.input::placeholder { color: var(--ink-3); }
select.input { appearance: none; padding-right: 34px; background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%); background-position: right 16px center, right 11px center; background-size: 5px 5px; background-repeat: no-repeat; }
.input--area { min-height: 90px; resize: vertical; line-height: 1.5; }
.input--compact { min-height: 34px; width: auto; padding: 5px 30px 5px 10px; font-size: 14px; }
.input--month { width: 205px; font-family: var(--font-mono); }
.input--file { padding: 6px; font-size: 14px; color: var(--ink-2); }
.input--file::file-selector-button {
  margin-right: 12px;
  padding: 7px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--panel);
  color: var(--ink);
  font: 700 13px/1 var(--font-label);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
}
.input--file::file-selector-button:hover { border-color: var(--brass); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-2);
}
.field-label .stamp { font-size: 11px; padding: 1px 6px 0; border-width: 3px; }
.field-hint { font-size: 13px; color: var(--ink-3); }

.check { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 15px; }
.check input { width: 18px; height: 18px; margin: 0; accent-color: var(--brass); }
.check--field { align-self: end; min-height: 42px; }

.switch { display: inline-flex; align-items: center; gap: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch-track {
  position: relative;
  width: 58px;
  height: 28px;
  border: 1px solid var(--rule-strong);
  background: var(--field);
  flex: none;
}
.switch-track::before {
  content: "Aus";
  position: absolute;
  inset: 3px auto 3px 3px;
  width: 28px;
  display: grid;
  place-items: center;
  background: var(--ink-3);
  color: var(--sheet);
  font: 700 10px/1 var(--font-label);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: transform 0.15s ease, background 0.15s ease;
}
.switch input:checked + .switch-track::before { content: "An"; transform: translateX(24px); background: var(--brass); color: var(--brass-ink); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch-text { font-family: var(--font-label); font-weight: 600; font-size: 16px; letter-spacing: 0.06em; }

.stack { display: flex; flex-direction: column; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; align-items: start; }
.form-grid--expense { grid-template-columns: repeat(4, 1fr); }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; grid-column: 1 / -1; }
.form-note { grid-column: 1 / -1; margin: 12px 0 0; font-size: 13.5px; color: var(--ink-3); }
.inline { display: inline-flex; align-items: center; gap: 8px; margin: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  background: var(--panel);
  color: var(--ink);
  font: 700 14px/1 var(--font-label);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--brass); }
.btn--brass {
  background: var(--brass);
  border-color: var(--brass);
  color: var(--brass-ink);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.22);
}
.btn--brass:hover { filter: brightness(1.08); }
.btn--brass:active { box-shadow: inset 0 2px 0 rgba(0, 0, 0, 0.25); }
.btn--quiet { background: transparent; }
.btn--danger { color: var(--red); }
.btn--lg { min-height: 52px; font-size: 16px; padding: 12px 24px; }
.btn--block { width: 100%; }

.text-link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--brass);
  font: 600 14px/1.4 var(--font-body);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: pointer;
}
.text-link:hover { text-decoration-thickness: 2px; }
.text-link--danger { color: var(--red); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -8px; }
.chip {
  padding: 3px 8px;
  border: 1px dashed var(--rule-strong);
  background: transparent;
  color: var(--ink-2);
  font: 400 12.5px/1.4 var(--font-mono);
  cursor: pointer;
}
.chip:hover { border-style: solid; border-color: var(--brass); color: var(--ink); }

.drawer { margin-top: 18px; border: 1px dashed var(--rule-strong); }
.drawer[open] { border-style: solid; background: var(--panel); }
.drawer-summary {
  padding: 12px 16px;
  cursor: pointer;
  font-family: var(--font-label);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brass);
  list-style: none;
}
.drawer-summary::-webkit-details-marker { display: none; }
.drawer-summary::before { content: "+"; display: inline-block; width: 18px; font-family: var(--font-mono); }
.drawer[open] .drawer-summary::before { content: "–"; }
.drawer > form { padding: 4px 16px 18px; }

.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.tool { display: flex; flex-direction: column; gap: 12px; padding: 20px; border: 1px solid var(--rule-strong); background: var(--panel); margin: 0; }
.tool h3 { margin: 0; font-family: var(--font-label); font-weight: 700; font-size: 17px; letter-spacing: 0.1em; text-transform: uppercase; }
.tool p { margin: 0; font-size: 14px; color: var(--ink-2); }
.tool .btn { align-self: flex-start; }
.tool-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.empty-note { margin: 0; padding: 18px; border: 1px dashed var(--rule-strong); color: var(--ink-3); font-style: italic; }
.preview-note { margin: 10px 0 0; font-size: 13.5px; color: var(--ink-3); }

.facts { display: grid; gap: 0; margin: 18px 0 0; }
.facts div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-top: 1px solid var(--rule); }
.facts dd { margin: 0; text-align: right; }

.legend { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px 20px; margin: 24px 0 0; padding: 14px 16px; border: 1px dashed var(--rule-strong); }
.legend div { display: flex; gap: 8px; align-items: baseline; }
.legend dt code { color: var(--brass); }
.legend dd { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.legend--roles { grid-template-columns: repeat(3, 1fr); }
.legend--roles div { flex-direction: column; gap: 2px; }
.legend--roles dt { font-family: var(--font-label); font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; font-size: 14px; }

.steps { margin: 0; padding-left: 22px; }
.steps li { margin-bottom: 14px; padding-left: 4px; }
.steps li::marker { font-family: var(--font-display); font-weight: 900; color: var(--brass); }
.steps p { margin: 0 0 8px; }

.copy-box { display: flex; align-items: stretch; gap: 0; border: 1px solid var(--rule-strong); background: var(--field); }
.copy-box code { flex: 1; padding: 10px 12px; overflow-wrap: anywhere; font-size: 13.5px; }
.copy-box .btn { border-width: 0 0 0 1px; min-height: auto; }

.tag-row { display: flex; flex-wrap: wrap; gap: 14px; }
.tag-row .dogtag { background:
    radial-gradient(circle at 12px 50%, var(--sheet) 0 5px, transparent 5.5px),
    linear-gradient(160deg, var(--steel-1), var(--steel-2) 70%, var(--steel-1)); }

.plain-list { margin: 0; padding-left: 18px; }

/* ----------------------------------------------------------- role cards -- */

.role-list { display: flex; flex-direction: column; gap: 18px; }
.role-card { border: 1px solid var(--rule-strong); background: var(--panel); }
.role-card > form { margin: 0; padding: 0 20px 18px; }
.role-card-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 -20px 16px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--rule-strong);
  font-size: 16px;
}
article.role-card > .role-card-head { margin: 0; }
.role-card-head .arrow { color: var(--ink-3); }
.role-card-flag { margin-left: auto; font-size: 13px; color: var(--ink-3); }
.dot { width: 12px; height: 12px; flex: none; }
.role-settings { display: grid; grid-template-columns: 1.2fr 1.2fr auto; gap: 16px; align-items: start; }
.role-texts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 18px 0 16px; }
article.role-card > .role-texts { padding: 0 20px; }
.role-text { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.role-text-label { margin: 0; font-family: var(--font-label); font-weight: 700; font-size: 14px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.role-text-label small { font-weight: 500; letter-spacing: 0.04em; text-transform: none; color: var(--ink-3); }
.role-text .text-link { align-self: flex-start; font-size: 13px; }
.role-preview { min-height: 20px; }

.retry .input { width: 150px; }

/* ------------------------------------------------ Discord preview (dc) -- */
/* Deliberately Discord's own dark palette so the preview reads true. */

.dc {
  padding: 14px 16px;
  background: #313338;
  border-radius: 6px;
  color: #dbdee1;
  font: 400 15px/1.375 "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.dc--compact { padding: 10px 12px; font-size: 14px; }
.dc-msg { display: flex; gap: 14px; }
.dc--compact .dc-msg { gap: 10px; }
.dc-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #1a1f11;
  color: #d4af37;
}
.dc--compact .dc-avatar { width: 30px; height: 30px; }
.dc-avatar .crate { width: 58%; height: 58%; }
.dc-body { min-width: 0; flex: 1; }
.dc-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.dc-name { font-weight: 600; color: #f2f3f5; }
.dc-badge { padding: 0 4px; border-radius: 3px; background: #5865f2; color: #fff; font-size: 10px; font-weight: 600; line-height: 15px; text-transform: uppercase; }
.dc-time { font-size: 12px; color: #949ba4; }
.dc-content { overflow-wrap: anywhere; }
.dc-embed { display: flex; max-width: 520px; margin-top: 4px; background: #2b2d31; border-radius: 4px; overflow: hidden; }
.dc-embed-bar { width: 4px; height: auto; flex: none; }
.dc-embed-inner { padding: 10px 16px 14px 12px; min-width: 0; }
.dc-embed-title { font-weight: 600; color: #f2f3f5; margin-bottom: 6px; }
.dc-embed-desc { font-size: 14px; }
.dc-field { margin-top: 8px; font-size: 14px; }
.dc-field-name { font-weight: 600; color: #f2f3f5; }
.dc-embed-footer { margin-top: 10px; font-size: 12px; color: #b5bac1; }
.dc strong { color: #f2f3f5; }
.dc code { padding: 0 3px; background: #1e1f22; border-radius: 3px; font-size: 0.85em; }
.mention { padding: 0 2px; border-radius: 3px; background: rgba(88, 101, 242, 0.3); color: #c9cdfb; font-weight: 500; }

/* ---------------------------------------------------------------- gate -- */

body.is-bare { display: grid; }
.gate { display: grid; place-items: center; align-content: center; gap: 18px; min-height: 100vh; padding: 32px 16px; }
.gate-card {
  position: relative;
  width: min(440px, 100%);
  padding: 40px 36px 34px;
  background: var(--sheet);
  border: 1px solid var(--rule-strong);
  box-shadow: var(--shadow);
  text-align: center;
}
.gate-card::before, .gate-card::after { content: ""; position: absolute; width: 18px; height: 18px; border: solid var(--brass); opacity: 0.7; }
.gate-card::before { top: 10px; right: 10px; border-width: 1px 1px 0 0; }
.gate-card::after { bottom: 10px; left: 10px; border-width: 0 0 1px 1px; }
.gate-mark { display: grid; place-items: center; margin-bottom: 16px; color: var(--brass); }
.gate-mark .crate { width: 58px; height: 58px; }
.gate-title {
  margin: 0 0 16px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: 46px;
  line-height: 1;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.gate-text { margin: 0 0 16px; color: var(--ink-2); }
.gate-card .flash { text-align: left; }
.gate-card form { margin-top: 16px; }
.gate-card .copy-box { margin-bottom: 4px; text-align: left; }
.gate-foot { margin: 0; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); text-align: center; }

/* ---------------------------------------------------------- responsive -- */

@media (max-width: 1020px) {
  .columns, .split, .hero { grid-template-columns: 1fr; }
  .status-list { grid-template-columns: 1fr; }
  .strip { grid-template-columns: repeat(2, 1fr); }
  .strip-cell { border-left: 0; border-top: 1px solid var(--rule); }
  .strip-cell:nth-child(-n + 2) { border-top: 0; }
  .strip-cell--result { grid-column: 1 / -1; }
  .role-texts { grid-template-columns: 1fr; }
  .legend { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .brand-sub { display: none; }
  .topbar-right { width: 100%; justify-content: space-between; gap: 10px; }
  .bot-state { font-size: 11px; }
  .dogtag-name { max-width: 110px; }
  .dogtag-id { display: none; }
  .tabs { padding: 0 16px; margin-top: 16px; }
  .tab { padding: 9px 12px 8px; font-size: 15px; }
  .sheet { padding: 24px 16px 36px; border-left: 0; border-right: 0; }
  .sheet-head { flex-direction: column; align-items: flex-start; }
  .form-grid, .form-grid--expense, .role-settings, .tool-grid, .tool-fields, .figures, .legend, .legend--roles { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .ledger-row { grid-template-columns: 1fr auto; }
  .ledger-leader { display: none; }
  .ledger-stamp { grid-column: 1 / -1; text-align: left; }
  .status-row { grid-template-columns: 12px 1fr; }
  .status-value { grid-column: 2; }
  .colophon { flex-direction: column; gap: 4px; padding: 14px 16px 32px; }
  .receipt { grid-template-columns: 1fr auto; }
  .receipt-date { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
