﻿/* ═══════════════════════════════════════════════════════════════
   Genesis Health Companion — Design System v2
   World-class, modern, professional health app UI
   ═══════════════════════════════════════════════════════════════ */

/* ── Google Fonts ───────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ── Design Tokens ──────────────────────────────────────────── */
:root {
  /* Brand */
  --primary:        #0d9488;
  --primary-dark:   #0f766e;
  --primary-mid:    #14b8a6;
  --primary-light:  #99f6e4;
  --primary-pale:   #ccfbf1;
  --primary-ghost:  #f0fdfa;

  /* Semantic */
  --success:        #16a34a;
  --success-light:  #dcfce7;
  --warning:        #d97706;
  --warning-light:  #fef3c7;
  --danger:         #dc2626;
  --danger-light:   #fee2e2;
  --info:           #2563eb;
  --info-light:     #dbeafe;

  /* Neutrals */
  --slate-50:  #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Semantic aliases (light mode) */
  --bg:          var(--slate-50);
  --bg-2:        var(--slate-100);
  --surface:     #ffffff;
  --border:      var(--slate-200);
  --border-mid:  var(--slate-300);
  --text:        var(--slate-900);
  --text-2:      var(--slate-700);
  --text-muted:  var(--slate-500);
  --text-subtle: var(--slate-400);

  /* Sidebar */
  --sidebar-bg:            #0f172a;
  --sidebar-text:          #94a3b8;
  --sidebar-text-active:   #f1f5f9;
  --sidebar-hover:         rgba(255,255,255,.06);
  --sidebar-active:        rgba(13,148,136,.22);
  --sidebar-active-border: #14b8a6;
  --sidebar-brand-text:    #f1f5f9;

  /* Dimensions */
  --sidebar-w:  256px;
  --topbar-h:   60px;
  --bnav-h:     64px;

  /* Shape */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px -1px rgba(0,0,0,.1);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
  --shadow-primary: 0 4px 14px rgba(13,148,136,.35);

  /* Motion */
  --ease:     cubic-bezier(.4,0,.2,1);
  --ease-out: cubic-bezier(0,0,.2,1);
  --dur:      200ms;
  --dur-fast: 120ms;

  /* Typography */
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'Fira Code', 'Cascadia Code', monospace;
}

/* ── Dark Mode ──────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:          #0a0f1a;
  --bg-2:        #111827;
  --surface:     #1a2235;
  --border:      #1f2d3d;
  --border-mid:  #2d3f52;
  --text:        #f1f5f9;
  --text-2:      #cbd5e1;
  --text-muted:  #64748b;
  --text-subtle: #475569;
  --primary-pale:  #042f2e;
  --primary-ghost: #081e1d;
  --success-light: #052e16;
  --warning-light: #1c0a00;
  --danger-light:  #1f0606;
  --info-light:    #0c1340;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.4);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.4), 0 2px 4px -2px rgba(0,0,0,.3);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.5), 0 4px 6px -4px rgba(0,0,0,.3);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.6), 0 8px 10px -6px rgba(0,0,0,.4);
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: var(--font); }
h1, h2, h3, h4, h5 { line-height: 1.25; color: var(--text); font-weight: 700; }
h1 { font-size: 1.875rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }
p { color: var(--text-2); }
small { font-size: 0.8125rem; color: var(--text-muted); }
input, textarea, select {
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13,148,136,.15);
}

/* ── Sidebar Overlay ────────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 150;
  backdrop-filter: blur(2px);
}
#sidebar-overlay.open { display: block; }

/* ── Sidebar ────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  position: fixed;
  left: 0; top: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform var(--dur) var(--ease-out);
  overflow: hidden;
  flex-shrink: 0;
}

/* ── Sidebar: Header ── */
.sidebar-header {
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1.125rem 1rem;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease);
}
.sidebar-brand:hover { background: rgba(255,255,255,.04); text-decoration: none; }
.sidebar-logo { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; }
.sidebar-brand-text { display: flex; flex-direction: column; gap: 2px; }
.sidebar-title { font-size: 0.9375rem; font-weight: 700; color: var(--sidebar-brand-text); line-height: 1.2; letter-spacing: -.01em; }
.sidebar-tagline { font-size: 0.6875rem; color: rgba(148,163,184,.65); font-weight: 400; line-height: 1.3; }

/* ── Sidebar: Scrollable nav area ── */
.nav-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0 0.75rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.08) transparent;
}

/* ── Nav groups ── */
.nav-group { padding: 0 0.625rem; margin-bottom: 0.125rem; }
.nav-group-label {
  display: block;
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: rgba(148,163,184,.4);
  padding: 0.875rem 0.5rem 0.3rem;
  user-select: none;
}
.nav-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--sidebar-text);
  text-decoration: none;
  transition: all var(--dur-fast) var(--ease);
  position: relative;
  white-space: nowrap;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; text-decoration: none; }
.nav-item.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
  border-color: rgba(20,184,166,.18);
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 65%;
  background: var(--sidebar-active-border);
  border-radius: 0 3px 3px 0;
}
.nav-icon { font-size: 1.0625rem; width: 1.25rem; text-align: center; flex-shrink: 0; opacity: .7; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-label { flex: 1; }

/* ── Sidebar: Footer ── */
.sidebar-footer {
  flex-shrink: 0;
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-footer-link {
  display: flex; align-items: center; gap: 0.4rem;
  font-size: 0.75rem;
  color: rgba(148,163,184,.55);
  font-weight: 500;
  margin-bottom: 0.3rem;
  transition: color var(--dur-fast);
}
.sidebar-footer-link:hover { color: var(--primary-mid); text-decoration: none; }
.sidebar-disclaimer { font-size: 0.625rem; color: rgba(148,163,184,.4); line-height: 1.5; margin: 0.25rem 0 0; }

/* ── Member Switcher (topbar) ─────────────────────────────── */
.member-switcher { position: relative; }

.member-switcher-btn {
  display: flex;
  align-items: center;
  gap: 0.4375rem;
  padding: 0.3125rem 0.625rem;
  border-radius: var(--radius);
  background: var(--bg-secondary);
  border: 1.5px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--dur-fast) var(--ease);
  max-width: 180px;
}
.member-switcher-btn:hover {
  border-color: var(--primary-light);
  background: var(--primary-xlight);
}

.member-avatar-circle {
  width: 28px; height: 28px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.625rem;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
}

.member-switcher-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-switcher-caret {
  font-size: 0.625rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Member Dropdown ── */
.member-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 30px rgba(0,0,0,.15), 0 2px 8px rgba(0,0,0,.08);
  z-index: 500;
  overflow: hidden;
}
.member-dropdown.hidden { display: none; }

.member-dropdown-header {
  padding: 0.625rem 1rem 0.375rem;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.member-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 1rem;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  text-decoration: none;
  transition: background var(--dur-fast);
}
.member-dropdown-item:hover { background: var(--bg-secondary); }
.member-dropdown-item.active-member {
  background: var(--primary-xlight);
  color: var(--primary);
  font-weight: 600;
}

.member-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}
.member-name-text {
  font-size: 0.875rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.member-age-text {
  font-size: 0.6875rem;
  color: var(--text-muted);
}
.member-active-check {
  font-size: 0.8125rem;
  color: var(--primary);
  font-weight: 700;
  flex-shrink: 0;
}

.member-dropdown-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
}

