/* ==========================================================================
   QLive demos — shared design layer
   One design language across Basic, Professional and Premium. Each tier then
   layers its own stylesheet on top to raise the level of finish; the tokens,
   components and behaviour below stay common so the three feel like one family.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --font-display: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --brand-50:#EEF3FF; --brand-100:#DBE5FF; --brand-200:#B8CBFF; --brand-300:#8AA9FF;
  --brand-400:#4B7BFB; --brand-500:#1554F0; --brand-600:#0B41D0; --brand-700:#0A35A6;

  --violet:#3B5BDB; --amber:#C2740A; --rose:#D91E45; --sky:#0B63CE; --whatsapp:#25D366;

  --r-xs:6px; --r-sm:10px; --r-md:14px; --r-lg:20px; --r-xl:28px; --r-pill:999px;
  --ease: cubic-bezier(.16,1,.3,1);
  --ease-soft: cubic-bezier(.4,0,.2,1);
  --topbar-h: 62px;
}

/* ---- Light ---- */
:root, [data-theme="light"] {
  color-scheme: light;
  --bg:#F7F9FD; --bg-alt:#EEF2FA; --surface:#FFFFFF; --surface-2:#F6F9FE; --surface-3:#E9EFFA;
  --ink:#0A0F1F; --text:#1F2739; --muted:#5A6478; --faint:#8B94A6;
  --line:rgba(10,15,28,.10); --line-strong:rgba(10,15,28,.17); --line-soft:rgba(10,15,28,.06);
  --brand:var(--brand-500); --brand-text:var(--brand-700); --brand-tint:var(--brand-50);
  --on-brand:#FFFFFF;
  --shadow-xs:0 1px 2px rgba(10,15,28,.05);
  --shadow-sm:0 2px 8px rgba(10,15,28,.06);
  --shadow-md:0 12px 28px -12px rgba(10,15,28,.18);
  --shadow-lg:0 32px 64px -28px rgba(10,15,28,.3);
}

/* ---- Dark ---- */
[data-theme="dark"] {
  color-scheme: dark;
  --bg:#060912; --bg-alt:#0A0F20; --surface:#0F1730; --surface-2:#141D3B; --surface-3:#1A2549;
  --ink:#F4F7FC; --text:#D6DDEC; --muted:#96A1BA; --faint:#6D7896;
  --line:rgba(255,255,255,.10); --line-strong:rgba(255,255,255,.19); --line-soft:rgba(255,255,255,.06);
  --brand:var(--brand-400); --brand-text:var(--brand-300); --brand-tint:rgba(75,123,251,.15);
  --on-brand:#04122E;
  --violet:#8FA2FF; --amber:#F5A93C; --rose:#FB7185; --sky:#63A9F0;
  --shadow-xs:0 1px 2px rgba(0,0,0,.5);
  --shadow-sm:0 2px 10px rgba(0,0,0,.45);
  --shadow-md:0 16px 34px -16px rgba(0,0,0,.7);
  --shadow-lg:0 40px 80px -32px rgba(0,0,0,.85);
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}

