:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #17201c;
  --muted: #647067;
  --line: #dfe6e2;
  --court: #198754;
  --court-dark: #0f5f3a;
  --accent: #2457d6;
  --accent-soft: #e8eefc;
  --danger: #d64545;
  --warning: #b76a00;
  --paid: #0c7a43;
  --shadow: 0 18px 44px rgba(23, 32, 28, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(25, 135, 84, 0.08) 1px, transparent 1px),
    linear-gradient(0deg, rgba(36, 87, 214, 0.06) 1px, transparent 1px),
    var(--bg);
  background-size: 36px 36px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 0 16px;
}

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

.venue-logo {
  width: 118px;
  height: 68px;
  flex: 0 0 118px;
  object-fit: contain;
  background: #111111;
  border-radius: 8px;
  padding: 8px;
}

.venue-visual {
  position: relative;
  overflow: hidden;
  height: 182px;
  margin-bottom: 14px;
  background: #111111;
  border: 1px solid #202520;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.venue-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(12, 16, 14, 0.42), rgba(12, 16, 14, 0));
  pointer-events: none;
}

.venue-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 44%;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--court-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 6px;
  font-size: 3.7rem;
  line-height: 0.95;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.05rem;
  line-height: 1.2;
}

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

.admin-link {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 11px 14px;
  color: var(--ink);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(23, 32, 28, 0.06);
}

.progress-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 14px;
}

.progress-step {
  min-height: 38px;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 750;
}

.progress-step.active {
  color: #ffffff;
  background: var(--court);
  border-color: var(--court);
}

.alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  color: #7a240e;
  background: #fff0e9;
  border: 1px solid #ffd0bd;
  border-radius: 8px;
}

.booking-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.82fr) minmax(0, 1fr) minmax(310px, 0.7fr);
  gap: 14px;
  align-items: start;
}

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

.scan-panel,
.court-panel,
.time-panel {
  min-height: 280px;
}

.summary-panel {
  position: sticky;
  top: 16px;
}

.panel-head {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.step-dot {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--ink);
  border-radius: 50%;
  font-weight: 800;
}

.qr-reader {
  overflow: hidden;
  min-height: 260px;
  background: #0f1512;
  border: 1px solid #23372d;
  border-radius: 8px;
}

.qr-reader video {
  width: 100%;
}

.button-row,
.input-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.button-row {
  margin: 14px 0 18px;
  flex-wrap: wrap;
}

.button {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 800;
}

.button.primary {
  color: #ffffff;
  background: var(--court);
  border-color: var(--court);
}

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

.button.secondary {
  color: var(--court-dark);
  background: #e8f6ee;
  border-color: #bfe4ce;
}

.button.ghost {
  color: var(--ink);
  background: transparent;
  border-color: var(--line);
}

.button.compact {
  min-width: 76px;
  color: #ffffff;
  background: var(--accent);
}

.button.full {
  width: 100%;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
}

input,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 87, 214, 0.15);
}

.manual-court {
  display: grid;
  gap: 10px;
}

.court-grid {
  display: grid;
  gap: 10px;
}

.court-card {
  width: 100%;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 88px;
  padding: 12px;
  text-align: left;
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.court-card.active {
  border-color: var(--court);
  box-shadow: 0 0 0 3px rgba(25, 135, 84, 0.13);
}

.court-card.master {
  border-color: #bfd86d;
  background: #fbfdf5;
}

.court-card.master.active {
  border-color: #85c628;
  box-shadow: 0 0 0 3px rgba(133, 198, 40, 0.18);
}

.court-card:disabled {
  opacity: 0.58;
}

.court-mini {
  position: relative;
  height: 58px;
  overflow: hidden;
  background: var(--court);
  border: 2px solid #ffffff;
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.38);
}

.court-mini::before,
.court-mini::after {
  content: "";
  position: absolute;
  inset: 9px 11px;
  border: 1px solid rgba(255, 255, 255, 0.78);
}

.court-mini::after {
  inset: 0 auto 0 50%;
  width: 1px;
  border: 0;
  background: rgba(255, 255, 255, 0.78);
}

.court-name {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-weight: 850;
}

.court-price {
  color: var(--court-dark);
  flex: 0 0 auto;
  font-size: 0.92rem;
  font-weight: 850;
}

.court-price-line {
  display: block;
  margin-top: 6px;
  color: var(--court-dark);
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.25;
}

.court-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.85rem;
}

.date-strip {
  min-width: 0;
  max-width: 100%;
  display: grid;
  grid-template-columns: repeat(7, minmax(84px, 1fr));
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.date-btn,
.duration-btn,
.slot-btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.date-btn {
  min-height: 58px;
  padding: 9px 10px;
  text-align: left;
}

.date-btn strong,
.date-btn span {
  display: block;
}

.date-btn span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.8rem;
}

.date-btn.active,
.duration-btn.active,
.slot-btn.active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.date-btn.active span {
  color: rgba(255, 255, 255, 0.82);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.duration-btn {
  min-height: 42px;
  font-weight: 800;
}

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px;
}

.slot-btn {
  min-height: 58px;
  padding: 8px;
  display: grid;
  align-content: center;
  gap: 3px;
  color: var(--ink);
  font-weight: 850;
}

.slot-btn small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.slot-btn.active small {
  color: rgba(255, 255, 255, 0.82);
}

.slot-btn:disabled {
  color: #879189;
  background: #eef2f0;
  text-decoration: line-through;
}

.booking-form {
  display: grid;
  gap: 13px;
}

.summary-box {
  min-height: 116px;
  padding: 13px;
  background: #f7faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(223, 230, 226, 0.8);
}

.summary-line:last-child {
  border-bottom: 0;
}

.summary-line span {
  color: var(--muted);
}

.summary-line strong {
  text-align: right;
}

.payment-panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.payment-code {
  display: inline-flex;
  width: fit-content;
  padding: 6px 9px;
  color: #ffffff;
  background: var(--ink);
  border-radius: 8px;
  font-weight: 850;
}

.payment-qr {
  width: min(100%, 360px);
  aspect-ratio: 1 / 1.18;
  object-fit: contain;
  justify-self: center;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.payment-fallback {
  padding: 12px;
  color: var(--warning);
  background: #fff7df;
  border: 1px solid #f2d694;
  border-radius: 8px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  width: fit-content;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 850;
}

.status-pill.pending_payment {
  color: #744300;
  background: #fff2cf;
}

.status-pill.payment_review {
  color: #16499c;
  background: #e7efff;
}

.status-pill.paid,
.status-pill.checked_in {
  color: #ffffff;
  background: var(--paid);
}

.status-pill.cancelled {
  color: #ffffff;
  background: var(--danger);
}

.status-pill.expired {
  color: #6b4a00;
  background: #fff2b8;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

@media (max-width: 1020px) {
  .booking-layout {
    grid-template-columns: 1fr 1fr;
  }

  .summary-panel,
  .time-panel {
    grid-column: 1 / -1;
  }

  .summary-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 620px);
    padding-top: 12px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-lockup {
    gap: 10px;
  }

  .venue-logo {
    width: 86px;
    height: 54px;
    flex-basis: 86px;
    padding: 6px;
  }

  .venue-visual {
    height: 128px;
  }

  .admin-link {
    min-height: 38px;
    padding: 9px 11px;
  }

  h1 {
    font-size: 2.4rem;
  }

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

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

  .panel {
    padding: 15px;
  }

  .date-strip {
    grid-template-columns: repeat(7, 94px);
  }

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

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