:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --ink: #17202a;
  --muted: #5d6875;
  --line: #d8dee7;
  --panel: #ffffff;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --danger: #b42318;
  --called: #fff7d6;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.kiosk-page {
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, rgba(15, 118, 110, 0.06) 0 1px, transparent 1px 100%),
    #f9fbfb;
  background-size: 42px 42px;
}

.app-page {
  background:
    linear-gradient(90deg, rgba(15, 118, 110, 0.08) 0 1px, transparent 1px 100%),
    linear-gradient(0deg, rgba(15, 118, 110, 0.06) 0 1px, transparent 1px 100%),
    #f9fbfb;
  background-size: 42px 42px;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.kiosk-shell {
  width: min(1060px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  place-items: center;
}

.kiosk-card {
  width: 100%;
  min-height: min(760px, calc(100vh - 56px));
  display: grid;
  grid-template-rows: auto 1fr;
  border: 1px solid #cfdedb;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.kiosk-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: end;
  padding: 28px;
  border-bottom: 1px solid #d7e5e2;
  background: #f4fbf9;
}

.kiosk-site {
  margin-bottom: 8px;
  color: var(--accent-strong);
  font-weight: 800;
}

.kiosk-header h1 {
  margin-bottom: 0;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 0.95;
}

.stepper {
  display: flex;
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.kiosk-page:not(.flow-active) .stepper {
  display: none;
}

.stepper li {
  position: relative;
  min-width: 92px;
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 0 8px;
  background: transparent;
  text-align: center;
  transition: color 180ms ease;
}

.stepper li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 18px;
  left: calc(50% + 20px);
  width: calc(100% - 40px);
  height: 2px;
  background: #cfdedb;
}

.stepper li.complete:not(:last-child)::after {
  background: var(--accent);
}

.stepper b {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 2px solid #cfdedb;
  border-radius: 999px;
  background: #fff;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.stepper span {
  display: block;
}

.stepper li.active,
.stepper li.complete {
  color: var(--accent-strong);
}

.stepper li.active b,
.stepper li.complete b {
  border-color: var(--accent);
  background: #dff4ef;
}

.stepper li.active b {
  transform: scale(1.08);
}

.kiosk-home {
  display: grid;
  gap: 28px;
  align-content: center;
  padding: 40px 28px;
}

.kiosk-home[hidden] {
  display: none;
}

.live-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.live-stats article {
  min-height: 170px;
  display: grid;
  align-content: center;
  gap: 10px;
  border: 1px solid #cfdedb;
  border-radius: 8px;
  padding: 60px 24px;
  background: #f8fcfb;
}

.live-stats span {
  color: var(--muted);
  font-weight: 850;
}

.live-stats strong {
  font-size: clamp(44px, 8vw, 82px);
  line-height: 0.95;
}

.begin-checkin {
  min-height: 96px;
  width: 100%;
  font-size: clamp(28px, 4vw, 42px);
  justify-self: stretch;
  transition: background 180ms ease, transform 180ms ease;
}

.begin-checkin:hover {
  transform: translateY(-2px);
}

.begin-checkin:active {
  transform: translateY(0);
}

.kiosk-flow {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
  padding: 28px;
}

.kiosk-flow[hidden] {
  display: none;
}

.kiosk-step {
  display: none;
  min-height: 0;
  opacity: 0;
  transform: translateY(8px);
}

.kiosk-step.active {
  display: grid;
  gap: 22px;
  align-content: start;
  animation: step-in 220ms ease forwards;
}

@keyframes step-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-copy h2 {
  margin-bottom: 8px;
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1;
}

.step-copy p {
  max-width: 620px;
  font-size: 18px;
}

.choice-grid {
  display: grid;
  gap: 14px;
}

.service-choice-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.visit-choice-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-card {
  min-height: 168px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 22px;
  border: 1px solid #cad9d6;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease, color 180ms ease;
}

.choice-card:hover {
  background: #f1faf7;
  border-color: #7cbfb3;
  transform: translateY(-2px);
}

.choice-card:active {
  transform: translateY(0);
}

.choice-card.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.choice-card strong {
  font-size: clamp(20px, 2.3vw, 28px);
  line-height: 1.05;
}

.choice-card span {
  color: inherit;
  opacity: 0.78;
  font-weight: 650;
  line-height: 1.35;
}

.kiosk-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.kiosk-input-grid label,
.kiosk-flow > .kiosk-step > label {
  color: #334155;
  font-size: 16px;
}

.kiosk-flow input,
.kiosk-flow textarea {
  min-height: 58px;
  border-color: #c9d8d5;
  border-radius: 8px;
  font-size: 20px;
  transition: border-color 160ms ease, background 160ms ease, outline-color 160ms ease;
}

.kiosk-flow input:focus,
.kiosk-flow textarea:focus {
  outline: 3px solid #bfe7de;
  outline-offset: 1px;
  border-color: var(--accent);
  background: #fbfffe;
}

.kiosk-controls {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 22px;
  border-top: 1px solid #e1ebe8;
}

.kiosk-nav {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kiosk-controls[hidden] {
  display: none;
}

.kiosk-controls button,
.success-step button {
  min-width: 160px;
  min-height: 56px;
}

.countdown-text {
  color: var(--danger);
  font-weight: 850;
}

.kiosk-flow.is-busy {
  cursor: progress;
}

.success-step {
  justify-items: center;
  text-align: center;
}

.success-mark {
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: #dff4ef;
  color: var(--accent-strong);
  font-size: 52px;
  font-weight: 900;
}

.success-summary {
  width: min(620px, 100%);
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.success-summary div {
  border: 1px solid #cfdedb;
  border-radius: 8px;
  padding: 18px;
  background: #f8fcfb;
}

.success-summary dt {
  color: var(--muted);
  font-weight: 800;
}

.success-summary dd {
  margin: 8px 0 0;
  font-size: clamp(30px, 5vw, 52px);
  font-weight: 900;
  line-height: 1;
}

.kiosk-modal .actions {
  justify-content: flex-end;
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.panel,
.queue {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.06);
}

.app-page .shell {
  width: min(1180px, calc(100vw - 28px));
  min-height: calc(100vh - 56px);
  display: grid;
  align-content: start;
  gap: 22px;
  margin: 28px auto;
  padding: 0 0 28px;
  border: 1px solid #cfdedb;
  border-radius: 8px;
  background: #fff;
  overflow: hidden;
}

.app-page .topbar {
  margin: 0;
  padding: 28px;
  border-bottom: 1px solid #d7e5e2;
  background: #f4fbf9;
}

.app-page .topbar h1 {
  margin-bottom: 8px;
  font-size: clamp(32px, 4vw, 52px);
  line-height: 0.95;
}

.app-page .topbar .muted {
  margin-bottom: 0;
  color: var(--accent-strong);
  font-weight: 800;
}

.app-page .panel,
.app-page .queue {
  margin: 0 28px;
  border-color: #cfdedb;
  box-shadow: none;
}

.app-page .panel {
  background: #f8fcfb;
}

.app-page input,
.app-page textarea {
  border-color: #c9d8d5;
  border-radius: 8px;
  transition: border-color 160ms ease, background 160ms ease, outline-color 160ms ease;
}

.app-page input:focus,
.app-page textarea:focus {
  outline: 3px solid #bfe7de;
  outline-offset: 1px;
  border-color: var(--accent);
  background: #fbfffe;
}

.app-page button,
.app-page .button {
  border-radius: 8px;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease;
}

.app-page button:hover,
.app-page .button:hover {
  transform: translateY(-1px);
}

.app-page button:active,
.app-page .button:active {
  transform: translateY(0);
}

.app-page .section-head {
  padding-bottom: 16px;
  border-bottom: 1px solid #e1ebe8;
}

.app-page .search-field {
  margin: 18px 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 20px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}

h1,
h2,
p {
  margin-top: 0;
}

h2 {
  margin-bottom: 0;
}

.muted {
  color: var(--muted);
}

.stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 650;
}

input,
textarea {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 88px;
  padding: 10px 12px;
  resize: vertical;
}

button,
.button {
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.secondary {
  background: #eef2f6;
  color: var(--ink);
}

.secondary:hover {
  background: #e1e7ef;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.search-field {
  margin-bottom: 16px;
}

.history-tools {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

.history-tools[hidden] {
  display: none;
}

.calendar-toggle {
  justify-self: start;
}

.calendar-picker {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.app-page .calendar-picker {
  border-color: #cfdedb;
  background: #f8fcfb;
}

.calendar-picker[hidden] {
  display: none;
}

.calendar-toolbar {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 10px;
  align-items: center;
}

.calendar-title {
  background: #f8fafc;
  color: var(--ink);
  min-width: 0;
  text-align: center;
}

.calendar-title:hover {
  background: #eef2f6;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.calendar-grid-large {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.calendar-weekday {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-align: center;
  padding: 4px;
}

.calendar-day {
  display: grid;
  gap: 3px;
  min-height: 82px;
  align-content: center;
  justify-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 4px;
  background: #f8fafc;
  color: var(--ink);
  text-align: center;
}

.calendar-period {
  min-height: 104px;
}

.calendar-day strong {
  font-size: 14px;
}

.calendar-day span {
  font-size: 26px;
  line-height: 1;
}

.calendar-day small {
  color: var(--muted);
  font-weight: 650;
  font-size: 11px;
}

.calendar-day.outside-month {
  opacity: 0.45;
}

.calendar-day.in-range {
  background: #dff4ef;
  border-color: #8ccdc0;
}

.calendar-day.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.calendar-day.selected small {
  color: #e9fffb;
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px #17202a;
}

.calendar-day:hover {
  background: #edf3f7;
}

.calendar-day.in-range:hover {
  background: #caebe4;
}

.calendar-day.selected:hover {
  background: var(--accent-strong);
}

.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;
}

.tab {
  min-height: 38px;
  background: #eef2f6;
  color: var(--ink);
}

.tab:hover {
  background: #e1e7ef;
}

.tab.active {
  background: var(--accent);
  color: #fff;
}

.tab.active:hover {
  background: var(--accent-strong);
}

.app-page .tabs {
  padding: 4px;
  border: 1px solid #cfdedb;
  border-radius: 8px;
  background: #eef7f4;
}

.app-page .tab {
  border-radius: 6px;
}

.danger {
  background: var(--danger);
  color: #fff;
}

.danger:hover {
  background: #8f1d14;
}

.actions,
.ticket-actions,
.service-grid,
.patient-grid,
.link-stack {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.patient-grid label {
  flex: 1 1 180px;
}

.service-grid button {
  flex: 1 1 150px;
  min-height: 80px;
}

.ticket-list {
  display: grid;
  gap: 12px;
}

.ticket {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
}

.dashboard-page .ticket {
  display: grid;
  align-items: stretch;
  grid-template-columns: minmax(0, 1fr);
}

.ticket-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.app-page .ticket {
  border-color: #cad9d6;
  padding: 18px;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.app-page .ticket:hover {
  border-color: #7cbfb3;
  background: #fbfffe;
  transform: translateY(-1px);
}

.ticket.called {
  background: var(--called);
  border-color: #e1c75d;
}

.app-page .ticket.called:hover {
  background: #fff4c2;
  border-color: #d8b943;
}

.ticket-main {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.ticket-mood {
  width: 64px;
  min-width: 64px;
  min-height: 64px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.app-page .ticket-mood {
  border-color: #cfdedb;
  background: #f4fbf9;
}

.ticket-mood span {
  margin: 0;
  font-size: 28px;
  line-height: 1;
}

.ticket-mood small {
  color: var(--muted);
  font-weight: 750;
  line-height: 1;
}

.ticket strong {
  display: block;
  font-size: 32px;
  line-height: 1;
}

.ticket span {
  display: block;
  color: var(--muted);
  margin-top: 6px;
}

.patient-details {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.patient-details li {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  background: #f8fafc;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
}

.app-page .patient-details li {
  border-color: #cfdedb;
  background: #f4fbf9;
}

.ticket code {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.ticket-log {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #e1ebe8;
  width: 100%;
  min-width: 0;
}

.ticket-log summary {
  width: fit-content;
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
}

.ticket-log summary:hover {
  color: var(--accent);
}

.ticket-log ol {
  position: relative;
  display: grid;
  gap: 14px;
  margin: 12px 0 0;
  padding: 2px 0;
  list-style: none;
}

.ticket-log ol::before {
  content: "";
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 0;
  width: 2px;
  background: #cfdedb;
}

.ticket-log li {
  position: relative;
  padding-left: 18px;
}

.ticket-log li::before {
  content: "";
  position: absolute;
  top: 12px;
  left: 1px;
  transform: translateX(-50%);
  z-index: 1;
  width: 10px;
  height: 10px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  background: #fff;
}

.timeline-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
  margin: 0;
  padding-top: 2px;
}

.timeline-copy span {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.timeline-copy small {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.ticket-log time {
  color: var(--ink);
  font-weight: 750;
}

.device-footer {
  color: var(--muted);
  font-size: 12px;
  margin: 12px auto 20px;
  max-width: min(100% - 32px, 1160px);
  text-align: center;
}

.device-footer code {
  color: inherit;
  overflow-wrap: anywhere;
}

.settings-view {
  display: grid;
  gap: 18px;
}

.settings-view[hidden],
#queue-view[hidden],
#defaults-panel[hidden],
#sites-panel[hidden],
#admin-panel[hidden],
#login-panel[hidden] {
  display: none;
}

.settings-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-page .ticket > div:first-child {
  min-width: 0;
}

.admin-page .ticket strong {
  color: var(--accent-strong);
}

.admin-page .link-stack {
  justify-content: flex-end;
}

.empty {
  color: var(--muted);
  margin-bottom: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(23, 32, 42, 0.45);
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(460px, 100%);
  background: var(--panel);
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 18px 48px rgba(23, 32, 42, 0.25);
}

.app-page .modal {
  border: 1px solid #cfdedb;
  box-shadow: 0 18px 48px rgba(23, 32, 42, 0.18);
}

@media (max-width: 760px) {
  .split,
  .topbar,
  .section-head,
  .ticket,
  .ticket-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .actions,
  .ticket-actions {
    width: 100%;
  }

  .actions > *,
  .ticket-actions > * {
    flex: 1 1 130px;
  }

  .ticket-log li {
    padding-left: 18px;
  }

  .app-page .shell {
    width: min(100vw - 16px, 680px);
    min-height: calc(100vh - 16px);
    margin: 8px auto;
    gap: 16px;
    padding-bottom: 20px;
  }

  .app-page .topbar {
    padding: 20px;
  }

  .app-page .panel,
  .app-page .queue {
    margin: 0 20px;
    padding: 20px;
  }

  .app-page .section-head {
    gap: 12px;
  }

  .app-page .tabs {
    width: 100%;
  }

  .app-page .tab {
    flex: 1 1 120px;
  }

  .admin-page .link-stack {
    justify-content: stretch;
    width: 100%;
  }

  .admin-page .link-stack > * {
    flex: 1 1 140px;
  }

  .calendar-day {
    min-height: 68px;
  }

  .calendar-day span {
    font-size: 20px;
  }

  .calendar-grid {
    gap: 4px;
  }

  .calendar-grid-large {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .kiosk-shell {
    width: min(100vw - 16px, 680px);
    padding: 8px 0;
    align-items: start;
  }

  .kiosk-card {
    min-height: calc(100vh - 16px);
  }

  .kiosk-header {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .stepper {
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .stepper li {
    min-width: 86px;
    font-size: 12px;
  }

  .stepper li:not(:last-child)::after {
    top: 16px;
  }

  .stepper b {
    width: 34px;
    height: 34px;
  }

  .kiosk-flow {
    padding: 20px;
  }

  .service-choice-grid,
  .visit-choice-grid,
  .kiosk-input-grid,
  .settings-grid,
  .live-stats,
  .success-summary {
    grid-template-columns: 1fr;
  }

  .kiosk-home {
    padding: 28px 20px;
    align-content: start;
  }

  .live-stats article {
    min-height: 126px;
  }

  .begin-checkin {
    width: 100%;
    font-size: 22px;
  }

  .choice-card {
    min-height: 126px;
    padding: 18px;
  }

  .kiosk-controls {
    display: grid;
    grid-template-columns: 1fr;
  }

  .kiosk-nav {
    display: grid;
    grid-template-columns: 1fr;
  }

  .kiosk-controls button,
  .success-step button {
    width: 100%;
  }
}
