:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --surface-soft: #f4f1e9;
  --surface-elevated: rgba(255,255,255,.96);
  --ink: #0a0a0b;
  --muted: #62636a;
  --line: #dedbd2;
  --gold: #a97920;
  --gold-bright: #cfa453;
  --gold-soft: #f4ead3;
  --success: #1f6f46;
  --danger: #9d2e2e;
  --warning: #7b5614;
  --panel-border: rgba(10,10,11,.08);
  --input-bg: #ffffff;
  --input-border: #cbc7bd;
  --shadow: 0 22px 60px rgba(25,22,15,.11);
  --topbar: rgba(251,250,247,.92);
  --primary-bg: #0a0a0b;
  --primary-text: #ffffff;
  --max: 1180px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Segoe UI", sans-serif;
  color-scheme: light;
}

body[data-theme="dark"] {
  --bg: #0f0d09;
  --surface: #17130e;
  --surface-soft: #211a12;
  --surface-elevated: rgba(22,18,13,.96);
  --ink: #f8f3e7;
  --muted: #c6beaf;
  --line: rgba(229,195,122,.20);
  --gold: #d6af61;
  --gold-bright: #e8c97f;
  --gold-soft: rgba(214,175,97,.15);
  --success: #71c99a;
  --danger: #ff9d9d;
  --warning: #f0d08c;
  --panel-border: rgba(229,195,122,.23);
  --input-bg: rgba(24,19,14,.94);
  --input-border: rgba(229,195,122,.25);
  --shadow: 0 28px 70px rgba(0,0,0,.38);
  --topbar: linear-gradient(180deg, rgba(31,24,18,.95), rgba(18,14,10,.91));
  --primary-bg: linear-gradient(180deg, #e5c273, #b88a38);
  --primary-text: #171109;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell {
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 10%, color-mix(in srgb, var(--gold-bright) 17%, transparent), transparent 25%),
    radial-gradient(circle at 83% 8%, rgba(255,255,255,.04), transparent 28%),
    radial-gradient(circle at 74% 75%, color-mix(in srgb, var(--gold) 10%, transparent), transparent 28%),
    var(--bg);
}

.fatal-banner { padding: 20px; background: #8b1f1f; color: white; text-align: center; }

.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: calc(28px + env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
}

.auth-card {
  width: min(100%, 520px);
  background: var(--surface-elevated);
  border: 1px solid var(--panel-border);
  border-radius: 34px;
  box-shadow: var(--shadow);
  padding: clamp(28px, 6vw, 52px);
}

.brand-lockup { text-align: center; margin-bottom: 36px; }
.brand-mark { width: 112px; height: 112px; color: var(--ink); display: block; margin: 0 auto 14px; }
.brand-name { font-size: 16px; font-weight: 800; letter-spacing: .22em; }
.brand-tag { margin-top: 7px; color: var(--gold); font-size: 12px; font-weight: 850; letter-spacing: .16em; }
.auth-copy { margin-bottom: 26px; text-align: center; }
.auth-copy h1 { margin: 7px 0 12px; font-size: clamp(34px, 7vw, 48px); line-height: 1; letter-spacing: -.045em; }
.auth-copy p { margin: 0; color: var(--muted); line-height: 1.55; font-size: 17px; }
.eyebrow { color: var(--gold); font-size: 12px; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }

.stack { display: grid; gap: 17px; }
.field label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 800; }
input, textarea, select {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--input-border);
  border-radius: 15px;
  background: var(--input-bg);
  color: var(--ink);
  padding: 14px 15px;
  font-size: 17px;
}
textarea { min-height: 112px; resize: vertical; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible {
  outline: 4px solid color-mix(in srgb, var(--gold-bright) 30%, transparent);
  outline-offset: 2px;
}
.password-wrap { position: relative; }
.password-wrap input { padding-right: 78px; }
.password-wrap .icon-button { position: absolute; top: 7px; right: 7px; }

.primary-button, .secondary-button, .ghost-button, .icon-button {
  border-radius: 15px;
  min-height: 50px;
  padding: 12px 18px;
  font-weight: 820;
  border: 1px solid transparent;
}
.primary-button { background: var(--primary-bg); color: var(--primary-text); box-shadow: 0 13px 28px rgba(0,0,0,.18); display: inline-flex; gap: 12px; align-items: center; justify-content: center; }
.primary-button:hover { transform: translateY(-1px); }
.primary-button:disabled { opacity: .58; cursor: not-allowed; transform: none; }
.secondary-button, .ghost-button, .icon-button { background: color-mix(in srgb, var(--surface) 88%, transparent); color: var(--ink); border-color: var(--line); }
.full { width: 100%; }
.compact { min-height: 42px; padding: 9px 13px; border-radius: 12px; }
.icon-button { min-height: 40px; padding: 7px 12px; border-radius: 11px; font-size: 14px; }
.security-note { margin: 24px 0 0; color: var(--muted); text-align: center; font-size: 13px; line-height: 1.45; }

.notice { border: 1px solid var(--line); background: var(--surface-soft); border-radius: 16px; padding: 15px 17px; line-height: 1.5; margin-bottom: 20px; }
.notice.warning { color: var(--warning); border-color: color-mix(in srgb, var(--gold) 32%, var(--line)); }
.notice.error { color: var(--danger); }
.notice.success { color: var(--success); }
.notice code { font-size: .92em; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: calc(12px + env(safe-area-inset-top)) 22px 12px;
  background: var(--topbar);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(22px);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.mini-mark { width: 50px; height: 50px; color: var(--ink); flex: 0 0 auto; }
.topbar-title { font-size: 16px; font-weight: 850; }
.topbar-subtitle { color: var(--muted); font-size: 12px; margin-top: 2px; }
.topbar-actions { display: flex; gap: 9px; }
.ghost-button { border-radius: 999px; min-height: 43px; padding: 9px 14px; }

.dashboard-main { width: min(100%, var(--max)); margin: 0 auto; padding: 36px 22px 72px; }
.dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.dashboard-heading h2 { margin: 7px 0 8px; font-size: clamp(34px, 5vw, 52px); letter-spacing: -.045em; line-height: 1; }
.muted { color: var(--muted); margin: 0; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--surface-elevated); border: 1px solid var(--panel-border); border-radius: 22px; padding: 20px; box-shadow: 0 14px 34px rgba(0,0,0,.07); }
.stat-card span { color: var(--muted); font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .09em; }
.stat-card strong { display: block; font-size: 38px; margin: 11px 0 2px; letter-spacing: -.04em; }
.stat-card small { color: var(--muted); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.7fr) minmax(280px,.8fr); gap: 20px; align-items: start; }
.panel { background: var(--surface-elevated); border: 1px solid var(--panel-border); border-radius: 28px; box-shadow: var(--shadow); overflow: hidden; }
.panel-header-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 24px 25px 20px; border-bottom: 1px solid var(--line); }
.panel h3 { margin: 6px 0 0; font-size: 25px; letter-spacing: -.03em; }

