/* ==========================================================================
   Equilibrium — Design System
   Calm wellness aesthetic: sage/teal greens, warm cream, soft shadows.
   ========================================================================== */

:root {
  /* Color palette */
  --color-bg: #F6F4EF;
  --color-bg-alt: #EFEBE2;
  --color-surface: #FFFFFF;
  --color-surface-2: #FBFAF7;

  --color-primary: #3F7D6B;
  --color-primary-dark: #2C5E4F;
  --color-primary-darker: #1F4A3E;
  --color-primary-light: #DCEDE6;
  --color-primary-light-2: #EAF4EF;

  --color-accent: #E2A857;
  --color-accent-dark: #C68A3B;
  --color-accent-light: #FBEFDD;

  --color-text: #232E2A;
  --color-text-muted: #647069;
  --color-text-faint: #93998F;

  --color-border: #E4E0D6;
  --color-border-strong: #D2CCBC;

  --color-danger: #C75C4F;
  --color-danger-light: #F8E4E0;
  --color-warning: #C68A3B;
  --color-warning-light: #FBEFDD;
  --color-success: #4C8C61;
  --color-success-light: #E2F0E5;
  --color-info: #3E7CA6;
  --color-info-light: #E1EDF5;

  /* Typography */
  --font-heading: 'Outfit', 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 32px;
  --space-8: 40px;
  --space-9: 56px;

  /* Radii & shadows */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(35, 46, 42, 0.06);
  --shadow-md: 0 4px 16px rgba(35, 46, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(35, 46, 42, 0.12);

  --sidebar-w: 264px;
  --topbar-h: 72px;
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5 {
  font-family: var(--font-heading);
  font-weight: 600;
  color: var(--color-primary-darker);
  margin: 0 0 var(--space-2);
  line-height: 1.25;
}
p { margin: 0 0 var(--space-3); }
a { color: var(--color-primary); text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
button { font-family: inherit; }
img, svg { display: block; max-width: 100%; }
input, select, textarea { font-family: inherit; font-size: 14px; }
::selection { background: var(--color-primary-light); }

.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0; }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: var(--radius-pill); }
::-webkit-scrollbar-thumb:hover { background: var(--color-text-faint); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  justify-content: center;
  border: none;
  border-radius: var(--radius-pill);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .15s ease, color .15s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }

.btn-primary { background: var(--color-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--color-primary-dark); box-shadow: var(--shadow-md); }

.btn-accent { background: var(--color-accent); color: #fff; }
.btn-accent:hover { background: var(--color-accent-dark); }

.btn-ghost { background: transparent; color: var(--color-primary-dark); border: 1px solid var(--color-border-strong); }
.btn-ghost:hover { background: var(--color-primary-light-2); border-color: var(--color-primary); }

.btn-text { background: transparent; color: var(--color-primary-dark); padding: 6px 10px; }
.btn-text:hover { background: var(--color-primary-light-2); }

.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #A8483D; }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: var(--radius-pill); background: transparent; border: 1px solid transparent; color: var(--color-text-muted); }
.btn-icon:hover { background: var(--color-primary-light-2); color: var(--color-primary-dark); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: var(--space-4); }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: var(--color-surface-2);
  color: var(--color-text);
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
  background: #fff;
}
.field textarea { resize: vertical; min-height: 80px; }
.field-hint { font-size: 12px; color: var(--color-text-faint); margin-top: 4px; }
.field-error { font-size: 12px; color: var(--color-danger); margin-top: 4px; display: none; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--color-danger); }
.field.has-error .field-error { display: block; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }

.form-actions { display: flex; gap: var(--space-3); margin-top: var(--space-5); }

/* ---------- Cards ---------- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); gap: var(--space-3); }
.card-title-row h3 { margin: 0; }

.grid { display: grid; gap: var(--space-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- Badges / chips / tags ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  white-space: nowrap;
}
.badge-warning { background: var(--color-warning-light); color: var(--color-accent-dark); }
.badge-danger { background: var(--color-danger-light); color: var(--color-danger); }
.badge-success { background: var(--color-success-light); color: var(--color-success); }
.badge-info { background: var(--color-info-light); color: var(--color-info); }
.badge-neutral { background: var(--color-bg-alt); color: var(--color-text-muted); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all .15s ease;
}
.chip:hover { border-color: var(--color-primary); color: var(--color-primary-dark); }
.chip.active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

/* ==========================================================================
   Landing page (logged-out marketing view)
   ========================================================================== */
