:root {
  --bg: #f4f6f8;
  --surface: #fff;
  --line: #e4e8ec;
  --line-soft: #eef1f4;
  --text: #111827;
  --muted: #64748b;
  --accent: #0f766e;
  --accent-hover: #0d5f59;
  --accent-soft: #e6f4f1;
  --in: #15803d;
  --in-soft: #e7f6ec;
  --out: #475569;
  --out-soft: #eef1f5;
  --none: #b45309;
  --none-soft: #fdf3e2;
  --misread: #be123c;
  --misread-soft: #fde8ec;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 8px rgba(15, 23, 42, .05);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 48px; }
h1 { font-size: 26px; line-height: 1.25; letter-spacing: -.01em; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 0 0 10px; }
p { margin: 0 0 14px; }
a { color: var(--accent); text-underline-offset: 2px; }
code { font: 14px ui-monospace, Consolas, monospace; background: var(--line-soft); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

.mark { width: 30px; height: 30px; flex: none; display: block; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 10px 24px; background: rgba(255, 255, 255, .92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(1.4) blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--text); text-decoration: none; }
.top nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; scrollbar-width: none; }
.top nav::-webkit-scrollbar { display: none; }
.top nav a {
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px;
  padding: 7px 12px; border-radius: 9px; white-space: nowrap;
}
.top nav a:hover { color: var(--text); background: var(--line-soft); }
.top nav a.on { color: var(--accent); background: var(--accent-soft); }
.logout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 15px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 14px;
}

.banner { display: flex; align-items: center; gap: 10px; background: var(--danger); color: #fff; font-weight: 600; padding: 12px 24px; }
.banner::before { content: "!"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: #fff; color: var(--danger); font-weight: 800; flex: none; }

/* Page heading */
.heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; margin-bottom: 20px; }
.heading h1 { margin: 0; }
.live { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--in); box-shadow: 0 0 0 3px var(--in-soft); }
.lead { color: var(--muted); margin: -2px 0 20px; max-width: 760px; }