h1,h2,h3,h4,h5 { font-family: var(--font-display); color: var(--ink); letter-spacing:-.025em; line-height:1.2; font-weight:700; }
h1 { font-size: clamp(1.5rem,3vw,2rem); letter-spacing:-.035em; }
h2 { font-size: clamp(1.2rem,2.2vw,1.5rem); letter-spacing:-.03em; }
h3 { font-size: 1.05rem; }
h4 { font-size: .95rem; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
ul, ol { list-style: none; }
svg { display: block; }
img { max-width: 100%; display: block; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.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;
}

/* ==========================================================================
   APP SHELL
   ========================================================================== */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px;
  padding: 0 clamp(14px, 3vw, 26px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 60;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--font-display); font-weight: 800;
  font-size: 1.05rem; letter-spacing: -.04em; color: var(--ink);
  flex: none;
}
.wordmark {
  font-family: var(--font-display); font-weight: 800;
  letter-spacing: -.045em; line-height: 1; white-space: nowrap;
}
.brand-dot { color: var(--brand); }
.wm-q { color: var(--ink); }
.wm-live, .wm-dot { color: var(--brand); }
.brand-sub {
  font-family: var(--font-mono); font-size: .6rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--brand-text);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent);
  background: var(--brand-tint);
  padding: 3px 7px; border-radius: var(--r-xs); font-weight: 700;
}
.topbar-clinic {
  display: flex; flex-direction: column; line-height: 1.25;
  padding-left: 16px; margin-left: 4px; border-left: 1px solid var(--line);
}
.topbar-clinic strong { font-family: var(--font-display); font-size: .9rem; color: var(--ink); letter-spacing:-.02em; }
.topbar-clinic span { font-size: .74rem; color: var(--faint); }
.topbar-spacer { flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.tabs-nav { display: flex; gap: 2px; }
.tabs-nav a, .tabs-nav button {
  padding: 8px 14px; border-radius: var(--r-xs);
  font-size: .875rem; font-weight: 550; color: var(--muted);
  transition: background-color .2s, color .2s;
}
.tabs-nav a:hover, .tabs-nav button:hover { background: var(--surface-2); color: var(--ink); }
.tabs-nav [aria-current="page"], .tabs-nav [aria-selected="true"] {
  background: var(--brand-tint); color: var(--brand-text); font-weight: 650;
}

/* min-width:0 is essential on grid/flex children: without it they size to
   min-content, so a wide table pushes the whole page wider instead of
   scrolling inside its own .table-wrap. */
.main { flex: 1; padding: clamp(16px, 2.6vw, 26px); width: 100%; max-width: 1480px; margin-inline: auto; min-width: 0; }
.app > *, .grid > *, .split-main > *, .panel, .stat { min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head p { color: var(--muted); font-size: .9rem; margin-top: 3px; }

.grid { display: grid; gap: clamp(12px, 1.6vw, 18px); }
.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.cols-5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.split-main { display: grid; grid-template-columns: minmax(0,1.45fr) minmax(0,1fr); gap: clamp(12px,1.6vw,18px); align-items: start; }

/* ==========================================================================
   PANELS & CARDS
   ========================================================================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}
.panel-title {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-weight: 700; font-size: .95rem;
  color: var(--ink); letter-spacing: -.02em;
}
.panel-title svg { width: 16px; height: 16px; color: var(--brand); }
.panel-body { padding: 18px; }
.panel-body.tight { padding: 12px; }

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: transform .4s var(--ease), box-shadow .4s var(--ease), border-color .3s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-label {
  font-size: .76rem; color: var(--muted); font-weight: 550;
  display: flex; align-items: center; gap: 7px; margin-bottom: 10px;
}
.stat-label svg { width: 15px; height: 15px; color: var(--faint); }
.stat-value {
  font-family: var(--font-display); font-size: clamp(1.5rem,3vw,1.95rem);
  font-weight: 800; letter-spacing: -.04em; color: var(--ink); line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat-value small { font-size: .5em; font-weight: 600; color: var(--muted); margin-left: 2px; }
.stat-meta { margin-top: 7px; font-size: .76rem; color: var(--faint); display: flex; align-items: center; gap: 5px; }
.stat-meta .up { color: var(--brand-text); font-weight: 600; }
.stat-meta .down { color: var(--rose); font-weight: 600; }
.stat.accent-brand  { border-left: 3px solid var(--brand); }
.stat.accent-violet { border-left: 3px solid var(--violet); }
.stat.accent-amber  { border-left: 3px solid var(--amber); }
.stat.accent-sky    { border-left: 3px solid var(--sky); }
.stat.accent-rose   { border-left: 3px solid var(--rose); }

/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--r-sm);
  font-family: var(--font-display); font-weight: 650; font-size: .885rem;
  letter-spacing: -.01em; white-space: nowrap;
  border: 1px solid transparent;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease),
              background-color .2s, border-color .2s, color .2s;
}
.btn svg { width: 16px; height: 16px; flex: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }

.btn-primary { background: var(--brand); color: var(--on-brand); box-shadow: 0 10px 24px -12px color-mix(in srgb, var(--brand) 70%, transparent); }
.btn-primary:hover:not(:disabled) { background: color-mix(in srgb, var(--brand) 88%, #000); transform: translateY(-1px); }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-text); }
.btn-quiet { background: var(--surface-2); color: var(--muted); }
.btn-quiet:hover:not(:disabled) { background: var(--surface-3); color: var(--ink); }
.btn-danger { background: color-mix(in srgb, var(--rose) 14%, transparent); color: var(--rose); border-color: color-mix(in srgb, var(--rose) 32%, transparent); }
.btn-danger:hover:not(:disabled) { background: var(--rose); color: #fff; border-color: transparent; }
.btn-warn { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 34%, transparent); }
.btn-warn:hover:not(:disabled) { background: var(--amber); color: #fff; border-color: transparent; }
.btn-sm { padding: 6px 12px; font-size: .8rem; border-radius: var(--r-xs); }
.btn-sm svg { width: 14px; height: 14px; }
.btn-lg { padding: 14px 26px; font-size: 1rem; border-radius: var(--r-md); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: var(--r-xs); border: 1px solid var(--line);
  color: var(--muted); background: var(--surface);
  transition: color .2s, border-color .2s, background-color .2s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }
.icon-btn svg { width: 16px; height: 16px; }
.theme-toggle .i-moon { display: none; }
[data-theme="dark"] .theme-toggle .i-sun { display: none; }
[data-theme="dark"] .theme-toggle .i-moon { display: block; }

/* ==========================================================================
   BADGES / CHIPS
   ========================================================================== */

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: .715rem; font-weight: 650; letter-spacing: .01em;
  background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.badge-brand   { background: var(--brand-tint); color: var(--brand-text); border-color: color-mix(in srgb,var(--brand) 26%,transparent); }
.badge-amber   { background: color-mix(in srgb,var(--amber) 13%,transparent); color: var(--amber); border-color: color-mix(in srgb,var(--amber) 30%,transparent); }
.badge-rose    { background: color-mix(in srgb,var(--rose) 13%,transparent); color: var(--rose); border-color: color-mix(in srgb,var(--rose) 30%,transparent); }
.badge-violet  { background: color-mix(in srgb,var(--violet) 13%,transparent); color: var(--violet); border-color: color-mix(in srgb,var(--violet) 30%,transparent); }
.badge-sky     { background: color-mix(in srgb,var(--sky) 13%,transparent); color: var(--sky); border-color: color-mix(in srgb,var(--sky) 30%,transparent); }

.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.pulse { animation: pulse 2.2s var(--ease-soft) infinite; }
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  70%  { box-shadow: 0 0 0 8px transparent; opacity: .85; }
  100% { box-shadow: 0 0 0 0 transparent; opacity: 1; }
}

/* ==========================================================================
   NOW SERVING / TOKEN
   ========================================================================== */

.now-panel {
  border-radius: var(--r-lg);
  border: 1px solid color-mix(in srgb, var(--brand) 26%, transparent);
  background: linear-gradient(160deg, var(--brand-tint), transparent 70%);
  padding: 20px;
}
.now-label {
  font-family: var(--font-mono); font-size: .64rem; letter-spacing: .18em;
  text-transform: uppercase; color: var(--brand-text); font-weight: 700;
}
.now-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 8px; }
.now-token {
  font-family: var(--font-mono); font-weight: 700; line-height: 1;
  font-size: clamp(2.6rem, 7vw, 3.6rem); letter-spacing: -.05em;
  color: var(--ink); font-variant-numeric: tabular-nums;
}
.now-person { text-align: right; }
.now-person strong { display: block; font-family: var(--font-display); font-size: 1rem; color: var(--ink); }
.now-person span { font-size: .8rem; color: var(--muted); }
.now-empty { color: var(--faint); font-size: .9rem; }

