:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #e4e8ed;
  --line-soft: #eef1f4;
  --text: #1f2328;
  --muted: #6b7280;
  --open: #2f9e6b;
  --open-soft: #e8f6ef;
  --closed: #d1685a;
  --warn: #b07d18;
  --bad: #c2410c;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0 2rem 3.5rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.75rem 0 0.5rem;
  gap: 1rem;
}

h1 { font-size: 1.5rem; margin: 0; font-weight: 650; letter-spacing: -0.01em; }

h2 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 2.25rem 0 0.9rem;
  font-weight: 650;
}

.badge {
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  box-shadow: var(--shadow);
  white-space: nowrap;
}
.badge-live { color: var(--open); border-color: #bfe4d2; background: var(--open-soft); }
.badge-wait { color: var(--warn); border-color: #ecdcb4; background: #fdf6e7; }
.badge-dead { color: var(--bad); border-color: #f3cdbb; background: #fdefe8; }

.notice {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 4px solid var(--warn);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1.1rem 1.3rem;
  margin-top: 1.5rem;
}
.notice h3 { margin: 0 0 0.4rem; font-size: 1rem; }
.notice p { margin: 0.3rem 0 0; color: var(--muted); font-size: 0.9rem; }
.notice code {
  background: var(--line-soft);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.hidden { display: none; }

/* --- Døre ------------------------------------------------------------ */

.wc-row { display: flex; flex-wrap: wrap; gap: 0.8rem; }

.wc {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 0.85rem 0.9rem 0.8rem;
  width: 132px;
  text-align: center;
}

.wc-frame {
  position: relative;
  width: 68px;
  height: 88px;
  margin: 0 auto 0.6rem;
  perspective: 440px;
}

.wc-room {
  position: absolute;
  inset: 0;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(#eceff3, #e2e6eb);
  border: 2px solid #cdd4dc;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 8px;
  overflow: hidden;
}

.wc-toilet { width: 30px; height: auto; fill: #aab4c0; }

.wc-door {
  position: absolute;
  inset: 0;
  border-radius: 6px 6px 3px 3px;
  background: linear-gradient(160deg, #fdfefe, #eef1f5);
  border: 2px solid #c8d0d9;
  transform-origin: left center;
  transition: transform 0.55s cubic-bezier(0.34, 1.2, 0.4, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset -6px 0 12px -8px rgba(31, 35, 40, 0.25);
}

.wc.is-open .wc-door { transform: rotateY(-74deg); }

.wc-door::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 50%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #9aa5b1;
  transform: translateY(-50%);
}

.wc-sign { width: 28px; height: auto; fill: #8d97a3; color: #8d97a3; }

.wc-name { font-weight: 650; font-size: 0.88rem; }
.wc-state { font-size: 0.95rem; font-weight: 700; margin-top: 0.1rem; }
.wc.is-open .wc-state { color: var(--open); }
.wc.is-closed .wc-state { color: var(--closed); }
.wc.is-unknown .wc-state { color: var(--muted); }
.wc-meta { margin-top: 0.5rem; font-size: 0.68rem; color: var(--muted); }

/* --- Kort ------------------------------------------------------------- */

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.9rem;
}

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

.card-name { font-weight: 650; }
.card-room { font-size: 0.78rem; color: var(--muted); margin-top: 0.1rem; min-height: 1.1em; }

.state { font-size: 1.5rem; font-weight: 700; margin-top: 0.55rem; }
.state-open { color: var(--open); }
.state-closed { color: var(--closed); }
.state-unknown { color: var(--muted); }

.readings { display: flex; flex-wrap: wrap; gap: 0.4rem 1.3rem; margin-top: 0.7rem; }
.reading-value { font-size: 1.3rem; font-weight: 650; }

.reading-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.meta {
  margin-top: 0.8rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--line-soft);
  font-size: 0.7rem;
  color: var(--muted);
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.flag-bad { color: var(--bad); font-weight: 600; }
.flag-warn { color: var(--warn); font-weight: 600; }

.empty { color: var(--muted); font-size: 0.85rem; margin: 0; }

/* --- Statistik -------------------------------------------------------- */

.section-note {
  font-weight: 400;
  font-size: 0.68rem;
  text-transform: none;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 0.5rem;
}

.stats {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 0.4rem 1.15rem 0.9rem;
  overflow-x: auto;
}

.stats table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }

.stats th {
  text-align: right;
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 650;
  padding: 0.7rem 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.stats th:first-child, .stats td:first-child { text-align: left; }

.stats td {
  text-align: right;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
}
.stats tbody tr:last-child td { border-bottom: none; }

.stats .stat-name { font-weight: 650; white-space: nowrap; }
.stats .stat-zero { color: var(--muted); }
.stats .stat-forgotten { color: var(--warn); font-weight: 600; }

/* Vinderen af dagen — flest besøg. */
.stats .stat-trophy { margin-right: 0.35rem; }
.stats tr.is-winner td { background: var(--open-soft); }
.stats tr.is-winner td:first-child { border-radius: 8px 0 0 8px; }
.stats tr.is-winner td:last-child { border-radius: 0 8px 8px 0; }

/* Søjlen gør fordelingen læsbar på afstand, hvor tal alene ikke er. */
.stats th.stat-usage-head { text-align: left; width: 34%; }

.stats .stat-usage { display: flex; align-items: center; gap: 0.6rem; }

.stats .stat-track {
  flex: 1;
  min-width: 60px;
  height: 9px;
  background: var(--line-soft);
  border-radius: 5px;
  overflow: hidden;
}

.stats .stat-bar {
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #6cc79a, var(--open));
  transition: width 0.5s ease;
}
.stats tr.is-winner .stat-bar {
  background: linear-gradient(90deg, #f0c14b, #d99b1c);
}

.coffee-headline { display: flex; align-items: baseline; gap: 0.6rem; padding: 0.7rem 0 0.2rem; }
.coffee-count { font-size: 2rem; font-weight: 700; line-height: 1; }
.coffee-label { color: var(--muted); font-size: 0.85rem; }

/* Ugesøjler */
.week {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  height: 92px;
  margin: 0.9rem 0 0.2rem;
}

.week-col { flex: 1; display: flex; flex-direction: column; height: 100%; }

.week-value {
  font-size: 0.72rem;
  font-weight: 650;
  text-align: center;
  color: var(--muted);
  height: 1.1em;
}

.week-track { flex: 1; display: flex; align-items: flex-end; }

.week-bar {
  width: 100%;
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: #cdd8e2;
}
.week-col.is-today .week-bar { background: linear-gradient(180deg, #6cc79a, var(--open)); }
.week-col.is-today .week-value { color: var(--open); }

.week-day {
  font-size: 0.66rem;
  text-align: center;
  color: var(--muted);
  padding-top: 0.3rem;
}

.week-total { font-size: 0.72rem; color: var(--muted); margin: 0 0 0.4rem; }

.stats .stat-count {
  min-width: 1.8em;
  text-align: right;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

footer { margin-top: 2.5rem; font-size: 0.72rem; color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .wc-door { transition: none; }
}

/* Perioder der ikke blev talt som kaffe - opstart, rensning, damp. */
.stats tr.is-ignored td { color: var(--muted); }

/* --- Udfoldelige besøg med farvetrin på varigheden --- */

.stats .stat-row { cursor: pointer; }
.stats .stat-row:hover td { background: var(--line-soft); }
.stats .caret {
  display: inline-block;
  width: 1em;
  color: var(--muted);
  font-size: 0.8em;
}

.stats tr.visits.is-hidden { display: none; }
.stats tr.visits td { background: var(--line-soft); padding: 0.5rem 0.9rem; }

.visit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 0.15rem 1.2rem;
  text-align: left;
}
.visit-list li { font-size: 0.82rem; }
.visit-time { font-variant-numeric: tabular-nums; }
.visit-empty { color: var(--muted); font-size: 0.82rem; text-align: left; }

.visit-len {
  font-weight: 650;
  margin-left: 0.5rem;
  padding: 0.02rem 0.4rem;
  border-radius: 5px;
}
.visit-len.dur-short    { color: #1f7a4d; background: #e4f4ec; }
.visit-len.dur-mid      { color: #8a6410; background: #fdf3dc; }
.visit-len.dur-long     { color: #a4501c; background: #fdeadd; }
.visit-len.dur-verylong { color: #a32f22; background: #fce4e1; }
.visit-len.dur-forgotten{ color: #5b6470; background: #e7eaee; }
.visit-len.dur-forgotten::after { content: " · glemt dør"; font-weight: 400; }

.visit-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  margin: 0 0 0.5rem;
  font-size: 0.7rem;
  color: var(--muted);
  align-items: center;
}

/* --- Toiletter pr. ugedag --------------------------------------------- */

/* Dagens mest brugte toilet. Farven er den samme som vinderrækken i dagens
   tabel, så pokalen betyder det samme to steder. */
.stats td.wc-best {
  background: var(--open-soft);
  font-weight: 650;
  border-radius: 6px;
}

.stats tr.is-today .stat-name { font-weight: 700; }

/* --- Sammenfoldede kaffetider ----------------------------------------- */

.peek-toggle {
  background: none;
  border: none;
  padding: 0.35rem 0;
  margin: 0;
  font: inherit;
  font-size: 0.82rem;
  color: var(--muted);
  cursor: pointer;
  display: block;
}
.peek-toggle:hover { color: var(--text); }

.peek-body.is-hidden { display: none; }
