:root {
  --font: Helvetica, "Helvetica Neue", Arial, sans-serif;
  --blue-600: #2563eb;
  --blue-700: #1d4ed8;
  --blue-50: #eff6ff;
  --blue-100: #dbeafe;
  --green-600: #0f766e;
  --green-50: #f0fdfa;
  --green-100: #ccfbf1;
  --amber-600: #d97706;
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --red-600: #dc2626;
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --gray-900: #0f172a;
  --gray-700: #334155;
  --gray-600: #475569;
  --gray-500: #64748b;
  --gray-400: #94a3b8;
  --gray-300: #cbd5e1;
  --gray-200: #e2e8f0;
  --gray-100: #f1f5f9;
  --gray-50: #f8fafc;
  --white: #ffffff;
  --bg-app: #e8e8e8;
  --surface: var(--white);
  --raised: rgba(255, 255, 255, 0.9);
  --border: var(--gray-200);
  --text: var(--gray-900);
  --muted: var(--gray-500);
  --accent: var(--blue-600);
  --accent-soft: #eff6ff;
  --panel: #f9f9fd;
  --panel-muted: #ececf2;
  --shadow-card: 0 22px 52px rgba(15, 23, 42, 0.12);
  --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.08);
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 8px;
  --r-full: 9999px;
  --fluid: cubic-bezier(0.22, 1, 0.36, 1);
}

@property --complete-sweep {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

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

html {
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: linear-gradient(180deg, #ededed 0%, #e4e4e4 100%);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: var(--font); }

.app-frame {
  width: min(100%, 448px);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px 14px;
}

.app-frame.is-completed {
  width: min(100%, 760px);
}

.state-container {
  width: 100%;
  min-height: calc(100vh - 32px);
  min-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.status-completed {
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  align-content: center;
  align-items: stretch;
  gap: 18px;
}

.status-completed .track-header,
.status-completed .doctor-panel,
.status-completed .notice,
.status-completed .track-footer {
  grid-column: 1 / -1;
}

.loading-view,
.error-view {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--r-lg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--white), var(--blue-50));
  border: 1px solid var(--blue-100);
  color: var(--accent);
  font-weight: 900;
  overflow: hidden;
  flex: 0 0 auto;
}

.brand-logo {
  width: 72%;
  height: 72%;
  object-fit: contain;
  display: block;
}

.loader-ring {
  width: 56px;
  height: 56px;
  border: 4px solid var(--blue-100);
  border-top-color: var(--accent);
  border-radius: var(--r-full);
  animation: spin 0.9s linear infinite;
}

.loading-text,
.muted {
  color: var(--muted);
  font-size: 13px;
}

.track-header,
.doctor-panel,
.queue-overview-card,
.token-hero,
.now-serving-card,
.stat-card,
.journey-card,
.travel-planner,
.counter-alert,
.completed-card,
.cancelled-card,
.feedback-card,
.tv-card,
.tv-login-card {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(246, 247, 252, 0.94)),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-soft);
}

.track-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.07);
}

.brand-block {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-block > span:last-child {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
}

.brand-sub {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  background: var(--green-50);
  border: 2px solid var(--gray-900);
  box-shadow: 3px 3px 0 var(--gray-900);
  color: var(--green-600);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.connection-status.reconnecting {
  background: var(--amber-50);
  color: var(--amber-600);
}

.connection-status.disconnected {
  background: var(--red-50);
  color: var(--red-600);
}

.conn-dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
  animation: blink 1.6s ease-in-out infinite;
}

.doctor-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
}

.doctor-copy {
  min-width: 0;
}

.doctor-panel h1 {
  font-size: 20px;
  line-height: 1.15;
  letter-spacing: 0;
}

.visit-chip {
  flex: 0 0 auto;
  border-radius: var(--r-sm);
  padding: 7px 10px;
  background: var(--blue-50);
  border: 2px solid var(--gray-900);
  box-shadow: 3px 3px 0 var(--gray-900);
  color: var(--gray-900);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.eyebrow {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.tv-link,
.primary-btn,
.secondary-btn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--r-sm);
  padding: 8px 14px;
  background: linear-gradient(145deg, var(--accent), var(--blue-700));
  color: var(--white);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.secondary-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--gray-700);
}

.notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-md);
  font-size: 13px;
}

.delay-alert,
.paused-banner {
  background: var(--amber-50);
  border: 1px solid var(--amber-100);
  color: var(--amber-600);
}

.recall-banner {
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  color: var(--accent);
}

.token-hero {
  padding: 17px;
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-card);
}

.overview-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.overview-head h2 {
  margin-top: 4px;
  color: #101218;
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: 0;
}

.queue-state-pill {
  min-height: 34px;
  border-radius: var(--r-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  background: var(--green-50);
  border: 2px solid var(--gray-900);
  box-shadow: 3px 3px 0 var(--gray-900);
  color: var(--green-600);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.queue-state-pill.is-paused {
  background: var(--amber-50);
  color: var(--amber-600);
}

.queue-insight {
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--panel-muted);
  color: var(--gray-700);
  font-size: 12px;
  font-weight: 800;
}

.token-hero.is-paused .queue-insight {
  background: var(--amber-50);
  color: var(--amber-600);
}

.insight-icon {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1px solid rgba(37, 99, 235, 0.32);
  background:
    linear-gradient(135deg, rgba(37, 99, 235, 0.1), rgba(255, 255, 255, 0.9)),
    var(--white);
  position: relative;
  flex: 0 0 auto;
}

.insight-icon::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: var(--r-full);
  background: var(--accent);
}

.queue-gauge {
  min-height: 240px;
  margin: 12px 0 10px;
  display: grid;
  place-items: center;
  position: relative;
}

.gauge-arc {
  --progress: 18%;
  --gauge-color: var(--accent);
  --gauge-track: #e5e7eb;
  width: min(100%, 224px);
  aspect-ratio: 1;
  border-radius: var(--r-full);
  position: absolute;
  left: 50%;
  top: 10px;
  transform: translateX(-50%);
  background:
    conic-gradient(var(--gauge-color) var(--progress), var(--gauge-track) 0);
  box-shadow:
    inset 0 0 0 1px rgba(15, 23, 42, 0.05),
    0 18px 32px rgba(15, 23, 42, 0.08);
}

.gauge-arc::before {
  content: "";
  position: absolute;
  inset: 13px;
  border-radius: var(--r-full);
  background:
    repeating-conic-gradient(from -2deg, rgba(255, 255, 255, 0.92) 0deg 2.2deg, transparent 2.2deg 12deg);
  opacity: 0.8;
  pointer-events: none;
}

.gauge-arc::after {
  content: "";
  position: absolute;
  inset: 26px;
  border-radius: var(--r-full);
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.06);
}

.status-completed .gauge-arc,
.status-in_consultation .gauge-arc {
  --gauge-color: var(--green-600);
}

.status-cancelled .gauge-arc,
.status-skipped .gauge-arc {
  --gauge-color: var(--red-600);
}

.status-waiting .token-hero.is-paused .gauge-arc,
.token-hero.is-paused .gauge-arc {
  --gauge-color: var(--amber-600);
}

.gauge-center {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  align-content: center;
  width: 150px;
  min-height: 150px;
  margin-top: 10px;
  border-radius: var(--r-full);
  background: transparent;
  text-align: center;
}

.token-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: nowrap;
  min-height: 58px;
  margin: 3px 0 8px;
  color: var(--text);
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.token-number.is-long-token {
  font-size: 34px;
}

.token-status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border-radius: var(--r-sm);
  padding: 6px 12px;
  background: var(--amber-50);
  border: 2px solid var(--gray-900);
  box-shadow: 3px 3px 0 var(--gray-900);
  color: var(--amber-600);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.chip-dot {
  width: 7px;
  height: 7px;
  border-radius: var(--r-full);
  background: currentColor;
}

.status-called .token-status-chip {
  background: var(--blue-50);
  color: var(--accent);
}

.status-in_consultation .token-status-chip,
.status-completed .token-status-chip {
  background: var(--green-50);
  color: var(--green-600);
}

.status-cancelled .token-status-chip,
.status-skipped .token-status-chip {
  background: var(--red-50);
  color: var(--red-600);
}

