:root {
  --bg: oklch(98% 0.006 130);
  --surface: oklch(100% 0 0);
  --surface-soft: oklch(96% 0.025 140);
  --fg: oklch(20% 0.025 145);
  --muted: oklch(48% 0.025 145);
  --border: oklch(88% 0.025 140);
  --accent: oklch(42% 0.13 145);
  --accent-strong: oklch(30% 0.11 145);
  --hero-green: #8FA68F;
  --gold: oklch(84% 0.18 96);
  --gold-soft: oklch(96% 0.045 96);
  --success: #17A34A;
  --warn: #EAB308;
  --danger: #DC2626;
  --font-display: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", Menlo, monospace;
  --radius: 18px;
  --radius-sm: 10px;
  --shadow: 0 16px 40px rgb(17 45 30 / 10%);
  --max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 86% 6%, rgb(234 179 8 / 15%), transparent 28%),
    linear-gradient(135deg, var(--surface-soft), var(--bg) 58%);
  color: var(--fg);
  font-family: var(--font-body);
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.wrap { width: min(var(--max), calc(100% - 40px)); margin: 0 auto; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in oklch, var(--bg) 92%, white);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
}
.nav {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.brand { display: inline-flex; align-items: center; min-width: 120px; }
.brand img {
  width: 128px;
  height: 54px;
  object-fit: contain;
  object-position: left center;
  mix-blend-mode: multiply;
}
.nav-actions { display: flex; align-items: center; gap: 10px; }
.crumb {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.btn {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  font-weight: 850;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: white; }
.btn-gold { background: var(--gold); color: var(--accent-strong); }
.btn-secondary { border-color: var(--border); background: var(--surface); color: var(--fg); }
.btn-danger { background: var(--danger); color: white; }
.btn-wide { width: 100%; }

.flow {
  flex: 1;
  padding: clamp(28px, 5vw, 58px) 0 clamp(42px, 7vw, 84px);
}
.flow-grid {
  display: grid;
  grid-template-columns: minmax(260px, .38fr) minmax(0, 1fr);
  gap: clamp(22px, 4vw, 44px);
  align-items: start;
}
.side {
  position: sticky;
  top: 102px;
  display: grid;
  gap: 16px;
}
.side-card, .main-card, .summary-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgb(255 255 255 / 86%);
  box-shadow: var(--shadow);
}
.side-card { padding: 22px; }
.main-card { padding: clamp(24px, 4vw, 42px); overflow: hidden; }
.summary-card { padding: 20px; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: .11em;
  text-transform: uppercase;
}
.eyebrow::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--gold);
}
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: var(--font-display); letter-spacing: -0.01em; line-height: 1.08; }
h1 { max-width: 780px; margin-bottom: 16px; font-size: clamp(34px, 5vw, 64px); }
h2 { margin-bottom: 10px; font-size: clamp(26px, 3vw, 38px); }
h3 { margin-bottom: 8px; font-size: 20px; }
p { color: var(--muted); }
.lead { max-width: 720px; margin-bottom: 28px; font-size: clamp(16px, 1.5vw, 20px); line-height: 1.65; }

.steps { display: grid; gap: 8px; margin: 16px 0 0; padding: 0; list-style: none; }
.steps li {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 14px;
}
.steps b {
  display: inline-grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: white;
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 12px;
}
.steps li.is-current { color: var(--fg); font-weight: 800; }
.steps li.is-current b { background: var(--accent); border-color: var(--accent); color: white; }
.steps li.is-done b { background: var(--gold); border-color: var(--gold); color: var(--accent-strong); }

.progress {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}
.progress span {
  display: block;
  width: var(--progress, 8%);
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.data-note {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  margin: 0 0 24px;
  padding: 16px;
  border: 1px solid color-mix(in oklch, var(--accent) 20%, var(--border));
  border-radius: var(--radius-sm);
  background: color-mix(in oklch, var(--accent) 6%, white);
  color: var(--muted);
  font-size: 14px;
}
.data-note b {
  display: inline-grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 10px;
  background: var(--accent);
  color: white;
  font-family: var(--font-mono);
}

.form { display: grid; gap: 18px; }
.field { display: grid; gap: 8px; }
label { color: var(--fg); font-size: 14px; font-weight: 850; }
input, select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  color: var(--fg);
  outline: none;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 12%, transparent);
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

.option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.option-card {
  display: grid;
  gap: 9px;
  min-height: 138px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: white;
  text-align: left;
  cursor: pointer;
}
.option-card:hover, .option-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in oklch, var(--accent) 9%, transparent);
}
.option-card strong { font-size: 17px; }
.option-card span, .option-card small { color: var(--muted); }
.option-card small { font-family: var(--font-mono); font-size: 12px; }
.option-card .pill { justify-self: start; }

.pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 850;
}
.pill-green { background: color-mix(in oklch, var(--accent) 10%, white); color: var(--accent); }
.pill-danger { background: rgb(220 38 38 / 10%); color: var(--danger); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}
.day-btn, .slot-btn {
  min-height: 54px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: white;
  color: var(--fg);
  font-weight: 850;
  cursor: pointer;
}
.day-btn span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.day-btn.is-selected, .slot-btn.is-selected {
  border-color: var(--accent);
  background: color-mix(in oklch, var(--accent) 9%, white);
  color: var(--accent-strong);
}
.slots {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.slot-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 8px;
  min-height: 64px;
}
.slot-btn__time {
  font-size: 1.05rem;
  font-weight: 900;
}
.slot-btn__doctor {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.2;
  text-align: center;
}