#landing { min-height: 100%; background: var(--color-bg); }

.landing-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-8);
  max-width: 1280px;
  margin: 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-heading); font-weight: 700; font-size: 20px; color: var(--color-primary-darker); }
.brand .brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.landing-nav-actions { display: flex; gap: var(--space-3); }

.hero {
  max-width: 1280px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-8) var(--space-9);
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: var(--space-8);
  align-items: center;
}
@media (max-width: 900px) { .hero { grid-template-columns: 1fr; padding: var(--space-6) var(--space-5); } }

.hero-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--color-primary-light-2); color: var(--color-primary-dark);
  font-weight: 700; font-size: 13px; padding: 6px 14px; border-radius: var(--radius-pill);
  margin-bottom: var(--space-4);
}
.hero h1 { font-size: 44px; line-height: 1.12; margin-bottom: var(--space-4); }
.hero h1 span { color: var(--color-primary); }
.hero-sub { font-size: 17px; color: var(--color-text-muted); max-width: 540px; margin-bottom: var(--space-6); }
.hero-actions { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.hero-note { margin-top: var(--space-4); font-size: 13px; color: var(--color-text-faint); }

.hero-visual {
  background: linear-gradient(160deg, var(--color-primary-light-2), var(--color-bg-alt));
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  position: relative;
  min-height: 420px;
}
.hero-visual .floating-card {
  position: absolute;
  background: var(--color-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-4);
  width: 200px;
}
.hero-visual .fc-1 { top: 20px; left: 10px; }
.hero-visual .fc-2 { top: 150px; right: 0; width: 220px; }
.hero-visual .fc-3 { bottom: 20px; left: 40px; width: 230px; }
.fc-title { font-size: 12px; font-weight: 700; color: var(--color-text-muted); margin-bottom: 6px; }
.fc-value { font-size: 22px; font-weight: 700; color: var(--color-primary-darker); font-family: var(--font-heading); }
.fc-bar { height: 6px; border-radius: var(--radius-pill); background: var(--color-bg-alt); margin-top: 8px; overflow: hidden; }
.fc-bar span { display: block; height: 100%; background: var(--color-primary); }

.section { max-width: 1280px; margin: 0 auto; padding: var(--space-9) var(--space-8); }
@media (max-width: 900px) { .section { padding: var(--space-7) var(--space-5); } }
.section-head { text-align: center; max-width: 640px; margin: 0 auto var(--space-7); }
.section-head h2 { font-size: 30px; }
.section-head p { color: var(--color-text-muted); }

.feature-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  transition: transform .15s ease, box-shadow .15s ease;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.feature-icon {
  width: 46px; height: 46px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-primary-light-2); color: var(--color-primary);
  margin-bottom: var(--space-4);
}
.feature-card h4 { font-size: 16px; margin-bottom: 6px; }
.feature-card p { font-size: 13.5px; color: var(--color-text-muted); margin: 0; }

