/* Litherapy Pro — clinic management premium UI
 * Palette: warm earth (sand + sage + clay + amber)
 * © אופיר ברנס + ליטל ביטון 2026
 */
* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color: transparent; }

:root {
  /* Earth scale */
  --sand-50: #fbf6ee;
  --sand-100: #f5ecdc;
  --sand-200: #ebd8b8;
  --sand-300: #e2c597;
  --sand-400: #d4a574;
  --sand-500: #c08a55;
  --sand-600: #a66f3f;

  --clay-300: #d6a888;
  --clay-400: #c8907b;
  --clay-500: #a87055;

  --sage-200: #d0d6b9;
  --sage-300: #b8c39a;
  --sage-400: #a3b18a;
  --sage-500: #88a06d;
  --sage-600: #677d4f;
  --sage-700: #4a5a3a;

  --bg-1: #1f1612;
  --bg-2: #2a1f17;
  --bg-3: #38291d;

  --amber-300: #fcd34d;
  --amber-400: #fbbf24;
  --rose-400: #fb7185;
  --rose-500: #f43f5e;
  --emerald-400: #34d399;

  --text-primary: #fef3e2;
  --text-secondary: rgba(254,243,226,0.74);
  --text-muted: rgba(254,243,226,0.46);
  --text-faint: rgba(254,243,226,0.32);

  --surface: rgba(254,243,226,0.05);
  --surface-strong: rgba(254,243,226,0.09);
  --surface-input: rgba(31,22,18,0.55);

  --border: rgba(212,165,116,0.18);
  --border-strong: rgba(212,165,116,0.32);
  --border-sage: rgba(163,177,138,0.30);

  --shadow-card: 0 16px 38px -18px rgba(0,0,0,0.65);
  --shadow-glass: 0 30px 60px -25px rgba(0,0,0,0.85);
  --shadow-warm: 0 10px 30px rgba(184,134,90,0.28);

  --bezier: cubic-bezier(.34,1.56,.64,1);
  --bezier-soft: cubic-bezier(.4,0,.2,1);
}