.member-add-btn { color: var(--primary) !important; font-weight: 600 !important; }
.member-profile-link { color: var(--text) !important; }

/* ── Add Member Modal ── */
.add-member-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(3px);
}

.add-member-modal-box {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  animation: page-in 0.18s ease-out;
}

.add-member-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.add-member-modal-header h3 {
  font-size: 1.0625rem;
  font-weight: 700;
  margin: 0;
}
.add-member-modal-footer {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* ── Topbar ─────────────────────────────────────────────────── */
#topbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.5rem;
  z-index: 100;
}
#menu-toggle { display: none; }
#page-title { font-size: 1.0625rem; font-weight: 700; color: var(--text); flex: 1; letter-spacing: -.015em; }
.topbar-actions { display: flex; align-items: center; gap: 0.5rem; }
.sos-btn-top {
  display: inline-flex; align-items: center; gap: 0.375rem;
  padding: 0.4375rem 0.875rem;
  background: var(--danger); color: #fff;
  border-radius: 99px; font-size: 0.8125rem; font-weight: 700;
  text-decoration: none;
  transition: all var(--dur) var(--ease);
  animation: sos-pulse 2.5s infinite;
}
.sos-btn-top:hover { background: #b91c1c; text-decoration: none; color: #fff; }
@keyframes sos-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
  60%       { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}

/* ── Main Content ───────────────────────────────────────────── */
#main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding-top: var(--topbar-h);
  min-height: 100vh;
  background: var(--bg);
  overflow-x: hidden;
}

/* ── Pages ──────────────────────────────────────────────────── */
.page { display: none; padding: 1.75rem 2rem; max-width: 1280px; }
.page.active { display: block; animation: page-in var(--dur) var(--ease-out); }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4375rem; padding: 0.5625rem 1.125rem;
  border-radius: var(--radius-sm); font-size: 0.875rem; font-weight: 600;
  border: 1.5px solid transparent; transition: all var(--dur-fast) var(--ease);
  line-height: 1; cursor: pointer; white-space: nowrap; font-family: var(--font);
  letter-spacing: -.01em;
}
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); box-shadow: var(--shadow-primary); transform: translateY(-1px); }
.btn-secondary { background: var(--primary-ghost); color: var(--primary-dark); border-color: var(--primary-pale); }
.btn-secondary:hover:not(:disabled) { background: var(--primary-pale); }
.btn-outline { background: transparent; color: var(--text-2); border-color: var(--border-mid); }
.btn-outline:hover:not(:disabled) { background: var(--bg-2); color: var(--text); }
.btn-danger { background: var(--danger-light); color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--text); border-color: var(--border); }
.btn-sm  { padding: .375rem .75rem; font-size: .8125rem; border-radius: 6px; }
.btn-lg  { padding: .75rem 1.5rem; font-size: 1rem; border-radius: var(--radius); }
.btn-xl  { padding: 1rem 2rem; font-size: 1.0625rem; border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-icon { width: 2.25rem; height: 2.25rem; padding: 0; border-radius: var(--radius-sm); font-size: 1rem; color: var(--text-muted); background: transparent; border: 1.5px solid transparent; }
.btn-icon:hover { background: var(--bg-2); color: var(--text); border-color: var(--border); }

/* ── Cards ──────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); }
.card-sm { padding: 1rem; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; }
.card-title { font-size: .9375rem; font-weight: 700; color: var(--text); display: flex; align-items: center; gap: .5rem; }
.card-subtitle { font-size: .8125rem; color: var(--text-muted); margin-top: 2px; }

/* Stat cards */
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; display: flex; flex-direction: column; gap: .5rem;
  transition: all var(--dur) var(--ease); box-shadow: var(--shadow-sm); cursor: default;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card-label { font-size: .6875rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .07em; }
.stat-card-value { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -.04em; }
.stat-card-sub { font-size: .8125rem; color: var(--text-muted); }
.stat-card-icon { font-size: 1.25rem; width: 2.25rem; height: 2.25rem; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; background: var(--primary-ghost); margin-bottom: .25rem; }

/* Metric cards */
.metric-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.125rem; display: flex; flex-direction: column; gap: .25rem;
  transition: all var(--dur) var(--ease); position: relative; overflow: hidden; box-shadow: var(--shadow-xs);
}
.metric-card::after {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--cat-color, var(--primary)); border-radius: var(--radius) var(--radius) 0 0;
}
.metric-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.metric-name  { font-size: .6875rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.metric-value { font-size: 1.75rem; font-weight: 800; color: var(--text); line-height: 1; letter-spacing: -.04em; }
.metric-unit  { font-size: .8125rem; font-weight: 500; color: var(--text-muted); }
.metric-date  { font-size: .6875rem; color: var(--text-subtle); margin-top: .375rem; }
.metric-trend { font-size: .75rem; font-weight: 700; }
.metric-trend.rising  { color: var(--danger); }
.metric-trend.falling { color: var(--success); }
.metric-trend.stable  { color: var(--text-muted); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .1875rem .5625rem; border-radius: 99px; font-size: .6875rem; font-weight: 700; letter-spacing: .03em; }
.badge-normal       { background: var(--success-light); color: var(--success); }
.badge-high         { background: var(--warning-light); color: var(--warning); }
.badge-low          { background: var(--info-light);    color: var(--info); }
.badge-warn-high    { background: #fff7ed; color: #c2410c; }
.badge-warn-low     { background: #faf5ff; color: #7c3aed; }
.badge-critical-high{ background: var(--danger-light);  color: var(--danger); }
.badge-critical-low { background: var(--info-light);    color: #1d4ed8; }
.badge-unknown      { background: var(--bg-2); color: var(--text-muted); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group   { display: flex; flex-direction: column; gap: .375rem; margin-bottom: 1rem; }
.form-label   { font-size: .875rem; font-weight: 600; color: var(--text-2); }
.form-hint    { font-size: .75rem; color: var(--text-muted); }
.form-note    { font-size: .75rem; color: var(--text-muted); padding: .625rem .875rem; background: var(--bg-2); border-radius: var(--radius-sm); border-left: 3px solid var(--primary); line-height: 1.5; }
.form-control { width: 100%; padding: .5625rem .875rem; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: .875rem; background: var(--surface); color: var(--text); transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,148,136,.15); outline: none; }
textarea.form-control { resize: vertical; min-height: 80px; line-height: 1.6; }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2.5rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead { border-bottom: 1px solid var(--border); }
th { background: var(--bg-2); color: var(--text-muted); font-weight: 600; font-size: .6875rem; text-transform: uppercase; letter-spacing: .07em; padding: .75rem 1rem; text-align: left; }
td { padding: .75rem 1rem; border-top: 1px solid var(--border); color: var(--text-2); }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg); }

/* ── Tabs ───────────────────────────────────────────────────── */
.tabs { display: flex; gap: 2px; background: var(--bg-2); padding: 3px; border-radius: var(--radius-sm); overflow-x: auto; border: 1px solid var(--border); }
.tab { flex-shrink: 0; padding: .5rem 1rem; border-radius: 6px; border: none; font-size: .875rem; font-weight: 500; color: var(--text-muted); background: transparent; cursor: pointer; transition: all var(--dur-fast) var(--ease); white-space: nowrap; font-family: var(--font); }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--primary); font-weight: 700; box-shadow: var(--shadow-xs); }
.tab-panel { display: none; padding-top: 1.5rem; }
.tab-panel.active { display: block; animation: page-in var(--dur) var(--ease-out); }

