:root {
  --navy-950: #020914;
  --navy-900: #071426;
  --navy-850: #0a1a30;
  --navy-800: #0e223d;
  --navy-700: #19375b;
  --gold: #cfa06b;
  --gold-light: #e9c79e;
  --ivory: #f7f3ec;
  --paper: #fffdfa;
  --ink: #142033;
  --muted: #667085;
  --line: #e5e7eb;
  --success: #1f8a70;
  --warning: #b7791f;
  --danger: #b42318;
  --danger-bg: #fff1f0;
  --shadow: 0 18px 50px rgba(2, 9, 20, .14);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #edf1f5;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }

/* Login */
.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 1.05fr) minmax(420px, .95fr);
  background: var(--navy-950);
}
.login-hero {
  min-height: 100vh;
  position: relative;
  padding: clamp(32px, 5vw, 80px);
  overflow: hidden;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: linear-gradient(90deg, rgba(2,9,20,.98) 0%, rgba(2,9,20,.87) 52%, rgba(2,9,20,.18) 100%), url('assets/auster-hero.jpg') center/cover;
}
.login-hero::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 80% 20%, rgba(99,146,204,.18), transparent 35%);
}
.login-logo { position: relative; z-index: 1; width: 255px; max-width: 60%; }
.login-copy { position: relative; z-index: 1; max-width: 700px; }
.eyebrow { color: var(--gold-light); text-transform: uppercase; letter-spacing: .2em; font-size: 12px; font-weight: 700; }
.login-copy h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(44px, 5vw, 78px); line-height: .98; margin: 18px 0 24px; }
.login-copy h1 span { color: var(--gold-light); }
.login-copy p { font-size: clamp(16px, 1.5vw, 21px); line-height: 1.6; color: #d7dfeb; max-width: 620px; }
.login-trust { position: relative; z-index: 1; display: flex; gap: 24px; flex-wrap: wrap; color: #c7d1df; font-size: 13px; }
.login-trust span::before { content: "•"; color: var(--gold); margin-right: 8px; }
.login-panel { min-height: 100vh; background: var(--ivory); display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-card { width: min(520px, 100%); background: rgba(255,255,255,.92); border: 1px solid rgba(7,20,38,.08); border-radius: 30px; padding: clamp(28px, 5vw, 48px); box-shadow: var(--shadow); }
.login-card h2 { margin: 0 0 8px; font-size: 28px; }
.login-card > p { color: var(--muted); margin: 0 0 26px; line-height: 1.55; }
.mode-badge { display:inline-flex; align-items:center; gap:8px; padding:7px 11px; border-radius:999px; font-size:12px; font-weight:700; background:#fff4e7; color:#8a5624; margin-bottom:18px; }
.mode-badge::before { content:""; width:7px; height:7px; border-radius:50%; background:var(--gold); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #eef1f5; border-radius: 14px; padding: 5px; margin-bottom: 20px; }
.auth-tabs button { border: 0; background: transparent; padding: 11px; border-radius: 10px; font-weight: 700; color: var(--muted); }
.auth-tabs button.active { background: white; color: var(--navy-900); box-shadow: 0 3px 12px rgba(7,20,38,.08); }
.demo-grid { display: grid; gap: 12px; margin-top: 16px; }
.demo-card { border: 1px solid var(--line); background: white; border-radius: 16px; padding: 15px; text-align: left; display:flex; align-items:center; justify-content:space-between; gap:12px; }
.demo-card:hover { border-color: var(--gold); transform: translateY(-1px); }
.demo-card strong { display:block; color:var(--navy-900); }
.demo-card small { color:var(--muted); }
.demo-icon { width:42px; height:42px; border-radius:13px; display:grid; place-items:center; background:#edf3fb; color:var(--navy-700); font-weight:800; }
.login-divider { display:flex; align-items:center; gap:12px; color:#98a2b3; font-size:12px; margin:24px 0; }
.login-divider::before,.login-divider::after { content:""; height:1px; background:var(--line); flex:1; }

/* Inputs */
.form-row { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.field { margin-bottom: 16px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { display:block; font-size:14px; font-weight:700; color:#26354a; margin-bottom:8px; }
.required::after { content:" *"; color:var(--danger); }
.field-help { display:block; color:var(--muted); font-size:12px; margin-top:6px; line-height:1.45; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="date"], input[type="number"], textarea, select {
  width:100%; border:1px solid #d5dae1; background:white; color:var(--ink); border-radius:12px; padding:12px 13px; outline:none; transition:.2s;
}
textarea { min-height:112px; resize:vertical; line-height:1.5; }
input:focus, textarea:focus, select:focus { border-color:var(--gold); box-shadow:0 0 0 3px rgba(207,160,107,.17); }
.choice-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
.choice { display:flex; gap:10px; align-items:flex-start; padding:11px 12px; border:1px solid var(--line); border-radius:12px; background:#fff; line-height:1.35; font-size:14px; }
.choice:hover { border-color:#c7a77f; }
.choice input { margin-top:2px; accent-color:var(--navy-700); }
.scale { display:grid; grid-template-columns:repeat(11,1fr); gap:5px; }
.scale label { display:grid; place-items:center; min-height:40px; margin:0; border:1px solid var(--line); border-radius:9px; font-size:12px; background:white; cursor:pointer; }
.scale input { position:absolute; opacity:0; pointer-events:none; }
.scale label:has(input:checked) { background:var(--navy-900); border-color:var(--navy-900); color:white; }
.severity { display:flex; gap:8px; }
.severity label { flex:1; display:grid; place-items:center; border:1px solid var(--line); padding:10px; border-radius:10px; margin:0; background:#fff; }
.severity label:has(input:checked) { color:white; background:var(--navy-900); }
.severity input { position:absolute; opacity:0; }
.consent-box { display:flex; gap:12px; padding:14px; border:1px solid #d8c5aa; background:#fffaf3; border-radius:14px; line-height:1.5; }
.consent-box input { margin-top:4px; accent-color:var(--navy-900); }
.form-alert { padding:14px 16px; border-radius:14px; color:#8f2d24; background:var(--danger-bg); border-left:4px solid var(--danger); line-height:1.5; margin:0 0 20px; }
.table-wrap { overflow-x:auto; border:1px solid var(--line); border-radius:14px; }
table { width:100%; border-collapse:collapse; }
th { background:var(--navy-900); color:white; font-size:12px; text-align:left; padding:12px; }
td { padding:10px; border-top:1px solid var(--line); vertical-align:top; }
td input, td textarea { min-width:120px; margin:0; }
.meal-table textarea { min-height:66px; }
.repeat-actions { display:flex; justify-content:flex-end; margin-top:10px; }
.icon-button { border:0; background:#f2f4f7; color:#344054; border-radius:10px; padding:8px 10px; }

/* App shell */
.app-shell { min-height:100vh; display:grid; grid-template-columns:270px minmax(0,1fr); }
.sidebar { background:var(--navy-950); color:white; padding:22px 16px; position:sticky; top:0; height:100vh; overflow:auto; }
.brand { padding:4px 8px 24px; border-bottom:1px solid rgba(255,255,255,.1); }
.brand img { width:210px; max-width:100%; }
.brand small { display:block; color:#aebbd0; margin-top:8px; letter-spacing:.08em; }
.nav { margin-top:20px; display:grid; gap:6px; }
.nav button { width:100%; border:0; background:transparent; color:#b9c5d7; padding:12px 13px; border-radius:12px; text-align:left; display:flex; align-items:center; gap:11px; font-weight:650; }
.nav button:hover, .nav button.active { background:rgba(255,255,255,.09); color:white; }
.nav button.active { box-shadow:inset 3px 0 0 var(--gold); }
.nav-icon { width:22px; text-align:center; }
.sidebar-footer { margin-top:30px; border-top:1px solid rgba(255,255,255,.1); padding:18px 8px 0; color:#aebbd0; font-size:12px; line-height:1.5; }
.main { min-width:0; }
.topbar { height:76px; background:rgba(255,255,255,.95); border-bottom:1px solid var(--line); display:flex; align-items:center; justify-content:space-between; padding:0 28px; position:sticky; top:0; z-index:20; backdrop-filter:blur(14px); }
.topbar h1 { margin:0; font-size:20px; }
.topbar-meta { display:flex; align-items:center; gap:12px; }
.avatar { width:40px; height:40px; border-radius:50%; background:linear-gradient(135deg,var(--navy-700),var(--gold)); color:white; display:grid; place-items:center; font-weight:800; }
.user-info { line-height:1.2; }
.user-info strong { display:block; font-size:13px; }
.user-info small { color:var(--muted); }
.content { padding:28px; max-width:1500px; margin:0 auto; }
.mobile-menu { display:none; border:0; background:#eef1f5; border-radius:10px; padding:9px 11px; }

.page-head { display:flex; align-items:flex-start; justify-content:space-between; gap:20px; margin-bottom:24px; }
.page-head h2 { margin:0 0 7px; font-size:30px; color:var(--navy-900); }
.page-head p { margin:0; color:var(--muted); line-height:1.5; }
.page-actions { display:flex; gap:10px; flex-wrap:wrap; justify-content:flex-end; }
.btn { border:0; border-radius:12px; padding:11px 16px; font-weight:750; display:inline-flex; align-items:center; justify-content:center; gap:8px; transition:.2s; }
.btn:hover { transform:translateY(-1px); }
.btn-primary { background:var(--navy-900); color:white; }
.btn-gold { background:var(--gold); color:var(--navy-950); }
.btn-secondary { background:white; color:var(--navy-900); border:1px solid var(--line); }
.btn-danger { background:#fff0ef; color:var(--danger); border:1px solid #f3c7c3; }
.btn-sm { padding:8px 11px; font-size:12px; }
.btn:disabled { opacity:.45; cursor:not-allowed; transform:none; }

.hero-card { background:linear-gradient(115deg,var(--navy-950),var(--navy-800)); color:white; border-radius:26px; padding:30px; box-shadow:var(--shadow); position:relative; overflow:hidden; }
.hero-card::after { content:""; position:absolute; right:-10%; top:-70%; width:55%; height:200%; background:radial-gradient(circle,rgba(109,158,219,.22),transparent 60%); }
.hero-card > * { position:relative; z-index:1; }
.hero-card h2 { font-family:Georgia,serif; font-weight:400; font-size:34px; margin:8px 0 12px; }
.hero-card p { color:#cbd5e1; max-width:720px; line-height:1.55; }
.hero-card .btn { margin-top:10px; }

.grid { display:grid; gap:18px; }
.grid-4 { grid-template-columns:repeat(4,minmax(0,1fr)); }
.grid-3 { grid-template-columns:repeat(3,minmax(0,1fr)); }
.grid-2 { grid-template-columns:repeat(2,minmax(0,1fr)); }
.card { background:white; border:1px solid rgba(7,20,38,.07); border-radius:var(--radius); padding:20px; box-shadow:0 6px 20px rgba(7,20,38,.04); min-width:0; }
.card h3 { margin:0 0 10px; color:var(--navy-900); }
.metric { display:flex; align-items:flex-start; justify-content:space-between; gap:12px; }
.metric-label { color:var(--muted); font-size:13px; }
.metric-value { font-size:27px; font-weight:850; margin-top:6px; color:var(--navy-900); }
.metric-icon { width:44px; height:44px; border-radius:14px; background:#edf3fb; color:var(--navy-700); display:grid; place-items:center; font-weight:900; }
.status { display:inline-flex; gap:6px; align-items:center; padding:5px 9px; border-radius:999px; font-size:11px; font-weight:750; }
.status::before { content:""; width:7px; height:7px; border-radius:50%; background:currentColor; }
.status-draft { background:#f2f4f7; color:#667085; }
.status-pending { background:#fff4e5; color:#a15c00; }
.status-complete, .status-published { background:#eaf8f3; color:#12745c; }
.status-alert { background:#fff0ef; color:#b42318; }
.progress { height:9px; background:#e9edf2; border-radius:999px; overflow:hidden; }
.progress > span { display:block; height:100%; background:linear-gradient(90deg,var(--gold),#efd3ae); border-radius:inherit; }
.timeline { display:grid; gap:0; }
.timeline-item { display:grid; grid-template-columns:38px 1fr; gap:14px; min-height:78px; }
.timeline-dot { width:28px; height:28px; border-radius:50%; display:grid; place-items:center; color:white; background:#98a2b3; font-size:12px; font-weight:800; position:relative; }
.timeline-dot::after { content:""; position:absolute; top:28px; width:2px; height:50px; background:#d9dee5; }
.timeline-item:last-child .timeline-dot::after { display:none; }
.timeline-item.done .timeline-dot { background:var(--success); }
.timeline-item.current .timeline-dot { background:var(--gold); color:var(--navy-950); box-shadow:0 0 0 5px rgba(207,160,107,.18); }
.timeline-copy strong { display:block; margin-top:3px; }
.timeline-copy span { color:var(--muted); font-size:13px; line-height:1.4; }

/* Form wizard */
.form-layout { display:grid; grid-template-columns:260px minmax(0,1fr); gap:22px; align-items:start; }
.form-steps { position:sticky; top:98px; background:white; border-radius:18px; padding:12px; border:1px solid var(--line); }
.form-steps button { width:100%; border:0; background:transparent; padding:11px; border-radius:11px; text-align:left; display:flex; gap:10px; color:var(--muted); font-size:13px; line-height:1.3; }
.form-steps button.active { color:var(--navy-900); background:#f3f6fa; font-weight:750; }
.form-steps .step-num { min-width:24px; height:24px; border-radius:50%; background:#e9edf2; display:grid; place-items:center; font-size:11px; }
.form-steps button.active .step-num { background:var(--gold); color:var(--navy-950); }
.form-section { background:white; border:1px solid var(--line); border-radius:22px; padding:clamp(20px,3vw,34px); }
.form-section-head { padding-bottom:18px; border-bottom:1px solid var(--line); margin-bottom:22px; }
.form-section-head h3 { font-size:24px; margin:0 0 7px; }
.form-section-head p { margin:0; color:var(--muted); line-height:1.5; }
.form-footer { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-top:24px; padding-top:20px; border-top:1px solid var(--line); }
.save-state { color:var(--muted); font-size:12px; }

/* Doctor patient list */
.toolbar { display:flex; gap:12px; align-items:center; margin-bottom:16px; flex-wrap:wrap; }
.search { position:relative; flex:1; min-width:220px; }
.search input { padding-left:40px; }
.search::before { content:"⌕"; position:absolute; left:14px; top:9px; color:#667085; font-size:20px; }
.patient-table td { vertical-align:middle; }
.patient-name { display:flex; align-items:center; gap:11px; }
.patient-name .avatar { width:36px; height:36px; font-size:12px; }
.patient-name strong { display:block; }
.patient-name small { color:var(--muted); }
.alert-count { color:var(--danger); font-weight:800; }

.tabs { display:flex; gap:6px; overflow:auto; border-bottom:1px solid var(--line); margin-bottom:20px; }
.tabs button { border:0; background:transparent; padding:12px 14px; color:var(--muted); white-space:nowrap; border-bottom:3px solid transparent; }
.tabs button.active { color:var(--navy-900); font-weight:800; border-color:var(--gold); }
.data-section { margin-bottom:22px; }
.data-section h4 { margin:0 0 12px; font-size:18px; }
.data-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:10px; }
.data-item { background:#f7f8fa; border-radius:12px; padding:12px; min-width:0; }
.data-item span { display:block; color:var(--muted); font-size:11px; text-transform:uppercase; letter-spacing:.05em; margin-bottom:5px; }
.data-item strong { display:block; font-size:14px; white-space:pre-wrap; overflow-wrap:anywhere; }
.flag-box { border:1px solid #f0c6c2; background:#fff5f4; border-radius:15px; padding:15px; color:#8e2b22; }
.flag-box h4 { margin:0 0 8px; }
.flag-box ul { margin:0; padding-left:20px; }

.document-card { display:flex; align-items:center; gap:14px; border:1px solid var(--line); border-radius:15px; padding:15px; }
.document-icon { width:46px; height:46px; border-radius:13px; background:#edf3fb; display:grid; place-items:center; color:var(--navy-700); font-size:20px; }
.document-main { flex:1; min-width:0; }
.document-main strong { display:block; }
.document-main small { color:var(--muted); }
.document-actions { display:flex; gap:7px; flex-wrap:wrap; }
.empty { text-align:center; color:var(--muted); padding:36px 16px; border:1px dashed #cfd5dd; border-radius:16px; }

.ai-box { background:var(--navy-950); color:#e5edf7; border-radius:18px; padding:18px; }
.ai-box pre { white-space:pre-wrap; overflow-wrap:anywhere; font-family:"SFMono-Regular",Consolas,monospace; font-size:12px; line-height:1.55; margin:0; max-height:620px; overflow:auto; }
.ai-controls { display:flex; gap:10px; margin-bottom:12px; flex-wrap:wrap; }
.ai-note { font-size:12px; color:#aebbd0; margin:12px 0 0; }

.chart { width:100%; height:230px; display:block; }
.chart-grid { stroke:#dde3ea; stroke-width:1; }
.chart-line { fill:none; stroke:var(--gold); stroke-width:3; stroke-linecap:round; stroke-linejoin:round; }
.chart-point { fill:var(--navy-900); stroke:white; stroke-width:2; }
.chart-label { font-size:11px; fill:#667085; }

.modal-backdrop { position:fixed; inset:0; z-index:100; background:rgba(2,9,20,.64); display:grid; place-items:center; padding:18px; }
.modal { background:white; width:min(760px,100%); max-height:92vh; overflow:auto; border-radius:22px; box-shadow:var(--shadow); }
.modal-head { display:flex; align-items:center; justify-content:space-between; padding:20px 22px; border-bottom:1px solid var(--line); }
.modal-head h3 { margin:0; }
.modal-body { padding:22px; }
.modal-footer { padding:16px 22px; border-top:1px solid var(--line); display:flex; justify-content:flex-end; gap:10px; }
.close-button { border:0; background:#f2f4f7; width:36px; height:36px; border-radius:10px; }

.toast-root { position:fixed; right:18px; bottom:18px; z-index:200; display:grid; gap:9px; }
.toast { background:var(--navy-900); color:white; box-shadow:var(--shadow); padding:13px 16px; border-radius:12px; max-width:360px; animation:toast-in .22s ease; }
.toast.error { background:#8f251d; }
@keyframes toast-in { from { transform:translateY(10px); opacity:0; } }

.print-only { display:none; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .grid-3 { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .form-layout { grid-template-columns:1fr; }
  .form-steps { position:static; display:flex; overflow:auto; }
  .form-steps button { min-width:190px; }
}
@media (max-width: 900px) {
  .login-shell { grid-template-columns:1fr; }
  .login-hero { min-height:46vh; }
  .login-panel { min-height:54vh; }
  .app-shell { grid-template-columns:1fr; }
  .sidebar { position:fixed; left:-290px; z-index:90; width:270px; transition:.25s; box-shadow:var(--shadow); }
  .sidebar.open { left:0; }
  .mobile-menu { display:block; }
  .content { padding:20px; }
  .topbar { padding:0 18px; }
  .user-info { display:none; }
}
@media (max-width: 680px) {
  .grid-4,.grid-3,.grid-2,.form-row,.data-grid { grid-template-columns:1fr; }
  .choice-grid { grid-template-columns:1fr; }
  .page-head { flex-direction:column; }
  .page-actions { justify-content:flex-start; }
  .scale { grid-template-columns:repeat(6,1fr); }
  .topbar h1 { font-size:16px; }
  .hero-card h2 { font-size:28px; }
  .patient-table th:nth-child(3), .patient-table td:nth-child(3), .patient-table th:nth-child(4), .patient-table td:nth-child(4) { display:none; }
  .document-card { align-items:flex-start; flex-wrap:wrap; }
  .document-actions { width:100%; }
  .form-footer { flex-wrap:wrap; }
}

@media print {
  body { background:white; }
  .sidebar,.topbar,.no-print,.page-actions,.tabs,.btn,.toolbar { display:none !important; }
  .app-shell { display:block; }
  .content { padding:0; max-width:none; }
  .card,.form-section { box-shadow:none; break-inside:avoid; }
  .print-only { display:block; }
}

/* Controlled onboarding */
.btn-link { background:transparent; border:0; color:var(--navy); box-shadow:none; text-decoration:underline; text-underline-offset:3px; }
.btn-link:hover { background:rgba(7,20,38,.05); }
.access-notice { margin-top:18px; padding:14px 16px; border:1px solid var(--line); border-radius:14px; background:#f7f3ec; display:grid; gap:4px; }
.access-notice strong { color:var(--navy); }
.access-notice span { color:var(--muted); font-size:.9rem; line-height:1.45; }