html, body {
  background: var(--bg-1);
  color: var(--text-primary);
  font-family: 'Heebo', system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
body {
  background:
    radial-gradient(ellipse 900px 800px at 80% -10%, rgba(212,165,116,0.16), transparent 60%),
    radial-gradient(ellipse 600px 700px at -10% 50%, rgba(163,177,138,0.10), transparent 65%),
    radial-gradient(ellipse 800px 1000px at 50% 110%, rgba(56,41,29,0.55), transparent 70%),
    linear-gradient(180deg, #1f1612 0%, #28201a 60%, #382c22 110%);
  background-attachment: fixed;
  overflow-x: hidden;
}
.mono { font-family: 'IBM Plex Mono', monospace; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
a { color: var(--sand-300); text-decoration: none; }
a:hover { color: var(--sand-200); text-decoration: underline; }
code {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.92em;
  color: var(--sand-300);
  background: rgba(212,165,116,0.10);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ─────────────────── Auth page ─────────────────── */
.auth-body {
  display: grid; place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    radial-gradient(ellipse 600px 600px at 20% 80%, rgba(212,165,116,0.20), transparent 60%),
    linear-gradient(180deg, #1f1612 0%, #2a1f17 100%);
}

.auth-stage {
  position: relative;
  width: 100%;
  max-width: 1240px;
  height: min(86vh, 760px);
  border-radius: 36px;
  overflow: hidden;
  box-shadow: 0 40px 100px -40px rgba(0,0,0,0.8);
  border: 1px solid var(--border);
  display: grid;
  grid-template-columns: 1fr 1fr;
}

.auth-bg {
  position: relative;
  overflow: hidden;
}
.auth-bg img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.auth-bg-overlay {
  position: absolute; inset: 0;
  background:
    linear-gradient(90deg, rgba(31,22,18,0) 0%, rgba(31,22,18,0.25) 100%),
    radial-gradient(ellipse 80% 100% at 0% 50%, rgba(212,165,116,0.10), transparent 60%);
}

.auth-card {
  background:
    radial-gradient(ellipse 60% 60% at 50% 0%, rgba(212,165,116,0.16), transparent 60%),
    linear-gradient(180deg, #2a1f17 0%, #1f1612 100%);
  padding: 56px 64px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 28px;
}

.auth-brand {
  display: flex; align-items: center; gap: 18px;
  margin-bottom: 8px;
}
.auth-brand-mark {
  display: block;
  filter: drop-shadow(0 4px 16px rgba(212,165,116,0.30));
}
.auth-brand-text h1 {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 32px; font-weight: 700;
  color: var(--sand-100);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.auth-brand-pro {
  background: linear-gradient(135deg, var(--sand-300), var(--amber-400));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  font-style: italic;
  font-family: 'Instrument Serif', serif;
  font-weight: 400;
}
.auth-brand-text p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.auth-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: rgba(31,22,18,0.55);
  border: 1px solid var(--border);
  border-radius: 100px;
  width: fit-content;
}
.auth-tab {
  padding: 8px 22px;
  background: none; border: none;
  color: var(--text-muted);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; border-radius: 100px;
  transition: all 0.2s var(--bezier-soft);
}
.auth-tab:hover { color: var(--text-primary); }
.auth-tab.active {
  background: linear-gradient(135deg, var(--sand-400), var(--sand-600));
  color: var(--bg-1);
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(212,165,116,0.30);
}

.auth-form {
  display: flex; flex-direction: column;
  gap: 16px;
}
.auth-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.auth-field {
  display: flex; flex-direction: column;
  gap: 6px;
}
.auth-field label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--sand-300);
}
.auth-field input {
  padding: 13px 16px;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: 'Heebo', sans-serif;
  font-size: 15px;
  transition: all 0.2s;
}
.auth-field input:focus {
  outline: none;
  border-color: var(--sand-400);
  background: rgba(31,22,18,0.7);
  box-shadow: 0 0 0 3px rgba(212,165,116,0.16);
}

.auth-submit {
  margin-top: 12px;
  padding: 14px 26px;
  background: linear-gradient(135deg, var(--sand-400), var(--sand-600));
  color: var(--bg-1);
  border: none; border-radius: 12px;
  font-family: inherit; font-size: 15px; font-weight: 700;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: 0 10px 28px rgba(212,165,116,0.32);
  transition: all 0.25s var(--bezier);
}
.auth-submit:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(212,165,116,0.45); }
.auth-submit:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.auth-submit.loading { animation: pulse-load 1.5s ease-in-out infinite; }
@keyframes pulse-load { 0%,100% { opacity: 0.6; } 50% { opacity: 1; } }

.auth-error {
  padding: 12px 16px;
  background: rgba(244,63,94,0.10);
  border: 1px solid rgba(244,63,94,0.30);
  border-radius: 12px;
  color: var(--rose-400);
  font-size: 13px;
}

.auth-foot {
  margin-top: 20px;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
}
.auth-foot-sep { color: var(--text-faint); }

@media (max-width: 900px) {
  .auth-stage { grid-template-columns: 1fr; height: auto; }
  .auth-bg { display: none; }
  .auth-card { padding: 36px 26px; }
}

/* ─────────────────── App layout ─────────────────── */
.app-body {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(120px); opacity: 0.34; }
.orb.o1 { width: 540px; height: 540px; top: -180px; right: -160px; background: radial-gradient(circle, #c08a55 0%, transparent 70%); animation: drift1 32s ease-in-out infinite; }
.orb.o2 { width: 380px; height: 380px; bottom: 5%; left: -120px; background: radial-gradient(circle, #a3b18a 0%, transparent 70%); opacity: 0.20; animation: drift2 36s ease-in-out infinite; }
.orb.o3 { width: 300px; height: 300px; top: 38%; right: 30%; background: radial-gradient(circle, #d4a574 0%, transparent 70%); opacity: 0.18; animation: drift3 42s ease-in-out infinite; }
@keyframes drift1 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-40px,50px) scale(1.10); } }
@keyframes drift2 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(50px,-40px) scale(1.08); } }
@keyframes drift3 { 0%,100% { transform: translate(0,0) scale(1); } 50% { transform: translate(-30px,-40px) scale(1.12); } }
.grain {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.96 0 0 0 0 0.92 0 0 0 0 0.85 0 0 0 0.6 0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.025;
  mix-blend-mode: overlay;
}

/* ─────────────────── Sidebar ─────────────────── */
.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  z-index: 50;
  display: flex; flex-direction: column;
  gap: 28px;
  padding: 26px 18px;
  background: linear-gradient(180deg, rgba(31,22,18,0.92), rgba(31,22,18,0.65));
  backdrop-filter: blur(22px) saturate(140%);
  border-left: 1px solid var(--border);
}
.side-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 0 8px;
}
.side-logo {
  width: 40px; height: 40px;
  display: block;
}
.side-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 18px; font-weight: 700;
  color: var(--sand-100);
  letter-spacing: -0.01em;
}
.side-title .pro {
  font-family: 'Instrument Serif', serif;
  font-style: italic;
  color: var(--sand-400);
}
.side-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.side-nav { display: flex; flex-direction: column; gap: 4px; }
.side-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: none; border: none;
  color: var(--text-secondary);
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; border-radius: 10px;
  transition: all 0.2s var(--bezier-soft);
  text-align: right;
}
.side-link svg { flex-shrink: 0; opacity: 0.7; }
.side-link span { flex: 1; }
.side-badge {
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(212,165,116,0.16);
  color: var(--sand-300);
  border-radius: 100px;
  font-weight: 600;
}
.side-link:hover { background: var(--surface); color: var(--text-primary); }
.side-link:hover svg { opacity: 1; }
.side-link.active {
  background: linear-gradient(135deg, rgba(212,165,116,0.20), rgba(163,177,138,0.10));
  color: var(--sand-100);
  border: 1px solid var(--border-strong);
}
.side-link.active svg { opacity: 1; color: var(--sand-300); }

