:root {
  color-scheme: light;
  --mit-red: #cc0000;
  --mit-red-dark: #990000;
  --mit-red-soft: #f8e7e7;
  --bg: #f7f7f7;
  --panel: #fffefe;
  --panel-strong: #ffffff;
  --text: #242424;
  --muted: #666666;
  --line: #dedede;
  --accent: #cc0000;
  --accent-dark: #990000;
  --accent-soft: #f8e7e7;
  --warn: #9a531b;
  --warn-soft: #f8eadf;
  --done: #245c35;
  --done-soft: #e5f3e8;
  --danger: #8a2e2e;
  --danger-soft: #f4dfdf;
  --shadow: 0 18px 48px rgba(37, 48, 64, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

body.walkup-active {
  background: var(--panel);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.hidden {
  display: none !important;
}

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

.eyebrow {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.15rem;
}

.topbar-actions,
.card-actions,
.booking-meta,
.status-actions,
.source-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button,
.icon-button,
.plain-button,
.danger-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 800;
  white-space: nowrap;
}

.primary-button {
  background: var(--accent);
  color: white;
  text-decoration: none;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.icon-button,
.plain-button,
.danger-button {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
}

.danger-button {
  border: 1px solid #d8bcbc;
  color: var(--danger);
}

.danger-button:hover {
  background: var(--danger-soft);
}

.plain-button {
  min-height: 36px;
  padding-inline: 10px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.stat-card,
.source-panel,
.device-panel,
.booking-card,
.controls,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.stat-card {
  min-height: 86px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.stat-card span,
label span,
.muted {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 700;
}

.stat-card strong {
  font-size: 2rem;
  line-height: 1;
}

.controls {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(5, minmax(120px, 1fr));
  gap: 10px;
  padding: 12px;
  margin-bottom: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-hint {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
}

.ceremony-note {
  display: block;
  margin-top: 4px;
  padding: 10px 12px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--mit-red-soft);
  color: #5d1111;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

input[type="checkbox"] {
  width: 24px;
  min-height: 24px;
  accent-color: var(--accent);
}

.source-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
}

.sync-panel {
  margin-top: -6px;
}

.sync-panel h2 {
  display: inline;
  margin: 0 8px 0 0;
  font-size: 0.95rem;
}

.sync-panel p {
  display: inline;
}

.device-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  align-items: end;
  gap: 12px;
  padding: 14px;
  margin-bottom: 12px;
}

.source-panel p,
.device-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.source-actions {
  justify-content: flex-end;
}

.booking-list {
  display: grid;
  gap: 10px;
}

.booking-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  padding: 14px;
}

.booking-main {
  min-width: 0;
}

.booking-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.booking-title-row h3 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.pill {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 900;
}

.pill.waiting {
  color: var(--warn);
  background: var(--warn-soft);
}

.pill.checked-in {
  color: var(--accent-dark);
  background: var(--accent-soft);
}

.pill.studio {
  color: var(--done);
  background: var(--done-soft);
}

.pill.completed {
  color: #465366;
  background: #e3e8ee;
}

.pill.no-show {
  color: var(--danger);
  background: var(--danger-soft);
}

.pill.source {
  color: var(--muted);
  background: #edf1f5;
}

.booking-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 1fr));
  align-items: stretch;
}

.booking-details-grid {
  display: grid;
  grid-template-columns: minmax(260px, 2.2fr) minmax(160px, 1.15fr) minmax(90px, 0.65fr) minmax(115px, 0.75fr) minmax(120px, 0.8fr);
  gap: 8px;
  align-items: end;
}

.booking-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(128px, 1fr));
  gap: 8px;
}

.booking-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.booking-section {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.section-label {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.complete-banner {
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--done);
  background: var(--done-soft);
  white-space: nowrap;
}

.booking-field {
  min-width: 0;
}

.booking-field.is-compact {
  gap: 3px;
}

.booking-field span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.booking-field select,
.booking-field input {
  margin-top: 4px;
  min-height: 38px;
  background: #f4f7fa;
  font-weight: 800;
  padding: 7px 9px;
}

.booking-field.is-compact select,
.booking-field.is-compact input {
  margin-top: 0;
  min-height: 34px;
  padding: 6px 8px;
}

.booking-details-grid .meta-item {
  min-width: 0;
}

.meta-item {
  min-width: 0;
  min-height: 34px;
  padding: 7px 10px;
  background: #f4f7fa;
  border-radius: 8px;
}

.meta-item span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
}