.trust-strip {
  background: var(--color-primary-darker);
  color: #fff;
  border-radius: var(--radius-lg);
  padding: var(--space-7);
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: var(--space-6);
  align-items: center;
}
@media (max-width: 900px) { .trust-strip { grid-template-columns: 1fr; text-align: center; } }
.trust-strip h3 { color: #fff; font-size: 22px; margin-bottom: 6px; }
.trust-strip p { color: rgba(255,255,255,0.75); margin: 0; font-size: 13.5px; }
.trust-stat { text-align: center; }
.trust-stat .num { font-family: var(--font-heading); font-size: 28px; font-weight: 700; }
.trust-stat .label { font-size: 12px; color: rgba(255,255,255,0.7); }

.landing-footer {
  border-top: 1px solid var(--color-border);
  padding: var(--space-6) var(--space-8);
  text-align: center;
  color: var(--color-text-faint);
  font-size: 13px;
}

/* ==========================================================================
   Auth modal / screens
   ========================================================================== */
.auth-overlay {
  position: fixed; inset: 0; background: rgba(35,46,42,0.45);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: var(--space-5);
  backdrop-filter: blur(2px);
}
.auth-card {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-7);
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  max-height: 92vh;
  overflow-y: auto;
  position: relative;
}
.auth-card .close-btn { position: absolute; top: var(--space-4); right: var(--space-4); }
.auth-tabs { display: flex; gap: var(--space-2); margin-bottom: var(--space-6); background: var(--color-bg-alt); border-radius: var(--radius-pill); padding: 4px; }
.auth-tab { flex: 1; text-align: center; padding: 8px; border-radius: var(--radius-pill); font-weight: 700; font-size: 13.5px; cursor: pointer; color: var(--color-text-muted); }
.auth-tab.active { background: var(--color-surface); color: var(--color-primary-dark); box-shadow: var(--shadow-sm); }
.auth-error {
  background: var(--color-danger-light); color: var(--color-danger);
  padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: var(--space-4);
}
.auth-foot { text-align: center; margin-top: var(--space-4); font-size: 13px; color: var(--color-text-muted); }

/* ==========================================================================
   App shell (logged-in)
   ========================================================================== */
#app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--color-primary-darker);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  transition: transform .2s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: var(--space-6) var(--space-5) var(--space-5); font-family: var(--font-heading); font-weight: 700; font-size: 18px; }
.sidebar-brand .brand-mark { width: 32px; height: 32px; border-radius: 9px; background: rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: center; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: var(--space-2) var(--space-3); }
.sidebar-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: rgba(255,255,255,0.4); padding: var(--space-4) var(--space-3) var(--space-2); font-weight: 700; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.78); font-size: 14px; font-weight: 600;
  cursor: pointer; margin-bottom: 2px; transition: background .15s ease, color .15s ease;
  position: relative;
}
.nav-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.14); color: #fff; }
.nav-link.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 4px; height: 60%; background: var(--color-accent); border-radius: var(--radius-pill);
}
.nav-link .nav-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-danger); margin-left: auto; }

.sidebar-footer { padding: var(--space-4); border-top: 1px solid rgba(255,255,255,0.1); }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-sm); cursor: pointer; }
.sidebar-user:hover { background: rgba(255,255,255,0.08); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.sidebar-user-info { overflow: hidden; }
.sidebar-user-info .name { font-size: 13.5px; font-weight: 700; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info .email { font-size: 11.5px; color: rgba(255,255,255,0.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.app-main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; min-width: 0; }

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--space-7);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky; top: 0; z-index: 30;
}
.topbar-title { display: flex; align-items: center; gap: var(--space-3); }
.topbar-title h1 { font-size: 20px; margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-3); }
.menu-toggle { display: none; }

.view-content { padding: var(--space-7); flex: 1; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .view-content { padding: var(--space-5); }
  .topbar { padding: 0 var(--space-4); }
}
.sidebar-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 45; display: none; }
.sidebar-overlay.show { display: block; }

/* Page header within a view */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: var(--space-6); gap: var(--space-4); flex-wrap: wrap; }
.page-head p { color: var(--color-text-muted); margin: 0; }

/* ---------- Stat tiles ---------- */
.stat-tile { display: flex; align-items: center; gap: var(--space-4); }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon svg { width: 22px; height: 22px; }
.stat-tile .stat-value { font-family: var(--font-heading); font-size: 24px; font-weight: 700; color: var(--color-primary-darker); }
.stat-tile .stat-label { font-size: 12.5px; color: var(--color-text-muted); font-weight: 600; }
.stat-tile .stat-sub { font-size: 11.5px; color: var(--color-text-faint); }

.icon-circle-primary { background: var(--color-primary-light); color: var(--color-primary-dark); }
.icon-circle-accent { background: var(--color-accent-light); color: var(--color-accent-dark); }
.icon-circle-danger { background: var(--color-danger-light); color: var(--color-danger); }
.icon-circle-info { background: var(--color-info-light); color: var(--color-info); }
.icon-circle-success { background: var(--color-success-light); color: var(--color-success); }