.side-foot {
  margin-top: auto;
  display: flex; align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.side-user { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.side-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--sand-400), var(--sand-600));
  display: grid; place-items: center;
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700; font-size: 14px;
  color: var(--bg-1);
  flex-shrink: 0;
}
.side-user-name {
  font-size: 13px; font-weight: 600;
  color: var(--sand-100);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-user-title { font-size: 10px; color: var(--text-muted); }
.side-logout {
  background: none; border: 1px solid var(--border);
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer; transition: all 0.2s;
}
.side-logout:hover { background: var(--surface-strong); color: var(--rose-400); border-color: rgba(244,63,94,0.30); }

/* ─────────────────── Content area ─────────────────── */
.content {
  position: relative; z-index: 1;
  padding: 28px 36px 60px;
  max-width: 1320px;
  margin: 0 auto;
  width: 100%;
}
.view { display: none; flex-direction: column; gap: 24px; }
.view.active { display: flex; }

/* ─────────────────── Hero (dashboard) ─────────────────── */
.hero {
  position: relative;
  border-radius: 28px;
  overflow: hidden;
  min-height: 340px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(135deg, rgba(212,165,116,0.12) 0%, rgba(163,177,138,0.06) 100%);
  box-shadow: var(--shadow-glass);
  isolation: isolate;
}
.hero-bg {
  position: absolute; inset: 0;
  background-image: url('hero_bg.png');
  background-size: cover;
  background-position: center left;
  opacity: 0.55;
  z-index: 0;
}
.hero-overlay {
  position: absolute; inset: 0;
  background:
    linear-gradient(95deg, rgba(31,22,18,0.10) 0%, rgba(31,22,18,0.55) 45%, rgba(31,22,18,0.92) 100%),
    radial-gradient(ellipse 70% 60% at 100% 50%, rgba(212,165,116,0.10), transparent 60%);
  z-index: 1;
}
.hero-content {
  position: relative; z-index: 2;
  padding: 44px 44px;
  max-width: 700px;
}
.hero-kicker {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--sand-300);
  margin-bottom: 18px;
}
.hero-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: clamp(32px, 4.5vw, 50px);
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 18px;
}
.hero-em {
  background: linear-gradient(135deg, var(--sand-300), var(--amber-400));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  font-style: italic;
  font-family: 'Instrument Serif', serif;
}
.hero-sub {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
  margin-bottom: 24px;
  max-width: 560px;
}
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ─────────────────── Buttons ─────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 12px 22px;
  border: none; border-radius: 12px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all 0.25s var(--bezier);
}
.btn-primary {
  background: linear-gradient(135deg, var(--sand-400), var(--sand-600));
  color: var(--bg-1);
  font-weight: 700;
  box-shadow: var(--shadow-warm);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(184,134,90,0.45); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-secondary {
  background: var(--surface-strong);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}
.btn-secondary:hover:not(:disabled) { background: rgba(254,243,226,0.14); }
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  background: rgba(254,243,226,0.06);
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-ghost:hover { background: rgba(254,243,226,0.12); }
.btn-mini {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 11px 16px;
  font-size: 13px; font-weight: 500;
  border-radius: 12px;
  font-family: inherit; cursor: pointer;
  transition: all 0.2s;
}
.btn-mini:hover { background: var(--surface-strong); color: var(--text-primary); }
.btn-mini.danger { color: var(--rose-400); border-color: rgba(244,63,94,0.30); }
.btn-mini.danger:hover { background: rgba(244,63,94,0.12); }
.link-btn {
  background: none; border: none;
  color: var(--sand-300);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 12px; cursor: pointer;
  padding: 6px 0;
  transition: color 0.2s;
}
.link-btn:hover { color: var(--sand-200); }

/* ─────────────────── KPI / stats ─────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
.kpi {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px 22px;
  transition: all 0.3s var(--bezier-soft);
}
.kpi:hover { transform: translateY(-2px); border-color: var(--border-strong); }
.kpi-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: 8px;
}
.kpi-value {
  font-size: 36px;
  font-weight: 700;
  color: var(--sand-100);
  line-height: 1;
  letter-spacing: -0.02em;
}
.kpi-value.accent {
  background: linear-gradient(135deg, var(--sand-300), var(--amber-400));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ─────────────────── Cards ─────────────────── */
.card {
  background: var(--surface);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px 26px;
  box-shadow: var(--shadow-card);
}
.grid-2col {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 22px;
}
.card-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 14px; margin-bottom: 18px;
  flex-wrap: wrap;
}
.section-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 20px; font-weight: 700;
  color: var(--sand-100);
  letter-spacing: -0.015em;
  margin-bottom: 4px;
}
.section-sub {
  font-size: 13px; color: var(--text-secondary);
  line-height: 1.6;
  max-width: 720px;
}

