*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --green: #3fb950;
  --green-dim: rgba(63, 185, 80, 0.08);
  --amber: #d4a017;
  --amber-dim: rgba(212, 160, 23, 0.09);
  --orange: #f0883e;
  --orange-dim: rgba(240, 136, 62, 0.1);
  --red: #f85149;
  --red-dim: rgba(248, 81, 73, 0.09);
  --blue: #2774ae;
  --radius: 10px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────── */

header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.875rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left h1 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.header-left .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  flex-shrink: 0;
}

#clock {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

#mute-btn {
  background: var(--border);
  border: 1px solid #3d444d;
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-size: 0.82rem;
  padding: 0.45rem 0.8rem;
  transition: background 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

#mute-btn:hover { background: #3a4048; }

/* ── Attention panel ─────────────────────────── */

.attention-panel {
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border);
  padding: 0.45rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.attention-panel.empty { display: none; }

.attention-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--orange);
  flex-shrink: 0;
}

.attention-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
}

.attention-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.76rem;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0.18rem 0.55rem;
  transition: background 0.4s, border-color 0.4s;
}

.attention-item.level-low {
  background: rgba(63, 185, 80, 0.09);
  border-color: rgba(63, 185, 80, 0.22);
}
.attention-item.level-low .attention-room { color: var(--green); }

.attention-item.level-med {
  background: rgba(212, 160, 23, 0.12);
  border-color: rgba(212, 160, 23, 0.3);
}
.attention-item.level-med .attention-room { color: var(--amber); }

.attention-item.level-high {
  background: rgba(240, 136, 62, 0.13);
  border-color: rgba(240, 136, 62, 0.35);
  font-weight: 500;
}
.attention-item.level-high .attention-room { color: var(--orange); }

.attention-item.level-urgent {
  background: rgba(248, 81, 73, 0.15);
  border-color: rgba(248, 81, 73, 0.5);
  font-weight: 600;
  animation: pulse-item 1.1s ease-in-out infinite;
}
.attention-item.level-urgent .attention-room { color: var(--red); }

@keyframes pulse-item {
  0%, 100% { box-shadow: none; }
  50%       { box-shadow: 0 0 0 3px rgba(248, 81, 73, 0.25); }
}

.attention-mins {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.08rem 0.3rem;
  border-radius: 3px;
  background: rgba(255,255,255,0.08);
}
.level-high   .attention-mins { color: var(--orange); }
.level-urgent .attention-mins { color: var(--red); }

.attention-room { font-weight: 700; }
.attention-next { color: var(--text-muted); }

/* ── Board grid ──────────────────────────────── */

#board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 0.875rem;
  padding: 1rem 1.25rem;
  flex: 1;
  align-content: start;
}

/* ── Room card ───────────────────────────────── */

.room-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: border-color 0.4s, background 0.4s;
}

.room-card.occupied {
  border-color: var(--orange);
  background: var(--orange-dim);
}

.room-card.free               { border-color: var(--green);  background: var(--green-dim); }
.room-card.free.level-med     { border-color: var(--amber);  background: var(--amber-dim); }
.room-card.free.level-high    { border-color: var(--orange); background: var(--orange-dim); }
.room-card.free.level-urgent  { border-color: var(--red);    background: var(--red-dim); }

/* Occupied cards ending soon */
.room-card.occupied.level-med    { border-color: var(--amber); }
.room-card.occupied.level-high   { border-color: var(--orange); }
.room-card.occupied.level-urgent { border-color: var(--red); }

/* Remaining time color follows urgency */
.room-card.level-med    .booking-remaining { color: var(--amber); }
.room-card.level-high   .booking-remaining { color: var(--orange); }
.room-card.level-urgent .booking-remaining { color: var(--red); font-weight: 700; }

/* Pulse on both free+urgent and occupied+urgent */
.room-card.level-urgent {
  animation: pulse-card 1.4s ease-in-out infinite;
}

@keyframes pulse-card {
  0%, 100% { box-shadow: 0 0 0 0   rgba(248, 81, 73, 0); }
  50%       { box-shadow: 0 0 0 5px rgba(248, 81, 73, 0.3); }
}

.room-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.room-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  padding: 0.22rem 0.55rem;
  border-radius: 5px;
  text-transform: uppercase;
  flex-shrink: 0;
}

.status-badge.occupied { background: var(--orange); color: #0d1117; }
.status-badge.free     { background: var(--green);  color: #0d1117; }

/* Badge inherits urgency color */
.room-card.level-med    .status-badge { background: var(--amber);  color: #0d1117; }
.room-card.level-high   .status-badge { background: var(--orange); color: #0d1117; }
.room-card.level-urgent .status-badge { background: var(--red);    color: #fff; }

/* ── Current booking ─────────────────────────── */

.current-booking {
  min-height: 2.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.booking-name {
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.booking-time {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.booking-remaining {
  font-size: 0.78rem;
  color: var(--orange);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

.free-label {
  font-size: 0.88rem;
  color: var(--green);
  font-weight: 500;
  margin-top: 0.3rem;
}
.level-med  .free-label { color: var(--amber); }
.level-high .free-label { color: var(--orange); }
.level-urgent .free-label { color: var(--red); font-weight: 600; }

/* ── Progress bar ────────────────────────────── */

.booking-progress {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.booking-progress-fill {
  height: 100%;
  background: var(--orange);
  border-radius: 2px;
  transition: width 1s linear;
}

/* ── Divider ─────────────────────────────────── */

.card-divider {
  border: none;
  border-top: 1px solid var(--border);
}

/* ── Next booking ────────────────────────────── */

.next-booking {
  font-size: 0.75rem;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
  min-width: 0;
}

.next-name {
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.next-time {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.no-more {
  color: var(--text-muted);
  opacity: 0.4;
  font-style: italic;
}

/* ── Status bar ──────────────────────────────── */

#status-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.4rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Loading placeholder ─────────────────────── */

#loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 3rem;
  font-size: 0.95rem;
}