/* ==========================================================================
   QUEUE LIST
   ========================================================================== */

.queue { display: flex; flex-direction: column; gap: 8px; }
.qrow {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 13px;
  border-radius: var(--r-md);
  background: var(--surface-2);
  border: 1px solid transparent;
  transition: background-color .25s, border-color .25s, transform .3s var(--ease);
}
.qrow:hover { border-color: var(--line-strong); }
.qrow.is-next { background: var(--brand-tint); border-color: color-mix(in srgb,var(--brand) 28%,transparent); }
.qrow.is-priority { border-left: 3px solid var(--amber); }
.qrow.is-emergency { border-left: 3px solid var(--rose); background: color-mix(in srgb,var(--rose) 8%,var(--surface-2)); }
.qrow.is-serving { background: color-mix(in srgb,var(--brand) 12%,var(--surface-2)); border-color: color-mix(in srgb,var(--brand) 34%,transparent); }
.qrow.is-skipped { opacity: .55; }

.qtoken {
  font-family: var(--font-mono); font-weight: 700; font-size: .92rem;
  color: var(--brand-text); min-width: 42px;
  font-variant-numeric: tabular-nums;
}
.qavatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--surface-3); color: var(--muted);
  font-family: var(--font-display); font-weight: 700; font-size: .74rem;
}
.qmain { flex: 1; min-width: 0; }
.qname { font-weight: 600; color: var(--ink); font-size: .9rem; display: flex; align-items: center; gap: 7px; }
.qmeta { font-size: .755rem; color: var(--faint); display: flex; gap: 10px; flex-wrap: wrap; margin-top: 1px; }
.qactions { display: flex; gap: 5px; flex: none; }
.qwait { font-family: var(--font-mono); font-size: .78rem; color: var(--muted); flex: none; text-align: right; }