/* ---------- Tables / lists ---------- */
.log-list { display: flex; flex-direction: column; gap: var(--space-3); }
.log-item {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4); border-radius: var(--radius-md);
  border: 1px solid var(--color-border); background: var(--color-surface-2);
  transition: box-shadow .15s ease;
}
.log-item:hover { box-shadow: var(--shadow-sm); }
.log-item-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.log-item-main { flex: 1; min-width: 0; }
.log-item-title { font-weight: 700; font-size: 14px; color: var(--color-text); }
.log-item-meta { font-size: 12.5px; color: var(--color-text-muted); margin-top: 2px; }
.log-item-actions { display: flex; gap: 4px; }

.empty-state { text-align: center; padding: var(--space-8) var(--space-5); color: var(--color-text-muted); }
.empty-state svg { width: 48px; height: 48px; margin: 0 auto var(--space-3); color: var(--color-text-faint); }
.empty-state h4 { color: var(--color-text-muted); margin-bottom: 4px; }
.empty-state p { font-size: 13.5px; margin: 0; }

/* ---------- Tabs (within views) ---------- */
.tabbar { display: flex; gap: var(--space-2); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-6); overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
.tabbar::-webkit-scrollbar { display: none; }
.tabbar-item {
  padding: 10px 4px; margin-right: var(--space-6);
  font-weight: 700; font-size: 14px; color: var(--color-text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabbar-item:hover { color: var(--color-primary-dark); }
.tabbar-item.active { color: var(--color-primary-dark); border-color: var(--color-primary); }

/* ---------- Progress bars ---------- */
.progress { height: 8px; border-radius: var(--radius-pill); background: var(--color-bg-alt); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--color-primary); border-radius: var(--radius-pill); }

/* ---------- Modal (in-app) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(35,46,42,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 200; padding: var(--space-5);
}
.modal-card {
  background: var(--color-surface); border-radius: var(--radius-lg);
  padding: var(--space-7); width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg); max-height: 90vh; overflow-y: auto; position: relative;
}
.modal-card.modal-wide { max-width: 720px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-5); }
.modal-head h3 { margin: 0; }

/* ---------- Toasts ---------- */
#toast-stack { position: fixed; bottom: var(--space-6); right: var(--space-6); z-index: 300; display: flex; flex-direction: column; gap: var(--space-3); }
.toast {
  background: var(--color-primary-darker); color: #fff; padding: 12px 18px;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: 13.5px; font-weight: 600;
  display: flex; align-items: center; gap: 10px; min-width: 220px;
  animation: toast-in .2s ease;
}
.toast.toast-danger { background: var(--color-danger); }
.toast.toast-success { background: var(--color-success); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--color-border); margin: var(--space-5) 0; }
.muted { color: var(--color-text-muted); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4); border-top-color: #fff;
  animation: spin .6s linear infinite;
}
.spinner-dark { border: 2px solid var(--color-border-strong); border-top-color: var(--color-primary); }
@keyframes spin { to { transform: rotate(360deg); } }

#loading-screen {
  position: fixed; inset: 0; background: var(--color-bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-4); z-index: 500;
}

/* ---------- Calendar (My Home) ---------- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.calendar-dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--color-text-faint); padding-bottom: 6px; }
.calendar-cell {
  aspect-ratio: 1; border-radius: var(--radius-sm); border: 1px solid var(--color-border);
  padding: 6px; cursor: pointer; background: var(--color-surface-2); display: flex; flex-direction: column; gap: 2px;
  position: relative; min-height: 64px;
}
.calendar-cell:hover { border-color: var(--color-primary); }
.calendar-cell.empty { background: transparent; border-color: transparent; cursor: default; }
.calendar-cell.today { border-color: var(--color-primary); box-shadow: 0 0 0 2px var(--color-primary-light); }
.calendar-cell .day-num { font-size: 12px; font-weight: 700; color: var(--color-text-muted); }
.calendar-cell .day-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-accent); position: absolute; bottom: 6px; left: 6px; }
.calendar-cell .day-dot.danger { background: var(--color-danger); }

/* ---------- Family tree ---------- */
.tree-gen { display: flex; justify-content: center; gap: var(--space-4); margin-bottom: var(--space-6); flex-wrap: wrap; }
.tree-card {
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: var(--space-4); width: 168px; text-align: center; box-shadow: var(--shadow-sm); cursor: pointer; transition: transform .15s ease;
}
.tree-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.tree-card .avatar { margin: 0 auto 8px; }
.tree-card .tree-name { font-weight: 700; font-size: 13.5px; }
.tree-card .tree-rel { font-size: 11.5px; color: var(--color-text-muted); margin-bottom: 6px; }

