:root {
  --paper: #eef0ec;
  --paper-raised: #ffffff;
  --ink: #1b2320;
  --ink-soft: #4b564f;
  --ink-faint: #7c877e;
  --line: #c9d0c7;
  --accent: #24547e;
  --accent-soft: #d8e4ec;
  --good: #3f6b4f;
  --good-bg: #dfe9e0;
  --warn: #9c6b1f;
  --warn-bg: #f1e6d0;
  --bad: #9c3f30;
  --bad-bg: #f2ddd8;
  --font-display: -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-body: -apple-system, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14181a; --paper-raised: #1c2225; --ink: #e7ece6; --ink-soft: #aab5ac;
    --ink-faint: #78837c; --line: #333c37; --accent: #7fb0d6; --accent-soft: #1f3546;
    --good: #7fb894; --good-bg: #1f3427; --warn: #d9ad64; --warn-bg: #3a2e17;
    --bad: #e08d7d; --bad-bg: #3a201b;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 22px; border-bottom: 2px solid var(--ink);
  background: var(--paper-raised);
}
.brand { font-family: var(--font-display); font-weight: 700; font-size: 19px; }

select, input, button {
  font-family: var(--font-body); font-size: 14px; color: var(--ink);
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 4px;
  padding: 7px 10px;
}
button {
  background: var(--accent); color: #fff; border: none; font-weight: 600; cursor: pointer;
}
button:hover { opacity: .9; }
button.secondary { background: var(--paper-raised); color: var(--ink); border: 1px solid var(--line); }
button.danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); }

.tabs {
  display: flex; gap: 4px; padding: 10px 22px; border-bottom: 1px solid var(--line);
  background: var(--paper-raised);
}
.tab-btn {
  background: transparent; color: var(--ink-soft); border: none; font-family: var(--font-display);
  font-weight: 600; font-size: 13.5px; padding: 8px 14px; border-radius: 4px 4px 0 0; cursor: pointer;
}
.tab-btn.active { color: var(--accent); background: var(--accent-soft); }

main { max-width: 980px; margin: 0 auto; padding: 24px 22px 60px; }
h2 {
  font-family: var(--font-display); font-weight: 700; font-size: 16px;
  margin: 28px 0 10px; color: var(--ink);
}
h2:first-child { margin-top: 0; }

.card {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 6px; padding: 16px 18px;
}
.card-row { display: flex; flex-wrap: wrap; gap: 10px; }
.stat-tile {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 6px;
  padding: 14px 18px; min-width: 130px; flex: 1;
}
.stat-tile .n { font-family: var(--font-mono); font-size: 24px; font-weight: 500; color: var(--accent); }
.stat-tile .label { font-size: 12px; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .05em; }

.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 14px; margin-bottom: 14px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--ink-soft); }
.filters label.check { flex-direction: row; align-items: center; gap: 6px; }

