/* Graphite and white, with one brick tone kept only for things that need action. */
:root {
  --bg: #f4f5f6; --surface: #ffffff; --ink: #15181b; --muted: #5f666d; --line: #e1e4e7;
  --soft: #eceef0; --strong: #15181b; --on-strong: #ffffff; --alert: #a23e2c; --alert-soft: #f7e9e6;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #111315; --surface: #181b1e; --ink: #eaecee; --muted: #969da4; --line: #2a2e33;
  --soft: #22262a; --strong: #eaecee; --on-strong: #111315; --alert: #e58a77; --alert-soft: #34211e;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.5 "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-variant-numeric: tabular-nums; }
h1, h2, h3 { font-family: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, sans-serif; margin: 0; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 650; letter-spacing: -.015em; }
h2 { font-size: 16px; font-weight: 600; }
a { color: inherit; text-underline-offset: 3px; }
p { margin: 0; }
.muted { color: var(--muted); }
.alert { color: var(--alert); }
.small { font-size: 12.5px; }

.shell { display: grid; grid-template-columns: 216px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 12px; display: flex;
  flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 700; font-size: 16px; padding: 0 10px 18px; overflow-wrap: anywhere; }
.side a { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 6px;
  text-decoration: none; color: var(--muted); }
.side a:hover { background: var(--soft); color: var(--ink); }
.side a[aria-current="page"] { background: var(--strong); color: var(--on-strong); font-weight: 600; }
.side .foot { margin-top: auto; display: grid; gap: 6px; padding-top: 16px; }
main { padding: 24px 28px 48px; max-width: 1680px; width: 100%; margin: 0 auto; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

button, .btn { font: inherit; font-weight: 550; padding: 7px 13px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-block; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--muted); }
button.primary, .btn.primary { background: var(--strong); color: var(--on-strong); border-color: var(--strong); }
button.link { border: 0; background: none; padding: 2px 4px; text-decoration: underline; text-underline-offset: 3px; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line);
  border-radius: 6px; padding: 8px 10px; width: 100%; }
textarea { min-height: 96px; resize: vertical; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--strong); }
input[type="search"] { max-width: 300px; }
input[type="date"].inline, input[type="month"].inline, select.inline { width: auto; }
label { display: grid; gap: 4px; font-weight: 550; align-content: start; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }

section { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; margin-bottom: 18px; }
section > header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 18px; flex-wrap: wrap; }
section > .pad { padding: 0 18px 18px; }
.cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; align-items: start; }
.cols > section { margin: 0; }
.cols { margin-bottom: 18px; }
/* wide screens: a main column and a side column, so the page uses the whole monitor */
.dash, .split { display: grid; gap: 18px; align-items: start; }
.dash { grid-template-columns: minmax(0, 1.75fr) minmax(340px, 1fr); }
.split { grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
.dash > div, .split > div { min-width: 0; }
.dash th, .dash td, .split th, .split td { padding-left: 14px; padding-right: 14px; }
.dash section > header, .split section > header { padding-left: 14px; padding-right: 14px; }
.dash .pad { padding-left: 14px; padding-right: 14px; }
.dash .empty, .split .empty { padding-left: 14px; padding-right: 14px; }

/* month register: one square per day present */
.muster th, .muster td { padding: 8px 2px; text-align: center; }
.muster th:first-child, .muster td:first-child { text-align: left; padding-left: 18px; padding-right: 10px; white-space: nowrap;
  position: sticky; left: 0; background: var(--surface); }
.muster th:nth-child(2), .muster td:nth-child(2) { padding-right: 8px; }
.muster th:last-child, .muster td:last-child { padding-right: 18px; }
.mark { display: inline-block; width: 13px; height: 13px; border-radius: 3px; background: var(--strong); vertical-align: middle; }
.mark.hand { background: none; border: 2px solid var(--strong); }
section > .legend { padding-top: 12px; border-top: 1px solid var(--line); }
.legend i, .legend span { margin: 0 4px 0 12px; }
.legend i:first-child { margin-left: 0; }

.title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title .tag { font-weight: 500; letter-spacing: 0; }
.figures.compact b { font-size: 21px; }
.detail { margin: 0; }
.detail > div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 14px; border-top: 1px solid var(--line); }
.detail dt { color: var(--muted); white-space: nowrap; }
.detail dd { margin: 0; text-align: right; overflow-wrap: anywhere; min-width: 0; }

