:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17251f;
  background: #f4f7f4;
  --ink: #17251f;
  --muted: #718078;
  --line: #e0e8e1;
  --paper: #ffffff;
  --soft: #edf5ee;
  --mint: #b8ddc4;
  --green: #1d6b4b;
  --deep: #154235;
  --danger: #b74646;
  --shadow: 0 16px 40px rgba(27, 72, 51, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f4f7f4; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .6; }
a { color: inherit; }

.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 12% 10%, #e6f3e7 0, transparent 38%), #f4f7f4; }
.auth-card { width: min(100%, 430px); padding: 42px; border: 1px solid var(--line); border-radius: 28px; background: var(--paper); box-shadow: var(--shadow); }
.brand-mark { display: grid; place-items: center; width: 52px; height: 52px; border-radius: 16px; color: #fff; background: var(--deep); font-weight: 800; font-size: 24px; }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 18px; }
.eyebrow { margin: 0 0 8px; color: var(--green); font-size: 11px; letter-spacing: .16em; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(28px, 4vw, 42px); letter-spacing: -.04em; }
h2 { margin-bottom: 0; font-size: 21px; letter-spacing: -.025em; }
h3 { margin-bottom: 4px; font-size: 15px; }
.muted { color: var(--muted); }
.safety-note { margin: 26px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: #7d665c; font-size: 12px; line-height: 1.7; }
.stack-form { display: grid; gap: 10px; margin-top: 26px; }
label { color: #435149; font-size: 13px; font-weight: 700; }
input, select, textarea { width: 100%; margin-top: 6px; padding: 11px 12px; color: var(--ink); border: 1px solid #cfdcd2; border-radius: 10px; outline: none; background: #fbfdfb; }
input:focus, select:focus, textarea:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29, 107, 75, .13); }
textarea { resize: vertical; }
.primary-button, .ghost-button, .text-button, .icon-button { border: 0; border-radius: 10px; }
.primary-button { margin-top: 10px; padding: 12px 18px; color: #fff; background: var(--deep); font-weight: 800; }
.primary-button:hover { background: #205e49; }
.ghost-button { padding: 9px 13px; color: var(--green); background: transparent; font-weight: 700; }
.ghost-button:hover, .text-button:hover { background: var(--soft); }
.text-button { padding: 7px 9px; color: var(--green); background: transparent; font-size: 13px; font-weight: 800; text-decoration: none; }
.icon-button { width: 30px; height: 30px; color: var(--muted); background: transparent; font-size: 22px; }
.form-error { min-height: 20px; margin: 4px 0 0; color: var(--danger); font-size: 13px; }
.form-success { min-height: 20px; margin: 5px 0 0; color: var(--green); font-size: 13px; }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; width: 238px; padding: 28px 18px 20px; border-right: 1px solid var(--line); background: #fbfdfb; }
.sidebar-brand { display: flex; align-items: center; gap: 11px; padding: 0 10px 36px; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand strong { font-size: 17px; }
.sidebar-brand span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 13px; border: 0; border-radius: 11px; color: #75817a; background: transparent; text-align: left; font-weight: 700; }
.nav-item span { display: grid; place-items: center; width: 20px; font-size: 17px; }
.nav-item:hover, .nav-item.active { color: var(--deep); background: var(--soft); }
.nav-item.active { box-shadow: inset 3px 0 var(--green); }
.sidebar-footer { margin-top: auto; padding: 14px 12px; border-top: 1px solid var(--line); color: #405047; font-size: 12px; line-height: 1.8; }
.sidebar-footer small { color: var(--muted); overflow-wrap: anywhere; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: #4fa976; }
.status-dot.warning { background: #c58548; }
.main-content { width: calc(100% - 238px); max-width: 1400px; margin-left: 238px; padding: 42px clamp(22px, 5vw, 70px) 70px; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 28px; }
.topbar h1 { margin-bottom: 0; font-size: clamp(27px, 4vw, 38px); }
.live-region { min-height: 20px; color: var(--green); font-size: 13px; }
.notice-banner { display: flex; gap: 13px; align-items: baseline; margin: 10px 0 20px; padding: 15px 18px; border: 1px solid #eadcc2; border-radius: 13px; color: #705a3b; background: #fff9ed; font-size: 13px; line-height: 1.5; }
.notice-banner strong { white-space: nowrap; }
.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.metric-card { padding: 20px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: 0 8px 24px rgba(27, 72, 51, .04); }
.metric-card span, .metric-card small { color: var(--muted); font-size: 12px; }
.metric-card strong { display: inline-block; margin: 12px 5px 0 0; color: var(--deep); font-size: 32px; letter-spacing: -.05em; }
.content-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(270px, 1fr); gap: 20px; }
.panel { margin-bottom: 20px; padding: 25px; border: 1px solid var(--line); border-radius: 17px; background: var(--paper); box-shadow: 0 8px 24px rgba(27, 72, 51, .04); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 15px; margin-bottom: 21px; }
.section-heading.compact { margin-bottom: 8px; }
.section-rule { margin: 30px 0 25px; border: 0; border-top: 1px solid var(--line); }
.section-heading .muted { font-size: 12px; }
.record-list, .report-list, .audit-list { display: grid; gap: 2px; }
.record-row, .report-row { display: flex; align-items: flex-start; gap: 13px; padding: 14px 0; border-bottom: 1px solid #edf1ee; }
.record-row:last-child, .report-row:last-child { border-bottom: 0; }
.record-icon, .report-icon { display: grid; place-items: center; flex: 0 0 auto; width: 35px; height: 35px; border-radius: 11px; color: var(--deep); background: var(--soft); font-size: 12px; font-weight: 900; }
.record-icon.allergy { color: #985b3e; background: #fff0e7; }
.record-icon.measurement { color: #4d639a; background: #edf1ff; }
.record-icon.medication { color: #76588f; background: #f6effb; }
.record-main { flex: 1; min-width: 0; }
.record-main > div { display: flex; justify-content: space-between; gap: 10px; }
.record-type { color: var(--green); font-size: 11px; font-weight: 800; }
time { color: var(--muted); font-size: 11px; }
.record-main p, .report-row p, .audit-row p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }
.profile-summary { display: grid; gap: 16px; margin: 0; }
.profile-summary div { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 12px; border-bottom: 1px solid #edf1ee; }
.profile-summary dt { color: var(--muted); font-size: 12px; }
.profile-summary dd { margin: 0; font-size: 13px; font-weight: 750; text-align: right; }
.ai-panel { display: flex; justify-content: space-between; align-items: center; gap: 20px; }
.ai-panel h2 { margin-bottom: 8px; }
.ai-panel p { max-width: 720px; margin-bottom: 0; font-size: 13px; line-height: 1.6; }
.status-pill { padding: 7px 11px; border-radius: 999px; font-size: 10px; font-weight: 900; letter-spacing: .08em; white-space: nowrap; }
.status-pill.neutral { color: #786747; background: #fff5de; }
.narrow-panel { max-width: 680px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.record-form { display: grid; grid-template-columns: 1fr 1.6fr 1fr; gap: 14px; align-items: end; }
.record-form .wide { grid-column: 1 / -1; }
.record-form .primary-button { width: max-content; }
.upload-form { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.file-drop { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center; flex: 1; min-width: 260px; padding: 17px; border: 1px dashed #aac8b2; border-radius: 13px; background: #f8fcf8; }
.file-drop strong, .file-drop span:not(.upload-icon) { grid-column: 2; }
.file-drop span:not(.upload-icon) { color: var(--muted); font-size: 12px; font-weight: 400; }
.upload-icon { grid-row: 1 / 3; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: #fff; background: var(--green); font-size: 22px; }
.file-drop input { grid-column: 2; margin-top: 8px; padding: 0; border: 0; background: transparent; font-size: 12px; }
.report-icon { width: 44px; color: #a36c41; background: #fff3e8; font-size: 10px; }
.empty-state { padding: 26px 10px; color: var(--muted); text-align: center; }
.empty-icon { margin-bottom: 8px; color: var(--mint); font-size: 29px; }
.empty-state h3 { color: var(--ink); }
.empty-state p { margin-bottom: 0; font-size: 13px; }
.audit-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 9px; padding: 14px 0; border-bottom: 1px solid #edf1ee; }
.audit-row:last-child { border-bottom: 0; }
.audit-row .status-dot { margin: 0; }
.loading-panel { display: grid; place-items: center; min-height: 260px; color: var(--muted); }
.spinner { width: 24px; height: 24px; margin-bottom: 10px; border: 3px solid var(--line); border-top-color: var(--green); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
  .sidebar { position: static; width: 100%; height: auto; padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .app-shell { display: block; }
  .sidebar-brand { padding: 0 4px 14px; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; padding: 9px 11px; font-size: 12px; }
  .sidebar-footer { display: none; }
  .main-content { width: 100%; margin-left: 0; padding: 28px 18px 50px; }
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .auth-card { padding: 28px 22px; }
  .topbar { align-items: center; }
  .topbar h1 { font-size: 27px; }
  .ghost-button { padding: 8px 4px; font-size: 12px; }
  .notice-banner { display: block; }
  .notice-banner strong { display: block; margin-bottom: 4px; }
  .panel { padding: 18px; }
  .record-form, .two-col { grid-template-columns: 1fr; }
  .record-form .wide { grid-column: auto; }
  .record-form .primary-button { width: 100%; }
  .ai-panel { display: block; }
  .ai-panel .status-pill { display: inline-block; margin-top: 14px; }
  .audit-row { grid-template-columns: auto 1fr; }
  .audit-row time { grid-column: 2; }
}