.map-legend { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; font-size: 12px; color: var(--ink-faint); margin-bottom: 10px; }
.swatch { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.swatch-avail { background: var(--accent-soft); border: 1px solid var(--accent); }
.swatch-hover { background: var(--accent); border: 1px solid var(--accent); }

.map-wrap { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.map-zone {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 6px;
  padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start;
}
.map-zone h4 { margin: 0; font-family: var(--font-display); font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.seat-rect { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; cursor: pointer; transition: fill .12s; }
.seat-rect:hover, .seat-rect.highlight { fill: var(--accent); }
.seat-rect-label { font-family: var(--font-mono); font-size: 7px; fill: var(--accent); pointer-events: none; }
.seat-rect:hover + .seat-rect-label, .seat-rect.highlight + .seat-rect-label { fill: #fff; }

.seat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.seat-card.highlight { outline: 2px solid var(--accent); outline-offset: 1px; }
.seat-card {
  background: var(--paper-raised); border: 1px solid var(--line); border-radius: 6px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.seat-card .code { font-family: var(--font-mono); font-weight: 500; font-size: 15px; }
.seat-card .loc { font-size: 12px; color: var(--ink-faint); }
.booking-row .loc { font-size: 13px; color: var(--ink-soft); }
.seat-card .tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag {
  font-family: var(--font-mono); font-size: 10.5px; padding: 2px 6px; border-radius: 10px;
  background: var(--accent-soft); color: var(--accent);
}

.data-table { width: 100%; border-collapse: collapse; background: var(--paper-raised); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.data-table th, .data-table td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.data-table th { font-family: var(--font-mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); background: var(--paper); }
.data-table tr:last-child td { border-bottom: none; }

.booking-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.booking-row:last-child { border-bottom: none; }
.pill { font-family: var(--font-mono); font-size: 11px; padding: 2px 8px; border-radius: 20px; }
.pill.confirmed { background: var(--good-bg); color: var(--good); }
.pill.auto_released { background: var(--warn-bg); color: var(--warn); }
.pill.cancelled { background: var(--bad-bg); color: var(--bad); }
.pill.checked_in { background: var(--accent-soft); color: var(--accent); }

.demo-banner { margin: 0; padding: 10px 24px; background: #fff4d6; color: #5c4400; font-size: 0.9375rem; }
.notice { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-weight: 500; }
.notice.good { background: var(--good-bg); color: var(--good); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }
.notice-action { margin-left: 8px; padding: 4px 12px; }
.calendar-btn { margin-top: 10px; }

.empty { color: var(--ink-faint); font-style: italic; padding: 10px 0; }
#directory-search { width: 100%; margin-bottom: 10px; }

.map-details { margin-bottom: 18px; }
.map-details > summary {
  cursor: pointer; font-family: var(--font-display); font-weight: 600; font-size: 13.5px;
  color: var(--ink-soft); padding: 6px 0; margin-bottom: 8px;
}

/* Who's in (RTM C-02 / C-03) */
.share-toggle { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.whosin-wrap { overflow-x: auto; }
#whosin-table th:not(:first-child), #whosin-table td:not(:first-child) { text-align: center; width: 15%; }
#whosin-table .today { background: var(--accent-soft); }
#whosin-table .day-num { color: var(--ink-faint); }
#whosin-table .who-sub { font-size: 12px; color: var(--ink-faint); }
.in-cell { font-family: var(--font-mono); font-size: 12px; padding: 2px 6px; border-radius: 10px; background: var(--good-bg); color: var(--good); white-space: nowrap; }
.in-cell.checked { background: var(--good); color: var(--paper-raised); }
.in-cell.office { background: transparent; border: 1px solid var(--good); }
.empty-cell { color: var(--line); }
.tag.released { background: var(--good-bg); color: var(--good); }
.day-picker { gap: 6px 16px; }
#whosin-table .total-row td { font-weight: 600; background: var(--paper); font-size: 12.5px; }

@media (max-width: 640px) {
  .topbar { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 16px; }
  .tabs { padding: 6px 8px; gap: 2px; }
  .tab-btn { flex: 1; white-space: nowrap; padding: 10px 4px; font-size: 13px; border-radius: 4px; }
  main { padding: 16px 16px 48px; }

  /* 16px stops iOS zooming into a field on focus; 44px is the minimum comfortable tap target. */
  select, input, button { font-size: 16px; min-height: 44px; }
  input[type="checkbox"] { min-height: 0; width: 20px; height: 20px; }
  .filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .filters label > select, .filters label > input:not([type="checkbox"]) { width: 100%; min-width: 0; }
  .filters label.check { min-height: 44px; }
  .filters > button, .filters > select, .filters > input { grid-column: 1 / -1; }

  .seat-grid { grid-template-columns: 1fr; }

  /* Who's in: five day columns still fit a phone; tighten so the names do too. */
  #whosin-table th, #whosin-table td { padding: 8px 4px; font-size: 12.5px; }
  #whosin-table td:first-child { padding-left: 8px; }
  .in-cell { font-size: 10.5px; padding: 2px 3px; }
  @media (min-width: 370px) { .in-cell { font-size: 11.5px; } }
  .day-picker { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .day-picker label.check { flex-direction: column; gap: 2px; font-size: 13px; }

  .booking-row { flex-wrap: wrap; gap: 8px; }
  .booking-row > div:last-child { display: flex; gap: 8px; width: 100%; }
  .booking-row button { flex: 1; }
  .calendar-btn { width: 100%; }

  /* Small things you tap get a 44px target; small type stays at 12px or more. */
  details > summary, .setup-steps a, label.check { display: flex; align-items: center; min-height: 44px; }
  .setup-steps a { display: inline-flex; }
  .tag, .pill { font-size: 12px; }
  .plan-wrap .pin { font-size: 11px; }
  .plan-wrap .pin::before { content: ""; position: absolute; inset: -11px -8px; }

  /* Admin tables are a desk task; on a phone they scroll inside themselves rather than widen the page. */
  #audit-table, #occ-table { display: block; overflow-x: auto; white-space: nowrap; }

  /* Directory: one stacked card per person instead of a four-column table. */
  #directory-table thead { display: none; }
  #directory-table tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  #directory-table tr:last-child { border-bottom: none; }
  #directory-table td { display: inline; padding: 0; border: none; font-size: 13.5px; }
  #directory-table .dir-name { display: block; font-weight: 600; font-size: 15px; }
  #directory-table .dir-team::after { content: " · "; color: var(--ink-faint); }
  #directory-table .dir-seat { font-family: var(--font-mono); }
  #directory-table .dir-loc.no-loc { display: none; }
  #directory-table .dir-loc { display: block; color: var(--ink-faint); font-size: 12.5px; }
}

#book-weeks { width: 60px; }
.whoami { display: flex; align-items: center; gap: 10px; }
.hint { color: var(--ink-faint); font-size: 13px; margin: -4px 0 10px; }
.setup-box { margin-bottom: 18px; }
.setup-box > summary { cursor: pointer; font-weight: 600; }
.setup-steps { margin: 12px 0 0; padding-left: 22px; }
.setup-steps li { margin: 8px 0; }
.setup-steps a { color: var(--ink); }
.setup-steps li > :first-child { font-weight: 500; }
.setup-steps li.done > :first-child { color: var(--ink-faint); }
.setup-steps li.done > :first-child::after { content: " ✓"; color: var(--good); }
.setup-steps li.next > :first-child { color: var(--accent); font-weight: 600; }
.setup-detail { display: block; color: var(--ink-soft); font-size: 13px; }
.setup-pending { margin: 0 0 16px; }
.setup-pending summary { cursor: pointer; color: var(--accent); font-weight: 500; }
.setup-pending ul { max-height: 240px; overflow-y: auto; padding-left: 18px; }
.setup-pending .setup-detail { display: inline; }
.setup-pending textarea { display: block; width: 100%; box-sizing: border-box; margin: 4px 0 8px; font: inherit; font-size: 13px; }
.roster-list { margin: 4px 0 10px; padding-left: 18px; font-size: 13px; }

/* Floor plans (RTM C-01): pins sit at fractions of the plan's box. */
.map-floor { flex: 1 1 100%; }
.map-floor h4 { margin: 0 0 6px; font-family: var(--font-display); font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.plan-wrap { position: relative; width: 100%; max-width: 1100px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: #fff; touch-action: pinch-zoom; }
.plan-img { position: absolute; inset: 0; width: 100%; height: 100%; user-select: none; }
.pin {
  position: absolute; transform: translate(-50%, -50%);
  min-width: 26px; height: 22px; padding: 0 4px; border-radius: 11px;
  background: var(--accent); color: #fff; border: 2px solid #fff;
  font-family: var(--font-mono); font-size: 10px; line-height: 18px; text-align: center;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .35); cursor: pointer;
}
.pin:hover, .pin.highlight { transform: translate(-50%, -50%) scale(1.25); z-index: 2; }
.plan-wrap.editing { cursor: crosshair; }
.plan-wrap.editing .pin { cursor: grab; touch-action: none; }
.svg-measure { position: fixed; left: -20000px; top: 0; visibility: hidden; pointer-events: none; }