/* ─────────────────── Recent sessions ─────────────────── */
.recent-sessions { display: flex; flex-direction: column; gap: 8px; }
.recent-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 16px;
  background: rgba(254,243,226,0.025);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.recent-row:hover { background: rgba(254,243,226,0.06); border-color: var(--border-strong); transform: translateY(-1px); }
.recent-avatar {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700; font-size: 13px;
  color: var(--bg-1);
  flex-shrink: 0;
}
.recent-name { font-size: 14px; font-weight: 600; color: var(--sand-100); margin-bottom: 2px; }
.recent-meta { font-size: 11px; color: var(--text-muted); }
.recent-meta-right { display: flex; gap: 6px; align-items: center; }
.pill {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  padding: 3px 9px;
  border-radius: 100px;
  background: rgba(254,243,226,0.06);
  color: var(--text-secondary);
}
.pill.pain { background: rgba(200,144,123,0.16); color: var(--clay-300); }
.pill.ai { background: rgba(212,165,116,0.16); color: var(--sand-300); }

/* ─────────────────── AI status card ─────────────────── */
.ai-status-card {
  display: flex; gap: 16px;
  padding: 22px;
  background: rgba(254,243,226,0.025);
  border-radius: 18px;
  border: 1px solid var(--border);
}
.ai-status-card.connected { border-color: var(--border-sage); background: linear-gradient(135deg, rgba(163,177,138,0.10), transparent 100%); }
.ai-status-card.disconnected { border-color: rgba(212,165,116,0.30); }
.ai-icon {
  width: 50px; height: 50px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--sand-400), var(--sand-600));
  display: grid; place-items: center;
  font-size: 24px;
  flex-shrink: 0;
}
.ai-status-card h3 {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 18px; font-weight: 700;
  color: var(--sand-100);
  margin-bottom: 4px;
}
.ai-status-card p { font-size: 13px; color: var(--text-secondary); line-height: 1.55; margin-bottom: 10px; }
.ai-status-card strong.mono { color: var(--sand-300); font-weight: 700; }