.slots > .panel-message,
.slots > .slots-day-heading,
.slots > .slots-empty-wrap {
  grid-column: 1 / -1;
}

.slots-day-heading {
  margin: 0 0 4px;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--accent-strong);
  text-align: left;
}

.slots.is-loading {
  opacity: 0.55;
  pointer-events: none;
}

.slot-btn__date {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--accent-strong);
  line-height: 1.2;
  text-transform: none;
}

.panel-message {
  margin: 0;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
  text-align: center;
}

.panel-message--empty {
  border-style: dashed;
}

.panel-message--info {
  border-color: color-mix(in oklch, var(--accent) 28%, var(--border));
  background: color-mix(in oklch, var(--accent) 6%, white);
  text-align: left;
  margin-bottom: 12px;
}

.panel-message__title {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--fg);
}

.panel-message__text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
}

.panel-message__meta {
  margin: 10px 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-strong);
}

.receipt {
  display: grid;
  gap: 10px;
  margin: 22px 0;
  padding: 0;
  list-style: none;
}
.receipt li {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.receipt strong { color: var(--fg); text-align: right; }

.success-hero {
  display: grid;
  gap: 16px;
  padding: clamp(24px, 4vw, 42px);
  border-radius: 28px;
  background:
    radial-gradient(circle at 82% 18%, rgb(234 179 8 / 22%), transparent 24%),
    linear-gradient(135deg, var(--accent-strong), var(--accent));
  color: white;
}
.success-hero h1, .success-hero p { color: white; }
.success-hero .receipt li {
  border-bottom-color: rgb(255 255 255 / 18%);
  color: rgb(255 255 255 / 78%);
}
.success-hero .receipt strong { color: white; }
.success-hero .btn-secondary {
  border-color: rgb(255 255 255 / 24%);
  background: rgb(255 255 255 / 12%);
  color: white;
}
.success-code {
  width: fit-content;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgb(255 255 255 / 14%);
  font-family: var(--font-mono);
  font-weight: 850;
}

.footer {
  border-top: 1px solid var(--border);
  padding: 22px 0;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 980px) {
  .flow-grid { grid-template-columns: 1fr; }
  .side { position: static; grid-template-columns: 1fr 1fr; }
}

.main-card.is-loading [data-options],
.main-card.is-loading .calendar-grid,
.main-card.is-loading .slots {
  opacity: 0.45;
  pointer-events: none;
}

.flow-status {
  margin: 16px 0;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.flow-status--error {
  border-color: color-mix(in oklch, var(--danger) 40%, var(--border));
  background: color-mix(in oklch, var(--danger) 8%, white);
}

.flow-status--success {
  background: rgba(34, 139, 34, 0.08);
  border-color: rgba(34, 139, 34, 0.35);
  color: #1a5c1a;
}

.hint {
  font-size: 0.9rem;
  color: var(--muted, #5c6570);
  margin: 0.5rem 0 0;
}

.hint a {
  color: var(--brand, #0d6b5c);
  text-decoration: underline;
}

.option-card--static {
  cursor: default;
  pointer-events: none;
  text-align: left;
}

.patient-panel {
  margin-top: 20px;
  padding: 16px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface-soft);
}

.patient-panel .receipt {
  margin: 12px 0 0;
}

.data-table-wrap {
  margin-top: 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--surface-soft);
  white-space: nowrap;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: color-mix(in oklch, var(--accent) 6%, white);
}

.option-card.is-busy,
.btn.is-busy {
  opacity: 0.7;
}

.flow-status--empty {
  border-color: var(--border);
}

.flow-status__text {
  margin: 0;
  color: var(--muted);
}

.flow-status__retry {
  margin-top: 10px;
}

.session-alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  border: 1px solid color-mix(in oklch, var(--gold) 50%, var(--border));
  font-size: 14px;
}

.btn:disabled,
.option-card:disabled,
.day-btn:disabled,
.slot-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 720px) {
  .wrap { width: min(100% - 28px, var(--max)); }
  .nav { height: auto; min-height: 70px; padding: 10px 0; }
  .brand img { width: 108px; }
  .crumb { display: none; }
  .nav-actions .btn-secondary { display: none; }
  .flow { padding-top: 22px; }
  .side { grid-template-columns: 1fr; }
  .main-card, .side-card, .summary-card { border-radius: 16px; }
  .option-grid, .form-grid { grid-template-columns: 1fr; }
  .calendar-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .actions .btn { width: 100%; }
  .receipt li { display: grid; gap: 4px; }
  .receipt strong { text-align: left; }
  .data-table thead { display: none; }
  .data-table tr {
    display: grid;
    gap: 6px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
  }
  .data-table td {
    display: grid;
    grid-template-columns: minmax(90px, 38%) 1fr;
    gap: 8px;
    padding: 4px 0;
    border: none;
  }
  .data-table td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 600;
  }
}
