:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --brand: #0f766e;
  --brand-ink: #0b5e57;
  --line: #e2e8f0;
  --ok: #15803d;
  --ok-bg: #dcfce7;
  --warn: #b45309;
  --warn-bg: #fef3c7;
  --off: #475569;
  --off-bg: #e2e8f0;
  --danger: #b91c1c;
  --danger-bg: #fee2e2;
  --radius: 14px;
}
* { box-sizing: border-box; }
/* hidden must always win: .sheet/.login set an explicit display that would otherwise
   override the UA [hidden] rule and leave a full-screen overlay capturing all input. */
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: system-ui, "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.view { min-height: 100vh; min-height: 100dvh; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
button { font: inherit; cursor: pointer; }

/* ===== Login ===== */
.login { display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: 100%; max-width: 380px; background: var(--card);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: 0 8px 30px rgba(15,23,42,.06);
}
.brand { font-size: 20px; font-weight: 800; display: flex; align-items: center; gap: 8px; color: var(--brand-ink); }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--brand); display: inline-block; }
.login-card p { margin: 6px 0 18px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
input {
  width: 100%; margin-top: 6px; padding: 12px; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
button[type=submit], #repRun {
  width: 100%; padding: 13px; font-size: 16px; font-weight: 700; color: #fff;
  background: var(--brand); border: none; border-radius: 10px; margin-top: 4px;
}
button[disabled] { opacity: .6; }
.error { background: var(--danger-bg); color: var(--danger); padding: 10px 12px; border-radius: 10px; margin-top: 12px; font-size: 14px; }

/* ===== App shell ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px calc(14px + env(safe-area-inset-top)); padding-top: max(14px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.hello { font-weight: 800; font-size: 17px; }
.topbar .muted { color: #c9efe9; }
.ghost { background: transparent; border: 1px solid rgba(255,255,255,.4); color: #fff; padding: 7px 12px; border-radius: 9px; }
.tabs { display: flex; gap: 8px; padding: 12px 16px 0; background: var(--brand); }
.tab { flex: 1; background: rgba(255,255,255,.15); color: #fff; border: none; padding: 10px; border-radius: 10px 10px 0 0; font-weight: 700; }
.tab.active { background: var(--bg); color: var(--brand-ink); }
.tab-body { padding: 16px; }

/* day / range bars */
.daybar { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.daybar input { text-align: center; }
.daybar .ghost { border-color: var(--line); color: var(--ink); background: #fff; }
.rangebar { display: flex; gap: 8px; align-items: end; flex-wrap: wrap; margin-bottom: 14px; }
.rangebar label { flex: 1; margin: 0; }
.rangebar #repRun { width: auto; padding: 12px 18px; margin: 0; }

/* chips */
.chips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.chip { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: center; }
.chip b { display: block; font-size: 22px; }
.chip span { font-size: 12px; color: var(--muted); }
.chip.in b { color: var(--ok); }
.chip.wait b { color: var(--warn); }
.chip.out b { color: var(--off); }

/* list */
.list { display: flex; flex-direction: column; gap: 8px; }
.group-h { font-size: 13px; font-weight: 800; color: var(--brand-ink); margin: 10px 2px 2px; }
.row {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.row .who { min-width: 0; }
.row .name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { font-size: 12px; color: var(--muted); }
.times { text-align: left; font-variant-numeric: tabular-nums; white-space: nowrap; }
.times .io { font-size: 13px; }
.pill { font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.pill.in { background: var(--ok-bg); color: var(--ok); }
.pill.wait { background: var(--warn-bg); color: var(--warn); }
.pill.out { background: var(--off-bg); color: var(--off); }
.pill.leave { background: #e0e7ff; color: #4338ca; }
.pill.issue { background: var(--danger-bg); color: var(--danger); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* sheet */
.sheet { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-end; z-index: 50; }
.sheet-card { background: var(--bg); width: 100%; max-height: 85vh; overflow: auto; border-radius: 18px 18px 0 0; padding: 16px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sheet-head .ghost { border-color: var(--line); color: var(--ink); }
.day-row { display: flex; justify-content: space-between; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.day-row .d { font-weight: 700; font-variant-numeric: tabular-nums; }