/* ─────────────────── Pages ─────────────────── */
.page-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 14px; flex-wrap: wrap;
}
.page-title {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 32px; font-weight: 700;
  color: var(--sand-100);
  letter-spacing: -0.02em;
  margin-bottom: 4px;
}
.page-sub { font-size: 13px; color: var(--text-secondary); }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-input { width: 240px; }

/* ─────────────────── Patient grid ─────────────────── */
.patient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.patient-card {
  display: flex; gap: 14px;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  cursor: pointer;
  transition: all 0.25s var(--bezier);
}
.patient-card:hover { transform: translateY(-3px); border-color: var(--border-strong); box-shadow: var(--shadow-warm); }
.patient-avatar {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: grid; place-items: center;
  font-family: 'Frank Ruhl Libre', serif;
  font-weight: 700; font-size: 18px;
  color: var(--bg-1);
  flex-shrink: 0;
}
.patient-info { flex: 1; min-width: 0; }
.patient-info h3 {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 16px; font-weight: 700;
  color: var(--sand-100);
  margin-bottom: 4px;
}
.patient-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.patient-complaint { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 8px; }
.patient-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 8px; }
.tag {
  font-size: 10px;
  padding: 2px 8px;
  background: rgba(163,177,138,0.16);
  color: var(--sage-300);
  border-radius: 100px;
  border: 1px solid var(--border-sage);
}
.tag.removable { cursor: pointer; }
.tag.removable:hover { background: rgba(244,63,94,0.16); color: var(--rose-400); border-color: rgba(244,63,94,0.30); }
.patient-foot { font-size: 10px; color: var(--text-faint); }

/* ─────────────────── Empty state ─────────────────── */
.empty-state-card {
  text-align: center;
  padding: 48px 24px;
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: 24px;
}
.empty-state-card img {
  opacity: 0.7;
  margin-bottom: 14px;
  filter: drop-shadow(0 6px 18px rgba(184,134,90,0.20));
}
.empty-state-card h3 {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 22px;
  color: var(--sand-100);
  margin-bottom: 6px;
}
.empty-state-card p {
  font-size: 13px; color: var(--text-secondary);
  margin-bottom: 18px;
}
.empty-mini {
  text-align: center;
  padding: 22px 14px;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-mini h4 { font-family: 'Frank Ruhl Libre', serif; font-size: 16px; color: var(--sand-100); margin-bottom: 4px; }
.empty-mini p { font-size: 12px; margin-bottom: 8px; }

/* ─────────────────── Journal ─────────────────── */
.journal { display: flex; flex-direction: column; gap: 22px; }
.day-group { display: flex; flex-direction: column; gap: 8px; }
.day-title {
  font-size: 12px;
  color: var(--sand-300);
  letter-spacing: 0.06em;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--border);
}

/* ─────────────────── Patterns view ─────────────────── */
.patterns-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 22px;
}
.patterns-card { padding: 24px 26px; }
.feet-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  padding: 24px 0;
}
.foot-svg {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
}
.foot-svg svg {
  width: 200px;
  height: auto;
  max-height: 400px;
}
.foot-label {
  font-size: 11px;
  color: var(--text-muted);
}
.body-svg {
  display: grid; place-items: center;
  padding: 18px 0;
}
.body-svg svg {
  width: 230px;
  height: 280px;
}

.zone-list {
  list-style: none;
  display: flex; flex-direction: column;
  gap: 4px;
  margin-top: 16px;
  font-size: 12px;
}
.zone-list li {
  padding: 8px 12px;
  background: rgba(254,243,226,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex; gap: 8px;
  color: var(--text-secondary);
  align-items: center;
}
.zone-list li.empty { color: var(--text-faint); justify-content: center; }
.zone-list .dot-level { color: var(--clay-400); font-weight: 700; }
.zone-list .foot-side { color: var(--sand-300); }

/* ─────────────────── Patient detail ─────────────────── */
.pd-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(31,22,18,0.55);
  border: 1px solid var(--border);
  border-radius: 100px;
  width: fit-content;
}
.pd-tab {
  padding: 8px 18px;
  background: none; border: none;
  color: var(--text-muted);
  font-family: inherit; font-size: 13px; font-weight: 500;
  cursor: pointer; border-radius: 100px;
  transition: all 0.2s;
}
.pd-tab:hover { color: var(--text-primary); }
.pd-tab.active {
  background: linear-gradient(135deg, var(--sand-400), var(--sand-600));
  color: var(--bg-1);
  font-weight: 700;
}
.pd-panel { display: none; flex-direction: column; gap: 18px; }
.pd-panel.active { display: flex; }