/* ---------- Program category banner (with real photo) ---------- */
.program-banner {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: 200px;
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.program-banner img {
  width: 100%; height: 100%; object-fit: cover;
}
.program-banner-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(31,74,62,0.05) 0%, rgba(31,74,62,0.78) 100%);
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: var(--space-5) var(--space-6);
}
.program-banner-overlay h3 { color: #fff; margin-bottom: 2px; }
.program-banner-overlay p { color: rgba(255,255,255,0.85); margin: 0; font-size: 13px; font-weight: 600; }
.program-banner-credit {
  position: absolute; bottom: 8px; right: 12px;
  font-size: 10.5px; color: rgba(255,255,255,0.7);
  text-decoration: none;
}
.program-banner-credit:hover { color: #fff; text-decoration: underline; }

/* ---------- Resource directory cards ---------- */
.resource-card { border-left: 4px solid var(--color-primary); }

/* ---------- Scrollable tabbar (My Health, etc.) ---------- */
.tabbar-scroll {
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 1px;
}
.tabbar-scroll::-webkit-scrollbar { display: none; }
.tabbar-scroll .tabbar-item { flex-shrink: 0; }

/* ---------- Exercise cards ---------- */
.exercise-card { transition: box-shadow .15s; }
.exercise-card:hover { box-shadow: var(--shadow-md); }
.exercise-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 4px;
}
.exercise-stats {
  display: flex;
  gap: 10px;
  padding: 10px 0 2px;
  border-top: 1px solid var(--color-border);
  flex-wrap: wrap;
}
.exercise-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 52px;
  background: var(--color-surface-2);
  border-radius: 8px;
  padding: 6px 10px;
}
.exercise-stat-val {
  font-weight: 700;
  font-size: 13.5px;
  color: var(--color-primary-dark);
  line-height: 1.2;
}
.exercise-stat-label {
  font-size: 10.5px;
  color: var(--color-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
  margin-top: 2px;
}

/* ---------- Workout plan goal option selector ---------- */
.goal-option { transition: border-color .15s, background .15s; }
.goal-option:hover { border-color: var(--color-primary) !important; background: var(--color-primary-light-2); }
.goal-option-active {
  border-color: var(--color-primary) !important;
  background: var(--color-primary-light) !important;
  color: var(--color-primary-dark);
}

/* ---------- Printable health summary ---------- */
@media print {
  #app-shell .sidebar, #app-shell .topbar, .no-print { display: none !important; }
  .app-main { margin-left: 0 !important; }
  body { background: #fff; }
}

/* ==========================================================================
   Polish pass — calm motion, hero atmosphere, focus states
   ========================================================================== */
html { scroll-behavior: smooth; }

/* Soft sage wash behind the hero */
#landing { position: relative; overflow-x: clip; }
#landing::before {
  content: '';
  position: absolute;
  top: -180px; right: -160px;
  width: 640px; height: 640px;
  background: radial-gradient(closest-side, rgba(63, 125, 107, 0.10), transparent 70%);
  pointer-events: none;
}
#landing::after {
  content: '';
  position: absolute;
  top: 380px; left: -220px;
  width: 560px; height: 560px;
  background: radial-gradient(closest-side, rgba(226, 168, 87, 0.08), transparent 70%);
  pointer-events: none;
}
#landing > * { position: relative; }