.empty {
  padding: 34px 20px; text-align: center; color: var(--faint); font-size: .88rem;
}
.empty svg { width: 34px; height: 34px; margin: 0 auto 12px; opacity: .4; }

/* ==========================================================================
   FORMS
   ========================================================================== */

.field { margin-bottom: 13px; }
.field label { display: block; font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px;
  border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font-size: .89rem;
  transition: border-color .2s, box-shadow .2s;
}
.input::placeholder { color: var(--faint); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px color-mix(in srgb,var(--brand) 16%,transparent);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235C667C' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 14px;
  padding-right: 34px;
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.search-wrap { position: relative; }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--faint); }
.search-wrap .input { padding-left: 35px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px; gap: 2px; }
.seg button {
  padding: 6px 13px; border-radius: var(--r-xs);
  font-size: .8rem; font-weight: 600; color: var(--muted);
  transition: background-color .25s, color .25s;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-xs); }

/* ==========================================================================
   TABLE
   ========================================================================== */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .855rem; min-width: 620px; }
table.data th {
  text-align: left; padding: 10px 14px;
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint); font-weight: 600;
  border-bottom: 1px solid var(--line); background: var(--surface-2);
  position: sticky; top: 0;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--line-soft); color: var(--text); }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   CHARTS (dependency-free)
   ========================================================================== */

.chart { width: 100%; }
.chart-bars { display: flex; align-items: flex-end; gap: 5px; height: 150px; }
.chart-bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.chart-bars .bar i {
  display: block; width: 100%;
  border-radius: 5px 5px 2px 2px;
  background: color-mix(in srgb, var(--brand) 32%, transparent);
  transform-origin: bottom;
  animation: growBar .8s var(--ease) both;
  animation-delay: calc(var(--i,0) * 35ms);
  min-height: 2px;
}
.chart-bars .bar.peak i { background: var(--brand); }
.chart-bars .bar:hover i { background: var(--brand); }
@keyframes growBar { from { transform: scaleY(0); } }
.chart-axis {
  display: flex; gap: 5px; margin-top: 8px;
  font-family: var(--font-mono); font-size: .62rem; color: var(--faint);
}
.chart-axis span { flex: 1; text-align: center; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .76rem; color: var(--muted); margin-top: 12px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 6px; }

