:root {
  --brand: #0f766e;
  --brand-600: #0d9488;
  --brand-50: #f0fdfa;
  --brand-100: #ccfbf1;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f6f8fb;
  --card: #ffffff;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --warn: #b45309;
  --warn-50: #fffbeb;
  --ok: #15803d;
  --ok-50: #f0fdf4;
  --info: #4338ca;
  --info-50: #eef2ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgb(15 23 42 / 4%), 0 4px 16px rgb(15 23 42 / 6%);
  --shadow-lg: 0 10px 40px rgb(15 23 42 / 16%);
  --nav-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.02em; margin: 0; }
h1 { font-size: clamp(1.6rem, 4vw, 2.25rem); font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 650; }
p { margin: 0; }
svg.icon { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 3px solid rgb(13 148 136 / 40%); outline-offset: 2px; }

/* Top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgb(255 255 255 / 85%);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 0 1.25rem; height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.2rem; color: var(--ink); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 32px; height: 32px; border-radius: 9px; background: url("/favicon.svg") center / cover; box-shadow: 0 4px 12px rgb(13 148 136 / 35%); }
nav { display: flex; align-items: center; gap: .25rem; }
.nav-item {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .5rem .85rem; border-radius: 999px; border: 0; background: none;
  color: var(--ink-2); font: inherit; font-weight: 550; font-size: .95rem; cursor: pointer;
}
.nav-item:hover { background: #f1f5f9; text-decoration: none; }
.nav-item.active { background: var(--brand-50); color: var(--brand); }
.nav-item.cta { background: var(--brand); color: #fff; }
.nav-item.cta:hover { background: var(--brand-600); }

main { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

/* Mobile: nav becomes a bottom tab bar */
@media (max-width: 720px) {
  main { padding: 1rem 1rem calc(var(--nav-h) + 2rem + env(safe-area-inset-bottom)); }
  /* backdrop-filter would make the fixed nav position relative to the top bar */
  .topbar { backdrop-filter: none; background: rgb(255 255 255 / 97%); }
  nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding: 0 .5rem env(safe-area-inset-bottom);
    background: rgb(255 255 255 / 95%); backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); justify-content: space-around;
  }
  .nav-item { flex-direction: column; gap: .15rem; font-size: .72rem; padding: .4rem .5rem; border-radius: 12px; flex: 1; justify-content: center; }
  .nav-item svg.icon { width: 1.35rem; height: 1.35rem; }
  .nav-item.cta { background: none; color: var(--brand); }
  .hide-mobile { display: none !important; }
}