.now-serving-card,
.stat-card {
  padding: 0;
  text-align: left;
}

.overview-metrics {
  display: grid;
  gap: 10px;
  position: relative;
  z-index: 1;
}

.metric-card {
  min-height: 74px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border: 1px solid rgba(15, 23, 42, 0.06);
  border-radius: var(--r-md);
  background: rgba(236, 236, 242, 0.78);
  box-shadow: none;
}

.metric-label {
  margin-bottom: 10px;
  color: #4b5563;
  font-size: 11px;
  font-weight: 800;
}

.metric-trend {
  border-radius: var(--r-sm);
  padding: 4px 8px;
  background: var(--white);
  border: 2px solid var(--gray-900);
  box-shadow: 2px 2px 0 var(--gray-900);
  color: var(--gray-900);
  font-size: 10px;
  font-weight: 900;
  line-height: 1.2;
  white-space: nowrap;
}

.live-trend {
  background: var(--blue-50);
  color: var(--accent);
}

.ns-token,
.stat-value {
  display: inline-flex;
  justify-content: flex-start;
  flex-wrap: nowrap;
  min-height: 28px;
  color: var(--text);
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stat-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.journey-card {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 14px 10px;
  gap: 8px;
}

.journey-step {
  display: grid;
  gap: 7px;
  justify-items: center;
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.journey-step span {
  width: 18px;
  height: 18px;
  border-radius: var(--r-full);
  border: 2px solid var(--gray-300);
  background: var(--white);
}

.journey-step.completed,
.journey-step.current {
  color: var(--accent);
}

.journey-step.completed span,
.journey-step.current span {
  border-color: var(--accent);
  background: var(--accent);
}

.travel-planner,
.counter-alert,
.completed-card,
.cancelled-card,
.feedback-card {
  padding: 16px;
}

.feedback-card {
  gap: 13px;
  box-shadow: var(--shadow-card);
  align-content: start;
  min-height: 344px;
}

.feedback-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 800;
}

.feedback-lang {
  border-radius: var(--r-sm);
  padding: 6px 9px;
  background: var(--green-50);
  border: 2px solid var(--gray-900);
  box-shadow: 2px 2px 0 var(--gray-900);
  color: var(--green-600);
  white-space: nowrap;
}

.feedback-copy {
  display: grid;
  gap: 5px;
}

.tp-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.tp-select,
.form-input,
.feedback-comment {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--white);
  color: var(--text);
  outline: none;
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color 180ms ease, box-shadow 180ms ease;
}

.tp-select:focus,
.form-input:focus,
.feedback-comment:focus {
  border-color: rgba(37, 99, 235, 0.48);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.tp-select { width: auto; padding: 7px 10px; }
.tp-body { text-align: center; color: var(--gray-700); }
.tp-highlight { color: var(--accent); font-weight: 900; }

.counter-alert {
  border-color: var(--blue-100);
  text-align: center;
}

.completed-card {
  min-height: 344px;
  align-content: center;
  justify-items: center;
  gap: 15px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(249, 249, 253, 0.96)),
    var(--surface);
}