.spark { width: 100%; height: 60px; }
.spark path.area { fill: color-mix(in srgb, var(--brand) 16%, transparent); }
.spark path.line { fill: none; stroke: var(--brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark circle { fill: var(--brand); }

.hbar { display: grid; gap: 10px; }
.hbar-row { display: grid; grid-template-columns: 92px 1fr 46px; align-items: center; gap: 11px; font-size: .8rem; }
.hbar-track { height: 9px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.hbar-fill {
  height: 100%; border-radius: 5px; background: var(--brand);
  transform-origin: left; animation: growX .9s var(--ease) both;
}
@keyframes growX { from { transform: scaleX(0); } }
.hbar-row .val { text-align: right; font-family: var(--font-mono); color: var(--muted); font-size: .78rem; }

/* ==========================================================================
   TOASTS / MODAL
   ========================================================================== */

.toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
  pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow-md); font-size: .855rem; color: var(--ink);
  animation: toastIn .45s var(--ease) both;
  max-width: min(360px, 90vw);
}
.toast svg { width: 17px; height: 17px; flex: none; color: var(--brand); }
.toast.is-warn svg { color: var(--amber); }
.toast.is-danger svg { color: var(--rose); }
.toast.is-out { animation: toastOut .35s var(--ease-soft) both; }
@keyframes toastIn  { from { opacity:0; transform: translateY(14px) scale(.96); } }
@keyframes toastOut { to   { opacity:0; transform: translateX(18px); } }

.modal-scrim {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(6,9,18,.55); backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 18px;
  animation: fade .3s var(--ease) both;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(560px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: modalIn .4s var(--ease) both;
}
@keyframes modalIn { from { opacity:0; transform: translateY(18px) scale(.97); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line-soft); }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); }

/* ==========================================================================
   TV DISPLAY
   ========================================================================== */