/* ── Settings Tabs ──────────────────────────────────────────── */
.settings-tabs-nav { display: flex; flex-wrap: wrap; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 0; }
.settings-tab-btn { padding: 0.625rem 1.125rem; border: none; background: transparent; cursor: pointer; font-size: 0.875rem; font-weight: 500; color: var(--text-muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color 0.15s, border-color 0.15s; white-space: nowrap; font-family: var(--font); }
.settings-tab-btn:hover { color: var(--text); }
.settings-tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.settings-tabs-nav + .tab-panel { padding-top: 1.25rem; }

/* ── Chat History Panel ─────────────────────────────────────── */
.chat-history-header { display: flex; align-items: center; justify-content: space-between; padding: 0.625rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.8125rem; font-weight: 600; color: var(--text-muted); background: var(--bg); border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.chat-history-list { max-height: 200px; overflow-y: auto; scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
.chat-history-list::-webkit-scrollbar { width: 4px; }
.chat-history-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.chat-history-list [data-conversation-id] { transition: background 0.12s; }
.chat-history-list [data-conversation-id]:hover { background: var(--bg); }

/* ── Modal ──────────────────────────────────────────────────── */
#modal-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.65); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 1rem; backdrop-filter: blur(6px); }
#modal-overlay.hidden { display: none; }
#modal-box { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow: hidden; animation: modal-in var(--dur) var(--ease-out); }
@keyframes modal-in { from { opacity: 0; transform: scale(.97) translateY(8px); } to { opacity: 1; transform: none; } }
#modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
#modal-title { font-size: 1.0625rem; font-weight: 700; }
#modal-body { flex: 1; padding: 1.5rem; overflow-y: auto; }
#modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: .75rem; justify-content: flex-end; flex-shrink: 0; background: var(--bg); }
.modal-close { border: none !important; }

/* ── Toasts ─────────────────────────────────────────────────── */
#toast-container { position: fixed; top: calc(var(--topbar-h) + .75rem); right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: .5rem; pointer-events: none; }
.toast { display: flex; align-items: center; gap: .75rem; padding: .875rem 1.125rem; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-md); border: 1px solid var(--border); font-size: .875rem; line-height: 1.4; opacity: 0; transform: translateX(1.5rem) scale(.96); transition: all .3s var(--ease-out); max-width: 380px; pointer-events: all; }
.toast-visible { opacity: 1; transform: none; }
.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-info    { border-left: 4px solid var(--info); }
.toast-icon    { font-size: 1.125rem; flex-shrink: 0; }
.toast-msg     { flex: 1; font-weight: 500; }

/* ── Loading / Empty ────────────────────────────────────────── */
.loading-overlay { display: flex; align-items: center; justify-content: center; min-height: 300px; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 4rem 2rem; min-height: 240px; }
.empty-state-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.125rem; margin-bottom: .5rem; }
.empty-state p { color: var(--text-muted); max-width: 300px; font-size: .9375rem; }
.empty-state .btn { margin-top: 1.25rem; }

/* ── Section headers ────────────────────────────────────────── */
.section-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.25rem; gap: 1rem; }
.section-title-group { display: flex; flex-direction: column; gap: 2px; }
.section-subtitle { font-size: .875rem; color: var(--text-muted); font-weight: 400; }
.section-actions { display: flex; gap: .5rem; flex-shrink: 0; align-items: center; }