.kv-list { display: flex; flex-direction: column; gap: 8px; }
.kv-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 16px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
}
.kv-row dt { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.kv-row dd { font-size: 13px; color: var(--text-primary); }
.kv-row dd.mono { font-family: 'IBM Plex Mono', monospace; }
.kv-paragraph {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.7;
  white-space: pre-wrap;
}

.session-list { display: flex; flex-direction: column; gap: 8px; }
.session-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.session-row:hover { background: var(--surface-strong); transform: translateY(-1px); }
.sr-num {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 22px;
  color: var(--sand-300);
  font-weight: 700;
  align-self: center;
}
.sr-info { min-width: 0; }
.sr-date { font-size: 13px; color: var(--sand-200); font-weight: 600; margin-bottom: 2px; }
.sr-meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.sr-notes { font-size: 12px; color: var(--text-secondary); line-height: 1.5; }
.sr-meta-right { align-self: center; display: flex; gap: 6px; }

.progress-chart-wrap { padding: 18px 0; }
#progressSvg { width: 100%; height: 320px; }
.chart-legend {
  display: flex; gap: 16px; flex-wrap: wrap;
  justify-content: center;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 11px; color: var(--text-secondary);
  font-family: 'IBM Plex Mono', monospace;
}
.leg-item { display: inline-flex; align-items: center; gap: 6px; }
.leg-line { width: 18px; height: 2px; border-radius: 2px; }

.ai-insights-list { display: flex; flex-direction: column; gap: 10px; }
.ai-card-mini {
  background: rgba(254,243,226,0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  cursor: pointer; transition: all 0.2s;
}
.ai-card-mini:hover { background: var(--surface-strong); transform: translateY(-1px); }
.ai-card-mini header { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.ai-card-mini strong { color: var(--sand-200); }
.ai-summary { font-size: 13px; color: var(--text-primary); line-height: 1.6; margin-bottom: 8px; }
.ai-pattern-row { display: flex; gap: 4px; flex-wrap: wrap; }
.ai-pattern {
  font-size: 11px;
  padding: 3px 10px;
  background: rgba(212,165,116,0.16);
  color: var(--sand-300);
  border-radius: 100px;
  border: 1px solid var(--border);
}

/* ─────────────────── Session detail ─────────────────── */
.sd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
.sd-block { display: flex; flex-direction: column; }
.sd-full { grid-column: 1 / -1; }
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}
.photo-card {
  background: rgba(254,243,226,0.04);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.photo-card img { width: 100%; height: 140px; object-fit: cover; display: block; }
.photo-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px;
}
.photo-ai-box {
  padding: 10px 12px;
  background: rgba(212,165,116,0.06);
  border-top: 1px dashed var(--border);
  font-size: 11px;
}
.photo-ai-box p { margin-bottom: 4px; color: var(--text-secondary); }
.photo-ai-box strong { color: var(--sand-300); }
.photo-ai-box .ai-note { font-style: italic; color: var(--text-muted); margin-top: 6px; }

.ai-card { background: rgba(212,165,116,0.06); border-color: var(--border-strong); }
.ai-card.has-content { background: linear-gradient(135deg, rgba(212,165,116,0.08), rgba(163,177,138,0.04)); }
.ai-content { font-size: 13px; line-height: 1.7; color: var(--text-secondary); }
.ai-content h4 {
  font-family: 'Frank Ruhl Libre', serif;
  font-size: 15px; color: var(--sand-200);
  margin-top: 16px; margin-bottom: 6px;
}
.ai-content h4:first-child { margin-top: 0; }
.ai-content h4.ai-red-flags { color: var(--rose-400); }
.ai-content ul { padding-right: 22px; margin-top: 4px; }
.ai-content li { margin-bottom: 4px; color: var(--text-primary); }
.ai-summary-box {
  padding: 14px 16px;
  background: rgba(254,243,226,0.06);
  border-right: 3px solid var(--sand-400);
  border-radius: 10px;
  color: var(--sand-100);
  font-size: 14px; line-height: 1.6;
  margin-bottom: 12px;
}
.ai-empty { color: var(--text-muted); font-size: 13px; text-align: center; padding: 14px; }
.ai-tone { color: var(--sage-300); font-size: 11px; }

/* ─────────────────── Modal ─────────────────── */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(8px);
  z-index: 200;
  display: flex; align-items: flex-end; justify-content: center;
  animation: modal-fade 0.25s var(--bezier-soft);
}
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: 100%;
  max-width: 540px;
  background: linear-gradient(180deg, #382c22 0%, #1f1612 100%);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: 28px 28px 0 0;
  padding: 20px 24px 32px;
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  animation: modal-slide 0.4s var(--bezier);
  max-height: 92vh;
  overflow-y: auto;
}
.modal-card.modal-wide { max-width: 820px; }
@keyframes modal-slide { from { transform: translateY(100%); } to { transform: translateY(0); } }
.handle {
  width: 38px; height: 4px;
  background: var(--border-strong);
  border-radius: 4px;
  margin: 0 auto 16px;
}
.modal-card h3 {
  font-family: 'Frank Ruhl Libre', serif;
  color: var(--sand-100);
  font-size: 22px; font-weight: 700;
  margin-bottom: 18px;
  letter-spacing: -0.01em;
}
.modal-actions {
  display: flex; gap: 8px;
  margin-top: 18px;
  justify-content: flex-end;
}

/* ─────────────────── Forms ─────────────────── */
.form-group {
  display: flex; flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}
.form-group label {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--sand-300);
}
.input, .auth-field input, textarea.input, select.input {
  width: 100%;
  padding: 12px 16px;
  background: var(--surface-input);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: 'Heebo', sans-serif;
  font-size: 14px;
  transition: all 0.2s;
}
.input.mono, textarea.input.mono { font-family: 'IBM Plex Mono', monospace; }
.input:focus {
  outline: none;
  border-color: var(--sand-400);
  background: rgba(31,22,18,0.7);
  box-shadow: 0 0 0 3px rgba(212,165,116,0.16);
}
input[type="number"], input[type="date"], input[type="datetime-local"], select.input {
  color-scheme: dark;
}
textarea.input { resize: vertical; min-height: 60px; line-height: 1.55; }
.form-hint { font-size: 11px; color: var(--text-muted); }
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.tag-row { display: flex; gap: 4px; flex-wrap: wrap; }

