:root {
  --bg: #eef2f5;
  --surface: #ffffff;
  --sunken: #f6f8fa;
  --ink: #14212b;
  --muted: #5b6875;
  --line: #dde3e9;
  --rail: #14212b;
  --rail-ink: #c9d3dc;
  --rail-hover: #1f303d;
  --accent: #0b6e5f;
  --accent-ink: #ffffff;
  --accent-soft: #e2f2ee;
  --good: #11704f;
  --good-bg: #e3f4ec;
  --warn: #965500;
  --warn-bg: #fdf1dc;
  --bad: #b42318;
  --bad-bg: #fdeceb;
  --radius-lg: 14px;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(20, 33, 43, 0.06), 0 4px 16px rgba(20, 33, 43, 0.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f171d;
    --surface: #16212a;
    --sunken: #121b22;
    --ink: #e6edf2;
    --muted: #93a3b1;
    --line: #26343f;
    --rail: #0b1217;
    --rail-ink: #9fb0be;
    --rail-hover: #16212a;
    --accent: #3fbfa6;
    --accent-ink: #062520;
    --accent-soft: #123a33;
    --good: #5fd3a6;
    --good-bg: #123327;
    --warn: #f0b860;
    --warn-bg: #3a2b12;
    --bad: #ff8a80;
    --bad-bg: #3d1a17;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }
.num, .amount { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Shell: dark rail with the menu, content on the light page */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.rail {
  background: var(--rail); color: var(--rail-ink);
  padding: 20px 12px; display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; color: #fff; font-weight: 700; font-size: 17px; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent);
  display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 800;
}
.rail nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.rail nav a {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  color: var(--rail-ink); padding: 8px 10px; border-radius: var(--radius-sm);
}
.rail nav a:hover { background: var(--rail-hover); color: #fff; text-decoration: none; }
.rail nav a[aria-current="page"] { background: var(--rail-hover); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.rail .count { background: #f0b860; color: #1b1200; border-radius: 999px; font-size: 12px; font-weight: 700; padding: 0 7px; }
.rail .who { border-top: 1px solid rgba(255, 255, 255, 0.08); padding: 12px 10px 0; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.rail .who button { color: var(--rail-ink); }

main { padding: 28px 32px 72px; max-width: 1120px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -0.015em; margin: 0; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
h2 { font-size: 17px; margin: 0 0 4px; letter-spacing: -0.005em; }
.section { margin-top: 28px; }
.section > h2 + .hint, .section > .hint { margin: 0 0 12px; color: var(--muted); font-size: 14px; max-width: 72ch; }
.section > h2:last-child { margin-bottom: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.section-head h2 { margin: 0; }

/* Surfaces */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.panel-pad { padding: 18px 20px; }

/* The status line: the first thing the owner reads */
.status {
  display: flex; align-items: center; gap: 14px; padding: 18px 20px; flex-wrap: wrap;
  border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
}
.status + .status { margin-top: 10px; }
.status .dot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--good); box-shadow: 0 0 0 5px var(--good-bg); }
.status b { display: block; font-size: 17px; }
.status span { color: var(--muted); font-size: 14px; }
.status .grow { flex: 1 1 260px; }
.status.bad { background: var(--bad-bg); border-color: transparent; box-shadow: none; }
.status.bad .dot { background: var(--bad); box-shadow: 0 0 0 5px rgba(180, 35, 24, 0.15); }
.status.bad b { color: var(--bad); }
.status.warn { background: var(--warn-bg); border-color: transparent; box-shadow: none; }
.status.warn .dot { background: var(--warn); box-shadow: 0 0 0 5px rgba(150, 85, 0, 0.15); }
@media (prefers-reduced-motion: no-preference) {
  .status.ok .dot { animation: beat 2.4s ease-in-out infinite; }
}
@keyframes beat { 50% { box-shadow: 0 0 0 9px transparent; } }

/* Today's numbers */
.figures { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: 16px; }
.figure { padding: 16px 20px; border-left: 1px solid var(--line); }
.figure:first-child { border-left: 0; }
.figure b { display: block; font-size: 28px; line-height: 1.15; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.figure b small { font-size: 15px; font-weight: 600; color: var(--muted); letter-spacing: 0; }
.figure span { color: var(--muted); font-size: 13px; }
.figure.alert b { color: var(--warn); }

/* Ledger: rows read like a bank statement */
.ledger { list-style: none; margin: 0; padding: 0; }
.ledger li { display: grid; grid-template-columns: 104px 120px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 12px 20px; border-top: 1px solid var(--line); }
.ledger li:first-child { border-top: 0; }
.ledger .when { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.ledger .amount { font-weight: 700; font-size: 17px; }
.ledger .amount::before { content: "+"; color: var(--muted); font-weight: 500; margin-right: 1px; }
.ledger .what { min-width: 0; }
.ledger .what a { font-weight: 600; }
.ledger .act { display: flex; gap: 12px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.ledger li.empty { display: block; color: var(--muted); padding: 20px; }

/* Tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 16px; border-top: 1px solid var(--line); vertical-align: middle; }
thead th { border-top: 0; font-size: 13px; color: var(--muted); font-weight: 600; background: var(--sunken); white-space: nowrap; }
tbody tr:hover { background: var(--sunken); }
td.num, th.num, td.end { text-align: right; }
td.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
td .sub { display: block; color: var(--muted); font-size: 13px; }
td.empty { color: var(--muted); padding: 24px 16px; }
td.empty:hover { background: none; }

/* Status words */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--sunken); color: var(--muted); white-space: nowrap; border: 1px solid var(--line); }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.8; }
.pill.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.tag { font-size: 13px; color: var(--muted); }

/* Messages */
.flash { padding: 12px 16px; border-radius: var(--radius); background: var(--good-bg); color: var(--good); margin: 0 0 16px; font-weight: 600; }
.flash.bad { background: var(--bad-bg); color: var(--bad); }
.reveal { border: 2px solid var(--accent); background: var(--accent-soft); border-radius: var(--radius-lg); padding: 18px 20px; margin-bottom: 20px; }
.reveal > b { display: block; margin-bottom: 10px; }
.reveal label { font-size: 13px; }
.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; background: var(--surface); border: 1px solid var(--line); padding: 10px 12px; border-radius: var(--radius-sm); word-break: break-all; margin: 4px 0 12px; user-select: all; }

/* Key–value facts */
dl { margin: 0; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.facts > div { padding: 14px 20px; border-left: 1px solid var(--line); }
.facts > div:first-child { border-left: 0; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 2px 0 0; font-weight: 600; font-size: 17px; font-variant-numeric: tabular-nums; }
dl.rows { display: grid; grid-template-columns: minmax(160px, 240px) 1fr; }
dl.rows dt, dl.rows dd { padding: 11px 20px; border-top: 1px solid var(--line); margin: 0; }
dl.rows dt { color: var(--muted); }
dl.rows dt:first-of-type, dl.rows dd:first-of-type { border-top: 0; }

/* Timeline of a reservation */
.timeline { list-style: none; margin: 0; padding: 10px 20px; }
.timeline li { position: relative; padding: 10px 0 10px 30px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; background: var(--line); }
.timeline li:first-child::before { top: 20px; }
.timeline li:last-child::before { bottom: calc(100% - 20px); }
.timeline li:only-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 0; top: 14px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--muted); }
.timeline li.good::after { border-color: var(--good); background: var(--good); }
.timeline li.warn::after { border-color: var(--warn); }
.timeline li.bad::after { border-color: var(--bad); background: var(--bad); }
.timeline b { display: block; }
.timeline .when { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* Forms */
form.stack { display: grid; gap: 16px; }
fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 14px; }
fieldset + fieldset { border-top: 1px solid var(--line); padding-top: 16px; }
legend { font-weight: 700; padding: 0; margin-bottom: 4px; float: left; width: 100%; }
legend + * { clear: both; }
label { display: grid; gap: 5px; font-size: 14px; font-weight: 600; }
label .hint, .field-hint { font-weight: 400; color: var(--muted); font-size: 13px; margin: 0; }
input, select, textarea {
  font: inherit; font-weight: 400; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 11px; width: 100%; min-height: 40px;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); outline: 3px solid var(--accent-soft); outline-offset: 0; }
textarea { min-height: 140px; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); margin: 0; }
.check { display: flex; align-items: center; gap: 10px; }
.cols { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: start; }
.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 14px; }
.filters label { flex: 1 1 160px; }
.filters button { flex: none; }
.inline { display: inline; margin: 0; }
.attach { display: flex; gap: 6px; align-items: center; margin: 0; }
.attach input { width: 180px; min-height: 36px; padding: 6px 10px; }

button, .button {
  font: inherit; font-weight: 600; cursor: pointer; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 8px 16px; min-height: 40px; background: var(--accent); color: var(--accent-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; justify-self: start;
}
.button:hover { text-decoration: none; }
button:hover, .button:hover { filter: brightness(1.07); }
button.small, .attach button { min-height: 36px; padding: 6px 12px; font-size: 14px; }
button.secondary, .button.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
button.danger { background: var(--surface); color: var(--bad); border-color: var(--bad); }
button.link { background: none; border: 0; color: var(--muted); padding: 0; min-height: 0; font-weight: 500; }
button.link:hover { color: var(--ink); text-decoration: underline; filter: none; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions form { margin: 0; }

/* Code samples */
pre { margin: 0; white-space: pre; overflow-x: auto; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; font-size: 13px; line-height: 1.55; }
.steps { margin: 0; padding-left: 22px; display: grid; gap: 8px; max-width: 72ch; }

/* Sign-in */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--rail); }
.login { width: 100%; max-width: 380px; display: grid; gap: 14px; padding: 28px; }
.login .brand { color: var(--ink); padding: 0 0 4px; font-size: 20px; }
.login > p { margin: 0 0 4px; color: var(--muted); font-size: 14px; }
.login button { justify-self: stretch; margin-top: 4px; }
.login .flash { margin: 0; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .rail { height: auto; z-index: 2; padding: 10px 12px 6px; flex-direction: row; align-items: center; gap: 8px; flex-wrap: wrap; }
  .brand { padding: 0 6px 0 2px; }
  .rail nav { flex-direction: row; order: 3; flex: 1 1 100%; overflow-x: auto; gap: 4px; scrollbar-width: none; }
  .rail nav a { white-space: nowrap; padding: 6px 10px; }
  .rail nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
  .rail .who { border: 0; padding: 0; margin-left: auto; }
  .rail .who span { display: none; }
  main { padding: 20px 16px 56px; }
  h1 { font-size: 22px; }
  .figures { grid-template-columns: 1fr 1fr; }
  .figure:nth-child(3) { border-left: 0; }
  .figure:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .figure b { font-size: 24px; }
  .ledger li { grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 16px; }
  .ledger .when { grid-row: 1; grid-column: 1; }
  .ledger .amount { grid-row: 1; grid-column: 2; text-align: right; }
  .ledger .what, .ledger .act { grid-column: 1 / -1; }
  .ledger .act { justify-content: flex-start; }
  .attach { flex: 1 1 100%; }
  .attach input { width: auto; flex: 1; }
  dl.rows { grid-template-columns: minmax(0, 1fr); }
  dl.rows dd { border-top: 0; padding-top: 0; }
  .facts > div { border-left: 0; border-top: 1px solid var(--line); }
  .facts > div:first-child { border-top: 0; }
}
