/* Clinic Token System — one stylesheet for all screens.
   The brand color comes from settings as --accent (set inline by the layout). */

:root {
  --accent: #0f766e;
  --accent-dark: #0c615a;
  --accent-soft: #e2f1ef;
  --accent-ink: #ffffff;
  --bg: #f3f5f7;
  --card: #ffffff;
  --text: #1b2430;
  --muted: #5b6776;
  --border: #d9dfe6;
  --border-strong: #b8c2cd;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --warn: #93370d;
  --warn-soft: #fef3e2;
  --ok: #067647;
  --ok-soft: #e6f4ec;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --tabular: ui-monospace, "SF Mono", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  overflow-wrap: anywhere;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
a { color: var(--accent-dark); }
img { max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  min-height: 44px;
  padding: .55rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  background: var(--card);
  color: var(--text);
  transition: background-color .12s, border-color .12s, color .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: .55; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: var(--accent-dark); }
.btn-secondary { border-color: var(--border-strong); }
.btn-secondary:hover:not(:disabled) { background: #eef1f4; }
.btn-quiet { background: transparent; color: var(--accent-dark); }
.btn-quiet:hover:not(:disabled) { background: var(--accent-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #912018; }
.btn-danger-quiet { background: transparent; color: var(--danger); }
.btn-danger-quiet:hover:not(:disabled) { background: var(--danger-soft); }
.btn-sm { min-height: 44px; padding: .35rem .75rem; font-size: .95rem; }
.btn-lg { min-height: 54px; padding: .75rem 1.4rem; font-size: 1.1rem; }
.btn-xl { min-height: 84px; padding: 1rem 1.5rem; font-size: 1.5rem; border-radius: var(--radius); }
.btn-block { display: flex; width: 100%; }
.btn.is-loading { position: relative; color: transparent !important; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 1.2em; height: 1.2em;
  border: 3px solid currentColor;
  border-color: var(--accent-ink) transparent var(--accent-ink) transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-quiet.is-loading::after { border-color: var(--accent) transparent var(--accent) transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; min-width: 0; }
.field-label { font-weight: 600; font-size: .95rem; }
.field-hint { color: var(--muted); font-size: .9rem; }
.field-error { color: var(--danger); font-size: .95rem; font-weight: 500; }
input[type="text"], input[type="password"], input[type="tel"], input[type="number"], input[type="date"],
input[type="search"], select, textarea {
  width: 100%;
  min-height: 46px;
  padding: .55rem .8rem;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[aria-invalid="true"] { border-color: var(--danger); }
input[readonly] { background: #f5f7f9; }
.input-lg { min-height: 54px; font-size: 1.15rem; }
input[type="color"] { width: 64px; height: 46px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: #fff; }
.input-with-button { display: flex; gap: .5rem; }
.input-with-button input { flex: 1; min-width: 0; }
.form-error {
  color: var(--danger);
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
  padding: .6rem .8rem;
  font-weight: 500;
}
.switch { display: flex; align-items: center; gap: .75rem; min-height: 44px; cursor: pointer; }
.switch input { width: 1.4rem; height: 1.4rem; accent-color: var(--accent); flex: none; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; }
.row > .field { flex: 1 1 10rem; }

/* ---------- Layout ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .5rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 60px;
  flex-wrap: wrap;
}
.topbar-brand { display: flex; align-items: center; gap: .6rem; min-width: 0; }
.topbar-logo { height: 36px; width: auto; max-width: 120px; object-fit: contain; }
.topbar-name { font-weight: 700; font-size: 1.1rem; }
.topbar-extra { flex: 1; display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; justify-content: flex-end; min-width: 0; }
.main { padding: 1rem; max-width: 1400px; margin: 0 auto; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
}
.card + .card { margin-top: 1rem; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; flex-wrap: wrap; }
.card-title h2 { margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .9rem; }
.tabular { font-variant-numeric: tabular-nums; }
.section-title { font-size: 1rem; text-transform: none; color: var(--muted); font-weight: 600; margin: 1.25rem 0 .5rem; }

/* ---------- Account menu ---------- */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-caret { width: .5rem; height: .5rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); }
.menu-user { max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px);
  min-width: 220px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(16, 24, 40, .15);
  padding: .4rem;
  z-index: 30;
}
.menu-role { padding: .5rem .75rem; color: var(--muted); font-size: .9rem; }
.menu-item {
  display: block; width: 100%; min-height: 44px;
  padding: .5rem .75rem;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; font: inherit; text-align: left; cursor: pointer; color: var(--text);
}
.menu-item:hover { background: var(--accent-soft); }
.menu form { margin: 0; }

/* ---------- Banners, toasts, dialogs ---------- */
.offline-banner {
  position: sticky; top: 0; z-index: 50;
  background: var(--warn); color: #fff;
  text-align: center; font-weight: 600; padding: .6rem 1rem;
}
.notice {
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  background: var(--accent-soft);
  margin-bottom: 1rem;
}
.notice-warn { background: var(--warn-soft); color: var(--warn); font-weight: 500; }
.toasts {
  position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: .5rem; align-items: center;
  z-index: 100; width: min(92vw, 520px); pointer-events: none;
}
.toast {
  background: #1b2430; color: #fff;
  padding: .8rem 1.1rem; border-radius: var(--radius-sm);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
  font-weight: 500; text-align: center;
  animation: toast-in .18s ease-out;
}
.toast-error { background: var(--danger); }
.toast-ok { background: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.dialog {
  border: 0; padding: 0;
  border-radius: var(--radius);
  width: min(94vw, 480px);
  box-shadow: 0 20px 50px rgba(16, 24, 40, .3);
  color: var(--text);
}
.dialog::backdrop { background: rgba(16, 24, 40, .45); }
.dialog-body { padding: 1.5rem; }
.dialog-body h2 { margin-bottom: .75rem; }
.dialog-actions { display: flex; gap: .75rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.25rem; }
.dialog-actions .btn { flex: 1 1 auto; }

.ios-hint {
  position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 90;
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: .75rem 1rem; box-shadow: 0 10px 30px rgba(16, 24, 40, .15);
}

/* ---------- Badges, lists, tables ---------- */
.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  font-size: .85rem; font-weight: 600; background: #eef1f4; color: var(--muted); white-space: nowrap;
}
.badge-waiting { background: var(--accent-soft); color: var(--accent-dark); }
.badge-called { background: var(--accent); color: var(--accent-ink); }
.badge-done, .badge-paid { background: var(--ok-soft); color: var(--ok); }
.badge-skipped, .badge-missed, .badge-unpaid { background: var(--warn-soft); color: var(--warn); }
.badge-cancelled, .badge-voided { background: var(--danger-soft); color: var(--danger); }
.badge-free { background: #eef1f4; color: var(--muted); }

.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 0; border-top: 1px solid var(--border);
  min-height: 56px;
}
.list-row:first-child { border-top: 0; }
.list-token { font-weight: 800; font-size: 1.25rem; min-width: 4.5rem; font-variant-numeric: tabular-nums; }
.list-main { flex: 1; min-width: 0; }
.list-name { font-weight: 600; }
.list-meta { color: var(--muted); font-size: .9rem; }
.list-actions { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
.empty {
  text-align: center; color: var(--muted);
  padding: 1.25rem .5rem; border: 1px dashed var(--border-strong); border-radius: var(--radius-sm);
}

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { color: var(--muted); font-weight: 600; white-space: nowrap; background: #f8fafb; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .75rem; flex-wrap: wrap; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.stat-label { color: var(--muted); font-size: .9rem; font-weight: 600; }
.stat-value { font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: .2rem; }
.stat-sm .stat-value { font-size: 1.4rem; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: min(100%, 420px); padding: 2rem 1.5rem; }
.login-brand { text-align: center; margin-bottom: 1rem; }
.login-logo { max-height: 72px; width: auto; margin-bottom: .5rem; }
.login-clinic { font-size: 1.3rem; font-weight: 700; }
.login-title { text-align: center; font-size: 1.15rem; color: var(--muted); font-weight: 600; margin-bottom: 1.5rem; }

/* ---------- Counter ---------- */
.counter-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 4fr); gap: 1rem; align-items: start; }
.queue-info { color: var(--muted); font-size: .95rem; }
.break-toggle { display: inline-flex; align-items: center; gap: .5rem; min-height: 44px; padding: 0 .75rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; background: var(--card); }
.break-toggle input { width: 1.25rem; height: 1.25rem; accent-color: var(--warn); }
.break-toggle.is-on { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.issue-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .75rem; }
.issue-fields .field { margin-bottom: .75rem; }
.results { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 1rem; overflow: hidden; }
.results-title { padding: .5rem .8rem; color: var(--muted); font-size: .9rem; font-weight: 600; background: #f8fafb; border-bottom: 1px solid var(--border); }
.result {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: .75rem;
  min-height: 52px; padding: .55rem .8rem;
  border: 0; border-top: 1px solid var(--border); background: #fff;
  font: inherit; text-align: left; cursor: pointer; color: var(--text);
}
.result:first-of-type { border-top: 0; }
.result:hover, .result.is-active { background: var(--accent-soft); }
.result.is-active { box-shadow: inset 4px 0 0 var(--accent); }
.result-name { font-weight: 600; }
.result-meta { color: var(--muted); font-size: .9rem; text-align: right; }
.result-add { color: var(--accent-dark); font-weight: 600; }
.patient-card { border: 2px solid var(--accent); border-radius: var(--radius); padding: 1rem 1.1rem; margin-bottom: 1rem; background: var(--accent-soft); }
.patient-card-name { font-size: 1.4rem; font-weight: 700; }
.patient-card-phone { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.patient-card-seen { color: var(--muted); margin-top: .2rem; }
.patient-card-links { display: flex; gap: .25rem; flex-wrap: wrap; margin-top: .5rem; }
.issue-actions { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }
.issue-actions .btn-primary { flex: 1 1 14rem; }
.fee-fields { display: flex; gap: .5rem; flex: 1 1 16rem; }
.fee-fields .field { margin: 0; flex: 1; }
.issued-box {
  text-align: center; padding: 1.75rem 1rem;
  border-radius: var(--radius); background: var(--ok-soft); border: 2px solid var(--ok);
}
.issued-token { font-size: clamp(3rem, 7vw, 5rem); font-weight: 800; line-height: 1; color: var(--ok); font-variant-numeric: tabular-nums; }
.issued-text { font-size: 1.3rem; font-weight: 600; margin-top: .75rem; }
.issued-ahead { color: var(--muted); font-size: 1.1rem; }
.issued-actions { display: flex; justify-content: center; gap: .75rem; margin-top: 1rem; flex-wrap: wrap; }
.current-box { display: flex; align-items: center; gap: 1rem; padding: .9rem 1rem; border-radius: var(--radius-sm); background: var(--accent-soft); margin-bottom: .75rem; }
.current-token { font-size: 2.2rem; font-weight: 800; color: var(--accent-dark); font-variant-numeric: tabular-nums; }
.current-name { font-weight: 600; font-size: 1.1rem; }
.queue-actions { display: flex; gap: .5rem; margin-bottom: .5rem; }
.queue-actions .btn { flex: 1; }
.counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-top: .75rem; }
.count { background: #f8fafb; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .6rem; text-align: center; }
.count-value { font-size: 1.5rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.count-label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.token-preview { font-weight: 600; color: var(--accent-dark); min-height: 1.5em; }

/* ---------- Doctor ---------- */
.page-doctor .main { max-width: 760px; }
.doctor-current { text-align: center; padding: 1.5rem 1rem; }
.doctor-current-label { color: var(--muted); font-weight: 600; }
.doctor-token { font-size: clamp(4rem, 22vw, 8rem); font-weight: 800; line-height: 1; color: var(--accent-dark); font-variant-numeric: tabular-nums; margin: .25rem 0; }
.doctor-token.is-empty { color: var(--border-strong); }
.doctor-name { font-size: 1.5rem; font-weight: 700; }
.doctor-seen { color: var(--muted); margin-top: .25rem; }
.doctor-actions { margin-top: 1rem; display: grid; gap: .75rem; }
.doctor-secondary { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; }
.doctor-secondary .btn { min-height: 54px; }
.call-sub { display: block; font-size: 1rem; font-weight: 600; opacity: .9; }
.btn-xl { flex-direction: column; gap: .15rem; }

/* ---------- Owner ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; overflow-x: auto; }
.tab {
  min-height: 48px; padding: .5rem 1rem; border: 0; background: transparent;
  font: inherit; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center;
}
.tab[aria-selected="true"], .tab.is-active { color: var(--accent-dark); border-bottom-color: var(--accent); }
.range-bar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.range-bar .btn[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.range-custom { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.range-custom .field { margin: 0; }
.owner-grid { display: grid; gap: 1rem; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; align-items: start; }
.settings-grid .card + .card { margin-top: 0; }
.logo-preview { display: flex; align-items: center; gap: 1rem; margin-bottom: .75rem; }
.logo-preview img { max-height: 64px; max-width: 160px; object-fit: contain; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 4px; background: #fff; }
.display-link { font-family: var(--tabular); font-size: .85rem; }
.bar-cell { width: 35%; min-width: 120px; }
.bar { height: 12px; background: var(--accent); border-radius: 6px; min-width: 2px; }
.danger-zone { border-color: #f3c4bf; }

/* ---------- Waiting room display ---------- */
.page-display {
  background: #0b1220; color: #f8fafc;
  height: 100vh; overflow: hidden; font-size: 1.6vw;
}
.display {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  padding: 2vw 3vw;
  gap: 1.5vw;
}
.display-header { display: flex; align-items: center; gap: 2vw; }
.display-logo { height: 6vw; width: auto; max-width: 18vw; object-fit: contain; background: #fff; border-radius: .6vw; padding: .4vw; }
.display-clinic { font-size: 3vw; font-weight: 800; line-height: 1.1; }
.display-doctor { font-size: 1.8vw; color: #cbd5e1; }
.display-clock { margin-left: auto; text-align: right; }
.display-time { font-size: 3vw; font-weight: 700; font-variant-numeric: tabular-nums; }
.display-date { font-size: 1.5vw; color: #cbd5e1; }
.display-body { display: grid; grid-template-columns: 3fr 2fr; gap: 2vw; min-height: 0; }
.display-now {
  background: var(--accent); color: var(--accent-ink);
  border-radius: 2vw; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 2vw; transition: background-color .3s;
}
.display-now-label { font-size: 3vw; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .95; }
.display-now-token { font-size: 17vw; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.display-now.is-flashing { animation: display-flash .6s ease-in-out 6; }
@keyframes display-flash {
  0%, 100% { background: var(--accent); }
  50% { background: #fde047; color: #111827; }
}
.display-side { display: grid; grid-template-rows: 1fr auto; gap: 2vw; min-height: 0; }
.display-next { background: #111a2e; border-radius: 2vw; padding: 2vw; min-height: 0; overflow: hidden; }
.display-next-label { font-size: 2.2vw; font-weight: 700; color: #cbd5e1; margin-bottom: 1vw; }
.display-next-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .8vw; }
.display-next-list li { font-size: 4.2vw; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; background: #1c2742; border-radius: 1vw; padding: .5vw 1.5vw; }
.display-next-empty { font-size: 2.2vw; color: #94a3b8; }
.display-waiting { background: #111a2e; border-radius: 2vw; padding: 1.5vw 2vw; display: flex; justify-content: space-between; align-items: center; }
.display-waiting-label { font-size: 2.2vw; color: #cbd5e1; font-weight: 700; }
.display-waiting-count { font-size: 5vw; font-weight: 800; font-variant-numeric: tabular-nums; }
.display-footer { display: flex; align-items: center; gap: 1vw; min-height: 3vw; }
.display-break {
  flex: 1; background: #fde047; color: #111827; text-align: center;
  font-size: 2.6vw; font-weight: 800; border-radius: 1vw; padding: .8vw;
}
.display-status { margin-left: auto; display: flex; gap: 1vw; align-items: center; }
.display-reconnecting { background: #7c2d12; color: #fff; font-size: 1.2vw; padding: .4vw 1vw; border-radius: 999px; font-weight: 600; }
.display-btn { background: #1c2742; color: #e2e8f0; border: 1px solid #334155; font-size: 1.1vw; min-height: 44px; }
.display-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(11, 18, 32, .92);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  cursor: pointer; padding: 2rem; border: 0; width: 100%; color: #fff; font: inherit;
}
.display-overlay-title { font-size: max(2rem, 4vw); font-weight: 800; }
.display-overlay-hint { font-size: max(1.1rem, 1.6vw); color: #cbd5e1; margin-top: 1rem; max-width: 50ch; }
.display-error { display: grid; place-items: center; height: 100vh; padding: 2rem; text-align: center; font-size: max(1.2rem, 2vw); }
@media (orientation: portrait) {
  .page-display { font-size: 3vw; overflow: auto; height: auto; }
  .display { height: auto; min-height: 100vh; }
  .display-body { grid-template-columns: 1fr; }
  .display-now-token { font-size: 30vw; }
}

/* ---------- Print slip (hidden iframe) ---------- */
.page-slip { background: #fff; color: #000; font-size: 14px; }
.slip { width: 72mm; margin: 0 auto; padding: 4mm 0; text-align: center; font-family: var(--font); }
.slip-clinic { font-size: 16px; font-weight: 700; }
.slip-label { margin-top: 3mm; font-size: 14px; text-transform: uppercase; letter-spacing: .1em; }
.slip-token { font-size: 56px; font-weight: 800; line-height: 1.05; }
.slip-line { margin-top: 2mm; font-size: 13px; }

/* ---------- Offline page ---------- */
.offline-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; text-align: center; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .counter-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .main { padding: .75rem; }
  .card { padding: 1rem; }
  .topbar { padding: .5rem .75rem; gap: .5rem; }
  .topbar-extra { order: 3; width: 100%; justify-content: flex-start; }
  .topbar-name { font-size: 1rem; }
  .menu { margin-left: auto; }
  .menu-user { max-width: 8rem; }
  .issue-fields { grid-template-columns: 1fr; }
  .list-row { flex-wrap: wrap; }
  .list-actions { width: 100%; justify-content: flex-start; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .btn { width: 100%; }
  .stat-value { font-size: 1.5rem; }
}
@media print {
  body:not(.page-slip) .topbar, .toasts, .offline-banner { display: none !important; }
}

/* Tappable payment badge (counter lists, owner visits table) */
.badge-button { border: 0; cursor: pointer; font-family: inherit; min-height: 44px; display: inline-flex; align-items: center; padding: 0 .8rem; }
.badge-button:hover { filter: brightness(.96); }

/* Layout fixes found in the browser pass */
.counter-grid > .card + .card { margin-top: 0; }
.topbar-extra:empty { display: none; }
.stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat-value { white-space: nowrap; }
@media (max-width: 600px) {
  .topbar-extra { flex: 1 1 100%; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-value { white-space: normal; }
  .queue-info { width: 100%; }
}
