:root {
  --page: #eef3f0;
  --panel: #fbfcf8;
  --ink: #15302a;
  --quiet: #55695f;
  --rule: #d2ddd7;
  --pine: #0b5f52;
  --on-pine: #fbfcf8;
  --rail: #0b4a40;
  --rail-ink: #d7e3dd;
  --alert-bg: #fbe9c8;
  --alert-ink: #6b3f00;
  --danger: #a3271c;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --page: #0f1f1b;
    --panel: #182b26;
    --ink: #e7f0eb;
    --quiet: #9db3a8;
    --rule: #2e4740;
    --pine: #6fd3bf;
    --on-pine: #0f1f1b;
    --rail: #0a1714;
    --alert-bg: #4a3208;
    --alert-ink: #fde3ae;
    --danger: #ff9d92;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, p { margin: 0; }
a { color: var(--pine); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--pine); outline-offset: 2px; }

.login { width: min(360px, calc(100% - 32px)); margin: 14vh auto 0; padding: 28px; background: var(--panel); border-radius: 6px; display: grid; gap: 10px; }
.login h1 { font-size: 22px; margin-bottom: 8px; }
.error { color: var(--danger); min-height: 1.5em; }

.shell { display: grid; grid-template-columns: 196px minmax(0, 1fr); min-height: 100dvh; }
.rail { background: var(--rail); color: var(--rail-ink); padding: 20px 10px; display: flex; flex-direction: column; gap: 2px; }
.brand { font: 500 22px/1 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; color: #fff; padding: 0 10px 20px; }
.rail button { text-align: left; padding: 9px 10px; background: none; border: 0; border-radius: 5px; color: inherit; cursor: pointer; }
.rail button:hover { background: rgba(255, 255, 255, .08); }
.rail button[aria-current="page"] { background: rgba(255, 255, 255, .16); color: #fff; font-weight: 600; }
.rail .logout { margin-top: auto; }
.view { padding: clamp(16px, 3vw, 32px); min-width: 0; display: grid; gap: 20px; align-content: start; }

.head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.head h1 { font-size: 24px; font-weight: 600; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.alert { padding: 12px 16px; background: var(--alert-bg); color: var(--alert-ink); border-radius: 6px; }
.figures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); background: var(--panel); border-radius: 6px; }
.figure { padding: 16px 18px; border-right: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
.figure p:first-child { color: var(--quiet); font-size: 13px; }
.figure .big { font: 500 27px/1.25 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; font-variant-numeric: lining-nums tabular-nums; }
.section-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; }

.table-wrap { overflow-x: auto; background: var(--panel); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--rule); white-space: nowrap; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { color: var(--quiet); font-weight: 500; font-size: 13px; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.actions { display: flex; gap: 6px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; }
/* Long addresses wrap, so the action buttons beside them stay on screen. */
td.wrap { white-space: normal; overflow-wrap: anywhere; min-width: 150px; }
.short { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 28px 16px; color: var(--quiet); }
.row-link { background: none; border: 0; padding: 0; color: var(--pine); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.state { font-weight: 600; }
.state-paid, .state-sent, .state-delivered, .state-on { color: var(--pine); }
.state-underpaid, .state-paid_late, .state-failed, .state-off, .state-rejected { color: var(--danger); }
.state-expired, .state-orphaned { color: var(--quiet); }

input, select { padding: 8px 10px; background: var(--panel); border: 1px solid var(--rule); border-radius: 5px; min-height: 38px; }
input { width: 100%; }
.tools input { width: 240px; max-width: 100%; }
button.primary, button.plain, button.danger { min-height: 36px; padding: 6px 12px; border-radius: 5px; cursor: pointer; }
button.primary { background: var(--pine); color: var(--on-pine); border: 1px solid var(--pine); font-weight: 600; }
button.plain { background: none; border: 1px solid var(--rule); }
button.danger { background: none; border: 1px solid var(--danger); color: var(--danger); }
button:disabled { opacity: .5; cursor: default; }
.pager { display: flex; gap: 8px; align-items: center; color: var(--quiet); }

dialog { width: min(560px, calc(100% - 32px)); padding: 24px; border: 0; border-radius: 6px; background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgba(8, 30, 25, .55); }
dialog h2 { font-size: 19px; margin-bottom: 12px; }
dialog form, .stack { display: grid; gap: 12px; }
dialog label { display: grid; gap: 4px; color: var(--quiet); font-size: 13px; }
dialog .note { color: var(--quiet); }
dialog .buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.secret { padding: 10px 12px; background: var(--page); border-radius: 5px; overflow-wrap: anywhere; user-select: all; }
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; }
.facts dt { color: var(--quiet); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts.panel { margin: 0; padding: 16px 18px; background: var(--panel); border-radius: 6px; }

@media (max-width: 760px) {
  .shell { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rail { flex-direction: row; overflow-x: auto; padding: 10px; align-items: center; position: sticky; top: 0; z-index: 2; }
  .brand { padding: 0 8px 0 4px; }
  .rail button { white-space: nowrap; }
  .rail .logout { margin: 0 0 0 auto; }
}
