:root {
  --bg: #FBF8F2; --card: #FFFFFF; --ink: #23201B; --muted: #6B645A; --line: #E6DFD2;
  --accent: #005837; --accent-ink: #FFFFFF; --accent-soft: #E1F0E5;
  --gold: #FDB913; --leaf: #79B774;
  --amber: #7A5200; --amber-soft: #FFF1CC; --clay: #A6402A; --clay-soft: #F8DDD6;
  --radius: 12px; --shadow: 0 1px 2px rgba(35,32,27,.06), 0 4px 14px rgba(35,32,27,.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17150F; --card: #211E17; --ink: #F1ECE0; --muted: #A59E90; --line: #3A352A;
    --accent: #79B774; --accent-ink: #0F1A16; --accent-soft: #1E3A2A;
    --amber: #FDB913; --amber-soft: #3A2C16; --clay: #E58468; --clay-soft: #3E211A;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--font); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
.wrap { max-width: 1040px; margin: 0 auto; padding: 16px 16px 48px; }

.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 3px solid var(--gold); background: var(--card); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; text-decoration: none; color: var(--ink); }
.brand img { display: block; height: 36px; width: auto; }
.topbar .btn { white-space: nowrap; }
.brand .app-name { white-space: nowrap; font-size: 1.05rem; padding-left: 12px; border-left: 2px solid var(--line); line-height: 1.1; }
.logo-hero { display: block; width: min(320px, 80%); height: auto; margin: 4px auto 14px; }
@media (max-width: 560px) { .topbar { gap: 8px; padding: 10px 12px; } .topbar .who { display: none; } .brand { gap: 8px; } .brand img { height: 26px; } .brand .app-name { font-size: .9rem; padding-left: 8px; } }
@media (max-width: 420px) { .brand img { height: 22px; } .brand .app-name { white-space: normal; font-size: .85rem; max-width: 9em; padding-left: 8px; } .topbar .btn.sm { padding: 0 10px; min-height: 32px; } }
/* The logo's dark-green lettering needs a light backdrop in dark mode. */
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .brand img, :root:not([data-theme="light"]) .logo-hero { background: #fff; border-radius: 8px; padding: 4px 8px; } }
.topbar .sp { flex: 1; }
.topbar .who { font-size: .85rem; color: var(--muted); max-width: 30ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-top: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; } .row.between { justify-content: space-between; }
.grid { display: grid; gap: 12px; }
.grid.cols2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid.cols4 { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); cursor: pointer; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--clay); border-color: var(--clay); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .9rem; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

label.f { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=date], input[type=number], select, textarea { width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
textarea { min-height: 88px; resize: vertical; }
textarea.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .85rem; min-height: 140px; }

.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--line); color: var(--muted); }
.pill.ok { background: var(--accent-soft); color: var(--accent); }
.pill.wait { background: var(--amber-soft); color: var(--amber); }
.pill.warn { background: var(--clay-soft); color: var(--clay); }

.banner { border-radius: 10px; padding: 10px 14px; margin-top: 12px; border: 1px solid var(--line); background: var(--accent-soft); }
.banner.warn { background: var(--amber-soft); border-color: var(--amber); }
.banner.err { background: var(--clay-soft); border-color: var(--clay); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 16px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; }
.tabs a.on { color: var(--accent); border-color: var(--accent); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
tr.missing td { background: var(--amber-soft); }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); font-size: 1.4rem; cursor: pointer; }
.stepper input { width: 84px; text-align: center; font-size: 1.4rem; font-weight: 700; min-height: 48px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { min-height: 40px; padding: 0 12px; border: 0; background: var(--card); cursor: pointer; font-weight: 600; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }

.stat { padding: 14px; border-radius: var(--radius); background: var(--accent-soft); }
.stat .n { font-size: 2.4rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat .l { font-size: .85rem; color: var(--muted); margin-top: 4px; }
.stat.amber { background: var(--amber-soft); } .stat.plain { background: var(--bg); border: 1px solid var(--line); }

.rosterline { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
@media (min-width: 720px) { .rosterline { grid-template-columns: minmax(180px, 1.2fr) auto auto minmax(160px, 1.4fr); align-items: center; } }
.rosterline .nm { font-weight: 600; } .rosterline .id { font-size: .8rem; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }

.sticky-summary { position: sticky; bottom: 0; background: var(--card); border-top: 1px solid var(--line); padding: 12px 16px; margin: 16px -16px -16px; border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 10px; z-index: 20; font-weight: 600; max-width: 90vw; }
.toast.err { background: var(--clay); color: #fff; }
.hero { text-align: center; padding: 56px 16px; }
.flag { color: var(--clay); font-weight: 600; }
.tag { display: inline-block; background: var(--clay-soft); color: var(--clay); border-radius: 6px; padding: 1px 8px; font-size: .85rem; margin: 2px 4px 2px 0; }
.devbox { border: 2px dashed var(--amber); background: var(--amber-soft); border-radius: var(--radius); padding: 12px; margin-top: 16px; }

@media print {
  .topbar, .noprint, .tabs { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #999; break-inside: avoid; }
  :root { --accent-soft: #eee; --amber-soft: #ddd; --clay-soft: #eee; }
}
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 12px 0; }
.grow { flex: 1; min-width: 200px; }
ul { padding-left: 20px; margin: 6px 0; }
.row input[type=date], .row select { width: auto; }
.row .grow input, .row input.grow { width: 100%; }
