:root {
  --bg: var(--tg-theme-bg-color, #ffffff);
  --bg-sec: var(--tg-theme-secondary-bg-color, #f4f7f6);
  --text: var(--tg-theme-text-color, #1d2b2d);
  --hint: var(--tg-theme-hint-color, #5f6f71);
  --teal: #176b67;
  --teal-soft: rgba(23, 107, 103, 0.1);
  --gold: #b89b66;
  --gold-soft: rgba(184, 155, 102, 0.16);
  --danger: #c63b3b;
  --danger-soft: rgba(198, 59, 59, 0.1);
  --line: rgba(23, 63, 69, 0.12);
  --serif: Georgia, "Times New Roman", serif;
  --sans: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --radius: 16px;
  --radius-sm: 12px;
}

:root[data-theme="dark"] {
  --bg: var(--tg-theme-bg-color, #151e1f);
  --bg-sec: var(--tg-theme-secondary-bg-color, #1e2a2c);
  --text: var(--tg-theme-text-color, #edf3f2);
  --hint: var(--tg-theme-hint-color, #93a6a8);
  --teal: #3aa39d;
  --teal-soft: rgba(58, 163, 157, 0.16);
  --gold: #b89b66;
  --gold-soft: rgba(184, 155, 102, 0.22);
  --danger: #e86b6b;
  --danger-soft: rgba(232, 107, 107, 0.16);
  --line: rgba(237, 243, 242, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--sans); font-size: 16px; line-height: 1.48; -webkit-font-smoothing: antialiased; }
img { display: block; max-width: 100%; }
img[hidden], [hidden] { display: none !important; }
button, input, a { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.app-shell { max-width: 480px; margin: 0 auto; padding: 16px 16px calc(32px + env(safe-area-inset-bottom, 0px)); }
body.has-dev-main .app-shell { padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
body.has-dev-back .app-shell { padding-top: 56px; }

.hero-card { background: var(--bg-sec); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 18px 18px; text-align: center; }
.portrait-wrap { width: 92px; height: 92px; margin: 0 auto 12px; border-radius: 50%; overflow: hidden; border: 2px solid var(--gold); background: var(--teal-soft); }
.portrait-wrap.img-hidden { display: none; }
.portrait-wrap img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; }
.hero-name { margin: 0; font-family: var(--serif); font-size: 1.38rem; font-weight: 700; line-height: 1.22; }
.hero-clinic { margin: 6px 0 0; color: var(--hint); font-size: 0.9rem; }
.lang-bar { display: inline-flex; gap: 8px; margin-top: 14px; padding: 4px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); }
.flag-btn { min-width: 46px; min-height: 44px; padding: 0 10px; border: 1.5px solid transparent; border-radius: 999px; background: transparent; font-size: 1.25rem; line-height: 1; cursor: pointer; }
.flag-btn.is-active { background: var(--teal-soft); border-color: var(--teal); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid transparent; font-size: 0.98rem; font-weight: 600; line-height: 1.25; text-align: center; text-decoration: none; cursor: pointer; }
.btn:active { transform: scale(0.99); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--teal); color: #ffffff; }
:root[data-theme="dark"] .btn-primary { color: #0d1d1c; }
.btn-outline { background: var(--bg-sec); border-color: var(--teal); color: var(--teal); }
.btn-soft { background: var(--bg-sec); border-color: var(--line); color: var(--text); }
.btn-danger-outline { background: transparent; border-color: var(--danger); color: var(--danger); }
.home-book { margin-top: 14px; min-height: 52px; font-size: 1.04rem; }

.tiles-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.tile-btn { position: relative; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; min-height: 76px; padding: 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-sec); text-align: left; font-weight: 600; font-size: 0.95rem; cursor: pointer; }
.tile-badge { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--teal); color: #ffffff; font-size: 0.78rem; font-weight: 700; }
:root[data-theme="dark"] .tile-badge { color: #0d1d1c; }

.screen-head { margin-bottom: 14px; }
.step-kicker { margin: 0 0 4px; color: var(--gold); font-family: var(--serif); font-size: 0.85rem; font-weight: 700; }
.screen-title { margin: 0; font-family: var(--serif); font-size: 1.45rem; font-weight: 700; line-height: 1.2; }
.screen-sub { margin: 6px 0 0; color: var(--hint); font-size: 0.92rem; }
.stack { display: grid; gap: 10px; }

.urgent-card { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 52px; padding: 12px 16px; border-radius: var(--radius); border: 1.5px solid var(--danger); background: var(--danger-soft); color: var(--danger); font-weight: 700; text-align: left; cursor: pointer; }
.unsure-card { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; min-height: 54px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--gold); background: var(--gold-soft); text-align: left; cursor: pointer; }
.unsure-card strong { font-size: 0.98rem; }
.unsure-card span { font-size: 0.84rem; color: var(--hint); }

.cat-card { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 68px; padding: 10px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-sec); text-align: left; cursor: pointer; }
.cat-thumb { flex-shrink: 0; width: 52px; height: 52px; border-radius: 10px; overflow: hidden; background: var(--teal-soft); }
.cat-thumb.img-hidden { display: none; }
.cat-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cat-title { flex: 1; font-family: var(--serif); font-size: 1.05rem; font-weight: 700; line-height: 1.25; }
.chevron { color: var(--gold); font-weight: 700; font-size: 1.1rem; flex-shrink: 0; }

.svc-card { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; width: 100%; min-height: 54px; padding: 13px 15px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-sec); text-align: left; cursor: pointer; }
.svc-name { font-weight: 600; font-size: 0.96rem; }
.svc-price { flex-shrink: 0; color: var(--gold); font-weight: 700; font-size: 0.9rem; text-align: right; }

.banner { padding: 12px 14px; margin-bottom: 12px; border-radius: var(--radius-sm); background: var(--teal-soft); border: 1px solid var(--line); font-size: 0.9rem; }
.banner-warn { background: var(--danger-soft); border-color: var(--danger); }
.day-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.chip-btn { min-height: 48px; padding: 11px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-sec); font-weight: 600; font-size: 0.94rem; text-align: center; cursor: pointer; }
.hour-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.hour-btn { min-height: 48px; padding: 10px 8px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg-sec); font-weight: 700; font-size: 1rem; font-variant-numeric: tabular-nums; cursor: pointer; }

.card { padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-sec); }
.summary-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.summary-row:first-child { padding-top: 0; }
.summary-row:last-child { padding-bottom: 0; border-bottom: 0; }
.summary-label { color: var(--hint); font-size: 0.86rem; flex-shrink: 0; }
.summary-val { font-weight: 600; text-align: right; }
.summary-val.is-price { color: var(--gold); font-weight: 700; }

.field { display: grid; gap: 6px; margin-top: 14px; }
.field:first-child { margin-top: 0; }
.field-label { font-size: 0.88rem; font-weight: 600; }
.field-caption { margin: 4px 0 0; color: var(--hint); font-size: 0.84rem; }
.input { width: 100%; min-height: 48px; padding: 10px 13px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; }
.input.is-invalid { border-color: var(--danger); }
.field-error { margin: 4px 0 0; color: var(--danger); font-size: 0.85rem; font-weight: 600; }
.poll-note { margin: 6px 0 0; color: var(--teal); font-size: 0.86rem; font-weight: 600; }

.status-pill { display: inline-flex; align-items: center; padding: 4px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; }
.status-confirmed { background: var(--teal-soft); color: var(--teal); }
.status-pending { background: var(--gold-soft); color: var(--gold); }
.status-proposed { background: var(--danger-soft); color: var(--danger); }

.appt-card { display: grid; gap: 10px; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-sec); }
.appt-when { margin: 0; font-family: var(--serif); font-size: 1.15rem; font-weight: 700; }
.appt-svc { margin: 0; font-weight: 600; }
.appt-price { margin: 0; color: var(--gold); font-size: 0.9rem; font-weight: 600; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-row .btn { min-height: 44px; padding: 10px 12px; font-size: 0.92rem; }

.fold-card { border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-sec); overflow: hidden; }
.fold-card summary { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 50px; padding: 13px 16px; font-family: var(--serif); font-size: 1.05rem; font-weight: 700; list-style: none; cursor: pointer; }
.fold-card summary::-webkit-details-marker { display: none; }
.fold-card summary::after { content: "+"; flex-shrink: 0; color: var(--gold); font-family: var(--sans); font-size: 1.35rem; font-weight: 400; line-height: 1; }
.fold-card[open] summary::after { content: "-"; }
.fold-body { padding: 0 16px 14px; border-top: 1px solid var(--line); }
.fold-body p { margin: 12px 0 0; color: var(--text); }

.price-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.93rem; }
.price-row:last-child { border-bottom: 0; padding-bottom: 0; }
.price-row strong { color: var(--gold); font-weight: 700; text-align: right; flex-shrink: 0; }
.info-title { margin: 0 0 4px; font-family: var(--serif); font-size: 1.02rem; font-weight: 700; }
.info-text { margin: 0; color: var(--hint); font-size: 0.92rem; }
.price-note { margin: 4px 2px 0; color: var(--hint); font-size: 0.86rem; }

.contact-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.contact-item:first-child { padding-top: 0; }
.contact-item:last-child { padding-bottom: 0; border-bottom: 0; }
.contact-label { display: block; color: var(--hint); font-size: 0.82rem; margin-bottom: 2px; }
.contact-value { font-weight: 600; }

.state-box { padding: 24px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg-sec); text-align: center; }
.state-box p { margin: 0 0 14px; }
.state-box p:last-child { margin-bottom: 0; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 200; max-width: calc(100vw - 32px); padding: 11px 18px; border-radius: 999px; background: #173f45; color: #ffffff; font-size: 0.9rem; font-weight: 600; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28); pointer-events: none; }
body.has-dev-main .toast { bottom: calc(80px + env(safe-area-inset-bottom, 0px)); }

@media (max-width: 360px) {
  .tiles-grid, .day-grid, .btn-row { grid-template-columns: 1fr; }
  .hour-grid { grid-template-columns: repeat(2, 1fr); }
  .price-row { flex-direction: column; gap: 2px; }
  .price-row strong { text-align: left; }
}