/* figures read as one ruled strip, not a row of cards */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 18px; }
.figures > a, .figures > div { background: var(--surface); padding: 14px 18px; text-decoration: none; }
.figures a:hover { background: var(--soft); }
.figures b { display: block; font-size: 28px; font-weight: 650; letter-spacing: -.02em; line-height: 1.25; }
.figures span { color: var(--muted); }

/* the next 30 days of expiries */
.runway { display: grid; grid-template-columns: repeat(30, minmax(0, 1fr)); gap: 4px; height: 132px; align-items: end; }
.runway button { border: 0; background: none; padding: 0; height: 100%; display: flex; flex-direction: column;
  justify-content: flex-end; align-items: stretch; gap: 3px; border-radius: 3px; min-width: 0; }
.runway button:hover { background: var(--soft); }
.runway i { display: block; background: var(--strong); border-radius: 2px 2px 0 0; min-height: 2px; }
.runway .zero i { background: var(--line); }
.runway .soon i { background: var(--alert); }
.runway .zero.soon i { background: var(--line); }
.runway em { font-style: normal; font-size: 11px; color: var(--muted); text-align: center; overflow: hidden; }
.runway strong { font-size: 11px; text-align: center; font-weight: 600; }
.runway-note { margin-top: 10px; min-height: 21px; }

.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 18px; border-top: 1px solid var(--line); vertical-align: middle; }
th { font-weight: 550; color: var(--muted); font-size: 12.5px; }
tbody tr:hover { background: var(--soft); }
td.num, th.num { text-align: right; }
td .actions { justify-content: flex-end; flex-wrap: nowrap; }
.empty { padding: 22px 18px; border-top: 1px solid var(--line); color: var(--muted); }

.tag { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; }
.tag.active, .tag.joined, .tag.sent, .tag.opened, .tag.present { background: var(--soft); border-color: var(--soft); }
.tag.expiring, .tag.ready, .tag.queued, .tag.sending, .tag.open { border-color: var(--alert); color: var(--alert); }
.tag.expired, .tag.failed, .tag.unlinked { background: var(--alert-soft); border-color: var(--alert-soft); color: var(--alert); }
.tag.frozen, .tag.upcoming, .tag.not-in, .tag.absent { border-style: dashed; }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button { border-color: transparent; background: none; color: var(--muted); font-weight: 450; }
.tabs button[aria-pressed="true"] { background: var(--soft); color: var(--ink); font-weight: 600; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 0; }
.facts dt { color: var(--muted); font-size: 12.5px; }
.facts dd { margin: 0; overflow-wrap: anywhere; }

.bars { display: grid; gap: 6px; }
.bars div { display: grid; grid-template-columns: 74px 1fr 90px; gap: 10px; align-items: center; }
.bars i { display: block; height: 10px; background: var(--strong); border-radius: 2px; min-width: 2px; }
.bars span:last-child { text-align: right; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.fields .wide { grid-column: 1 / -1; }
.fields small { color: var(--muted); font-weight: 400; }
dialog { background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 22px;
  width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
dialog h2 { font-size: 19px; margin-bottom: 14px; }
dialog footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.error { color: var(--alert); margin-top: 10px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--strong); color: var(--on-strong);
  padding: 10px 16px; border-radius: 8px; max-width: calc(100vw - 32px); display: none; z-index: 5; }
#toast.show { display: block; }

.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate form { width: min(360px, 100%); display: grid; gap: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 26px; }
#receipt { display: none; }

@media (max-width: 1280px) {
  .dash { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1040px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; align-items: center; }
  .side a { white-space: nowrap; gap: 6px; }
  .side .foot { margin: 0; padding: 0; display: flex; }
  .brand { padding: 0 8px; white-space: nowrap; }
  main { padding: 18px 14px 50px; }
  .cols, .fields { grid-template-columns: minmax(0, 1fr); }
  .head .actions { width: 100%; }
  .runway { gap: 2px; }
  .runway em { visibility: hidden; }
  .runway button:nth-child(5n+1) em { visibility: visible; overflow: visible; }
}
@media print {
  body { background: #fff; color: #000; }
  #app, #toast, dialog { display: none !important; }
  #receipt { display: block; max-width: 420px; margin: 0 auto; }
  #receipt td { padding: 6px 0; }
}