.tv {
  min-height: 100vh; background: #05070E; color: #fff;
  display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.tv::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(75,123,251,.18), transparent 62%);
  pointer-events: none;
}
.tv-head {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 22px clamp(20px,4vw,48px);
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.tv-head .brand { color: #fff; font-size: 1.2rem; }
.tv-clinic { text-align: right; }
.tv-clinic strong { display: block; font-family: var(--font-display); font-size: 1.05rem; }
.tv-clinic span { font-size: .8rem; color: rgba(255,255,255,.55); }
.tv-body { position: relative; flex: 1; display: grid; grid-template-columns: 1.35fr 1fr; gap: clamp(20px,3vw,44px); padding: clamp(20px,4vw,48px); }
.tv-now { display: flex; flex-direction: column; justify-content: center; }
.tv-now-label {
  font-family: var(--font-mono); font-size: clamp(.7rem,1.2vw,.9rem);
  letter-spacing: .3em; text-transform: uppercase; color: var(--brand-300);
}
.tv-now-token {
  font-family: var(--font-mono); font-weight: 700; line-height: .9;
  font-size: clamp(6rem, 22vw, 16rem); letter-spacing: -.06em;
  color: #fff; text-shadow: 0 0 90px rgba(75,123,251,.55);
  font-variant-numeric: tabular-nums;
}
.tv-now-person { font-size: clamp(1rem,2.2vw,1.7rem); color: rgba(255,255,255,.85); margin-top: 8px; font-family: var(--font-display); }
.tv-now-room { font-size: clamp(.9rem,1.6vw,1.2rem); color: var(--brand-300); margin-top: 4px; }
.tv-next { display: flex; flex-direction: column; justify-content: center; gap: 12px; }
.tv-next-label {
  font-family: var(--font-mono); font-size: .74rem; letter-spacing: .24em;
  text-transform: uppercase; color: rgba(255,255,255,.42); margin-bottom: 4px;
}
.tv-next-row {
  display: flex; align-items: center; gap: 16px;
  padding: clamp(12px,1.6vw,18px) clamp(14px,2vw,22px);
  border-radius: var(--r-lg);
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.09);
}
.tv-next-row .t {
  font-family: var(--font-mono); font-weight: 700;
  font-size: clamp(1.5rem,3.4vw,2.4rem); color: var(--brand-300);
  letter-spacing: -.04em; min-width: 2.4em;
}
.tv-next-row .n { font-size: clamp(.9rem,1.6vw,1.15rem); color: rgba(255,255,255,.8); }
.tv-foot {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 16px clamp(20px,4vw,48px);
  border-top: 1px solid rgba(255,255,255,.09);
  font-size: .85rem; color: rgba(255,255,255,.5);
}
.tv-ticker { overflow: hidden; flex: 1; }
.tv-ticker span { display: inline-block; white-space: nowrap; animation: ticker 26s linear infinite; }
@keyframes ticker { from { transform: translateX(100%); } to { transform: translateX(-100%); } }

/* ==========================================================================
   PATIENT MOBILE VIEW
   ========================================================================== */

.pt { min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
.pt-shell { width: min(460px, 100%); margin-inline: auto; padding: 18px; flex: 1; display: flex; flex-direction: column; }
.pt-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.pt-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); padding: 26px 22px; text-align: center;
  box-shadow: var(--shadow-md);
}
.pt-token {
  font-family: var(--font-mono); font-weight: 700; line-height: 1;
  font-size: clamp(3.4rem, 18vw, 4.6rem); letter-spacing: -.05em;
  color: var(--brand-text); font-variant-numeric: tabular-nums;
}
.pt-label { font-family: var(--font-mono); font-size: .66rem; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }
.pt-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line-soft); }
.pt-split div { text-align: center; }
.pt-split .v { font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700; color: var(--ink); }
.pt-split .l { font-size: .72rem; color: var(--faint); margin-top: 2px; }
.pt-status {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px;
  padding: 8px 15px; border-radius: var(--r-pill);
  background: var(--brand-tint); color: var(--brand-text);
  border: 1px solid color-mix(in srgb,var(--brand) 28%,transparent);
  font-size: .8rem; font-weight: 600;
}
.pt-progress { margin-top: 20px; }
.pt-progress-track { height: 7px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.pt-progress-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--brand), var(--brand-300)); transition: width .8s var(--ease); }
.pt-steps { display: flex; justify-content: space-between; margin-top: 8px; font-size: .68rem; color: var(--faint); }

.qr-box {
  background: #fff; padding: 12px; border-radius: var(--r-md);
  border: 1px solid var(--line); width: 168px; margin-inline: auto;
}
.qr-box svg { width: 100%; height: auto; }

/* ==========================================================================
   MISC
   ========================================================================== */

.demo-bar {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 7px 14px; font-size: .775rem;
  background: color-mix(in srgb, var(--amber) 12%, var(--surface));
  border-bottom: 1px solid color-mix(in srgb, var(--amber) 26%, transparent);
  color: var(--text); flex-wrap: wrap; text-align: center;
}
.demo-bar strong { color: var(--amber); }
.demo-bar a { color: var(--brand-text); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }

.hint { font-size: .76rem; color: var(--faint); margin-top: 5px; }
.divider { height: 1px; background: var(--line); border: 0; margin: 16px 0; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.right { margin-left: auto; }
.center { text-align: center; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .8rem; }
.nowrap { white-space: nowrap; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1100px) {
  .cols-5 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .split-main { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .cols-5, .cols-4, .cols-3, .cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .topbar-clinic { display: none; }
  .tv-body { grid-template-columns: 1fr; }
  .tabs-nav { overflow-x: auto; }
}
@media (max-width: 520px) {
  .cols-5, .cols-4, .cols-3, .cols-2 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .qactions { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