/* ── Grids & Utils ──────────────────────────────────────────── */
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.grid-auto-sm { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: .5rem; }
.gap-3 { gap: .75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.mb-2 { margin-bottom: .5rem; }
.mb-3 { margin-bottom: .75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }
.mt-2 { margin-top: .5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.text-muted { color: var(--text-muted) !important; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.font-bold { font-weight: 700; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.divider { height: 1px; background: var(--border); margin: 1.25rem 0; }
.disclaimer-banner { display: flex; align-items: flex-start; gap: .625rem; padding: .75rem 1rem; background: var(--primary-ghost); border: 1px solid var(--primary-pale); border-left: 4px solid var(--primary); border-radius: var(--radius-sm); font-size: .8125rem; color: var(--text-muted); line-height: 1.5; margin-bottom: 1.5rem; }

/* ── Dashboard ──────────────────────────────────────────────── */
.dash-hero {
  background: linear-gradient(135deg, #0f172a 0%, #0d2e2c 60%, #0a2523 100%);
  border-radius: var(--radius-lg);
  padding: 2rem 2.5rem;
  margin-bottom: 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  overflow: hidden;
  position: relative;
}
.dash-hero::before { content: ''; position: absolute; top: -80px; right: -80px; width: 260px; height: 260px; background: radial-gradient(circle, rgba(13,148,136,.25) 0%, transparent 70%); border-radius: 50%; pointer-events: none; }
.dash-hero-text { position: relative; z-index: 1; }
.dash-greeting { font-size: 1.625rem; font-weight: 800; color: #f1f5f9; line-height: 1.2; letter-spacing: -.025em; margin-bottom: .5rem; }
.dash-date { font-size: .875rem; color: rgba(148,163,184,.75); }
.dash-persona-tag { display: inline-flex; align-items: center; gap: .375rem; margin-top: .625rem; padding: .3125rem .75rem; background: rgba(13,148,136,.2); border: 1px solid rgba(20,184,166,.3); border-radius: 99px; font-size: .75rem; font-weight: 600; color: #5eead4; }
.health-score-wrap { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: .5rem; flex-shrink: 0; }
.health-score-ring { width: 100px; height: 100px; position: relative; }
.health-score-ring svg { transform: rotate(-90deg); }
.health-score-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #fff; }
.health-score-num span:first-child { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.health-score-num span:last-child  { font-size: .5625rem; opacity: .55; font-weight: 500; letter-spacing: .05em; }
.health-score-label { font-size: .6875rem; color: rgba(148,163,184,.65); font-weight: 500; letter-spacing: .05em; text-transform: uppercase; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 1rem; margin-bottom: 1.75rem; }

.reminder-list { display: flex; flex-direction: column; gap: .5rem; }
.reminder-item { display: flex; align-items: center; gap: .875rem; padding: .75rem; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); transition: all var(--dur-fast) var(--ease); }
.reminder-item:hover { border-color: var(--primary-pale); background: var(--primary-ghost); }
.reminder-icon { font-size: 1.25rem; flex-shrink: 0; }
.reminder-text { font-size: .875rem; font-weight: 500; color: var(--text-2); flex: 1; }
.reminder-time { font-size: .75rem; color: var(--text-muted); flex-shrink: 0; }

.trend-warning { display: flex; align-items: flex-start; gap: .875rem; padding: 1rem; border-radius: var(--radius); margin-bottom: .75rem; border: 1px solid; }
.trend-warning.warn-high { background: var(--warning-light); border-color: #fde68a; }
.trend-warning.warn-low  { background: var(--info-light);    border-color: #bfdbfe; }
.trend-warning h4 { font-size: .875rem; margin-bottom: 2px; }
.trend-warning p  { font-size: .8125rem; color: var(--text-2); }

.quick-action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .625rem; }
.quick-action { display: flex; flex-direction: column; align-items: center; gap: .375rem; padding: .875rem .5rem; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all var(--dur-fast) var(--ease); background: var(--surface); font-size: .8125rem; font-weight: 600; color: var(--text-2); font-family: var(--font); }
.quick-action:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-ghost); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.quick-action-icon { font-size: 1.5rem; }

.tips-card { background: linear-gradient(135deg, var(--primary-ghost), #e8f9f7); border: 1px solid var(--primary-pale); border-radius: var(--radius); padding: 1.25rem 1.5rem; }
[data-theme="dark"] .tips-card { background: linear-gradient(135deg, var(--primary-ghost), rgba(13,148,136,.05)); }
.tips-card h3 { font-size: .9375rem; color: var(--primary-dark); margin-bottom: .75rem; }
.tip-item { font-size: .875rem; color: var(--text-2); padding: .3125rem 0; display: flex; gap: .5rem; align-items: flex-start; }
.tip-item::before { content: '→'; color: var(--primary); font-weight: 700; flex-shrink: 0; }

/* ── Records ────────────────────────────────────────────────── */
.records-category-nav { display: flex; gap: .375rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.cat-btn { display: inline-flex; align-items: center; gap: .375rem; padding: .375rem .875rem; border-radius: 99px; border: 1.5px solid var(--border); background: var(--surface); font-size: .8125rem; font-weight: 600; cursor: pointer; transition: all var(--dur-fast) var(--ease); color: var(--text-2); font-family: var(--font); white-space: nowrap; }
.cat-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-ghost); }
.cat-btn.active { background: var(--primary); color: #fff; border-color: var(--primary-dark); box-shadow: var(--shadow-primary); }

.record-item { display: flex; align-items: center; gap: 1rem; padding: .875rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: all var(--dur-fast) var(--ease); margin-bottom: .5rem; }
.record-item:hover { box-shadow: var(--shadow); border-color: var(--border-mid); }
.record-name  { flex: 1; font-size: .9375rem; font-weight: 600; color: var(--text); }
.record-value { font-size: 1.25rem; font-weight: 800; color: var(--text); letter-spacing: -.02em; }
.record-unit  { font-size: .8125rem; color: var(--text-muted); }
.record-date  { font-size: .8125rem; color: var(--text-muted); min-width: 90px; text-align: right; }

/* ── AI Chat ────────────────────────────────────────────────── */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h) - 3.5rem); max-height: 820px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1rem 0; display: flex; flex-direction: column; gap: 1rem; scroll-behavior: smooth; }
.message { display: flex; gap: .75rem; max-width: 82%; animation: msg-in .2s var(--ease-out); }
.message-user { align-self: flex-end; flex-direction: row-reverse; }
.message-assistant { align-self: flex-start; }
@keyframes msg-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.message-avatar { width: 2rem; height: 2rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: .875rem; flex-shrink: 0; font-weight: 700; background: var(--primary-pale); color: var(--primary-dark); }
.message-user .message-avatar { background: var(--primary); color: #fff; }
.message-bubble { padding: .75rem 1rem; border-radius: var(--radius); font-size: .9375rem; line-height: 1.7; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); }
.message-user .message-bubble { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.message-bubble p { margin-bottom: .5rem; color: inherit; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble code { background: rgba(0,0,0,.08); padding: 1px 5px; border-radius: 4px; font-family: var(--font-mono); font-size: .875em; }
.message-bubble pre { background: rgba(0,0,0,.08); padding: .75rem; border-radius: 8px; overflow-x: auto; margin: .5rem 0; }
.message-bubble ul, .message-bubble ol { padding-left: 1.25rem; margin: .375rem 0; }
.message-disclaimer { font-size: .6875rem; color: var(--text-subtle); margin-top: .375rem; }
.chat-input-area { border-top: 1px solid var(--border); padding-top: 1rem; display: flex; flex-direction: column; gap: .625rem; }
.chat-suggestions { display: flex; gap: .5rem; flex-wrap: wrap; }
.chat-suggestion { font-size: .8125rem; padding: .375rem .75rem; border-radius: 99px; border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; transition: all var(--dur-fast) var(--ease); color: var(--text-2); white-space: nowrap; font-family: var(--font); }
.chat-suggestion:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-ghost); }
.chat-input-row { display: flex; gap: .5rem; align-items: flex-end; }
.chat-input { flex: 1; resize: none; padding: .625rem .875rem; min-height: 44px; max-height: 120px; border-radius: var(--radius); }
.typing-indicator { display: flex; gap: 5px; align-items: center; padding: .875rem 1rem; }
.typing-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); animation: dot-bounce 1.2s infinite; }
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes dot-bounce { 0%, 100% { transform: translateY(0); opacity: .4; } 50% { transform: translateY(-5px); opacity: 1; } }
.provider-selector { display: flex; gap: .375rem; align-items: center; flex-wrap: wrap; }
.provider-chip { font-size: .75rem; padding: .25rem .625rem; border-radius: 99px; border: 1.5px solid var(--border); cursor: pointer; transition: all var(--dur-fast) var(--ease); font-family: var(--font); color: var(--text-muted); }
.provider-chip.active { border-color: var(--primary); background: var(--primary-ghost); color: var(--primary); font-weight: 600; }

/* ── Symptoms ───────────────────────────────────────────────── */
.symptom-tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.symptom-tag { padding: .375rem .75rem; border-radius: 99px; border: 1.5px solid var(--border); font-size: .8125rem; cursor: pointer; transition: all var(--dur-fast) var(--ease); color: var(--text-2); font-family: var(--font); font-weight: 500; }
.symptom-tag:hover, .symptom-tag.selected { border-color: var(--primary); background: var(--primary-ghost); color: var(--primary); }
.triage-card { padding: 1.25rem; border-radius: var(--radius); margin-top: 1rem; display: flex; align-items: flex-start; gap: 1rem; border: 1.5px solid; }
.triage-self   { background: var(--success-light); border-color: #86efac; }
.triage-doctor { background: var(--warning-light); border-color: #fde68a; }
.triage-urgent { background: var(--danger-light);  border-color: #fca5a5; }
.triage-icon   { font-size: 2rem; flex-shrink: 0; }
.triage-level  { font-weight: 700; font-size: .9375rem; margin-bottom: 3px; }
.triage-self   .triage-level { color: var(--success); }
.triage-doctor .triage-level { color: var(--warning); }
.triage-urgent .triage-level { color: var(--danger);  }

/* ── Lifestyle ──────────────────────────────────────────────── */
.mood-scale { display: flex; gap: .5rem; justify-content: center; flex-wrap: wrap; margin: .625rem 0; }
.mood-btn { width: 3rem; height: 3rem; border-radius: 50%; border: 2px solid var(--border); font-size: 1.5rem; cursor: pointer; transition: all var(--dur-fast) var(--ease); display: flex; align-items: center; justify-content: center; background: var(--surface); }
.mood-btn:hover, .mood-btn.selected { border-color: var(--primary); transform: scale(1.18); box-shadow: 0 0 0 4px rgba(13,148,136,.15); }
.water-tracker { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.water-glass { font-size: 1.625rem; cursor: pointer; filter: grayscale(1) opacity(.35); transition: all var(--dur-fast) var(--ease); }
.water-glass.filled { filter: none; transform: scale(1.1); }
.exercise-type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: .625rem; }
.exercise-type { padding: .75rem .5rem; border: 2px solid var(--border); border-radius: var(--radius-sm); text-align: center; cursor: pointer; font-size: .8125rem; font-weight: 500; transition: all var(--dur-fast) var(--ease); background: var(--surface); color: var(--text-2); font-family: var(--font); }
.exercise-type:hover, .exercise-type.active { border-color: var(--primary); background: var(--primary-ghost); color: var(--primary); }
.exercise-type span { font-size: 1.5rem; display: block; margin-bottom: .3125rem; }

/* ── Trends ─────────────────────────────────────────────────── */
.chart-wrap { position: relative; margin: 1.25rem 0; }
.chart-wrap canvas { max-height: 300px; }

/* ── Reminders ──────────────────────────────────────────────── */
.reminder-card { display: flex; align-items: center; gap: 1rem; padding: 1rem 1.25rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .5rem; transition: all var(--dur-fast) var(--ease); }
.reminder-card:hover { box-shadow: var(--shadow); border-color: var(--border-mid); }
.reminder-card-icon { font-size: 1.75rem; flex-shrink: 0; }
.reminder-card-info { flex: 1; min-width: 0; }
.reminder-card-info h4 { font-size: .9375rem; font-weight: 600; }
.reminder-card-info p  { font-size: .8125rem; color: var(--text-muted); }
.reminder-card-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.toggle { position: relative; width: 44px; height: 24px; display: inline-block; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-slider { position: absolute; inset: 0; background: var(--border-mid); border-radius: 99px; cursor: pointer; transition: background var(--dur) var(--ease); }
.toggle-slider::before { content: ''; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform var(--dur) var(--ease); box-shadow: var(--shadow-xs); }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Emergency ──────────────────────────────────────────────── */
.emergency-card-print { background: #fff; border: 2px solid #dc2626; border-radius: var(--radius-lg); padding: 1.75rem; max-width: 520px; }
.emergency-header { display: flex; align-items: center; gap: .875rem; margin-bottom: 1.25rem; padding-bottom: 1rem; border-bottom: 2px solid #fee2e2; }
.emergency-title { font-size: 1.125rem; font-weight: 800; color: #dc2626; }
.emergency-row { display: flex; gap: .75rem; margin-bottom: .625rem; font-size: .9375rem; align-items: flex-start; }
.emergency-label { font-weight: 700; min-width: 130px; color: #374151; flex-shrink: 0; }
.emergency-value { color: #111827; }
.sos-btn { background: var(--danger); color: #fff; border: none; border-radius: var(--radius); padding: 1rem 1.5rem; font-size: 1.125rem; font-weight: 800; cursor: pointer; width: 100%; display: flex; align-items: center; justify-content: center; gap: .75rem; animation: sos-pulse 2s infinite; transition: all var(--dur) var(--ease); font-family: var(--font); }
@keyframes sos-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); } 60% { box-shadow: 0 0 0 14px rgba(220,38,38,0); } }

/* ── Settings ───────────────────────────────────────────────── */
.settings-section { margin-bottom: 2rem; }
.settings-section > h3 { font-size: .8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); margin-bottom: .875rem; padding-bottom: .5rem; border-bottom: 1px solid var(--border); }
.api-key-wrap { position: relative; }
.api-key-wrap input { padding-right: 2.75rem; }
.api-key-toggle { position: absolute; right: .75rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--text-muted); }
.provider-card { padding: 1.125rem 1.25rem; border: 2px solid var(--border); border-radius: var(--radius); margin-bottom: .75rem; transition: all var(--dur-fast) var(--ease); cursor: pointer; }
.provider-card:hover { border-color: var(--primary-pale); }
.provider-card.active { border-color: var(--primary); background: var(--primary-ghost); }
.provider-card h4 { font-size: .9375rem; font-weight: 700; margin-bottom: .25rem; display: flex; align-items: center; gap: .5rem; }
.provider-card p { font-size: .8125rem; color: var(--text-muted); }
.provider-free-badge { background: var(--success-light); color: var(--success); font-size: .625rem; font-weight: 700; padding: 1px 6px; border-radius: 99px; letter-spacing: .04em; }

/* ── Upload ─────────────────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--border-mid); border-radius: var(--radius-lg); padding: 3rem 2rem; text-align: center; cursor: pointer; transition: all var(--dur) var(--ease); background: var(--surface); }
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--primary); background: var(--primary-ghost); box-shadow: 0 0 0 4px rgba(13,148,136,.08); }
.upload-zone-icon { font-size: 3.5rem; display: block; margin-bottom: 1rem; }
.upload-zone p { color: var(--text-muted); font-size: .9375rem; }
.ocr-row { display: flex; align-items: center; gap: .75rem; padding: .625rem .875rem; background: var(--bg); border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: .375rem; }
.ocr-row-name { flex: 1; font-size: .875rem; font-weight: 600; }
.ocr-row-val  { width: 80px; }

/* ── Onboarding ─────────────────────────────────────────────── */
#onboarding-overlay { position: fixed; inset: 0; background: linear-gradient(135deg, #0f172a 0%, #0a1f1e 100%); z-index: 500; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 1.5rem; overflow-y: auto; }
#onboarding-overlay.hidden { display: none; }
.onboarding-card { background: var(--surface); border-radius: var(--radius-xl); padding: 2rem 2.5rem 2.5rem; width: 100%; box-shadow: var(--shadow-lg); margin: auto 0; }
.onboarding-step { display: none; }
.onboarding-step.active { display: block; animation: page-in .3s var(--ease-out); }
.onboarding-progress { display: flex; gap: .5rem; justify-content: center; margin-bottom: 2rem; }
.progress-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--border); transition: all var(--dur) var(--ease); }
.progress-dot.active { background: var(--primary); width: 28px; }
.progress-dot.done { background: var(--primary-dark); }
.persona-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .875rem; margin: 1.25rem 0; }
.persona-card { padding: .875rem 1rem; border: 2px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all var(--dur-fast) var(--ease); }
.persona-card:hover, .persona-card.selected { border-color: var(--primary); background: var(--primary-ghost); }
.persona-card.selected { box-shadow: 0 0 0 4px rgba(13,148,136,.12); }
.persona-icon { font-size: 2rem; margin-bottom: .5rem; }
.persona-card h4 { font-size: .9375rem; margin-bottom: .25rem; }
.persona-card p { font-size: .8125rem; color: var(--text-muted); }

/* ── Progress bar ───────────────────────────────────────────── */
.progress-bar-wrap { height: 6px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--primary); border-radius: 99px; transition: width .5s var(--ease); }

/* ── Print ──────────────────────────────────────────────────── */
.no-print {}
@media print {
  #sidebar, #topbar, #bottom-nav, .no-print { display: none !important; }
  #main-content { margin: 0 !important; padding: 0 !important; }
  .page { display: block !important; padding: 0 !important; }
}

/* ── Bottom Nav (Mobile) ────────────────────────────────────── */
#bottom-nav { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: var(--bnav-h); background: var(--surface); border-top: 1px solid var(--border); z-index: 200; padding: 0 .25rem; padding-bottom: env(safe-area-inset-bottom, 0); }
.bnav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .6875rem; font-weight: 500; color: var(--text-muted); gap: 3px; padding: .5rem 0; text-decoration: none; transition: color var(--dur-fast) var(--ease); }
.bnav-icon { font-size: 1.25rem; }
.bnav-item.active { color: var(--primary); }
.bnav-item:hover { color: var(--primary); text-decoration: none; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) { :root { --sidebar-w: 220px; } }
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); width: 280px; box-shadow: var(--shadow-lg); }
  #sidebar.open { transform: translateX(0); }
  #main-content { margin-left: 0; }
  #topbar { left: 0; }
  #bottom-nav { display: flex; }
  #menu-toggle { display: inline-flex; }
  #main-content { padding-bottom: var(--bnav-h); }
  .page { padding: 1.25rem 1rem; }
  .dash-hero { padding: 1.5rem; flex-direction: column; align-items: flex-start; }
  .health-score-wrap { display: none; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .page { padding: 1rem .875rem; }
  .card { padding: 1rem; }
  .stat-grid, .grid-2, .grid-4 { grid-template-columns: repeat(2, 1fr); gap: .75rem; }
  .form-row { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════
   AI-Enhanced Page Components — v3
   ═══════════════════════════════════════════════════════════════ */

/* ── AI Insight Panel ───────────────────────────────────────── */
.ai-panel {
  background: linear-gradient(135deg, var(--primary-ghost) 0%, rgba(240,253,250,.55) 100%);
  border: 1px solid var(--primary-pale);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 1.125rem 1.25rem;
  margin: .875rem 0;
  animation: insight-in .35s var(--ease-out);
}
[data-theme="dark"] .ai-panel {
  background: linear-gradient(135deg, var(--primary-ghost), rgba(13,148,136,.06));
}
.ai-panel-header {
  display: flex; align-items: center; gap: .5rem;
  font-size: .6875rem; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: .625rem;
}
.ai-panel-content {
  font-size: .875rem; color: var(--text-2); line-height: 1.75;
}
.ai-panel-content p { margin-bottom: .375rem; color: inherit; }
.ai-panel-content ul { padding-left: 1.25rem; }
.ai-panel-content li { margin-bottom: .3rem; }
.ai-panel-loading {
  display: flex; align-items: center; gap: .75rem;
  font-size: .875rem; color: var(--text-muted); padding: .25rem 0;
}
@keyframes insight-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* ── AI Buttons ─────────────────────────────────────────────── */
.btn-ai {
  background: linear-gradient(135deg, #0d9488, #0f766e);
  color: #fff; border-color: #0f766e;
  box-shadow: 0 2px 8px rgba(13,148,136,.28);
}
.btn-ai:hover:not(:disabled) {
  background: linear-gradient(135deg, #0f766e, #115e59);
  box-shadow: 0 4px 14px rgba(13,148,136,.42);
  transform: translateY(-1px);
}

/* Inline spinner for buttons */
.inline-spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block; flex-shrink: 0;
}

/* ── Sparklines ─────────────────────────────────────────────── */
.sparkline {
  display: flex; align-items: flex-end; gap: 2px; height: 28px;
  margin-top: .375rem;
}
.sparkline-bar {
  width: 5px; min-height: 3px;
  border-radius: 2px 2px 0 0;
  background: var(--primary); opacity: .6;
  transition: opacity var(--dur-fast);
}
.sparkline-bar:last-child { opacity: 1; }
.sparkline-bar.bar-warn   { background: var(--warning); }
.sparkline-bar.bar-danger { background: var(--danger); }
.sparkline-bar.bar-low    { background: var(--info); }
.sparkline-bar.bar-normal { background: var(--success); }

/* ── Quick Add Tray ─────────────────────────────────────────── */
.quick-vital-tray { display: flex; gap: .625rem; flex-wrap: wrap; padding: .25rem 0; }
.quick-vital-btn {
  display: flex; flex-direction: column; align-items: center; gap: .25rem;
  padding: .75rem 1rem; min-width: 96px;
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); cursor: pointer; font-family: var(--font);
  transition: all var(--dur-fast) var(--ease); flex-shrink: 0;
}
.quick-vital-btn:hover {
  border-color: var(--primary); background: var(--primary-ghost);
  transform: translateY(-2px); box-shadow: var(--shadow-sm);
}
.quick-vital-btn.has-value {
  border-color: var(--primary-pale); background: var(--primary-ghost);
}
.quick-vital-btn .qv-icon  { font-size: 1.375rem; }
.quick-vital-btn .qv-label { font-size: .75rem; font-weight: 600; color: var(--text-2); }
.quick-vital-btn .qv-value { font-size: .6875rem; color: var(--primary); font-weight: 700; }
.quick-vital-btn .qv-empty { font-size: .6875rem; color: var(--text-muted); }

/* ── AI Daily Brief Banner ──────────────────────────────────── */
.ai-brief-bar {
  display: flex; align-items: center; gap: .875rem;
  padding: .875rem 1.25rem;
  background: linear-gradient(135deg, rgba(13,148,136,.1), rgba(13,148,136,.04));
  border: 1px solid var(--primary-pale);
  border-radius: var(--radius); cursor: pointer; margin-bottom: 1.25rem;
  transition: all var(--dur-fast) var(--ease);
}
.ai-brief-bar:hover {
  background: linear-gradient(135deg, rgba(13,148,136,.16), rgba(13,148,136,.08));
  border-color: var(--primary); box-shadow: var(--shadow-sm);
}
.ai-brief-icon {
  font-size: 1.75rem; flex-shrink: 0;
  animation: gentle-pulse 3s ease-in-out infinite;
}
@keyframes gentle-pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.07); }
}
.ai-brief-text { flex: 1; min-width: 0; }
.ai-brief-text strong { display: block; font-size: .9375rem; font-weight: 700; color: var(--text); }
.ai-brief-text span   { font-size: .8125rem; color: var(--text-muted); }

/* ── Category AI Button ─────────────────────────────────────── */
.cat-ai-strip {
  display: flex; align-items: center; gap: .75rem;
  padding: .75rem 1.25rem; width: 100%; margin-bottom: .875rem;
  background: linear-gradient(135deg, var(--primary-ghost), #e8f9f7);
  border: 1.5px dashed var(--primary-pale); border-radius: var(--radius);
  cursor: pointer; font-family: var(--font); font-weight: 600;
  font-size: .875rem; color: var(--primary-dark);
  transition: all var(--dur-fast) var(--ease);
}
.cat-ai-strip:hover {
  background: linear-gradient(135deg, var(--primary-pale), #d1faf5);
  border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .cat-ai-strip {
  background: var(--primary-ghost); border-color: rgba(20,184,166,.3); color: var(--primary-mid);
}

/* ── Symptom History Enhanced ───────────────────────────────── */
.sym-card {
  display: flex; align-items: flex-start; gap: .875rem;
  padding: 1rem 1.25rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: .625rem;
  transition: all var(--dur-fast) var(--ease); position: relative;
}
.sym-card:hover { box-shadow: var(--shadow); border-color: var(--border-mid); }
.sym-card-dot {
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0; margin-top: .3125rem;
}
.sym-card-dot.dot-urgent { background: var(--danger);  box-shadow: 0 0 0 3px var(--danger-light);  }
.sym-card-dot.dot-doctor { background: var(--warning); box-shadow: 0 0 0 3px var(--warning-light); }
.sym-card-dot.dot-self   { background: var(--success); box-shadow: 0 0 0 3px var(--success-light); }
.sym-card-body { flex: 1; min-width: 0; }
.sym-card-title { font-size: .9375rem; font-weight: 600; color: var(--text); }
.sym-card-meta  { font-size: .8125rem; color: var(--text-muted); margin-top: .1875rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.sym-card-notes { font-size: .8125rem; color: var(--text-2); margin-top: .375rem; padding-top: .375rem; border-top: 1px solid var(--border); }
.sym-card-actions { display: flex; flex-direction: column; gap: .375rem; flex-shrink: 0; }

/* Symptom pattern callout */
.pattern-callout {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .875rem 1.125rem;
  background: var(--warning-light); border: 1px solid #fde68a;
  border-left: 4px solid var(--warning); border-radius: var(--radius);
  font-size: .875rem; margin-bottom: 1rem;
}
.pattern-callout.pattern-ok {
  background: var(--success-light); border-color: #86efac; border-left-color: var(--success);
}

/* ── Lifestyle AI insight strip ─────────────────────────────── */
.lifestyle-ai-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: .75rem 1.125rem;
  background: var(--primary-ghost); border: 1px solid var(--primary-pale);
  border-radius: var(--radius); margin-bottom: 1rem;
  gap: .75rem;
}
.lifestyle-ai-row .lai-text { font-size: .875rem; color: var(--text-2); flex: 1; }
.lifestyle-ai-row .lai-text strong { color: var(--primary-dark); }

/* ── History log items (Lifestyle) ─────────────────────────── */
.log-item {
  display: flex; align-items: center; gap: .875rem;
  padding: .75rem 1rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); transition: all var(--dur-fast) var(--ease);
}
.log-item:hover { box-shadow: var(--shadow-xs); border-color: var(--border-mid); }
.log-item-main { flex: 1; min-width: 0; }
.log-item-title { font-size: .875rem; font-weight: 600; color: var(--text); }
.log-item-sub   { font-size: .75rem; color: var(--text-muted); margin-top: .125rem; }
.log-item-val   { font-size: 1.0625rem; font-weight: 800; color: var(--primary); letter-spacing: -.02em; flex-shrink: 0; }
.log-item-actions { display: flex; gap: .375rem; flex-shrink: 0; }

/* ── Record item enhancements ───────────────────────────────── */
.rec-ai-btn {
  display: inline-flex; align-items: center; gap: .3125rem;
  padding: .1875rem .5rem; border-radius: 99px; font-size: .6875rem;
  font-weight: 600; background: var(--primary-ghost); color: var(--primary-dark);
  border: 1px solid var(--primary-pale); cursor: pointer;
  transition: all var(--dur-fast) var(--ease); font-family: var(--font);
  margin-top: .25rem;
}
.rec-ai-btn:hover {
  background: var(--primary-pale); border-color: var(--primary); color: var(--primary);
}

/* ── Insight badge on record item ───────────────────────────── */
.rec-insight-row {
  border-top: 1px solid var(--border); padding-top: .625rem; margin-top: .5rem;
}

/* ── Reminder smart suggestions ─────────────────────────────── */
.rem-suggest-list { display: flex; flex-direction: column; gap: .5rem; }
.rem-suggest-item {
  display: flex; align-items: center; gap: .875rem;
  padding: .75rem 1rem;
  background: var(--primary-ghost); border: 1px solid var(--primary-pale);
  border-radius: var(--radius-sm); transition: all var(--dur-fast) var(--ease);
}
.rem-suggest-item:hover { border-color: var(--primary); background: var(--primary-pale); }
.rem-suggest-item .rs-icon  { font-size: 1.375rem; flex-shrink: 0; }
.rem-suggest-item .rs-body  { flex: 1; min-width: 0; }
.rem-suggest-item .rs-title { font-size: .875rem; font-weight: 600; color: var(--text); }
.rem-suggest-item .rs-sub   { font-size: .75rem; color: var(--text-muted); }

/* ── Post-log AI action strip ───────────────────────────────── */
.post-save-strip {
  display: flex; align-items: center; gap: .75rem;
  padding: .875rem 1.125rem; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--success-light), rgba(220,252,231,.4));
  border: 1px solid #86efac; margin-top: .875rem;
  animation: insight-in .3s var(--ease-out);
}
.post-save-strip .ps-icon { font-size: 1.375rem; flex-shrink: 0; }
.post-save-strip .ps-text { flex: 1; font-size: .875rem; color: var(--text-2); }
.post-save-strip .ps-text strong { color: var(--success); display: block; }

/* ── Stats row mini ─────────────────────────────────────────── */
.mini-stats { display: flex; gap: .625rem; flex-wrap: wrap; margin-bottom: 1rem; }
.mini-stat {
  flex: 1; min-width: 80px;
  padding: .75rem 1rem; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  text-align: center; box-shadow: var(--shadow-xs);
}
.mini-stat-val { font-size: 1.375rem; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.mini-stat-label { font-size: .6875rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-top: .25rem; }

/* ── Expandable notes ───────────────────────────────────────── */
.expand-toggle {
  font-size: .75rem; color: var(--primary); cursor: pointer;
  background: none; border: none; padding: 0; font-family: var(--font);
  font-weight: 600;
}
.expand-toggle:hover { text-decoration: underline; }

/* ── Pinned insight card ────────────────────────────────────── */
.pinned-insight {
  position: relative; overflow: hidden;
  background: linear-gradient(135deg, #0f172a 0%, #0c2927 100%);
  border: 1px solid rgba(20,184,166,.3);
  border-radius: var(--radius-lg); padding: 1.25rem 1.5rem;
  color: #f1f5f9; margin-bottom: 1.5rem;
}
.pinned-insight::before {
  content: ''; position: absolute; top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(13,148,136,.3) 0%, transparent 70%);
  border-radius: 50%; pointer-events: none;
}
.pinned-insight h3 {
  font-size: 1rem; color: #5eead4; margin-bottom: .625rem; position: relative; z-index: 1;
}
.pinned-insight p {
  font-size: .875rem; color: rgba(241,245,249,.8); line-height: 1.7; position: relative; z-index: 1;
}

/* ── Mobile tweaks for new components ──────────────────────── */
@media (max-width: 768px) {
  .quick-vital-tray { gap: .5rem; }
  .quick-vital-btn  { min-width: 80px; padding: .625rem .75rem; }
  .cat-ai-strip     { font-size: .8125rem; }
  .sym-card         { padding: .875rem 1rem; }
  .mini-stats       { gap: .5rem; }
  .mini-stat        { padding: .625rem .75rem; }
  .ai-brief-bar     { padding: .75rem 1rem; }
}

/* ═══════════════════════════════════════════════════════════
   TERMS OF USE OVERLAY
   ═══════════════════════════════════════════════════════════ */
.terms-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: terms-in 0.35s ease;
}
.terms-overlay.hidden { display: none; }

@keyframes terms-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.terms-box {
  /* Always light — force explicit colours regardless of app theme */
  background: #ffffff;
  color: #111827;
  border-radius: 16px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.55);
  max-width: 700px;
  width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1.5px solid #e5e7eb;
}