.completion-ring {
  --complete-sweep: 360deg;
  width: 142px;
  height: 142px;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  padding: 10px;
  background:
    conic-gradient(from -90deg, var(--green-600) 0deg var(--complete-sweep), #e7eaef var(--complete-sweep) 360deg);
  box-shadow: 0 18px 30px rgba(15, 118, 110, 0.18);
  animation: completionFill 920ms var(--fluid) both;
}

.completion-ring-inner {
  width: 100%;
  height: 100%;
  border-radius: var(--r-full);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1px;
  background: var(--white);
}

.completion-ring strong {
  color: #0f172a;
  font-size: 30px;
  line-height: 1;
  font-weight: 900;
  max-width: 104px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.completion-ring strong.is-long-token {
  font-size: 23px;
  line-height: 1.05;
}

.completion-ring span {
  color: var(--gray-400);
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.completion-ring small {
  color: var(--green-600);
  font-size: 12px;
  font-weight: 800;
}

.completion-copy {
  display: grid;
  gap: 7px;
  justify-items: center;
}

.completion-copy h2 {
  color: #101218;
  font-size: 27px;
  line-height: 1.18;
}

.completion-note {
  width: 100%;
  border-radius: var(--r-md);
  padding: 11px 13px;
  background: var(--green-100);
  color: #115e59;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.35;
}

.counter-alert h2,
.completed-card h2,
.cancelled-card h2,
.feedback-card h2 {
  font-size: 20px;
}

.completed-card .completion-copy h2 {
  font-size: 27px;
}

.status-completed .feedback-card h2 {
  font-size: 23px;
  line-height: 1.18;
}

.alert-counter {
  margin-top: 8px;
  color: var(--accent);
  font-size: 28px;
  font-weight: 900;
}

.status-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green-50);
  border: 1px solid var(--green-100);
  color: var(--green-600);
  font-weight: 900;
}

.status-icon.danger {
  background: var(--red-50);
  border-color: var(--red-100);
  color: var(--red-600);
}

.rating-row {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin: 6px 0 8px;
}

.rating-btn {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--r-md);
  background: rgba(236, 236, 242, 0.78);
  color: var(--gray-400);
  cursor: pointer;
  font-size: 25px;
  font-weight: 900;
  line-height: 1;
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease, box-shadow 180ms ease;
}