/* ─────────────────── Wizard ─────────────────── */
.wizard-head { margin-bottom: 18px; }
.wizard-progress {
  display: flex; gap: 4px;
  margin-top: 12px;
  padding: 6px;
  background: rgba(31,22,18,0.55);
  border-radius: 100px;
  border: 1px solid var(--border);
  overflow-x: auto;
}
.wp-step {
  flex: 1;
  padding: 8px 12px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  border-radius: 100px;
  text-align: center;
  font-weight: 500;
  white-space: nowrap;
  transition: all 0.3s var(--bezier-soft);
}
.wp-step.active {
  background: linear-gradient(135deg, var(--sand-400), var(--sand-600));
  color: var(--bg-1);
  font-weight: 700;
}
.wizard-form { display: flex; flex-direction: column; }
.wizard-step { display: none; flex-direction: column; }
.wizard-step.active { display: flex; }
.wizard-helper {
  font-size: 13px; color: var(--text-secondary);
  background: rgba(212,165,116,0.06);
  padding: 12px 14px;
  border-radius: 10px;
  margin-bottom: 14px;
  border-right: 3px solid var(--sand-400);
}

.chip-picker {
  display: flex; flex-wrap: wrap;
  gap: 6px;
}
.chip-opt {
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-family: inherit; font-size: 13px;
  border-radius: 100px;
  cursor: pointer; transition: all 0.2s var(--bezier-soft);
}
.chip-opt:hover { background: var(--surface-strong); color: var(--sand-100); }
.chip-opt.active {
  background: linear-gradient(135deg, var(--sand-400), var(--sand-600));
  color: var(--bg-1);
  border-color: transparent;
  font-weight: 600;
}

