*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #0b1f33;
  color: #f8fafc;
}

/* Must beat .display-setup { display: flex } or [hidden] panels stay visible */
[hidden] {
  display: none !important;
}

.display-setup {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  background: #f5f7fa;
  color: #1a1a1a;
}

.display-setup code {
  background: #e8edf3;
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
}

.display-setup .muted {
  color: #64748b;
}

.launch-form {
  margin: 1.25rem 0;
  text-align: left;
  max-width: 22rem;
  width: 100%;
}

.launch-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}

.launch-row {
  display: flex;
  gap: 0.5rem;
}

.launch-row input {
  flex: 1;
  font: inherit;
  padding: 0.55rem 0.65rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.35rem;
}

.launch-row button {
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.9rem;
  border: none;
  border-radius: 0.35rem;
  background: #0f4c81;
  color: #fff;
  cursor: pointer;
}

.display-root {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
}

.offline-banner {
  background: #b45309;
  color: #fff;
  text-align: center;
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: clamp(0.85rem, 1.5vw, 1.1rem);
}

.display-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem 0.65rem;
  background: linear-gradient(180deg, #0f4c81 0%, #0b3d66 100%);
  border-bottom: 3px solid #38bdf8;
}

.display-clinic {
  margin: 0;
  font-size: clamp(0.75rem, 1.2vw, 0.95rem);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.85;
}

.display-screen {
  margin: 0.15rem 0 0;
  font-size: clamp(1.25rem, 2.5vw, 2rem);
  font-weight: 700;
}

.display-clock {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.5rem);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  opacity: 0.9;
}

.boot-status {
  margin: 0.25rem 0 0;
  font-size: 0.85rem;
  color: #fde68a;
  min-height: 1.1rem;
}

.display-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.health-panel {
  flex: 0 0 70%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 0.75rem 1rem 0.5rem;
  background: #102a43;
  border-right: 2px solid #1e3a5f;
}

.ad-panel {
  flex: 0 0 30%;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #0a1628;
  position: relative;
}

.ad-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
  overflow: hidden;
}

.ad-stage img,
.ad-stage video {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0.35rem;
}

.ad-stage .ad-html {
  width: 100%;
  height: 100%;
  overflow: auto;
  font-size: clamp(0.8rem, 1.2vw, 1rem);
}

.ad-placeholder {
  text-align: center;
  padding: 1rem;
  color: #64748b;
}

.ad-label {
  margin: 0;
  padding: 0.35rem 0.75rem;
  text-align: center;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  background: #060d18;
}

.health-panel h2 {
  margin: 0 0 0.4rem;
  font-size: clamp(0.85rem, 1.4vw, 1.05rem);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.now-serving {
  flex: 0 0 auto;
  margin-bottom: 0.65rem;
}

.now-serving-list {
  display: grid;
  gap: 0.5rem;
}

.serving-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem 1rem;
  align-items: center;
  padding: 0.65rem 0.85rem;
  background: #16324f;
  border-radius: 0.5rem;
  border-left: 5px solid #fbbf24;
}

.serving-card.recalled {
  animation: flash-recall 1s ease-in-out infinite;
  border-left-color: #f97316;
}

@keyframes flash-recall {
  0%,
  100% {
    background: #16324f;
  }
  50% {
    background: #7c2d12;
  }
}

.serving-token {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #fde68a;
}

.serving-meta {
  font-size: clamp(0.9rem, 1.6vw, 1.25rem);
}

.serving-meta strong {
  display: block;
  font-size: clamp(1rem, 1.8vw, 1.35rem);
}

.serving-room {
  font-size: clamp(1.25rem, 2.5vw, 2rem);
  font-weight: 700;
  text-align: right;
  color: #7dd3fc;
}

.queue-section {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  margin-bottom: 0.5rem;
}

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
}

.queue-list li {
  display: grid;
  grid-template-columns: 5rem 1fr auto;
  gap: 0.75rem;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #1e3a5f;
  font-size: clamp(0.85rem, 1.4vw, 1.1rem);
}

.queue-list .token-num {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #bae6fd;
}

.queue-list .held {
  opacity: 0.65;
  font-style: italic;
}

.roster-section {
  flex: 0 0 auto;
  max-height: 28%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: 0.4rem;
  overflow-y: auto;
}

.roster-card {
  padding: 0.45rem 0.55rem;
  background: #16324f;
  border-radius: 0.35rem;
  font-size: clamp(0.75rem, 1.2vw, 0.95rem);
}

.roster-card .doc-name {
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.roster-status {
  display: inline-block;
  margin-top: 0.2rem;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
}

.roster-status.available {
  background: #064e3b;
  color: #6ee7b7;
}

.roster-status.in_consultation {
  background: #78350f;
  color: #fcd34d;
}

.roster-status.on_break {
  background: #374151;
  color: #d1d5db;
}

.roster-status.out_of_office {
  background: #450a0a;
  color: #fca5a5;
}

.ticker-bar {
  flex: 0 0 auto;
  background: #060d18;
  border-top: 2px solid #1e3a5f;
  overflow: hidden;
  padding: 0.45rem 0;
}

.ticker-track {
  display: inline-block;
  white-space: nowrap;
  padding-left: 100%;
  animation: ticker-scroll 40s linear infinite;
  font-size: clamp(0.85rem, 1.5vw, 1.15rem);
  color: #e2e8f0;
}

.ticker-track.paused {
  animation: none;
  padding-left: 1rem;
}

@keyframes ticker-scroll {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

.empty-hint {
  color: #64748b;
  font-size: clamp(0.85rem, 1.3vw, 1rem);
  margin: 0.25rem 0;
}

@media (max-width: 768px) {
  .display-body {
    flex-direction: column;
  }

  .health-panel,
  .ad-panel {
    flex: 1 1 auto;
  }

  .ad-panel {
    min-height: 25vh;
  }
}