.meta-item strong {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.notes {
  margin: 10px 0 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.status-actions {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 220px;
  max-width: 240px;
}

.status-actions button {
  min-width: 0;
}

.compact-button {
  min-height: 36px;
}

.action-panel {
  display: grid;
  gap: 10px;
}

.action-primary {
  width: 100%;
  min-height: 52px;
  font-size: 1.02rem;
}

.action-utility {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.action-utility .primary-button,
.action-utility .secondary-button,
.action-utility .danger-button {
  padding-inline: 10px;
}

.action-utility .danger-button {
  grid-column: 1 / -1;
}

.timer-pill {
  width: 100%;
  padding: 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 900;
  text-align: center;
}

.booking-card.is-completed {
  background: #edf1f5;
  border-color: #c6d0dc;
  color: #38475a;
}

.booking-card.is-completed .meta-item,
.booking-card.is-completed .booking-field select,
.booking-card.is-completed .booking-field input {
  background: #e2e8ef;
}

.booking-card.is-completed .status-actions .primary-button,
.booking-card.is-completed .status-actions .secondary-button {
  opacity: 0.82;
}

.empty-state {
  text-align: center;
  padding: 42px 18px;
}

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

dialog {
  width: min(720px, calc(100% - 24px));
  padding: 0;
  border: 0;
  border-radius: 10px;
  box-shadow: var(--shadow);
  background: transparent;
}

dialog::backdrop {
  background: rgba(31, 37, 35, 0.42);
}

.dialog-card {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.dialog-card header,
.dialog-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dialog-card footer {
  margin-top: 16px;
  justify-content: flex-end;
}

.dialog-help,
.column-guide p {
  color: var(--muted);
}

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

.wide {
  grid-column: 1 / -1;
}

.column-guide {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7fa;
}

.column-guide p {
  margin: 6px 0 0;
}

.walkup-view {
  min-height: 100vh;
  background: var(--panel);
}

.qr-booking-view {
  background: linear-gradient(180deg, #f8fafc 0%, #e9eef4 100%);
}

.walkup-shell {
  width: min(860px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.qr-booking-view .walkup-shell {
  width: min(900px, 100%);
  justify-content: flex-start;
  padding-top: clamp(56px, 10vh, 110px);
  padding-bottom: 46px;
}

.staff-gate-shell {
  width: min(680px, 100%);
}

.staff-gate-panel {
  border-top: 5px solid var(--accent);
}

.walkup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.customer-logo {
  display: block;
  width: auto;
  height: 62px;
  max-width: min(320px, 62vw);
  margin: 0 0 18px;
  filter: saturate(1.22) contrast(1.16) drop-shadow(0 8px 14px rgba(32, 42, 53, 0.16));
}

.qr-booking-view .customer-logo {
  height: 70px;
  max-width: min(360px, 70vw);
  margin-bottom: 24px;
}

.walkup-header h1 {
  font-size: clamp(2rem, 6vw, 4rem);
}

.qr-booking-view .walkup-header {
  margin-bottom: 22px;
}

.qr-booking-view .walkup-header h1 {
  max-width: 760px;
  font-size: clamp(2.45rem, 8vw, 4.6rem);
  letter-spacing: 0;
}

.staff-exit {
  opacity: 0.66;
}

.walkup-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.qr-booking-view .walkup-panel {
  border-color: #cbd5e0;
  padding: clamp(22px, 4vw, 34px);
  box-shadow: 0 22px 58px rgba(52, 70, 90, 0.16);
}

.qr-booking-view .walkup-success {
  text-align: left;
  border-top: 5px solid var(--accent);
}

.walkup-panel h2 {
  font-size: 1.4rem;
}

.qr-booking-view .walkup-panel h2 {
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1.05;
}

.walkup-form input,
.walkup-form select,
.walkup-form textarea {
  min-height: 52px;
  font-size: 1.1rem;
}

.walkup-form select {
  font-weight: 650;
}

.walkup-form textarea {
  min-height: 104px;
}

.walkup-footer {
  margin-top: 16px;
  display: flex;
  justify-content: flex-end;
}

.submit-walkup {
  min-height: 56px;
  min-width: 210px;
  font-size: 1.05rem;
}

.walkup-success {
  text-align: center;
}

.walkup-success h2 {
  font-size: clamp(2rem, 6vw, 3.2rem);
}

.walkup-success p {
  color: var(--muted);
  font-size: 1.2rem;
}

.walkup-success .success-reminder {
  margin: 14px 0 0;
  padding: 12px 14px;
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  background: var(--accent-soft);
  color: #5d1111;
  font-size: 1rem;
  font-weight: 700;
  text-align: left;
}

.qr-booking-view .walkup-success p {
  max-width: 520px;
}

.success-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.qr-booking-view .success-actions {
  justify-content: flex-start;
}

.checkbox-row {
  min-height: 52px;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  padding: 13px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-strong);
}

.checkbox-row span {
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 800;
}

.staff-code-panel {
  width: min(480px, 100%);
  margin: 0 auto;
}

.staff-code-panel p {
  color: var(--muted);
}

.staff-code-form {
  display: grid;
  gap: 12px;
}

.staff-code-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.staff-code-error {
  margin: 0;
  color: var(--danger) !important;
  font-weight: 800;
}

@media (max-width: 800px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .source-panel,
  .device-panel,
  .booking-card,
  .walkup-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    display: grid;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .source-actions {
    display: grid;
  }

  .status-grid,
  .controls,
  .device-panel,
  .form-grid,
  .source-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .search-box,
  .wide {
    grid-column: 1 / -1;
  }

  .booking-card {
    grid-template-columns: 1fr;
  }

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

  .booking-details-grid .booking-field,
  .booking-details-grid .meta-item {
    min-width: 0;
  }

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

  .status-actions {
    display: grid;
    grid-template-columns: 1fr;
    min-width: 0;
    max-width: none;
  }

  .status-actions button {
    min-width: 0;
  }

  .walkup-shell {
    justify-content: flex-start;
  }

  .walkup-footer,
  .success-actions,
  .staff-code-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .submit-walkup {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .status-grid,
  .controls,
  .device-panel,
  .form-grid,
  .topbar-actions,
  .status-actions,
  .source-actions {
    grid-template-columns: 1fr;
  }

  .booking-details-grid,
  .booking-meta,
  .booking-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .action-utility {
    grid-template-columns: 1fr;
  }
}