.range-input { width: 100%; margin: 6px 0; }
.range-value {
  display: inline-block;
  font-size: 18px; font-weight: 700;
  color: var(--sand-300);
}

.photo-upload-row { display: flex; gap: 10px; flex-wrap: wrap; }
.photo-upload-btn {
  padding: 14px 22px;
  background: var(--surface);
  border: 1.5px dashed var(--border-strong);
  border-radius: 14px;
  color: var(--text-secondary);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.photo-upload-btn:hover { background: var(--surface-strong); border-color: var(--sand-400); color: var(--sand-100); }
.photo-preview-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.photo-preview {
  width: 120px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.photo-preview img { width: 100%; height: 120px; object-fit: cover; display: block; }
.pp-meta { font-family: 'IBM Plex Mono', monospace; font-size: 10px; color: var(--text-muted); padding: 6px 8px; text-align: center; }

.wizard-actions {
  display: flex; justify-content: space-between;
  gap: 8px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
}
.wizard-step-actions { display: flex; gap: 8px; }

/* ─────────────────── Settings ─────────────────── */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}
.settings-form { display: flex; flex-direction: column; gap: 14px; }
.form-actions {
  display: flex; gap: 8px;
  justify-content: flex-end;
  margin-top: 6px;
  flex-wrap: wrap;
}
.badge {
  font-size: 11px;
  padding: 4px 12px;
  border-radius: 100px;
  font-weight: 500;
}
.badge.connected { background: rgba(163,177,138,0.16); color: var(--sage-300); border: 1px solid var(--border-sage); }
.badge.disconnected { background: rgba(254,243,226,0.06); color: var(--text-muted); border: 1px solid var(--border); }

/* ─────────────────── Toast ─────────────────── */
.toast-container {
  position: fixed; bottom: 22px; left: 22px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 300; pointer-events: none;
}
.toast {
  background: linear-gradient(135deg, rgba(56,41,29,0.95), rgba(31,22,18,0.95));
  border: 1px solid var(--border-strong);
  border-right: 3px solid var(--sand-400);
  border-radius: 12px;
  padding: 12px 18px;
  color: var(--sand-100);
  font-size: 13px;
  box-shadow: 0 14px 32px rgba(0,0,0,0.55);
  pointer-events: auto;
  backdrop-filter: blur(20px);
  animation: toast-in 0.4s var(--bezier);
  max-width: 380px;
}
.toast.success { border-right-color: var(--sage-400); }
.toast.danger { border-right-color: var(--rose-400); }
.toast.info { border-right-color: var(--sand-300); }
@keyframes toast-in {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─────────────────── Responsive ─────────────────── */
@media (max-width: 1100px) {
  .app-body { grid-template-columns: 1fr; }
  .sidebar {
    position: relative; height: auto;
    flex-direction: row;
    overflow-x: auto;
    padding: 14px 16px;
    border-left: none;
    border-bottom: 1px solid var(--border);
  }
  .side-nav { flex-direction: row; gap: 2px; }
  .side-link { white-space: nowrap; padding: 8px 10px; font-size: 12px; }
  .side-link span { display: none; }
  .side-link svg { opacity: 1; }
  .side-link.active span { display: inline; }
  .side-foot { margin-top: 0; margin-right: auto; }
  .grid-2col { grid-template-columns: 1fr; }
  .patterns-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .sd-grid { grid-template-columns: 1fr 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .content { padding: 20px 16px 40px; }
  .stats-row { grid-template-columns: 1fr; }
  .form-row-2 { grid-template-columns: 1fr; }
  .auth-row { grid-template-columns: 1fr; }
  .sd-grid { grid-template-columns: 1fr; }
  .hero-content { padding: 28px 22px; }
  .feet-row { flex-direction: column; }
  .foot-svg svg { width: 160px; }
}