.loading-state, .empty-state { padding: 48px 26px; text-align: center; color: var(--muted); }
.empty-icon { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 18px; background: var(--gold-soft); color: var(--gold); margin: 0 auto 15px; font-size: 30px; font-weight: 600; }
.empty-state h4 { color: var(--ink); font-size: 20px; margin: 0 0 8px; }
.empty-state p { max-width: 440px; margin: 0 auto; line-height: 1.5; }

.appointment-list { display: grid; }
.appointment-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.appointment-row:last-child { border-bottom: 0; }
.appointment-name { font-weight: 840; font-size: 18px; }
.appointment-service { color: var(--muted); margin-top: 6px; line-height: 1.45; }
.appointment-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 11px; color: var(--muted); font-size: 13px; }
.status-pill { align-self: start; border: 1px solid var(--line); background: var(--surface-soft); border-radius: 999px; padding: 7px 10px; color: var(--gold); font-size: 12px; font-weight: 850; text-transform: uppercase; letter-spacing: .05em; }

.security-panel { padding: 25px; }
.security-list { list-style: none; padding: 0; margin: 23px 0; display: grid; gap: 14px; }
.security-list li { display: grid; grid-template-columns: 25px 1fr; gap: 10px; align-items: start; line-height: 1.45; }
.check { color: var(--success); font-weight: 900; }
.pending { color: var(--gold); font-size: 22px; line-height: 17px; }
.session-card { display: flex; justify-content: space-between; gap: 10px; border: 1px solid var(--line); background: var(--surface-soft); border-radius: 16px; padding: 15px; }
.session-card span { color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.62); backdrop-filter: blur(9px); display: grid; place-items: center; padding: 18px; }
.modal { width: min(100%, 900px); max-height: calc(100vh - 36px); overflow: auto; background: var(--surface); border: 1px solid var(--panel-border); border-radius: 28px; box-shadow: 0 30px 90px rgba(0,0,0,.45); }
.modal-header { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; padding: 24px 25px 18px; border-bottom: 1px solid var(--line); background: var(--surface); }
.modal-header h2 { margin: 7px 0 0; font-size: 34px; letter-spacing: -.04em; }
.modal-body { padding: 24px 25px 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 17px; }
.field.full { grid-column: 1/-1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 26px; }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 100; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; background: #0a0a0b; color: #fff; padding: 13px 17px; border-radius: 999px; font-weight: 760; box-shadow: 0 16px 36px rgba(0,0,0,.28); transition: .2s ease; max-width: calc(100vw - 34px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar { align-items: flex-start; padding-left: 14px; padding-right: 14px; }
  .topbar-subtitle { display: none; }
  .topbar-actions { flex-direction: column; }
  .ghost-button { min-height: 38px; padding: 7px 11px; font-size: 13px; }
  .dashboard-main { padding: 25px 13px 54px; }
  .dashboard-heading { align-items: stretch; flex-direction: column; }
  .dashboard-heading .primary-button { width: 100%; }
  .stats-grid { gap: 10px; }
  .stat-card { padding: 16px; border-radius: 18px; }
  .stat-card strong { font-size: 32px; }
  .appointment-row { grid-template-columns: 1fr; }
  .status-pill { justify-self: start; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { max-height: 94vh; border-radius: 28px 28px 0 0; }
  .modal-header, .modal-body { padding-left: 18px; padding-right: 18px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