/* Force all text inside terms-box to use explicit light-mode colours */
.terms-box * { color: inherit; }
.terms-box .terms-title     { color: #111827; }
.terms-box .terms-subtitle  { color: #6b7280; }
.terms-box h2               { color: #111827; }
.terms-box p, .terms-box li { color: #1f2937; }
.terms-box strong           { color: #111827; }

.terms-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem 1.75rem 1rem;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  background: #ffffff;
}
.terms-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.terms-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.125rem 0 0;
}

.terms-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.125rem;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  background: #f9fafb;
}
.terms-body:focus { outline: none; }

.terms-section {
  background: #ffffff;
  border-radius: 10px;
  padding: 1rem 1.125rem;
  border: 1px solid #e5e7eb;
}
.terms-section h2 {
  font-size: 0.9375rem;
  font-weight: 700;
  margin: 0 0 0.625rem;
  color: #111827;
}
.terms-section p {
  font-size: 0.9375rem;
  color: #1f2937;
  line-height: 1.65;
  margin: 0;
}
.terms-section ul {
  margin: 0;
  padding-left: 1.375rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.terms-section ul li {
  font-size: 0.9375rem;
  color: #1f2937;
  line-height: 1.6;
}

.terms-warning-box {
  background: #fff7ed;
  border-color: #fb923c;
  border-width: 1.5px;
}
.terms-warning-box h2 { color: #c2410c !important; }
.terms-warning-box p  { color: #7c2d12 !important; }

.terms-footer {
  padding: 1.25rem 1.75rem 1.5rem;
  border-top: 2px solid #e5e7eb;
  background: #ffffff;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.06);
}

.terms-check-label {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  cursor: pointer;
  padding: 1rem 1.125rem;
  background: #f9fafb;
  border: 2px solid #d1d5db;
  border-radius: 10px;
  transition: border-color 0.2s, background 0.2s;
}
.terms-check-label:has(input:checked) {
  border-color: #0d9488;
  background: #f0fdfa;
}
.terms-check-label input[type="checkbox"] {
  width: 22px;
  height: 22px;
  min-width: 22px;
  margin-top: 1px;
  flex-shrink: 0;
  accent-color: #0d9488;
  cursor: pointer;
  border-radius: 4px;
}
.terms-check-label span {
  font-size: 0.9375rem;
  color: #111827;
  line-height: 1.6;
  font-weight: 500;
}

.terms-agree-btn {
  width: 100%;
  padding: 1rem;
  font-size: 1.0625rem;
  font-weight: 700;
  border-radius: 10px;
  transition: opacity 0.2s, transform 0.15s, background 0.2s;
  letter-spacing: 0.01em;
}
.terms-agree-btn:disabled {
  background: #e5e7eb !important;
  border-color: #e5e7eb !important;
  color: #6b7280 !important;
  cursor: not-allowed;
  transform: none;
  opacity: 1;
}
.terms-agree-btn:not(:disabled) {
  background: #0d9488;
  border-color: #0d9488;
  color: #fff;
  box-shadow: 0 4px 14px rgba(13,148,136,0.35);
}
.terms-agree-btn:not(:disabled):hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(13,148,136,0.45); }

.terms-legal-note {
  font-size: 0.75rem;
  color: #6b7280;
  text-align: center;
  margin: 0;
  line-height: 1.55;
}

@media (max-width: 600px) {
  .terms-box    { border-radius: 12px; max-height: 96vh; }
  .terms-header { padding: 1.125rem 1.125rem 0.875rem; flex-direction: column; text-align: center; }
  .terms-body   { padding: 1rem 1.125rem; gap: 0.875rem; }
  .terms-footer { padding: 1rem 1.125rem 1.25rem; }
  .terms-section { padding: 0.875rem 1rem; }
}

/* ═══════════════════════════════════════════════════
   Medical Systems Explorer
═══════════════════════════════════════════════════ */

/* ── Disclaimer banner ── */
.disclaimer-banner {
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  color: #78350f;
  line-height: 1.6;
}

/* ── Systems grid ── */
.medsys-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.medsys-card {
  background: var(--sys-bg, var(--bg-secondary));
  border: 1.5px solid var(--sys-border, var(--border));
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.medsys-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.medsys-card-icon {
  font-size: 2.25rem;
  line-height: 1;
}

.medsys-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  flex: 1;
}

.medsys-card-name {
  font-weight: 700;
  font-size: 1rem;
  color: var(--sys-color, var(--text-primary));
}

.medsys-card-origin {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.medsys-card-tagline {
  font-style: italic;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.medsys-card-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.55;
}

.medsys-highlights {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.medsys-tag {
  font-size: 0.6875rem;
  background: rgba(0,0,0,0.06);
  color: var(--sys-color, var(--text-secondary));
  border-radius: 999px;
  padding: 0.2rem 0.6rem;
  white-space: nowrap;
}

.medsys-chat-btn {
  margin-top: auto;
  background: var(--sys-color, var(--primary));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
  width: 100%;
}
.medsys-chat-btn:hover {
  opacity: 0.88;
}

/* ── Chat view header ── */
.medsys-chat-header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  background: var(--sys-bg, var(--bg-secondary));
  border: 1.5px solid var(--sys-border, var(--border));
  border-radius: var(--radius-lg);
  padding: 0.875rem 1rem;
  margin-bottom: 0.75rem;
  justify-content: space-between;
}

.medsys-chat-title {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex: 1;
}

/* ── Web search toggle ── */
.medsys-search-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.medsys-search-toggle input[type="checkbox"] {
  accent-color: var(--primary);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}
.medsys-search-toggle:has(input:checked) span {
  color: var(--primary);
  font-weight: 600;
}

/* ── Chat suggestion chips ── */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
}
.chat-suggestions.hidden { display: none; }

.chat-suggestion {
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.chat-suggestion:hover {
  background: var(--primary-xlight);
  color: var(--primary);
  border-color: var(--primary-light);
}

/* ── Message error bubble ── */
.message-bubble-error {
  background: #fef2f2 !important;
  border-left-color: #ef4444 !important;
  color: #991b1b;
}

/* ── Provider chips in systems chat ── */
.provider-chip {
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.12s;
}
.provider-chip:hover {
  background: var(--primary-xlight);
  color: var(--primary);
  border-color: var(--primary-light);
}
.provider-chip.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.provider-chip.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ── Typing dots ── */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.1s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

@media (max-width: 640px) {
  .medsys-grid { grid-template-columns: 1fr; }
  .medsys-chat-header { flex-wrap: wrap; gap: 0.5rem; }
  .medsys-chat-title { flex: none; width: 100%; }
}