/* Surfaces */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 1rem; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 2rem 0 .85rem; }
.muted { color: var(--muted); font-size: .92rem; }
.small { font-size: .85rem; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; color: var(--muted); font-size: .9rem; }
.meta > span { display: inline-flex; align-items: center; gap: .35rem; }
.grid { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.page-head { margin-bottom: 1.25rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head p { margin-top: .35rem; }
.back { display: inline-flex; align-items: center; gap: .35rem; color: var(--muted); font-weight: 550; margin-bottom: 1rem; }

/* Hero */
.hero {
  position: relative; overflow: hidden; border-radius: 24px; padding: 2rem 1.5rem 1.5rem;
  background: radial-gradient(1200px 300px at 100% 0%, #5eead4 0%, transparent 60%), linear-gradient(135deg, #0f766e, #115e59 60%, #134e4a);
  color: #fff; box-shadow: var(--shadow-lg);
}
.hero h1 { max-width: 560px; }
.hero > p { color: rgb(255 255 255 / 85%); margin-top: .5rem; max-width: 520px; }
.search-panel { margin-top: 1.5rem; background: #fff; border-radius: 16px; padding: .5rem; display: grid; gap: .5rem; grid-template-columns: 1fr 1fr auto; box-shadow: var(--shadow-lg); }
.search-panel .input-wrap { margin: 0; }
.search-panel input { border: 0; background: #f8fafc; }
.hero-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.chip-light { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid rgb(255 255 255 / 35%); background: rgb(255 255 255 / 12%); color: #fff; border-radius: 999px; padding: .45rem .9rem; font: inherit; font-size: .9rem; font-weight: 550; cursor: pointer; }
.chip-light:hover { background: rgb(255 255 255 / 22%); }
@media (max-width: 720px) {
  .hero { padding: 1.5rem 1.1rem 1.1rem; border-radius: 20px; }
  .search-panel { grid-template-columns: 1fr; }
}

/* Forms */
form { display: block; }
.field { margin-top: 1rem; }
.field:first-child { margin-top: 0; }
label, .label { display: block; font-weight: 600; font-size: .9rem; color: var(--ink-2); margin-bottom: .4rem; }
.hint { color: var(--muted); font-size: .82rem; margin-top: .35rem; }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap > svg.icon { position: absolute; left: .85rem; color: var(--muted); pointer-events: none; }
.input-wrap > .prefix { position: absolute; left: .9rem; color: var(--muted); font-weight: 600; pointer-events: none; }
.input-wrap.has-icon input { padding-left: 2.6rem; }
input, select, textarea {
  width: 100%; padding: .75rem .9rem; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; font: inherit; color: var(--ink); transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-600); box-shadow: 0 0 0 4px rgb(13 148 136 / 15%); }
input::placeholder { color: #94a3b8; }
.otp-input { text-align: center; font-size: 1.6rem; letter-spacing: .6em; font-weight: 700; padding-left: 1.5rem; font-variant-numeric: tabular-nums; }
.row { display: grid; gap: 0 1rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.row > .field { margin-top: 1rem; }
.checkbox { display: flex; gap: .6rem; align-items: flex-start; font-weight: 450; color: var(--ink-2); font-size: .9rem; margin-top: 1rem; cursor: pointer; }
.checkbox input { width: 1.1rem; height: 1.1rem; margin-top: .15rem; accent-color: var(--brand); flex: none; }
.form-section + .form-section { margin-top: 1rem; }
.form-section h3 { display: flex; align-items: center; gap: .5rem; margin-bottom: 1rem; }
.form-section h3 svg.icon { color: var(--brand); }

/* Role picker */
.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.choice { position: relative; border: 2px solid var(--line); border-radius: 14px; padding: 1rem; cursor: pointer; display: grid; gap: .35rem; transition: border-color .15s, background .15s; margin: 0; }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice .choice-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #f1f5f9; color: var(--ink-2); }
.choice strong { color: var(--ink); }
.choice span { font-weight: 450; }
.choice:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); }
.choice:has(input:checked) .choice-icon { background: var(--brand); color: #fff; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .72rem 1.15rem; border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 650; font-size: .95rem; cursor: pointer; white-space: nowrap;
  transition: background .15s, transform .05s, box-shadow .15s; text-decoration: none;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgb(15 118 110 / 30%); }
.btn.primary:hover { background: var(--brand-600); }
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: #f8fafc; }
.btn.ghost { background: none; color: var(--brand); padding-left: .5rem; padding-right: .5rem; }
.btn.ghost:hover { background: var(--brand-50); }
.btn.danger { background: var(--danger-50); color: var(--danger); }
.btn.danger:hover { background: #fee2e2; }
.btn.block { width: 100%; }
.btn.lg { padding: .9rem 1.3rem; font-size: 1rem; }
.btn.sm { padding: .45rem .75rem; font-size: .85rem; border-radius: 10px; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1.25rem; }
.spinner { width: 1rem; height: 1rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .6rem; border-radius: 999px; font-size: .76rem; font-weight: 650; background: #f1f5f9; color: var(--ink-2); text-transform: capitalize; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.confirmed, .badge.approved, .badge.paid, .badge.completed { background: var(--ok-50); color: var(--ok); }
.badge.cancelled, .badge.no_show { background: var(--danger-50); color: var(--danger); }
.badge.unverified, .badge.pending { background: var(--warn-50); color: var(--warn); }
.badge.online { background: var(--info-50); color: var(--info); }
.badge.clinic { background: var(--brand-50); color: var(--brand); }
.badges { display: flex; flex-wrap: wrap; gap: .35rem; }

/* Avatars */
.avatar { --hue: 170; width: 56px; height: 56px; flex: none; border-radius: 16px; display: grid; place-items: center; font-weight: 750; font-size: 1.1rem; color: hsl(var(--hue) 60% 28%); background: linear-gradient(135deg, hsl(var(--hue) 75% 90%), hsl(var(--hue) 70% 80%)); }
.avatar.lg { width: 84px; height: 84px; border-radius: 22px; font-size: 1.6rem; }

/* Doctor card */
.doctor-card { display: flex; flex-direction: column; gap: 1rem; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; }
.doctor-card:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--brand-100); }
.doctor-card .top { display: flex; gap: .9rem; align-items: center; }
.doctor-card .spec { color: var(--brand); font-weight: 600; font-size: .9rem; }
.doctor-card .bottom { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding-top: .9rem; border-top: 1px dashed var(--line); }
.fee { font-weight: 750; font-size: 1.1rem; }
.fee small { color: var(--muted); font-weight: 500; font-size: .8rem; }

/* Doctor profile header */
.profile-head { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.profile-head .info { flex: 1; min-width: 220px; display: grid; gap: .35rem; }
.fee-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin-top: 1.25rem; }
.tile { background: #f8fafc; border: 1px solid var(--line); border-radius: 14px; padding: .85rem 1rem; }
.tile .label { margin: 0; font-weight: 550; color: var(--muted); font-size: .82rem; }
.tile .value { font-size: 1.35rem; font-weight: 750; margin-top: .15rem; }

/* Slots */
.tabs { display: inline-flex; background: #eef2f6; border-radius: 12px; padding: 4px; gap: 4px; }
.tab { border: 0; background: none; padding: .5rem 1rem; border-radius: 9px; font: inherit; font-weight: 600; font-size: .9rem; color: var(--ink-2); cursor: pointer; display: inline-flex; gap: .4rem; align-items: center; }
.tab.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgb(15 23 42 / 12%); }
.day { margin-top: 1.25rem; }
.day-label { font-weight: 650; font-size: .9rem; color: var(--ink-2); margin-bottom: .6rem; }
.slot-grid { display: flex; flex-wrap: wrap; gap: .5rem; }
.slot { border: 1px solid var(--brand-100); background: var(--brand-50); color: var(--brand); border-radius: 10px; padding: .55rem .9rem; font: inherit; font-weight: 650; font-size: .9rem; cursor: pointer; font-variant-numeric: tabular-nums; }
.slot:hover { background: var(--brand); color: #fff; border-color: var(--brand); }
.slot.booked { background: #f1f5f9; border-color: var(--line); color: var(--muted); cursor: pointer; }
.slot-chip { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: .35rem .35rem .35rem .75rem; font-weight: 600; font-size: .9rem; font-variant-numeric: tabular-nums; }
.slot-chip .mode-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-600); }
.slot-chip .mode-dot.online { background: var(--info); }
.slot-chip a { display: inline-flex; }
.icon-btn { width: 30px; height: 30px; border: 0; border-radius: 8px; display: grid; place-items: center; background: none; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--danger-50); color: var(--danger); }

/* Appointments */
.appt { display: flex; gap: 1rem; align-items: flex-start; }
.date-block { flex: none; width: 64px; border-radius: 14px; overflow: hidden; text-align: center; border: 1px solid var(--line); background: #fff; }
.date-block .mon { background: var(--brand); color: #fff; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: .2rem 0; }
.date-block .dd { font-size: 1.5rem; font-weight: 800; line-height: 1.1; padding: .3rem 0 0; }
.date-block .tt { font-size: .72rem; color: var(--muted); padding-bottom: .35rem; font-weight: 600; }
.appt .body { flex: 1; min-width: 0; display: grid; gap: .4rem; }
.appt .title { display: flex; justify-content: space-between; gap: .75rem; align-items: baseline; flex-wrap: wrap; }
.appt .title a { color: var(--ink); }
a.card.appt:hover { text-decoration: none; border-color: var(--brand-100); box-shadow: var(--shadow-lg); }

/* Payment */
.pay { display: grid; gap: 1.5rem; grid-template-columns: auto 1fr; align-items: center; }
.qr-frame { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: .75rem; box-shadow: var(--shadow); }
.qr { display: block; width: 200px; height: 200px; image-rendering: pixelated; }
.amount { font-size: 2rem; font-weight: 800; letter-spacing: -0.02em; }
.copy-row { display: flex; align-items: center; gap: .5rem; background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: .35rem .35rem .35rem .85rem; font-weight: 600; word-break: break-all; }
.copy-row span { flex: 1; }
@media (max-width: 600px) { .pay { grid-template-columns: 1fr; justify-items: center; text-align: center; } .pay .copy-row { text-align: left; width: 100%; } }

/* Callouts */
.callout { display: flex; gap: .75rem; align-items: flex-start; border-radius: 14px; padding: .9rem 1rem; font-size: .92rem; }
.callout svg.icon { margin-top: .15rem; }
.callout.ok { background: var(--ok-50); color: #14532d; }
.callout.warn { background: var(--warn-50); color: #78350f; }
.callout.info { background: var(--info-50); color: #312e81; }

/* Auth */
.auth { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; max-width: 940px; margin: 1rem auto; border-radius: 24px; overflow: hidden; box-shadow: var(--shadow-lg); background: #fff; border: 1px solid var(--line); }
.auth-aside { padding: 2.5rem; color: #fff; background: radial-gradient(600px 300px at 0% 100%, #5eead4 0%, transparent 60%), linear-gradient(160deg, #0f766e, #134e4a); display: flex; flex-direction: column; gap: 1.5rem; }
.auth-aside ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 1rem; }
.auth-aside li { display: flex; gap: .75rem; align-items: flex-start; color: rgb(255 255 255 / 90%); }
.auth-aside li .bullet { width: 36px; height: 36px; border-radius: 10px; background: rgb(255 255 255 / 16%); display: grid; place-items: center; flex: none; }
.auth-main { padding: 2.5rem; }
.auth-main h2 { font-size: 1.5rem; }
.auth-main > p, .auth-main .lead { margin: .4rem 0 1.5rem; color: var(--muted); }
.steps { display: flex; gap: .4rem; margin-bottom: 1.5rem; }
.steps span { height: 4px; flex: 1; border-radius: 4px; background: var(--line); }
.steps span.on { background: var(--brand-600); }
.wa-badge { display: inline-flex; align-items: center; gap: .4rem; background: #dcfce7; color: #166534; font-weight: 650; font-size: .8rem; padding: .25rem .6rem; border-radius: 999px; }
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; margin: 0; }
  .auth-aside { display: none; }
  .auth-main { padding: 1.5rem; }
}

/* Empty & loading */
.empty { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty .empty-icon { width: 56px; height: 56px; border-radius: 16px; background: #eef2f6; color: var(--muted); display: grid; place-items: center; margin: 0 auto .9rem; }
.empty .empty-icon svg.icon { width: 1.6rem; height: 1.6rem; }
.empty h3 { color: var(--ink); margin-bottom: .3rem; }
.loading { display: grid; place-items: center; padding: 4rem 0; color: var(--brand); }
.loading .spinner { width: 2rem; height: 2rem; border-width: 3px; }
.skeleton { background: linear-gradient(90deg, #eef2f6 25%, #f8fafc 50%, #eef2f6 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: var(--radius); height: 150px; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Dialog */
dialog { border: 0; border-radius: 20px; padding: 0; width: min(440px, calc(100vw - 2rem)); box-shadow: var(--shadow-lg); color: var(--ink); }
dialog::backdrop { background: rgb(15 23 42 / 45%); backdrop-filter: blur(2px); }
.dialog-body { padding: 1.5rem; }
.dialog-body h2 { margin-bottom: .5rem; }
.dialog-body .actions { justify-content: flex-end; }
.summary { margin-top: 1rem; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.summary div { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem .9rem; font-size: .92rem; }
.summary div + div { border-top: 1px solid var(--line); }
.summary dt, .summary span:first-child { color: var(--muted); }
.summary strong { text-align: right; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: #fff; padding: .75rem 1.1rem; border-radius: 12px; box-shadow: var(--shadow-lg);
  max-width: min(90vw, 460px); font-weight: 550; font-size: .92rem; animation: rise .2s ease-out;
}
#toast.error { background: var(--danger); }
@media (max-width: 720px) { #toast { bottom: calc(var(--nav-h) + 1rem + env(safe-area-inset-bottom)); } }
@keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Helpers */
.spaced { margin-top: 1rem; }
.actions.center { justify-content: center; }
.chip-light.static { cursor: default; }
.chip-light.static:hover { background: rgb(255 255 255 / 12%); }
.mode-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-600); }
.mode-dot.online { background: var(--info); }
.legend { display: inline-flex; align-items: center; gap: .4rem; }
.doctor-card .top h3 { margin-bottom: .1rem; }

/* Footer and legal pages */
.site-footer { max-width: 1080px; margin: 0 auto; padding: 1.5rem 1.25rem 2rem; display: flex; flex-wrap: wrap; gap: 1.25rem; justify-content: center; border-top: 1px solid var(--line); color: var(--muted); font-size: .9rem; }
.site-footer a { color: var(--muted); }
@media (max-width: 720px) {
  main#view { padding-bottom: 2rem; }
  .site-footer { padding-bottom: calc(var(--nav-h) + 1.5rem + env(safe-area-inset-bottom)); }
}
.legal { max-width: 760px; line-height: 1.7; }
.legal h1 { margin-bottom: .25rem; }
.legal h2 { font-size: 1.2rem; margin: 2rem 0 .5rem; }
.legal ul { padding-left: 1.25rem; }
.legal li { margin: .35rem 0; }