/* Gradient accent on the brand word */
.hero h1 span {
  background: linear-gradient(115deg, var(--color-primary) 30%, var(--color-info) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Gentle staggered entrance */
@keyframes eq-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.hero-eyebrow { animation: eq-rise .55s ease both; }
.hero h1 { animation: eq-rise .55s .07s ease both; }
.hero-sub { animation: eq-rise .55s .14s ease both; }
.hero-actions { animation: eq-rise .55s .21s ease both; }
.hero-note { animation: eq-rise .55s .28s ease both; }
.hero-visual { animation: eq-rise .6s .18s ease both; }

/* Floating cards drift slowly and lift on hover */
@keyframes eq-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.hero-visual .floating-card { animation: eq-float 5.5s ease-in-out infinite; transition: box-shadow .25s ease; }
.hero-visual .fc-2 { animation-delay: 1.4s; }
.hero-visual .fc-3 { animation-delay: 2.8s; }
.hero-visual .floating-card:hover { box-shadow: 0 18px 44px rgba(35, 46, 42, 0.16); }

/* Progress bars sweep in */
@keyframes eq-fill { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.fc-bar span { transform-origin: left center; animation: eq-fill .9s .5s cubic-bezier(.25,.8,.35,1) both; }

/* Primary button refinement */
.btn-primary { background: linear-gradient(160deg, var(--color-primary), var(--color-primary-dark)); }
.btn-primary:hover { background: linear-gradient(160deg, var(--color-primary-dark), var(--color-primary-darker)); transform: translateY(-1px); }

/* Trust strip inner glow */
.trust-strip {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--color-primary-darker), var(--color-primary-dark));
}
.trust-strip::before {
  content: '';
  position: absolute;
  top: -120px; right: -80px;
  width: 380px; height: 380px;
  background: radial-gradient(closest-side, rgba(255,255,255,0.10), transparent 70%);
  pointer-events: none;
}
.trust-strip > * { position: relative; }

/* Visible keyboard focus everywhere */
:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; border-radius: 4px; }
.btn:focus-visible { outline-offset: 3px; }

/* Sidebar nav links: smooth hover slide */
.nav-link { transition: background .15s ease, color .15s ease, padding-left .2s ease; }
.nav-link:hover { padding-left: 18px; }

/* Respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Info banner (plan/goal saved indicator) ---------- */
.info-banner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  background: var(--color-primary-light-2);
  border: 1px solid var(--color-primary-light);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  font-size: 14px;
}
.info-banner strong { display: block; color: var(--color-primary-darker); font-size: 14px; }
.info-banner span { color: var(--color-text-muted); font-size: 13px; }
.info-banner > i[data-lucide] { flex-shrink: 0; color: var(--color-primary); width: 20px; height: 20px; }
.info-banner > div { flex: 1; }

/* ---------- Meditation timer preset buttons ---------- */
.timer-preset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  background: var(--color-surface-2);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color .15s, background .15s, color .15s;
}
.timer-preset-btn:hover { border-color: var(--color-primary); color: var(--color-primary-dark); background: var(--color-primary-light-2); }
.timer-preset-btn.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

/* ---------- Google sign-in ---------- */
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 14px 0; color: var(--color-text-faint); font-size: 12px; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--color-border); }
.btn-google { background: #fff; color: var(--color-text); border: 1px solid var(--color-border-strong); }
.btn-google:hover { background: var(--color-surface-2); border-color: var(--color-text-faint); transform: none; }

/* ---------- File upload widget (logModule type:"files") ---------- */
.file-upload-area {
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--color-surface-2);
  transition: border-color .15s;
}
.file-upload-area:focus-within { border-color: var(--color-primary); }

.file-chips-row { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; }

.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--color-primary-light-2, var(--color-primary-light));
  border: 1px solid var(--color-primary-light);
  border-radius: var(--radius-pill);
  padding: 3px 8px 3px 9px;
  font-size: 12.5px;
  max-width: 280px;
}
.file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.file-chip-remove {
  background: none; border: none; padding: 1px; cursor: pointer;
  display: flex; align-items: center; color: var(--color-text-faint); flex-shrink: 0;
  border-radius: 99px;
}
.file-chip-remove:hover { color: #d95f5f; background: rgba(217,95,95,.10); }

.file-progress { display: flex; flex-direction: column; gap: 4px; }
.file-progress span { font-size: 12px; color: var(--color-text-muted); }
.file-progress-track { background: var(--color-primary-light); border-radius: 99px; height: 4px; overflow: hidden; }
.file-progress-fill { height: 100%; background: var(--color-primary); width: 0%; transition: width .2s; }

/* ==========================================================================
   Dashboard design upgrade — borderless stat tiles, editorial nav,
   assertive type scale, warm empty states, cohesive focus.
   ========================================================================== */

/* ---------- Borderless dashboard stat tiles ---------- */
.dash-stat {
  position: relative;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--accent, var(--color-primary));
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}
.dash-stat-value {
  font-family: var(--font-heading);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.05;
  color: var(--color-primary);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.dash-stat-unit { font-size: 1.25rem; font-weight: 600; color: var(--color-text-muted); margin-left: 2px; }
.dash-stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-top: 4px;
}

