:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #17212b;
  --muted: #61707f;
  --line: #dde3ea;
  --brand: #0f766e;
  --brand-text: #ffffff;
  --danger: #b42318;
  --active: #16a34a;
  --online: #2563eb;
  --idle: #d97706;
  --locked: #7c3aed;
  --offline: #9aa5b1;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1418;
    --card: #182027;
    --text: #e8edf2;
    --muted: #93a1af;
    --line: #2a353f;
    --brand: #2dd4bf;
    --brand-text: #06201d;
    --danger: #f97066;
    --active: #22c55e;
    --online: #60a5fa;
    --idle: #f59e0b;
    --locked: #a78bfa;
    --offline: #5b6875;
    --shadow: none;
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

h1, h2 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.1rem; }
p { margin: 0; }

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.room-name { color: var(--muted); overflow-wrap: anywhere; }
.top nav { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

main:has(#view-admin:not([hidden])) { max-width: 1100px; }

section { display: grid; gap: 16px; }

.hero { display: grid; gap: 8px; padding: 8px 0; }
.hero p { color: var(--muted); max-width: 56ch; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 4px; font-weight: 600; font-size: 0.92rem; }
.form small { font-weight: 400; color: var(--muted); }

input {
  font: inherit;
  color: inherit;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}

input:focus-visible, .btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  white-space: nowrap;
}

.btn.primary { background: var(--brand); color: var(--brand-text); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); }
.btn.small { padding: 5px 10px; font-size: 0.85rem; }
.btn.danger { color: var(--danger); }
.btn.big { font-size: 1.2rem; padding: 14px 28px; }
.btn:disabled { opacity: 0.45; cursor: default; }

.row { display: flex; gap: 8px; justify-content: flex-end; }

.error { color: var(--danger); font-size: 0.92rem; }
.notice {
  background: color-mix(in srgb, var(--idle) 14%, transparent);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.92rem;
}
.muted { color: var(--muted); font-size: 0.9rem; }

.room-list { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.room-list a { color: var(--brand); font-weight: 600; }

/* Banners that ask for a permission or report a problem */
.banners { display: grid; gap: 8px; }
.banners:empty { display: none; }
.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--idle) 45%, var(--line));
  background: color-mix(in srgb, var(--idle) 12%, var(--card));
  font-size: 0.92rem;
}

.me { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.me-label { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.me-name { font-size: 1.25rem; font-weight: 700; overflow-wrap: anywhere; }

.board-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.person {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
}

.person.offline .who { opacity: 0.65; }

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--offline);
}
.dot.active { background: var(--active); box-shadow: 0 0 0 4px color-mix(in srgb, var(--active) 22%, transparent); }
.dot.online { background: var(--online); }
.dot.idle { background: var(--idle); }
.dot.locked { background: var(--locked); }

.who { min-width: 0; }
.who .name { font-weight: 600; overflow-wrap: anywhere; }
.who .you { font-weight: 400; color: var(--muted); font-size: 0.85rem; }
.who .sub { color: var(--muted); font-size: 0.88rem; }
.who .status { font-weight: 600; }
.status.active { color: var(--active); }
.status.online { color: var(--online); }
.status.idle { color: var(--idle); }
.status.locked { color: var(--locked); }

.ping-btn { min-width: 96px; }
.ping-btn.ringing { background: var(--idle); color: #201400; }
.ping-btn.answered { background: var(--active); color: #04210f; }

/* Incoming ping */
dialog {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  padding: 24px;
  width: min(92vw, 400px);
}
dialog::backdrop { background: rgba(8, 12, 16, 0.6); }

.ping-dialog { text-align: center; }
.ping-dialog[open] { display: grid; gap: 18px; justify-items: center; }
.ping-dialog h2 { font-size: 1.35rem; overflow-wrap: anywhere; }

.bell {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--brand);
  animation: pulse 1.2s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 60%, transparent); }
  100% { box-shadow: 0 0 0 26px transparent; }
}
@media (prefers-reduced-motion: reduce) {
  .bell { animation: none; }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.92rem;
  max-width: calc(100vw - 32px);
  z-index: 10;
}

/* Daily report */
.report-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.report-controls input { width: auto; padding: 8px 10px; }

.table-wrap { padding: 0; overflow-x: auto; }
.report { border-collapse: collapse; width: 100%; font-size: 0.92rem; }
.report th, .report td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.report tbody tr:last-child td { border-bottom: 0; }
.report th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }
.report .num { text-align: right; font-variant-numeric: tabular-nums; }
.report td.empty { color: var(--muted); text-align: center; padding: 28px; }
.report .name { font-weight: 600; }
.report .device { color: var(--muted); font-size: 0.82rem; }
.report .actions { display: flex; gap: 6px; justify-content: flex-end; }

.tl-head { min-width: 240px; display: flex; justify-content: space-between; }

.timeline {
  position: relative;
  min-width: 240px;
  height: 16px;
  border-radius: 4px;
  background:
    linear-gradient(to right, var(--line) 1px, transparent 1px) 0 0 / 25% 100%,
    var(--bg);
  overflow: hidden;
}
.timeline i { position: absolute; top: 0; bottom: 0; min-width: 1px; }
.timeline i.active, .sw.active { background: var(--active); }
.timeline i.online, .sw.online { background: var(--online); }
.timeline i.idle, .sw.idle { background: var(--idle); }
.timeline i.locked, .sw.locked { background: var(--locked); }

.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); font-size: 0.85rem; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

@media (max-width: 520px) {
  .person { grid-template-columns: auto 1fr; }
  .person .ping-btn { grid-column: 1 / -1; }
  .top nav { margin-left: 0; width: 100%; }
}