.rating-btn.active {
  background: linear-gradient(180deg, #fbbf24, #f59e0b);
  border-color: rgba(245, 158, 11, 0.45);
  color: #ffffff;
  box-shadow: 0 8px 16px rgba(217, 119, 6, 0.22);
  transform: translateY(-1px);
}

.rating-caption {
  min-height: 17px;
  margin-bottom: 10px;
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.feedback-comment {
  resize: vertical;
  margin-bottom: 12px;
  min-height: 92px;
  background: rgba(255, 255, 255, 0.86);
}

.feedback-card .primary-btn {
  width: 100%;
  min-height: 44px;
  box-shadow: 0 10px 18px rgba(37, 99, 235, 0.2);
}

.feedback-card .primary-btn:disabled {
  cursor: wait;
  opacity: 0.72;
}

.is-submitting {
  opacity: 0.78;
  pointer-events: none;
}

.feedback-success {
  border-radius: var(--r-md);
  padding: 12px;
  background: var(--green-50);
  border: 1px solid var(--green-100);
  color: var(--green-600);
  font-weight: 800;
  text-align: center;
}

.feedback-error {
  border-radius: var(--r-md);
  padding: 10px 12px;
  background: var(--red-50);
  border: 1px solid var(--red-100);
  color: var(--red-600);
  font-size: 13px;
  font-weight: 800;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.track-footer {
  margin-top: auto;
  padding: 18px 4px 4px;
  display: grid;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  font-size: 12px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  color: var(--gray-600);
}

.footer-links a {
  color: var(--accent);
  font-weight: 800;
}

.made-by {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.made-by span {
  color: var(--gray-500);
  font-weight: 700;
}

.copyright { color: var(--gray-400); }
.compact { margin-top: 16px; }

.error-view h1 {
  font-size: 24px;
}

.error-view p {
  max-width: 320px;
  color: var(--muted);
  line-height: 1.5;
}

.rolling-value {
  font-variant-numeric: tabular-nums;
}

.roll-digit,
.roll-char {
  display: inline-block;
  flex: 0 0 auto;
  min-width: 0.64em;
  text-align: center;
  color: inherit;
  line-height: inherit;
}

.value-changed .roll-digit {
  animation: digitRoll 560ms var(--fluid);
}

.value-changed .roll-char {
  animation: charPop 360ms var(--fluid);
}

.value-changed {
  animation: valueGlow 580ms var(--fluid);
}

/* Adapted from the requested rolling counter: the digit scrolls through a short vertical stack on change. */
@keyframes digitRoll {
  0% { transform: translateY(-0.52em); filter: blur(1px); }
  72% { transform: translateY(0.08em); filter: blur(0); }
  100% { transform: translateY(0); }
}

@keyframes charPop {
  0% { transform: scale(0.92); opacity: 0.55; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes valueGlow {
  0% { color: var(--accent); }
  100% { color: inherit; }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes shimmer {
  0% { background-position: -220% 0; }
  100% { background-position: 220% 0; }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes completionFill {
  from {
    --complete-sweep: 0deg;
    transform: scale(0.96);
  }
  to {
    --complete-sweep: 360deg;
    transform: scale(1);
  }
}

/* Hospital TV */
.tv-app {
  width: min(100%, 1180px);
  margin: 0 auto;
  padding: 20px;
  min-height: 100vh;
  min-height: 100dvh;
}

.tv-shell {
  min-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.tv-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tv-brand h1 {
  font-size: clamp(22px, 3vw, 36px);
  line-height: 1.1;
}

.tv-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tv-login-view {
  min-height: calc(100vh - 40px);
  display: grid;
  place-items: center;
}

.tv-login-card {
  width: min(100%, 420px);
  padding: 24px;
  display: grid;
  gap: 14px;
}

.tv-login-card h1 {
  font-size: 28px;
}

.form-group {
  display: grid;
  gap: 6px;
}

.form-group label {
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.tv-dashboard {
  display: grid;
  grid-template-columns: minmax(280px, 0.7fr) minmax(420px, 1.3fr);
  gap: 16px;
  align-items: start;
}

.tv-card {
  padding: 18px;
}

.doctor-select-card {
  display: grid;
  gap: 14px;
}

.tv-current {
  min-height: 420px;
  display: grid;
  place-items: center;
  text-align: center;
}

.tv-token-label {
  color: var(--muted);
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
}

.tv-token {
  display: inline-flex;
  justify-content: center;
  min-height: 128px;
  color: var(--accent);
  font-size: clamp(82px, 13vw, 156px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0;
}

.tv-status {
  margin-top: 12px;
  display: inline-flex;
  border-radius: var(--r-full);
  padding: 8px 18px;
  background: var(--blue-50);
  border: 1px solid var(--blue-100);
  color: var(--accent);
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
}

.tv-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 16px;
}

.tv-stat {
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--white);
  border: 1px solid var(--border);
  text-align: center;
}

.tv-stat strong {
  display: block;
  font-size: 34px;
  line-height: 1;
}

.tv-stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.tv-list {
  display: grid;
  gap: 8px;
}

.tv-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--white);
}

.tv-row-token {
  color: var(--accent);
  font-size: 24px;
  font-weight: 900;
}

.tv-row-name {
  min-width: 0;
  font-size: 16px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tv-row-status {
  color: var(--gray-600);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.tv-error {
  color: var(--red-600);
  font-size: 13px;
  font-weight: 700;
}

@media (max-width: 760px) {
  .app-frame,
  .app-frame.is-completed { width: min(100%, 448px); padding: 12px; }
  .state-container { min-height: calc(100vh - 24px); }
  .status-completed { grid-template-columns: 1fr; align-content: start; gap: 14px; }
  .doctor-panel { align-items: flex-start; flex-direction: column; }
  .visit-chip { max-width: 100%; white-space: normal; }
  .token-hero { padding: 15px; }
  .overview-head h2 { font-size: 22px; }
  .queue-gauge { min-height: 226px; }
  .gauge-arc { width: min(100%, 208px); }
  .token-number { font-size: 48px; min-height: 55px; }
  .token-number.is-long-token { font-size: 31px; }
  .completed-card,
  .feedback-card { min-height: auto; }
  .completion-ring { width: 130px; height: 130px; }
  .completed-card .completion-copy h2 { font-size: 25px; }
  .rating-btn { width: 42px; height: 42px; }
  .tv-app { padding: 14px; }
  .tv-header,
  .tv-actions { align-items: stretch; flex-direction: column; }
  .tv-dashboard { grid-template-columns: 1fr; }
  .tv-stats { grid-template-columns: 1fr; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .rating-row { gap: 6px; }
  .rating-btn { width: 38px; height: 38px; font-size: 21px; }
  .queue-insight { align-items: flex-start; }
  .gauge-arc { width: min(100%, 194px); }
  .gauge-center { width: 138px; min-height: 138px; }
}
