/* Met Tower Shift Board. Tokens first; everything else derives from them. */
:root {
  --bg: #f7f7f4; --panel: #ffffff; --line: #dcdfd9; --fg: #1d2420; --muted: #5b655e;
  --accent: #c7641a; --accent-ink: #ffffff; --accent-soft: #fbe9dc;
  --good: #2e7d4f; --good-soft: #e1f1e7; --warn: #b3261e; --warn-soft: #fbe3e1;
  --amber: #9a6b00; --amber-soft: #fff0c2; --off: #8a8f8b;
  --display: "Barlow Semi Condensed", "Arial Narrow", Arial, sans-serif;
  --body: "Barlow", "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171a18; --panel: #222623; --line: #353a36; --fg: #e9ebe6; --muted: #a2a9a3;
    --accent: #e0853f; --accent-ink: #1a1208; --accent-soft: #3a2a1b;
    --good: #5fbf85; --good-soft: #1f3a2a; --warn: #ef7d75; --warn-soft: #432321;
    --amber: #e6b84a; --amber-soft: #3d3010; --off: #6f746f; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #171a18; --panel: #222623; --line: #353a36; --fg: #e9ebe6; --muted: #a2a9a3;
  --accent: #e0853f; --accent-ink: #1a1208; --accent-soft: #3a2a1b;
  --good: #5fbf85; --good-soft: #1f3a2a; --warn: #ef7d75; --warn-soft: #432321;
  --amber: #e6b84a; --amber-soft: #3d3010; --off: #6f746f; color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--body); font-size: 16px; line-height: 1.4; padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
[hidden] { display: none !important; }
.wrap { max-width: 1100px; margin: 0 auto; padding-block: 0 48px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
h1, h2, h3, h4 { font-family: var(--display); margin: 0; text-wrap: balance; line-height: 1.1; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 700; }
h3 { font-size: 20px; font-weight: 700; }
h4 { font-size: 15px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, select:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.eyebrow { font-family: var(--display); text-transform: uppercase; letter-spacing: .08em; font-size: 12px; color: var(--muted); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.block { display: block; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mb18 { margin-bottom: 18px; }
.small-text { font-size: 13px; } .body-sm { font-size: 14px; }

/* Top bar */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); padding-block: 12px 10px; display: flex; flex-direction: column; gap: 10px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand .sub { color: var(--muted); font-size: 14px; }
.who-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 3px; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font-family: var(--display); font-weight: 600; font-size: 15px; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--accent); color: var(--accent-ink); }
.datebar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.datebar .date { font-family: var(--display); font-weight: 700; font-size: 20px; flex: 1 1 auto; min-width: 0; }
.icon-btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; width: 36px; height: 36px; font-size: 18px; line-height: 1; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 7px 12px; font-weight: 500; font-size: 14px; text-decoration: none; display: inline-block; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.quiet { background: transparent; }
.btn.small { padding: 3px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

/* Today */
.view { padding-top: 16px; }
.summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.summary .bar { flex: 1 1 140px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; min-width: 0; }
.summary .bar i { display: block; height: 100%; background: var(--good); width: 0; transition: width .3s; }
.summary .label { font-size: 14px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px 12px; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.card.off { opacity: .75; }
.card.off .who h3 { color: var(--muted); }
.card.mine { border-color: var(--accent); }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.who .slot { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-family: var(--display); font-weight: 600; }
.who h3 { margin-top: 2px; }
.head-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.count { font-family: var(--display); font-weight: 600; color: var(--muted); font-size: 14px; }
.count b { color: var(--fg); font-size: 18px; }
.off-toggle { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 3px 10px; font-size: 12px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.card.off .off-toggle { background: var(--off); color: #fff; border-color: var(--off); }
.route { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.route-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.route-head h4 { color: var(--fg); }
.route-head select, .flag-select { max-width: 130px; font: inherit; font-size: 13px; color: var(--muted); background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 2px 4px; }
.route-head select:hover, .flag-select:hover { border-color: var(--line); }
.tasks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.task { display: grid; grid-template-columns: 22px 1fr auto; align-items: start; gap: 8px; padding: 5px 0; min-width: 0; }
.task input[type="checkbox"] { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--good); }
.task .name { min-width: 0; overflow-wrap: anywhere; }
.task.done > .name, .task.done > label.name { color: var(--muted); text-decoration: line-through; }
.task .meta { font-size: 12px; color: var(--muted); white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.subs { list-style: none; margin: 0 0 0 30px; padding: 0; }
.subs .task { padding: 3px 0; font-size: 15px; }
.flag-note { font: inherit; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); padding: 3px 6px; width: 100%; min-width: 0; grid-column: 2 / -1; }
.evening-line { border-top: 1px solid var(--line); padding-top: 8px; display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; }
.evening-line .tag { font-family: var(--display); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.evening-line .evcover { grid-column: 2; }
.evening-line input[type="checkbox"] { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--good); }
.cover { border-color: var(--warn); background: var(--warn-soft); }
.pill { display: inline-block; border-radius: 999px; padding: 1px 8px; font-size: 12px; font-weight: 600; font-family: var(--display); letter-spacing: .03em; }
.pill.warn { background: var(--warn); color: #fff; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }
.pill.off { background: var(--off); color: #fff; }
.note { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; color: var(--muted); max-width: 62ch; }
.note b { color: var(--fg); }
.notes { margin-top: 16px; }
.notes textarea { width: 100%; min-height: 70px; font: inherit; font-size: 15px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); padding: 8px 10px; margin-top: 6px; resize: vertical; }
textarea.copybox { width: 100%; min-height: 160px; font: 14px/1.4 ui-monospace, Menlo, Consolas, monospace; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--fg); padding: 10px; margin-top: 10px; }
.thin { background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.thin-text { white-space: pre-line; margin-top: 4px; max-width: 70ch; }

/* Week + record tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; min-width: 640px; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-family: var(--display); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); white-space: nowrap; }
th.today, td.today { background: var(--accent-soft); }
td.rname { font-weight: 600; white-space: nowrap; }
td .sub { display: block; font-size: 12px; color: var(--muted); }
tr.evening td { border-top: 2px solid var(--line); }
tr.clickable { cursor: pointer; }
tr.detail td { background: var(--bg); }
td.needs { color: var(--warn); font-weight: 600; }
td.none { color: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 8px; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.log li { display: grid; grid-template-columns: 56px 110px 1fr auto; gap: 10px; align-items: center; font-size: 14px; }
.log li .t { font-variant-numeric: tabular-nums; color: var(--muted); }
.log li .flagbox { display: flex; gap: 6px; align-items: center; }

/* Setup */
.setup { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; min-width: 0; }
.panel.wide { grid-column: 1 / -1; }
.panel h2 { margin-bottom: 4px; }
.panel .hint { color: var(--muted); font-size: 13px; margin: 0 0 10px; max-width: 70ch; }
.pos { border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; background: var(--bg); }
.pos .full { grid-column: 1 / -1; }
.pos label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.pos label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 14px; color: var(--fg); }
.pos input[type="text"], .pos select { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--fg); width: 100%; min-width: 0; }
.pos .row-actions { grid-column: 1 / -1; display: flex; gap: 6px; justify-content: flex-end; }
.routebox { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; background: var(--bg); display: flex; flex-direction: column; gap: 6px; }
.routebox .rhead { display: flex; gap: 6px; align-items: center; }
.routebox .rhead .order { font-family: var(--display); font-weight: 700; color: var(--muted); width: 22px; text-align: center; }
.routebox input[type="text"] { flex: 1 1 auto; min-width: 0; font: inherit; font-weight: 600; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--fg); }
.routebox textarea { width: 100%; min-height: 96px; font: inherit; font-size: 14px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--fg); resize: vertical; }
.routebox .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.wk { display: grid; grid-template-columns: 56px 1fr; gap: 6px 10px; align-items: center; }
.wk input { font: inherit; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); width: 100%; min-width: 0; }
.wk span { font-family: var(--display); font-weight: 600; color: var(--muted); }
.days { display: flex; gap: 10px; flex-wrap: wrap; }
.daychk { display: flex; gap: 4px; align-items: center; font-size: 13px; color: var(--fg); }
.thin-input { width: 100%; min-height: 110px; font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); padding: 8px 10px; margin-top: 8px; resize: vertical; }
.select-input { min-height: 0; margin-top: 4px; }
.time-input { font: inherit; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); margin-left: 6px; }
.radio { display: flex; gap: 14px; flex-wrap: wrap; font-size: 15px; align-items: center; }
.radio label { display: flex; gap: 6px; align-items: center; }
.save-row { display: flex; gap: 8px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.status { font-size: 13px; color: var(--muted); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 8px 14px; border-radius: 8px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 20; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; }

/* Sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px; width: min(100%, 380px); display: grid; gap: 12px; }
.auth-card .sub { color: var(--muted); font-size: 14px; margin: 0; }
.auth-card label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.auth-card input { font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--fg); }
#auth-error { color: var(--warn); min-height: 1.2em; margin: 0; }

/* Wall display: bigger, no controls, same cards */
body.wall { font-size: 20px; }
body.wall .wrap { max-width: none; }
body.wall .tabs, body.wall .actions, body.wall .notes, body.wall .off-toggle, body.wall .route-head select, body.wall .flag-select, body.wall .icon-btn, body.wall #today-btn, body.wall #signout, body.wall #theme { display: none !important; }
body.wall h1 { font-size: 34px; } body.wall .datebar .date { font-size: 30px; } body.wall h3 { font-size: 28px; } body.wall h4 { font-size: 18px; }
body.wall .grid { grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
body.wall .task input[type="checkbox"], body.wall .evening-line input[type="checkbox"] { width: 26px; height: 26px; }
body.wall .task { grid-template-columns: 30px 1fr auto; }
body.wall .thin-text { font-size: 20px; }
body.wall #clock { font-size: 20px; color: var(--fg); font-family: var(--display); font-weight: 600; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
@media (max-width: 480px) { h1 { font-size: 22px; } .datebar .date { font-size: 17px; } .pos { grid-template-columns: 1fr; } .log li { grid-template-columns: 50px 1fr; } .log li .flagbox { grid-column: 1 / -1; } }

/* Finish target and after-routine line */
.target { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.after { border-top: 1px solid var(--line); padding-top: 8px; display: grid; gap: 4px; }
.after .tag { font-family: var(--display); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.after-input { font: inherit; font-size: 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); color: var(--fg); padding: 5px 8px; width: 100%; min-width: 0; }
.after-text { font-size: 15px; }
.mb8 { margin-bottom: 8px; }
body.wall .after-text { font-size: 20px; }

/* One line per route */
.route-line { display: flex; align-items: center; gap: 10px; min-width: 0; }
.route-line input[type="checkbox"] { width: 22px; height: 22px; margin: 0; accent-color: var(--good); flex-shrink: 0; }
.route-name { font-family: var(--display); font-weight: 700; font-size: 18px; min-width: 0; overflow-wrap: anywhere; flex: 1 1 auto; }
.route.done .route-name { color: var(--muted); text-decoration: line-through; }
.route-tasks { font-size: 13px; color: var(--muted); margin-left: 32px; }
.route-line select { margin-left: auto; }
body.wall .route-name { font-size: 24px; } body.wall .route-line input[type="checkbox"] { width: 28px; height: 28px; } body.wall .route-tasks { font-size: 16px; }