/* ---------- Editorial sidebar active state (clean left-border, not a pill) ---------- */
.nav-link.active {
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-weight: 600;
  border-left: 3px solid var(--color-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding-left: 11px;
}
.nav-link.active svg { color: var(--color-primary); }
.nav-link.active::before { display: none; }

/* ---------- Assertive typography scale ---------- */
.card-title-row h3 {
  font-family: var(--font-heading);
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-text);
}
.panel-eyebrow {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-faint);
  font-family: var(--font-body);
  font-weight: 700;
}
.stat-value, .stat-tile .stat-value, .fc-value, .trust-stat .num { font-variant-numeric: tabular-nums; }

/* ---------- Warm empty-state badge + active prompt ---------- */
.empty-badge {
  width: 64px; height: 64px; border-radius: 50%;
  background: rgba(63, 125, 107, 0.18);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto var(--space-4);
}
.empty-badge svg { width: 28px; height: 28px; margin: 0; color: var(--color-primary); }
.empty-prompt { font-weight: 700; font-size: 13.5px; color: var(--color-primary); }
.empty-prompt:hover { color: var(--color-primary-dark); text-decoration: underline; }

/* ---------- Editorial topbar logout (text, not a button) ---------- */
#logout-btn {
  background: none;
  border: none;
  box-shadow: none;
  color: var(--color-text-muted);
  font-size: 13px;
  padding: 6px 10px;
}
#logout-btn:hover { background: none; color: var(--color-danger); }

/* ---------- Cohesive focus ring on every input/select ---------- */
input:focus, select:focus, textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
  outline: none;
}

/* ==========================================================================
   AI Features — AI Dashboard, Medical AI, Diagnosis Assistant,
   Appointment AI, Hospital ERP, Radiology AI
   ========================================================================== */

/* AI Module Cards */
.ai-module-card {
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  cursor: pointer;
}
.ai-module-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

/* AI Hero Banners */
.section-hero {
  position: relative;
  overflow: hidden;
}

/* AI Response Cards */
.ai-response-card {
  background: var(--color-surface-2);
  border-left: 4px solid var(--color-primary);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

/* AI Chat / Input Areas */
.ai-chat-input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.ai-chat-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
  background: #fff;
}

/* AI Confidence Badge */
.ai-confidence {
  font-size: 12px;
  color: var(--color-text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}
.ai-confidence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.ai-confidence-dot.high { background: var(--color-success); }
.ai-confidence-dot.medium { background: var(--color-accent); }
.ai-confidence-dot.low { background: var(--color-danger); }

/* AI Result Container */
.ai-result {
  margin-top: var(--space-5);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* AI Stat Cards */
.ai-stat {
  text-align: center;
  padding: var(--space-5);
}
.ai-stat-value {
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 800;
  line-height: 1.1;
  color: var(--color-primary);
}
.ai-stat-label {
  font-size: 12px;
  color: var(--color-text-muted);
  font-weight: 600;
  margin-top: 4px;
}

/* Toggle Switch (Appointment AI) */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-border-strong);
  border-radius: 26px;
  transition: 0.3s;
}
.toggle-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--color-primary);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px);
}

/* AI Loading Animation */
@keyframes ai-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
.ai-loading {
  animation: ai-pulse 1.5s ease-in-out infinite;
}

/* Pre-line for AI responses */
.ai-response-text {
  white-space: pre-line;
  line-height: 1.6;
}

/* Responsive AI grid adjustments */
@media (max-width: 768px) {
  .ai-grid-2 {
    grid-template-columns: 1fr;
  }
}
