:root {
  --bg: #f5f5f7;
  --surface: rgba(255,255,255,.94);
  --surface-solid: #fff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #8e8e93;
  --line: #dedee3;
  --line-soft: #ececf0;
  --accent: #8f6a3a;
  --accent-dark: #71512c;
  --accent-soft: #f3ece3;
  --success: #397a4b;
  --danger: #b44949;
  --warning: #9a6a20;
  --radius: 14px;
  --radius-sm: 10px;
  --sidebar: 232px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 28px rgba(0,0,0,.04);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin:0; min-height:100vh; background:var(--bg); color:var(--text); font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",sans-serif; font-size:14px; line-height:1.45; letter-spacing:-.01em; }
button,input,select,textarea { font:inherit; }
button,a,label.file-button { -webkit-tap-highlight-color:transparent; }
[hidden] { display:none !important; }

.auth-screen { min-height:100vh; display:grid; place-items:center; padding:28px; background:linear-gradient(180deg,#fafafa 0%,#f3f3f5 100%); }
.auth-layout { width:min(940px,100%); min-height:560px; background:var(--surface-solid); border:1px solid var(--line-soft); border-radius:22px; box-shadow:0 18px 60px rgba(0,0,0,.08); display:grid; grid-template-columns:1.05fr .95fr; overflow:hidden; }
.auth-brand { padding:42px; display:flex; align-items:flex-start; gap:14px; background:#1e1e20; color:white; }
.brand-symbol { width:40px; height:40px; display:grid; place-items:center; border-radius:12px; border:1px solid rgba(255,255,255,.24); font-family:Georgia,serif; font-size:22px; font-weight:400; background:rgba(255,255,255,.07); }
.brand-symbol.small { width:34px; height:34px; border-color:var(--line); color:var(--accent-dark); background:var(--accent-soft); font-size:18px; border-radius:10px; }
.brand-name { margin:2px 0 2px; font-size:12px; font-weight:650; letter-spacing:.12em; }
.brand-subtitle { margin:0; color:rgba(255,255,255,.62); font-size:12px; }
.auth-panel { padding:56px; align-self:center; }
.auth-heading { margin-bottom:30px; }
.auth-heading h1 { margin:4px 0 8px; font-size:30px; line-height:1.12; font-weight:570; letter-spacing:-.03em; }
.auth-heading p:last-child { margin:0; color:var(--text-2); max-width:430px; }
.kicker,.section-label { margin:0; color:var(--text-3); font-size:11px; text-transform:uppercase; letter-spacing:.09em; font-weight:650; }
.access-form { display:grid; gap:10px; }
.access-form label,.modal-card label,.compare-controls label { display:grid; gap:7px; color:var(--text-2); font-size:12px; font-weight:560; }
.auth-foot { margin-top:30px; padding-top:20px; border-top:1px solid var(--line-soft); color:var(--text-3); font-size:11px; }
.form-error { margin:0; color:var(--danger); font-size:12px; }

.main-app { min-height:100vh; display:grid; grid-template-columns:var(--sidebar) 1fr; }
.sidebar { position:sticky; top:0; height:100vh; padding:18px 14px; background:rgba(249,249,250,.88); backdrop-filter:blur(18px); border-right:1px solid var(--line-soft); display:flex; flex-direction:column; z-index:20; }
.sidebar-brand { display:flex; gap:11px; align-items:center; padding:8px 8px 22px; }
.sidebar-brand strong { display:block; font-size:13px; font-weight:620; }
.sidebar-brand span { display:block; color:var(--text-3); font-size:11px; margin-top:1px; }
.sidebar-nav { display:grid; gap:4px; }
.sidebar-nav button,.sidebar-footer button,.sidebar-footer a { width:100%; height:38px; padding:0 11px; border:0; background:transparent; color:var(--text-2); border-radius:9px; display:flex; align-items:center; gap:10px; text-decoration:none; cursor:pointer; font-size:13px; text-align:left; }
.sidebar-nav button:hover,.sidebar-footer button:hover,.sidebar-footer a:hover { background:#ededf0; color:var(--text); }
.sidebar-nav button.active { background:#e7e7ea; color:var(--text); font-weight:590; }
.nav-icon { width:18px; text-align:center; font-size:15px; color:var(--text-3); }
.sidebar-footer { margin-top:auto; display:grid; gap:4px; padding-top:12px; border-top:1px solid var(--line-soft); }
.workspace { min-width:0; }
.topbar { height:66px; padding:0 30px; display:flex; align-items:center; justify-content:space-between; border-bottom:1px solid var(--line-soft); background:rgba(245,245,247,.82); backdrop-filter:blur(18px); position:sticky; top:0; z-index:15; }
.topbar h1 { margin:2px 0 0; font-size:15px; font-weight:610; letter-spacing:-.015em; }
.topbar-actions { display:flex; align-items:center; gap:8px; }
.content { width:min(1240px,100%); margin:0 auto; padding:30px 30px 70px; }
.view { display:none; }
.view.active { display:block; animation:fade .14s ease; }
@keyframes fade { from{opacity:.35;transform:translateY(3px)} to{opacity:1;transform:none} }
.page-intro { display:flex; justify-content:space-between; align-items:flex-end; gap:20px; margin-bottom:24px; }
.page-intro.compact { align-items:center; }
.page-intro h2 { margin:4px 0 5px; font-size:24px; line-height:1.15; font-weight:560; letter-spacing:-.03em; }
.page-intro p:last-child { margin:0; color:var(--text-2); }
.page-actions { display:flex; gap:8px; }

button,.primary-button,.secondary-button,.ghost-button,.file-button { border-radius:9px; min-height:36px; padding:0 14px; border:1px solid transparent; cursor:pointer; transition:.14s ease; font-weight:560; font-size:13px; display:inline-flex; align-items:center; justify-content:center; text-decoration:none; white-space:nowrap; }
.primary-button { color:white; background:var(--accent); border-color:var(--accent); box-shadow:0 1px 1px rgba(0,0,0,.05); }
.primary-button:hover { background:var(--accent-dark); border-color:var(--accent-dark); }
.secondary-button,.ghost-button,.file-button { color:var(--text); background:var(--surface-solid); border-color:var(--line); }
.secondary-button:hover,.ghost-button:hover,.file-button:hover { background:#f5f5f6; }
.small { min-height:32px; padding:0 11px; font-size:12px; }
.full { width:100%; }
.icon-button { width:34px; height:34px; min-height:34px; padding:0; border:1px solid var(--line); background:var(--surface-solid); color:var(--text-2); border-radius:9px; }
.text-button { padding:0; min-height:auto; border:0; background:transparent; color:var(--accent-dark); font-size:12px; }

input,select,textarea { width:100%; min-height:38px; border:1px solid var(--line); border-radius:9px; background:var(--surface-solid); color:var(--text); padding:0 11px; outline:none; transition:border-color .12s, box-shadow .12s; }
textarea { min-height:110px; padding:11px; resize:vertical; }
input::placeholder,textarea::placeholder { color:#aaaab0; }
input:focus,select:focus,textarea:focus { border-color:#aaa0; box-shadow:0 0 0 3px rgba(143,106,58,.15); outline:1px solid rgba(143,106,58,.55); }
.compact-select { width:auto; min-width:120px; min-height:34px; font-size:12px; }

.metric-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:12px; margin-bottom:16px; }
.metric-card { background:var(--surface); border:1px solid var(--line-soft); border-radius:var(--radius); padding:17px 18px; box-shadow:0 1px 0 rgba(0,0,0,.02); }
.metric-card span { color:var(--text-2); font-size:12px; }
.metric-card strong { display:block; margin:8px 0 2px; font-size:24px; line-height:1; font-weight:560; letter-spacing:-.03em; }
.metric-card em { color:var(--text-3); font-style:normal; font-size:11px; }
.dashboard-grid { display:grid; grid-template-columns:minmax(0,1.6fr) minmax(300px,.85fr); gap:16px; }
.panel { background:var(--surface); border:1px solid var(--line-soft); border-radius:var(--radius); box-shadow:var(--shadow); }
.panel-large { min-width:0; }
.panel-head { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; padding:18px 18px 12px; }
.panel h3,.modal-card h3 { margin:4px 0 0; font-size:15px; font-weight:610; letter-spacing:-.015em; }
.muted { color:var(--text-2); }
.panel-head .muted { margin:3px 0 0; font-size:12px; }
#trendCanvas { width:100%; height:auto; display:block; padding:0 10px 12px; }
.activity-list { padding:0 18px 8px; }
.activity-item { display:flex; justify-content:space-between; gap:14px; padding:13px 0; border-top:1px solid var(--line-soft); }
.activity-item strong { font-weight:590; }
.activity-item small,.patient-item small,.results-table small { color:var(--text-3); font-size:11px; }
.status { display:inline-flex; align-items:center; min-height:23px; padding:0 8px; border-radius:999px; background:#f0f0f2; color:var(--text-2); font-size:10.5px; font-weight:600; white-space:nowrap; }
.status.high,.status.low { background:#faecec; color:var(--danger); }
.status.normal { background:#eaf4ed; color:var(--success); }

.toolbar { margin-bottom:12px; padding:10px; border:1px solid var(--line-soft); background:rgba(255,255,255,.72); border-radius:12px; }
.search-input { max-width:440px; }
.filter-grid { display:grid; grid-template-columns:1fr 1fr 1.2fr; gap:8px; }
.table-panel { overflow:hidden; box-shadow:none; }
.patient-list { display:grid; }
.patient-item { min-height:62px; padding:12px 16px; display:flex; align-items:center; justify-content:space-between; gap:14px; border-bottom:1px solid var(--line-soft); }
.patient-item:last-child { border-bottom:0; }
.patient-item:hover { background:#fafafa; }
.patient-item strong { font-weight:590; }
.results-table-wrap { overflow:auto; }
.results-table { width:100%; border-collapse:collapse; min-width:720px; }
.results-table th { padding:10px 14px; color:var(--text-3); background:#fafafa; font-size:10.5px; text-transform:uppercase; letter-spacing:.07em; text-align:left; font-weight:650; border-bottom:1px solid var(--line-soft); }
.results-table td { padding:12px 14px; border-bottom:1px solid var(--line-soft); vertical-align:middle; }
.results-table tr:last-child td { border-bottom:0; }
.results-table tbody tr:hover { background:#fafafa; }
.results-table strong { font-weight:590; }

.compare-controls { padding:16px; display:grid; grid-template-columns:1.3fr 1fr 1fr; gap:12px; margin-bottom:12px; box-shadow:none; }
.compare-list { padding:0 16px; }
.compare-item { padding:13px 0; border-bottom:1px solid var(--line-soft); display:flex; align-items:center; justify-content:space-between; gap:14px; }
.compare-item:last-child { border-bottom:0; }
.delta { font-size:12px; color:var(--text-2); }
.delta.up { color:var(--warning); }
.delta.down { color:var(--success); }
.ai-card { padding:18px; }
.suggestion-row { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px; }
.suggestion-row button { min-height:32px; background:#f7f7f8; color:var(--text-2); border:1px solid var(--line-soft); font-size:12px; }
.prompt-box { display:grid; gap:10px; }
.prompt-box .primary-button { justify-self:end; }
.ai-output { margin-top:14px; padding:14px; border:1px solid var(--line-soft); border-radius:10px; background:#fafafa; color:var(--text-2); min-height:76px; }
.settings-grid { display:grid; gap:10px; }
.settings-section { padding:16px 18px; display:flex; align-items:center; justify-content:space-between; gap:18px; box-shadow:none; }
.settings-section h3 { margin:0 0 4px; }
.settings-section p { margin:0; color:var(--text-2); font-size:12px; }
.roadmap-panel { align-items:flex-start; }
.roadmap { margin:0; padding-left:18px; color:var(--text-2); font-size:12px; }
.roadmap li { margin:4px 0; }
code { padding:2px 5px; border-radius:5px; background:#f1f1f3; font-size:11px; }

.modal { width:min(560px,calc(100% - 28px)); border:0; padding:0; border-radius:17px; background:transparent; }
.modal::backdrop { background:rgba(21,21,24,.36); backdrop-filter:blur(4px); }
.modal-card { background:var(--surface-solid); border:1px solid rgba(255,255,255,.9); border-radius:17px; box-shadow:0 24px 80px rgba(0,0,0,.2); padding:20px; display:grid; gap:13px; }
.modal-head { display:flex; align-items:flex-start; justify-content:space-between; margin-bottom:3px; }
.modal-head > button { width:30px; height:30px; min-height:30px; padding:0; border:1px solid var(--line); background:#fafafa; border-radius:50%; color:var(--text-2); font-size:18px; }
.two-col { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.three-col { display:grid; grid-template-columns:1fr 1fr 1fr; gap:10px; }
.modal-actions { display:flex; justify-content:flex-end; gap:8px; padding-top:6px; }
.bottom-nav { display:none; }

@media (max-width:980px) {
  .metric-grid { grid-template-columns:repeat(2,1fr); }
  .dashboard-grid { grid-template-columns:1fr; }
}
@media (max-width:760px) {
  :root { --sidebar:0px; }
  body { padding-bottom:calc(68px + env(safe-area-inset-bottom)); }
  .main-app { display:block; }
  .sidebar { display:none; }
  .topbar { height:58px; padding:0 16px; }
  .topbar-actions .secondary-button { display:none; }
  .content { padding:20px 14px 24px; }
  .page-intro { align-items:flex-start; margin-bottom:18px; }
  .page-intro h2 { font-size:22px; }
  .page-actions { width:100%; margin-top:6px; }
  .page-intro:not(.compact) { display:grid; }
  .page-actions button { flex:1; }
  .metric-grid { grid-template-columns:repeat(2,1fr); gap:8px; }
  .metric-card { padding:14px; }
  .metric-card strong { font-size:21px; }
  .filter-grid,.compare-controls { grid-template-columns:1fr; }
  .settings-section { align-items:flex-start; flex-direction:column; }
  .bottom-nav { position:fixed; left:0; right:0; bottom:0; z-index:40; min-height:60px; padding:7px 8px calc(7px + env(safe-area-inset-bottom)); display:grid; grid-template-columns:repeat(5,1fr); background:rgba(250,250,251,.92); backdrop-filter:blur(20px); border-top:1px solid var(--line-soft); }
  .bottom-nav button { min-width:0; min-height:46px; padding:3px 2px; border:0; background:transparent; color:var(--text-3); display:grid; place-items:center; align-content:center; gap:2px; font-size:10px; font-weight:560; border-radius:10px; }
  .bottom-nav button span { font-size:16px; line-height:1; }
  .bottom-nav button.active { color:var(--accent-dark); background:var(--accent-soft); }
  .auth-screen { padding:0; background:#f5f5f7; }
  .auth-layout { min-height:100vh; border-radius:0; border:0; box-shadow:none; display:block; }
  .auth-brand { min-height:180px; padding:28px 22px; }
  .auth-panel { padding:34px 22px; }
  .auth-heading h1 { font-size:28px; }
  .two-col,.three-col { grid-template-columns:1fr; }
  .modal { width:calc(100% - 20px); }
  .modal-card { padding:17px; max-height:88vh; overflow:auto; }
}
@media (max-width:420px) {
  .metric-grid { grid-template-columns:1fr 1fr; }
  .metric-card span { font-size:11px; }
  .page-intro.compact { display:grid; }
  .page-intro.compact > button { justify-self:start; }
}
@media (prefers-reduced-motion:reduce) { *,*::before,*::after { animation-duration:.01ms !important; transition-duration:.01ms !important; } }