/* Tiles */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.tile {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 18px 14px; box-shadow: var(--shadow); color: var(--muted); font-size: 14px; font-weight: 500;
}
.tile::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: #cbd5e1; }
.tile .n { display: block; font-size: 34px; font-weight: 700; line-height: 1.15; color: var(--text); font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.tile.in::before { background: var(--in); }
.tile.in .n { color: var(--in); }
.tile.out::before { background: var(--out); }
.tile.none::before { background: #f59e0b; }
.tile.none .n { color: var(--none); }

/* Tablet health */
.health {
  padding: 10px 14px 10px 32px; position: relative; border-radius: 12px; margin-bottom: 20px; font-size: 15px;
  background: var(--in-soft); color: #14532d; border: 1px solid #cdebd6;
}
.health::before { content: ""; position: absolute; left: 14px; top: 19px; width: 8px; height: 8px; border-radius: 50%; background: var(--in); }
.health.bad { background: #fdecec; color: #7f1d1d; border-color: #f7cfcf; }
.health.bad::before { background: var(--danger); }
.health .warn { color: #b91c1c; font-weight: 600; }

/* Tables */
.table-wrap {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow-x: auto; margin-bottom: 24px;
}
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.list th {
  background: #f8fafb; color: var(--muted); font-size: 12px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; white-space: nowrap;
}
table.list tbody tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #fafbfc; }
table.list td a { color: var(--text); font-weight: 600; text-decoration: none; }
table.list td a:hover { color: var(--accent); text-decoration: underline; }
table.list td.muted { text-align: center; padding: 32px 16px; }
.sub { color: var(--muted); font-size: 15px; }

/* Status pills */
.status {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px 3px 8px;
  border-radius: 999px; font-size: 14px; font-weight: 600; white-space: nowrap;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.in { background: var(--in-soft); color: var(--in); }
.status.out { background: var(--out-soft); color: var(--out); }
.status.none { background: var(--none-soft); color: var(--none); }
.status.misread { background: var(--misread-soft); color: var(--misread); }
.tag { font-size: 13px; font-weight: 600; background: var(--line-soft); color: var(--muted); padding: 3px 10px; border-radius: 999px; vertical-align: middle; }

.back { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; text-decoration: none; margin-bottom: 10px; }
.back:hover { text-decoration: underline; }
.day h2 { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .05em; margin: 4px 0 10px; }

/* Cards and forms */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 24px; margin-bottom: 18px; max-width: 640px;
}
.card > :last-child { margin-bottom: 0; }
.card form { margin-bottom: 12px; }
label { display: block; margin-bottom: 14px; font-size: 14px; font-weight: 600; color: #334155; }
input:not([type=checkbox]), select {
  display: block; width: 100%; font: inherit; font-size: 16px; font-weight: 400; color: var(--text);
  padding: 10px 12px; margin-top: 6px; background: #fff;
  border: 1px solid #cfd6de; border-radius: 10px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(15, 118, 110, .18); }
input[type=checkbox] { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); flex: none; }
label.check { display: flex; align-items: center; gap: 10px; font-weight: 500; color: var(--text); font-size: 15px; }
form.inline { display: flex; gap: 8px; align-items: center; }
form.inline label { margin: 0; display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--muted); }
form.inline select { width: auto; margin: 0; padding: 7px 10px; }
.error { background: #fdecec; color: #991b1b; border: 1px solid #f7cfcf; padding: 10px 14px; border-radius: 10px; font-size: 15px; }
.code {
  font: 700 40px/1.2 ui-monospace, Consolas, monospace; letter-spacing: 6px; color: var(--accent);
  background: var(--accent-soft); border-radius: 12px; padding: 14px 18px; display: inline-block; margin: 4px 0 14px;
}

button {
  font: inherit; font-size: 15px; font-weight: 600; padding: 9px 16px; border-radius: 10px;
  border: 1px solid #cfd6de; background: #fff; color: var(--text); cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
button:hover { background: var(--line-soft); }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(15, 118, 110, .35); outline-offset: 2px; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.logout button { padding: 6px 12px; font-size: 14px; }

/* Sign-in page */
body.auth {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #d7efe9 0%, transparent 60%), var(--bg);
}
body.auth main { width: 100%; max-width: 440px; padding: 32px 20px; }
.login { max-width: none; padding: 32px 30px 28px; }
.login .mark { width: 44px; height: 44px; margin-bottom: 18px; }
.login h1 { font-size: 24px; margin-bottom: 4px; }
.login .lead { margin: 0 0 22px; }
.login button.primary { width: 100%; padding: 12px 16px; font-size: 16px; margin-top: 6px; }
.login .hint { font-size: 13px; color: var(--muted); margin: 6px 0 16px 28px; }
.optional { font-weight: 400; color: var(--muted); }
.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 18px; }

.login.behind { filter: blur(2px); opacity: .55; pointer-events: none; user-select: none; }
.overlay {
  position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px;
  background: rgba(15, 23, 42, .35); animation: fade .15s ease-out;
}
.modal { width: 100%; max-width: 380px; padding: 28px 26px 22px; box-shadow: 0 20px 50px rgba(15, 23, 42, .25); animation: rise .18s ease-out; }
.modal h2 { font-size: 20px; margin-bottom: 4px; }
.modal .lead { margin: 0 0 18px; }
.otp { text-align: center; font: 600 26px/1.2 ui-monospace, Consolas, monospace !important; letter-spacing: 8px; padding: 12px !important; margin: 0 0 14px !important; }
.otp::placeholder { color: #cbd5e1; letter-spacing: 6px; }
.modal button.primary { width: 100%; padding: 12px 16px; font-size: 16px; }
.cancel { display: block; text-align: center; margin-top: 12px; color: var(--muted); font-size: 14px; text-decoration: none; }
.cancel:hover { color: var(--text); text-decoration: underline; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .overlay, .modal { animation: none; } }

@media (max-width: 760px) {
  main { padding: 20px 16px 40px; }
  h1 { font-size: 22px; }
  .top { flex-wrap: wrap; gap: 8px 12px; padding: 10px 16px 0; }
  .top nav { order: 3; flex-basis: 100%; margin: 0 -16px; padding: 0 12px 8px; }
  .logout { margin-left: auto; }
  .who span:last-child { display: none; }
  .tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .tile .n { font-size: 28px; }
  .card { padding: 18px; }
  table.list th, table.list td { padding: 10px 12px; }
  .banner { padding: 12px 16px; }
}
