:root {
  --ink: #173632;
  --muted: #6c7f7b;
  --green: #0d5b50;
  --green-2: #1e7468;
  --mint: #e9f2ef;
  --cream: #f7f4ec;
  --paper: #fffefa;
  --line: #dbe5e1;
  --amber: #b06b20;
  --amber-bg: #fff3dc;
  --red: #a74237;
  --shadow: 0 18px 50px rgba(26, 65, 59, .09);
  --radius: 20px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: radial-gradient(circle at 90% 0%, #e2efe9 0, transparent 33%), var(--cream);
  font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 72px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 22px;
  align-items: center;
  padding: 0 max(24px, calc((100vw - 1220px) / 2));
  border-bottom: 1px solid rgba(13,91,80,.12);
  background: rgba(247,244,236,.88);
  backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { display: flex; gap: 10px; align-items: center; color: var(--ink); font-weight: 760; font-size: 18px; text-decoration: none; }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 11px; color: white; background: var(--green); }
nav { display: flex; justify-content: center; gap: 4px; }
.topbar nav { min-width: 0; overflow: visible; scrollbar-width: none; }
.topbar nav::-webkit-scrollbar { display: none; }
.nav-link { flex: none; border: 0; background: transparent; padding: 9px 12px; color: var(--muted); border-radius: 999px; white-space: nowrap; }
.nav-link:hover, .nav-more-toggle:hover { color: var(--green); background: rgba(255,255,255,.62); }
.nav-link.active { background: white; color: var(--green); box-shadow: 0 3px 12px rgba(22,58,52,.07); }
.nav-more { position: relative; flex: none; }
.nav-more-toggle { height: 38px; display: flex; align-items: center; gap: 5px; padding: 8px 11px; color: var(--muted); background: transparent; border: 0; border-radius: 999px; white-space: nowrap; }
.nav-more-toggle > span { font-size: 13px; transition: transform .15s ease; }
.nav-more-toggle[aria-expanded="true"] > span { transform: rotate(180deg); }
.nav-more-toggle.active { color: var(--green); background: white; box-shadow: 0 3px 12px rgba(22,58,52,.07); }
.nav-more-menu { position: absolute; top: calc(100% + 10px); right: 0; z-index: 30; width: 210px; display: grid; gap: 3px; padding: 8px; background: var(--paper); border: 1px solid var(--line); border-radius: 15px; box-shadow: 0 18px 48px rgba(24,64,58,.16); }
.nav-more-menu[hidden] { display: none; }
.nav-more-menu .nav-link { width: 100%; text-align: left; border-radius: 10px; }
.privacy-pill { justify-self: end; display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 750; color: var(--green); background: #e6f1ed; padding: 8px 10px; border-radius: 999px; white-space: nowrap; }
.privacy-pill .status-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: #28a47d; }
.account-controls { justify-self: end; display: flex; align-items: center; gap: 7px; min-width: 0; }
.logout-button { padding: 7px 9px; color: var(--muted); background: transparent; border: 0; font-size: 12px; font-weight: 700; }
.logout-button:hover { color: var(--green); }

main { max-width: 1220px; margin: 0 auto; padding: 58px 24px 80px; }
.view { display: none; animation: fade .25s ease; }
.active-view { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } }
.hero { display: flex; justify-content: space-between; gap: 40px; align-items: end; margin-bottom: 34px; }
h1, h2, p { margin-top: 0; }
h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(42px, 5.5vw, 70px); line-height: 1.03; letter-spacing: -.035em; margin-bottom: 18px; }
h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: 28px; margin-bottom: 0; }
.eyebrow { color: var(--green-2); font-size: 11px; font-weight: 800; letter-spacing: .16em; margin-bottom: 10px; }
.hero-copy { color: var(--muted); max-width: 610px; font-size: 17px; margin-bottom: 0; }
.hero-actions, .button-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.primary, .secondary { border-radius: 12px; padding: 11px 17px; border: 1px solid var(--green); font-weight: 700; transition: .15s ease; }
.primary { background: var(--green); color: white; }
.primary:hover { background: #08483f; transform: translateY(-1px); }
.primary:disabled { opacity: .6; cursor: wait; }
.secondary { background: transparent; color: var(--green); }
.secondary:hover { background: var(--mint); }
.text-button { border: 0; color: var(--green); background: transparent; font-weight: 700; }

.disclaimer { display: flex; gap: 13px; align-items: flex-start; border: 1px solid #d6e5df; background: rgba(255,255,255,.5); border-radius: 15px; padding: 14px 16px; }
.disclaimer > span { flex: none; width: 23px; height: 23px; display: grid; place-items: center; color: white; background: var(--green-2); border-radius: 50%; font: 700 13px Georgia; }
.disclaimer p { margin: 0; color: var(--muted); }
.disclaimer strong { color: var(--ink); }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 28px 0 50px; }
.stat { background: rgba(255,255,255,.65); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.stat strong { display: block; font: 500 32px Georgia, serif; }
.stat span { color: var(--muted); font-size: 13px; }
.section-heading, .page-title, .panel-header { display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-heading { margin-bottom: 18px; }
.indicator-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 50px; }
.indicator-card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.indicator-top { display: flex; justify-content: space-between; gap: 10px; }
.indicator-name { font-weight: 760; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { font-size: 11px; font-weight: 800; padding: 5px 8px; border-radius: 999px; white-space: nowrap; }
.badge.normal { color: #29705d; background: #e4f2ed; }
.badge.high, .badge.low { color: var(--amber); background: var(--amber-bg); }
.badge.unknown { color: var(--muted); background: #eef1ef; }
.indicator-value { font: 500 34px Georgia, serif; margin: 17px 0 1px; }
.indicator-unit, .indicator-meta { color: var(--muted); font-size: 12px; }
.sparkline { width: 100%; height: 58px; margin-top: 12px; overflow: visible; }
.sparkline path { fill: none; stroke: var(--green-2); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.sparkline circle { fill: var(--paper); stroke: var(--green); stroke-width: 2; }

.two-column { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.panel { border-radius: var(--radius); border: 1px solid var(--line); background: rgba(255,255,255,.66); padding: 24px; box-shadow: var(--shadow); }
.panel-header { align-items: center; margin-bottom: 20px; }
.alert-item, .timeline-item { display: grid; grid-template-columns: auto 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.alert-item:first-child, .timeline-item:first-child { border-top: 0; }
.alert-icon, .timeline-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--amber-bg); color: var(--amber); font-weight: 900; }
.timeline-icon { background: var(--mint); color: var(--green); }
.alert-item p, .timeline-item p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; border: 1px dashed var(--line); border-radius: 14px; }
.empty strong { display: block; color: var(--ink); margin-bottom: 3px; }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); background: white; color: var(--green); border-radius: 10px; font-size: 21px; line-height: 1; }

.page-title { margin-bottom: 30px; }
.page-title h1 { font-size: clamp(40px, 5vw, 58px); margin-bottom: 8px; }
.page-title p:last-child { color: var(--muted); margin-bottom: 0; }
.table-panel { padding: 0; overflow: visible; }
.filters { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.filters input { width: min(360px, 70%); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 15px 18px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
td strong { display: block; }
.delete-button { color: var(--red); background: transparent; border: 0; font-size: 18px; }
.file-button input { display: none; }
.journal-list { display: grid; gap: 12px; }
.journal-card { display: grid; grid-template-columns: 130px 1fr auto; gap: 20px; align-items: start; background: var(--paper); border: 1px solid var(--line); padding: 20px; border-radius: 16px; }
.journal-card time, .journal-card p { color: var(--muted); }
.journal-card h3 { margin: 0 0 5px; }
.journal-card p { margin: 0; white-space: pre-wrap; }
.category { color: var(--green); font-weight: 750; font-size: 12px; }
.document-filters { gap: 12px; background: rgba(255,255,255,.55); border: 1px solid var(--line); border-radius: 15px; margin-bottom: 16px; }
.document-filters select { width: auto; min-width: 190px; }
.document-list, .medication-list { display: grid; gap: 13px; }
.document-card { display: grid; grid-template-columns: 112px 1fr auto; gap: 20px; align-items: start; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; padding: 20px; box-shadow: var(--shadow); }
.document-card h3, .medication-card h3 { margin: 0 0 5px; }
.document-card p, .medication-card p { margin: 0; color: var(--muted); }
.document-card details { margin-top: 13px; color: var(--muted); }
.document-card details summary { cursor: pointer; color: var(--green); font-weight: 700; }
.document-details { max-height: 300px; overflow: auto; white-space: pre-wrap; padding-top: 10px; font-size: 13px; }
.doc-actions { display: grid; gap: 8px; min-width: 170px; }
.import-drafts-panel { margin-bottom: 16px; }
.import-draft { display: grid; grid-template-columns: minmax(220px,1fr) auto auto; gap: 14px; align-items: center; padding: 12px 0; border-top: 1px solid var(--line); }
.import-draft:first-child { border-top: 0; }
.import-draft strong, .import-draft small, .import-review-head strong, .import-review-head small { display: block; }
.import-draft small, .import-review-head small { color: var(--muted); margin-top: 3px; }
.draft-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.error-text { color: #a14c43 !important; }
#document-import-modal { width: min(860px, calc(100% - 20px)); }
.document-import-card { width: 100%; max-width: 100%; max-height: calc(100vh - 24px); overflow-x: hidden; overflow-y: auto; }
.document-drop { min-height: 190px; border: 2px dashed #9bbdb5; background: #f5fbf8; border-radius: 18px; display: grid; place-items: center; align-content: center; gap: 6px; text-align: center; padding: 28px; cursor: pointer; transition: .15s ease; }
.document-drop:hover, .document-drop.dragging { border-color: var(--green); background: var(--mint); transform: translateY(-1px); }
.document-drop small { color: var(--muted); }
.document-drop #document-file-name { color: var(--green); font-weight: 800; margin-top: 8px; }
.import-existing-file { padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--mint); font-weight: 700; }
.drop-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 15px; background: white; color: var(--green); font-size: 28px; box-shadow: var(--shadow); }
.privacy-consent { display: grid; grid-template-columns: auto 1fr; gap: 11px; align-items: start; margin-top: 16px; padding: 14px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.privacy-consent input { width: 18px; height: 18px; margin-top: 2px; }
.privacy-consent strong, .privacy-consent small { display: block; }
.privacy-consent small { color: var(--muted); margin-top: 4px; line-height: 1.45; }
.import-status { min-height: 28px; margin-top: 14px; color: var(--muted); }
.import-status strong, .import-status span { display: block; }
.import-review-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 13px 0 17px; }
.import-document-fields { padding: 18px 0; border-bottom: 1px solid var(--line); }
.import-warning, .import-questions, .import-ok { border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.import-warning, .import-questions { background: var(--amber-bg); color: #795832; }
.import-ok { background: #e4f2ed; color: #275f50; }
.import-warning p, .import-questions p, .import-ok p { margin: 5px 0 0; }
.duplicate-comparison { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin: 14px 0; }
.duplicate-comparison > div { border: 1px solid #dfc9a6; border-radius: 10px; background: rgba(255,255,255,.6); padding: 11px; min-width: 0; }
.duplicate-comparison small, .duplicate-comparison strong, .duplicate-comparison span { display: block; overflow-wrap: anywhere; }
.duplicate-comparison small { font-size: 11px; opacity: .85; }
.duplicate-comparison strong { margin: 4px 0; }
.duplicate-review > a { display: inline-block; margin-top: 10px; }
.duplicate-decisions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 15px 0; }
.duplicate-review > label { display: flex; align-items: flex-start; gap: 8px; font-weight: 700; }
.import-warning label { display: flex; gap: 9px; align-items: flex-start; margin-top: 10px; font-weight: 700; }
.import-questions small { display: block; opacity: .85; }
.import-facts { padding-top: 20px; }
.import-facts h3 { margin: 0; }
.import-table-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 13px; }
.import-table-wrap table { width: 100%; min-width: 0; table-layout: fixed; margin: 0; }
.import-table-wrap th { white-space: nowrap; }
.import-table-wrap th, .import-table-wrap td { padding: 8px 6px; overflow: hidden; }
.import-table-wrap th:first-child, .import-table-wrap td:first-child { width: 54px; text-align: center; }
.import-table-wrap input:not([type="checkbox"]), .import-table-wrap select { width: 100%; min-width: 0; padding: 8px 7px; border-radius: 9px; }
.import-table-wrap .row-name, .import-table-wrap .row-result, .import-table-wrap .row-instruction, .import-table-wrap .row-reference { min-width: 0 !important; }
.key-input-wrap { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
.key-input-wrap .text-button { padding: 8px; }
.doc-kind { display: inline-block; color: var(--green); background: var(--mint); border-radius: 999px; padding: 5px 9px; font-size: 11px; font-weight: 800; }
.doc-open { text-decoration: none; display: inline-block; }
.observation-preview { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.observation-preview span { background: #f0f3f1; border-radius: 7px; padding: 4px 7px; color: var(--muted); font-size: 11px; }
.medication-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 4px; }
.medication-stat { display: grid; grid-template-columns: auto auto 1fr; gap: 9px; align-items: center; min-width: 0; padding: 13px 15px; color: var(--ink); text-align: left; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 14px; }
.medication-stat:hover { border-color: #a9c6bd; background: white; }
.medication-stat.active { border-color: #7fae9f; box-shadow: 0 0 0 3px rgba(30,116,104,.08); }
.medication-stat strong { font: 500 24px Georgia, serif; }
.medication-stat small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.medication-stat-dot { width: 10px; height: 10px; border-radius: 50%; padding: 0; }
.medication-card { display: grid; grid-template-columns: 165px minmax(0, 1fr); gap: 22px; position: relative; overflow: hidden; background: var(--paper); border: 1px solid var(--line); border-radius: 17px; padding: 20px 22px; box-shadow: 0 8px 28px rgba(26,65,59,.05); }
.medication-card::before { content: ''; position: absolute; inset: 0 auto 0 0; width: 5px; background: #aab8b4; }
.medication-card.status-border-active::before { background: #2f9676; }
.medication-card.status-border-planned::before { background: #4d86b3; }
.medication-date { display: grid; align-content: start; gap: 1px; padding-right: 18px; border-right: 1px solid var(--line); }
.medication-date strong { font-size: 14px; }
.medication-date span, .medication-date small { color: var(--muted); font-size: 12px; }
.medication-date small { width: fit-content; margin-top: 8px; padding: 4px 8px; color: var(--green); background: var(--mint); border-radius: 999px; font-weight: 800; }
.medication-body { min-width: 0; }
.medication-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.medication-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 12px; color: var(--muted); font-size: 13px; }
.status-active { color: #176c53; background: #dff1e9; }
.status-planned { color: #2e608e; background: #e4effa; }
.status-historical { color: var(--muted); background: #edf0ef; }
.medication-period-preview { display: grid; grid-template-columns: 1fr auto; gap: 1px 14px; margin-top: 16px; padding: 13px 15px; background: var(--mint); border-radius: 13px; }
.medication-period-preview span { grid-column: 1 / -1; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.medication-period-preview strong { font-size: 15px; }
.medication-period-preview small { color: var(--green); font-weight: 800; }
.medication-chart-panel { margin-top: 18px; padding-bottom: 18px; overflow: visible; }
.medication-chart-header { align-items: flex-end; }
.medication-chart-header p:last-child { max-width: 650px; margin: 5px 0 0; color: var(--muted); font-size: 13px; }
.medication-chart-controls { display: flex; align-items: end; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.medication-chart-controls > label { min-width: 190px; }
.medication-range-label { position: relative; z-index: 5; }
.medication-range-menu { min-width: 210px; }
.medication-range-menu .filter-menu-options { left: auto; right: 0; }
.medication-custom-range { display: grid; grid-template-columns: 145px 145px; gap: 8px; }
.medication-custom-range[hidden] { display: none; }
.medication-custom-range input { padding: 9px 10px; }
.medication-chart-legend { display: flex; flex-wrap: wrap; gap: 9px 18px; margin: -3px 0 17px; color: var(--muted); font-size: 11px; }
.medication-chart-legend span { display: flex; align-items: center; gap: 6px; }
.medication-chart-legend i { width: 18px; height: 7px; border-radius: 999px; }
.medication-chart-legend i.active { background: #2f9676; }
.medication-chart-legend i.planned { background: #4d86b3; }
.medication-chart-legend i.historical { background: #aab8b4; }
.medication-chart-legend b { width: 8px; height: 8px; border: 2px solid #879792; border-radius: 50%; background: white; }
.medication-chart { min-width: 0; }
.medication-chart-axis, .medication-chart-row { display: grid; grid-template-columns: minmax(220px, 280px) minmax(420px, 1fr); gap: 16px; }
.medication-chart-axis { height: 30px; color: var(--muted); font-size: 10px; }
.medication-chart-axis > div { border-bottom: 1px solid var(--line); }
.medication-chart-ticks { display: grid; grid-template-columns: repeat(5, 1fr); align-items: start; }
.medication-chart-tick { white-space: nowrap; text-align: center; }
.medication-chart-tick.first { text-align: left; }
.medication-chart-tick.last { text-align: right; }
.medication-chart-scroll { display: grid; gap: 3px; max-height: 520px; overflow-y: auto; padding-right: 5px; scrollbar-color: #b8cbc5 transparent; }
.medication-chart-row { min-height: 56px; align-items: center; }
.medication-chart-name { min-width: 0; }
.medication-chart-name strong, .medication-chart-name small { display: block; overflow: hidden; text-overflow: ellipsis; }
.medication-chart-name strong { font-size: 12px; }
.medication-chart-name small { margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.35; white-space: normal; }
.medication-chart-track { position: relative; height: 30px; overflow: hidden; border-radius: 8px; background: repeating-linear-gradient(to right, transparent 0, transparent calc(25% - 1px), rgba(158,180,173,.25) calc(25% - 1px), rgba(158,180,173,.25) 25%), #f7faf8; }
.medication-chart-mark { position: absolute; inset: 0; width: 100%; height: 30px; overflow: visible; }
.medication-chart-mark.status-active, .medication-chart-mark.status-planned, .medication-chart-mark.status-historical { background: transparent; }
.medication-chart-mark.status-active rect { fill: #2f9676; }
.medication-chart-mark.status-planned rect { fill: #4d86b3; }
.medication-chart-mark.status-historical rect { fill: #aab8b4; }
.medication-chart-mark circle { fill: white; stroke: #879792; stroke-width: 3; vector-effect: non-scaling-stroke; }
.medication-chart-mark.clipped-start rect, .medication-chart-mark.clipped-end rect { rx: 2; }

dialog { padding: 0; border: 0; background: transparent; width: min(620px, calc(100% - 28px)); }
dialog::backdrop { background: rgba(15,45,41,.55); backdrop-filter: blur(4px); }
.modal-card { background: var(--paper); padding: 26px; border-radius: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.24); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.span-2 { grid-column: span 2; }
label { display: grid; gap: 6px; color: var(--ink); font-size: 13px; font-weight: 700; }
input, textarea, select { width: 100%; color: var(--ink); background: white; border: 1px solid #cddbd6; border-radius: 10px; padding: 10px 11px; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(30,116,104,.1); }
textarea { resize: vertical; }
.form-hint { color: var(--muted); font-size: 12px; margin: 15px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; flex-wrap: wrap; }
.ai-panel { margin-top: 20px; border-color: #b8d5cc; }
.ai-content { white-space: pre-wrap; line-height: 1.7; }

/* Universal indicator graph */
.wide-dialog { width: min(980px, calc(100% - 24px)); max-height: calc(100vh - 24px); }
.indicator-modal-card { max-height: calc(100vh - 24px); overflow-y: auto; padding: 28px; }
.indicator-modal-header { align-items: flex-start; margin-bottom: 18px; }
.indicator-modal-header h2 { max-width: 660px; font-size: 34px; }
#indicator-subtitle { margin: 4px 0 0; color: var(--muted); }
#indicator-pin.pinned { color: #8d5d19; border-color: #d8b878; background: #fff6e4; }
.indicator-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 16px; }
.indicator-summary > div { min-width: 0; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; background: #f8faf8; }
.indicator-summary strong, .indicator-summary span { display: block; overflow: hidden; text-overflow: ellipsis; }
.indicator-summary strong { font: 500 22px Georgia, serif; white-space: nowrap; }
.indicator-summary span { color: var(--muted); font-size: 11px; }
.chart-toolbar { display: grid; grid-template-columns: 150px 150px 1fr; gap: 10px; align-items: end; margin: 18px 0 10px; }
.chart-toolbar select { padding: 8px 10px; }
.chart-toolbar .check-label { display: flex; align-items: center; align-self: center; gap: 8px; }
.check-label input { width: auto; accent-color: var(--green); }
.form-grid > .check-label { display: flex; align-items: center; gap: 8px; }
.chart-stage { width: 100%; height: 330px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: linear-gradient(180deg,#fbfdfc,#f7faf8); }
.chart-stage svg { display: block; width: 100%; height: 100%; overflow: visible; }
.chart-grid-line { stroke: #dfe8e5; stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-axis-label, .chart-date-label { fill: var(--muted); font: 11px Inter, ui-sans-serif, system-ui, sans-serif; }
.reference-band { fill: #dcefe8; opacity: .75; }
.chart-line { fill: none; stroke: var(--green-2); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.chart-point { fill: white; stroke: var(--green); stroke-width: 3; vector-effect: non-scaling-stroke; }
.chart-point.status-high, .chart-point.status-low { fill: #fff3dc; stroke: var(--amber); }
.chart-point.method-calculated { stroke-dasharray: 2 3; stroke-width: 4; }
.chart-bar { fill: var(--green-2); opacity: .88; }
.chart-bar.status-high, .chart-bar.status-low { fill: var(--amber); }
.chart-bar.method-calculated { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 4 3; }
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; margin: 8px 4px 20px; color: var(--muted); font-size: 11px; }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.chart-legend i { display: inline-block; width: 20px; height: 7px; border-radius: 999px; }
.legend-value { background: var(--green-2); }
.legend-reference { background: #cfe8df; }
.chart-history { margin-top: 8px; }
.chart-history h3, .explanation-card h3 { margin: 0; font: 500 24px Georgia, serif; }
.chart-history > .history-primary, .history-more > div { display: grid; grid-template-columns: 1fr; margin-top: 7px; }
.history-row { display: grid; grid-template-columns: 95px 1fr auto; gap: 10px; align-items: center; min-width: 0; padding: 10px 0; border-bottom: 1px solid var(--line); }
.history-row time { color: var(--muted); font-size: 12px; }
.history-row strong, .history-row small { display: block; }
.history-row small { max-width: 210px; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.history-more { margin-top: 8px; }
.history-more summary { width: fit-content; cursor: pointer; color: var(--green); font-weight: 750; padding: 7px 0; }
.related-history { margin-top: 18px; padding: 14px 16px; border: 1px solid #dce8e3; border-radius: 16px; background: #f7fbf9; }
.related-history h3 { margin: 0 0 4px; font-size: 16px; }
.related-history > p { margin: 0 0 5px; color: var(--muted); font-size: 12px; }
.history-row-related small { max-width: 430px; }
.explanation-card { margin-top: 22px; padding: 20px; border: 1px solid #cfe0da; border-radius: 16px; background: var(--mint); }
.explanation-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.explanation-heading .eyebrow { margin-bottom: 5px; }
.explanation-card p { margin: 12px 0; }
.explanation-card h4 { margin: 17px 0 7px; }
.explanation-card ul { margin: 0; padding-left: 20px; }
.explanation-card li { margin: 6px 0; }
.explanation-note { color: var(--muted); font-size: 12px; }
.attention-box { display: grid; gap: 4px; margin: 18px 0; padding: 15px 16px; border: 1px solid #bdd8cf; border-radius: 13px; background: rgba(255,255,255,.7); }
.attention-box span, .health-impact-grid section > span { color: var(--green-2); font-size: 10px; font-weight: 850; letter-spacing: .1em; }
.attention-box.status-high, .attention-box.status-low { border-color: #e6c48d; background: #fff8e9; }
.attention-box.status-high span, .attention-box.status-low span { color: var(--amber); }
.reference-orientation { margin: 14px 0; padding: 13px 14px; border: 1px dashed #d1b47c; border-radius: 12px; background: #fff9ec; }
.reference-orientation span { color: var(--amber); font-size: 10px; font-weight: 850; letter-spacing: .08em; }
.reference-orientation p { margin: 6px 0 0; }
.health-impact-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 18px; }
.health-impact-grid section { padding: 15px; border: 1px solid #cbded7; border-radius: 13px; background: rgba(255,255,255,.58); }
.health-impact-grid p { margin: 7px 0 0; }
.explanation-source { padding-top: 12px; border-top: 1px solid #bdd5cd; color: var(--muted); font-size: 12px; }
.explanation-source a { color: var(--green); font-weight: 750; text-decoration: none; }
.consultant-addendum { margin-top: 18px; padding-top: 18px; border-top: 1px solid #b9d4cb; }
.indicator-actions { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 16px; }
.indicator-actions a { text-decoration: none; }
tr[data-graph-kind] { cursor: pointer; }
tr[data-graph-kind]:hover td { background: rgba(233,242,239,.55); }

/* Health watcher */
.watcher-layout { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
.watcher-layout > * { min-width: 0; }
.watcher-priority, .reference-panel { grid-column: 1 / -1; }
.watch-item { display: grid; width: 100%; grid-template-columns: 92px 1fr auto; gap: 14px; align-items: center; padding: 14px 0; color: var(--ink); text-align: left; font: inherit; background: transparent; border: 0; border-bottom: 1px solid var(--line); }
.watch-item:hover { background: rgba(233,242,239,.55); }
.watch-item strong, .watch-item small, .watch-item em { display: block; min-width: 0; overflow-wrap: anywhere; }
.watch-item small { color: var(--muted); }
.watch-item em { color: var(--green); font-size: 12px; font-style: normal; font-weight: 750; margin-top: 3px; }
.watch-item time { color: var(--muted); font-size: 12px; white-space: nowrap; }
.watch-status { width: fit-content; padding: 5px 8px; border-radius: 999px; color: var(--amber); background: var(--amber-bg); font-size: 10px; font-weight: 850; }
.level-context .watch-status { color: var(--green); background: var(--mint); }
.schedule-row { display: grid; grid-template-columns: 1fr auto; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.schedule-row > span:last-child { text-align: right; }
.schedule-row strong, .schedule-row small, .schedule-row em { display: block; min-width: 0; overflow-wrap: anywhere; }
.schedule-row small { color: var(--muted); }
.schedule-row em { width: fit-content; margin-top: 5px; padding: 3px 6px; border-radius: 6px; color: var(--green); background: var(--mint); font-size: 9px; font-style: normal; font-weight: 800; }
.selection-note { padding: 15px; border: 1px solid #c8ddd6; border-radius: 13px; background: var(--mint); }
.selection-note p { margin: 5px 0 0; color: var(--muted); }
.catalog-options { display: grid; gap: 8px; margin-top: 12px; }
.catalog-options a { display: grid; min-width: 0; padding: 12px; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 11px; background: white; }
.catalog-options a:hover { border-color: #9fc7bb; }
.catalog-options span { color: var(--green); font-size: 12px; }
.audit-summary { display: grid; grid-template-columns: repeat(4,1fr); gap: 8px; margin-bottom: 14px; }
.audit-summary span { min-width: 0; padding: 11px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); overflow-wrap: anywhere; background: rgba(255,255,255,.55); font-size: 11px; }
.audit-summary strong { display: block; color: var(--ink); font: 500 24px Georgia,serif; }
.audit-list { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.audit-list button { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 12px 0; color: var(--ink); text-align: left; font: inherit; background: transparent; border: 0; border-bottom: 1px solid var(--line); }
.audit-list strong, .audit-list small, .audit-list em { display: block; min-width: 0; overflow-wrap: anywhere; }
.audit-list small { color: var(--muted); font-size: 11px; }
.audit-list em { color: var(--amber); font-size: 10px; font-style: normal; font-weight: 800; }
.ai-settings-status { display: grid; gap: 2px; margin-top: 15px; padding: 12px; border-radius: 11px; color: var(--green); background: var(--mint); }
.ai-settings-status span { color: var(--muted); font-size: 11px; }
.ai-settings-status.error { color: var(--red); background: #fff1ef; }
.ai-settings-status.error span { color: #8c3f37; }
.ai-connections { display: grid; gap: 8px; margin-top: 12px; max-height: 220px; overflow-y: auto; }
.ai-connection { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 11px; }
.ai-connection strong { display: block; font-size: 13px; }
.ai-connection small { display: block; color: var(--muted); margin-top: 3px; }
.ai-connection-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.ai-connection-actions button { white-space: nowrap; }

/* Task-first dashboard */
.today-header { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 24px; }
.today-header h1 { font-size: clamp(48px, 7vw, 76px); margin-bottom: 10px; }
.compact-stats { margin: 20px 0 18px; }
.compact-stats .stat { padding: 14px 17px; background: rgba(255,255,255,.55); }
.compact-stats .stat strong { font-size: 27px; }
.dashboard-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; margin-top: 18px; }
.dashboard-grid .panel { min-width: 0; }
.dashboard-attention { grid-row: span 2; }
.dashboard-section-heading { margin-top: 44px; }
.dashboard-lower { margin-top: 18px; }
.quiet-label { color: var(--muted); font-size: 12px; white-space: nowrap; }
.panel-link { display: block; margin: 10px 0 0 auto; }

.alert-item { width: 100%; text-align: left; border-left: 0; border-right: 0; border-bottom: 0; background: transparent; color: var(--ink); font: inherit; }
.alert-item:hover { background: rgba(233,242,239,.55); }
.alert-item > span:last-child { min-width: 0; }
.alert-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.alert-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-title em { color: var(--amber); background: var(--amber-bg); border-radius: 999px; padding: 4px 7px; font-size: 10px; font-style: normal; font-weight: 800; white-space: nowrap; }
.alert-item small { display: block; color: var(--muted); margin-top: 3px; }
.severity-prominent .alert-icon { color: #9e3c32; background: #fbe6e1; }
.severity-prominent .alert-title em { color: #9e3c32; background: #fbe6e1; }
.historical-panel .alert-item { opacity: .78; }
.historical-panel .alert-title em { color: var(--muted); background: #edf0ef; }

.indicator-card { appearance: none; width: 100%; text-align: left; color: var(--ink); font: inherit; cursor: pointer; transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease; }
.indicator-card:hover { transform: translateY(-2px); border-color: #aaccc2; box-shadow: 0 22px 55px rgba(26,65,59,.13); }
.indicator-card > span { display: block; }

.today-med, .recent-doc, .inbox-file, .inbox-clear { display: grid; grid-template-columns: auto 1fr; gap: 11px; align-items: center; padding: 11px 0; border-top: 1px solid var(--line); }
.today-med:first-child, .recent-doc:first-child, .inbox-file:first-child { border-top: 0; }
.today-med strong, .today-med small, .recent-doc strong, .recent-doc small, .inbox-file strong, .inbox-file small, .inbox-clear strong, .inbox-clear small { display: block; }
.today-med small, .recent-doc small, .inbox-file small, .inbox-clear small { color: var(--muted); font-size: 12px; margin-top: 2px; }
.med-dot { width: 11px; height: 11px; border-radius: 50%; background: #8aa39d; box-shadow: 0 0 0 5px #edf3f1; }
.med-dot.status-active { background: #2f9676; box-shadow: 0 0 0 5px #e0f2eb; }
.med-dot.status-planned { background: #5488b5; box-shadow: 0 0 0 5px #e7f0f8; }
.recent-doc { width: 100%; text-align: left; color: var(--ink); background: transparent; border-left: 0; border-right: 0; border-bottom: 0; font: inherit; }
.recent-doc:hover { background: rgba(233,242,239,.5); }
.doc-type-icon { width: 34px; height: 34px; display: grid; place-items: center; color: var(--green); background: var(--mint); border-radius: 10px; font-size: 11px; font-weight: 900; }
.inbox-clear > span { width: 42px; height: 42px; display: grid; place-items: center; color: #28755f; background: #e0f2eb; border-radius: 13px; font-size: 20px; }
.inbox-warning { display: flex; justify-content: space-between; gap: 10px; color: var(--amber); background: var(--amber-bg); border-radius: 11px; padding: 10px 12px; margin-bottom: 7px; }
.inbox-warning span { color: #8c6a45; }
.inbox-file > span { min-width: 42px; text-align: center; color: var(--amber); background: var(--amber-bg); border-radius: 8px; padding: 6px; font-size: 9px; font-weight: 900; }
.skeleton-line { height: 13px; margin: 12px 0; border-radius: 999px; background: linear-gradient(90deg,#eef2f0,#f8faf9,#eef2f0); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
.skeleton-line.short { width: 62%; }
@keyframes shimmer { to { background-position: -200% 0; } }

.measurement-tools { position: relative; z-index: 2; display: grid; grid-template-columns: minmax(260px, 1fr) auto auto auto; gap: 10px; align-items: center; overflow: visible; padding: 16px 18px; border-bottom: 1px solid var(--line); color: var(--muted); }
.filter-menu { position: relative; z-index: 3; min-width: 180px; }
.filter-menu-trigger { width: 100%; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; color: var(--ink); text-align: left; background: white; border: 1px solid #cddbd6; border-radius: 10px; touch-action: manipulation; }
.filter-menu-trigger:focus-visible, .filter-menu.open .filter-menu-trigger { border-color: var(--green-2); box-shadow: 0 0 0 3px rgba(30,116,104,.1); outline: none; }
.filter-menu-options { position: absolute; z-index: 60; top: calc(100% + 6px); left: 0; width: max(100%, 230px); max-height: 310px; display: none; overflow-y: auto; padding: 6px; background: white; border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 18px 45px rgba(26,65,59,.18); }
.filter-menu.open .filter-menu-options { display: grid; }
.filter-menu-options button { width: 100%; padding: 10px 11px; color: var(--ink); text-align: left; background: transparent; border: 0; border-radius: 8px; }
.filter-menu-options button:hover, .filter-menu-options button:focus-visible { background: var(--mint); outline: none; }
.filter-menu-options button[aria-selected="true"] { color: var(--green); background: var(--mint); font-weight: 750; }
.measurement-tools span { white-space: nowrap; text-align: right; }
td small { display: block; max-width: 440px; overflow: hidden; color: var(--muted); text-overflow: ellipsis; }
td .badge { display: inline-block; margin-bottom: 4px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 14px; padding: 18px; color: var(--muted); }
.pagination .secondary { padding: 8px 13px; }
.pagination button:disabled { opacity: .35; cursor: default; }

.segmented { display: flex; width: fit-content; max-width: 100%; gap: 4px; margin: 18px 0; padding: 4px; overflow-x: auto; background: rgba(255,255,255,.65); border: 1px solid var(--line); border-radius: 13px; }
.segmented button { border: 0; padding: 8px 13px; color: var(--muted); background: transparent; border-radius: 9px; white-space: nowrap; }
.segmented button.active { color: white; background: var(--green); }
.medication-card .badge { align-self: start; }
.compact-button { padding: 7px 11px; font-size: 12px; white-space: nowrap; }
.target-stats { margin: 20px 0; }

/* Doctor-facing view */
.visit-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 26px; }
.visit-toolbar h1 { font-size: clamp(44px, 6vw, 64px); margin-bottom: 8px; }
.visit-toolbar p:last-child { color: var(--muted); margin-bottom: 0; }
.visit-sheet { color: #16332f; background: white; border: 1px solid var(--line); border-radius: 22px; padding: 30px; box-shadow: var(--shadow); }
.visit-sheet-header { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding-bottom: 22px; border-bottom: 2px solid var(--ink); }
.visit-sheet-header > div { display: flex; gap: 11px; align-items: center; }
.visit-sheet-header > div:last-child { display: grid; text-align: right; }
.visit-sheet-header strong, .visit-sheet-header small { display: block; }
.visit-sheet-header small { color: var(--muted); }
.visit-summary-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 30px; padding: 28px 0; }
.visit-summary-grid > section { min-width: 0; }
.visit-line { display: grid; gap: 2px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.visit-line span { color: var(--muted); }
.visit-line small { color: var(--green-2); }
.visit-alert-measure { width: 100%; color: inherit; text-align: left; font: inherit; background: transparent; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.visit-alert-measure:hover, .visit-alert-measure:focus-visible { padding-left: 10px; background: var(--mint); outline: none; }
.visit-block { padding: 26px 0; border-top: 1px solid var(--line); }
.visit-block .panel-header { margin-bottom: 15px; }
.visit-block input { max-width: 340px; }
.visit-graph-hint { display: block; margin-top: 4px; color: var(--green-2); font-size: 11px; }
.visit-documents { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 24px; }
.visit-documents a { display: flex; justify-content: space-between; gap: 15px; color: var(--ink); text-decoration: none; padding: 11px 0; border-bottom: 1px solid var(--line); }
.visit-documents strong, .visit-documents small { display: block; }
.visit-documents small, .visit-documents time { color: var(--muted); font-size: 12px; }
.visit-measurements { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.visit-measure { display: flex; width: 100%; justify-content: space-between; gap: 18px; padding: 11px 0; color: inherit; text-align: left; font: inherit; background: transparent; border: 0; border-bottom: 1px solid var(--line); }
.visit-measure { cursor: pointer; transition: padding .15s ease, background .15s ease; }
.visit-measure:hover, .visit-measure:focus-visible { padding-left: 10px; padding-right: 10px; background: var(--mint); outline: none; }
.visit-measure > span:last-child { text-align: right; }
.visit-measure strong, .visit-measure small { display: block; }
.visit-measure small { color: var(--muted); }
.visit-sheet footer { padding-top: 18px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--line); }

/* Medical consultant */
.consult-layout { display: grid; grid-template-columns: 270px minmax(0,1fr); gap: 18px; }
.consult-sidebar { align-self: start; position: sticky; top: 92px; display: grid; gap: 8px; }
.question-chip { width: 100%; text-align: left; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 11px; padding: 10px 11px; }
.question-chip:hover { color: var(--green); border-color: #a8cbc0; background: var(--mint); }
.consult-privacy { display: grid; gap: 3px; margin-top: 10px; padding: 12px; color: var(--green); background: var(--mint); border-radius: 12px; }
.consult-privacy span { color: var(--muted); font-size: 11px; }
.consult-chat { padding: 0; overflow: hidden; }
.consult-messages { min-height: 430px; max-height: 62vh; overflow-y: auto; padding: 22px; background: rgba(255,255,255,.42); }
.chat-message { width: min(82%, 720px); margin-bottom: 13px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 16px 16px 16px 5px; background: white; }
.chat-message.user { margin-left: auto; color: white; background: var(--green); border-color: var(--green); border-radius: 16px 16px 5px 16px; }
.chat-message p { margin: 5px 0 0; white-space: normal; }
.chat-message.pending { opacity: .65; }
.source-link { color: var(--green-2); font-weight: 750; }
.consult-form { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: end; padding: 16px 18px 7px; border-top: 1px solid var(--line); background: white; }
.consult-compose { min-width: 0; }
.consult-form textarea { min-height: 74px; }
.voice-controls { display: flex; align-items: center; gap: 9px; min-height: 34px; margin-top: 7px; }
.voice-record { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; padding: 7px 10px; color: var(--green); background: var(--mint); border: 1px solid #b8d9cf; border-radius: 10px; font-weight: 800; }
.voice-record > span:first-child { width: 17px; height: 17px; display: grid; place-items: center; color: white; background: var(--green); border-radius: 50%; font-size: 8px; }
.voice-record:hover:not(:disabled) { border-color: var(--green); }
.voice-record.recording { color: #9e3027; background: #fff0ed; border-color: #efb8b2; }
.voice-record.recording > span:first-child { background: #bd473d; animation: voicePulse 1s infinite; }
.voice-record:disabled { opacity: .48; cursor: not-allowed; }
.voice-status { min-width: 0; flex: 1 1 auto; color: var(--muted); font-size: 11px; line-height: 1.35; }
.voice-auto { display: inline-flex; align-items: center; gap: 5px; flex: 0 0 auto; color: var(--muted); font-size: 11px; white-space: nowrap; }
.voice-auto input { width: auto; }
.voice-stop { flex: 0 0 auto; padding: 7px 9px; font-size: 11px; }
.voice-disclosure { padding: 0 18px 5px; margin: 0; color: var(--muted); background: white; font-size: 10px; }
.chat-speak { margin-top: 10px; padding: 6px 9px; color: var(--green); background: var(--mint); border: 0; border-radius: 9px; font-size: 11px; font-weight: 800; }
@keyframes voicePulse { 50% { transform: scale(.72); opacity: .65; } }
.consult-chat > .form-hint { padding: 0 18px 13px; margin: 0; background: white; }

/* Controlled AI review agent */
.agent-title { align-items: flex-end; }
.agent-status { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; margin: 20px 0 14px; padding: 20px 22px; }
.agent-status h2 { margin: 2px 0 4px; }
.agent-status p:last-child { margin: 0; color: var(--muted); }
.agent-status-mark { width: 15px; height: 15px; border-radius: 50%; background: #87a29b; box-shadow: 0 0 0 7px #edf3f1; }
.agent-status.status-running .agent-status-mark { background: var(--amber); box-shadow: 0 0 0 7px var(--amber-bg); animation: agentPulse 1.2s infinite; }
.agent-status.status-draft .agent-status-mark { background: #427daa; box-shadow: 0 0 0 7px #e6f0f7; }
.agent-status.status-confirmed .agent-status-mark { background: #2f9676; box-shadow: 0 0 0 7px #e0f2eb; }
.agent-status.status-error .agent-status-mark { background: var(--red); box-shadow: 0 0 0 7px #fbe6e1; }
@keyframes agentPulse { 50% { transform: scale(.72); opacity: .65; } }
.agent-evidence { margin: 0 0 18px; }
.agent-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 18px; align-items: start; }
.agent-report-panel { min-width: 0; }
.agent-report { color: #263d39; line-height: 1.68; overflow-wrap: anywhere; }
.agent-report h2, .agent-report h3, .agent-report h4 { margin: 25px 0 8px; color: var(--ink); }
.agent-report h2:first-child, .agent-report h3:first-child { margin-top: 0; }
.agent-report h3 { font-size: 19px; }
.agent-report h4 { font-size: 16px; }
.agent-bullet { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin: 6px 0; }
.agent-bullet > span { min-width: 0; }
.agent-review-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.agent-review-actions[hidden] { display: none; }
.agent-side { display: grid; gap: 22px; position: sticky; top: 92px; }
.agent-stages { display: grid; gap: 14px; margin: 14px 0 0; padding: 0; list-style: none; counter-reset: stage; }
.agent-stages li { counter-increment: stage; display: grid; grid-template-columns: 30px 1fr; column-gap: 10px; }
.agent-stages li::before { content: counter(stage); grid-row: span 2; width: 27px; height: 27px; display: grid; place-items: center; color: var(--green); background: var(--mint); border-radius: 9px; font-size: 12px; font-weight: 900; }
.agent-stages strong, .agent-stages span { display: block; }
.agent-stages span { margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.agent-side-block { padding-top: 18px; border-top: 1px solid var(--line); }
.agent-source-list { display: grid; gap: 7px; margin-top: 10px; }
.agent-source-list a { display: grid; grid-template-columns: 25px 1fr; gap: 8px; align-items: start; color: var(--ink); text-decoration: none; font-size: 12px; overflow-wrap: anywhere; }
.agent-source-list a:hover { color: var(--green); }
.agent-source-list a > span { width: 23px; height: 23px; display: grid; place-items: center; color: var(--green); background: var(--mint); border-radius: 7px; font-weight: 800; }
.agent-history-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.agent-history-row time { color: var(--muted); text-align: right; }
#toast { position: fixed; right: 22px; bottom: 22px; max-width: 380px; color: white; background: var(--ink); border-radius: 12px; padding: 13px 16px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(8px); transition: .2s; z-index: 30; }
#toast.show { opacity: 1; transform: none; }
#toast.error { background: var(--red); }

/* Protected owner login */
.landing-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; overflow: hidden; background: radial-gradient(circle at 82% 14%, rgba(183,218,205,.72) 0, transparent 30%), radial-gradient(circle at 10% 88%, rgba(232,218,181,.62) 0, transparent 32%), var(--cream); }
.landing-shell { position: relative; width: min(720px, 100%); max-width: none; margin: 0; padding: clamp(40px, 8vw, 86px); text-align: center; background: rgba(255,254,250,.78); border: 1px solid rgba(42,91,82,.14); border-radius: 34px; box-shadow: 0 32px 100px rgba(24,64,58,.13); backdrop-filter: blur(14px); }
.landing-mark { width: 58px; height: 58px; display: grid; place-items: center; margin: 0 auto 34px; color: white; background: var(--green); border-radius: 19px; font-size: 25px; box-shadow: 0 13px 35px rgba(13,91,80,.22); }
.landing-shell h1 { margin: 5px 0 18px; font-size: clamp(48px, 9vw, 82px); line-height: .98; letter-spacing: -.055em; }
.landing-shell > p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: clamp(16px, 2.4vw, 20px); }
.landing-line { width: 150px; height: 3px; margin: 38px auto 0; overflow: hidden; background: #dce7e3; border-radius: 999px; }
.landing-line span { display: block; width: 45%; height: 100%; background: var(--green); border-radius: inherit; animation: landingProgress 2.6s ease-in-out infinite alternate; }
@keyframes landingProgress { from { transform: translateX(0); } to { transform: translateX(122%); } }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 85% 10%, #dbece6 0, transparent 34%), radial-gradient(circle at 10% 90%, #eee7d6 0, transparent 34%), var(--cream); }
.login-shell { width: min(520px, 100%); max-width: none; margin: 0; padding: 0; }
.login-card { padding: clamp(28px, 6vw, 48px); background: rgba(255,254,250,.94); border: 1px solid var(--line); border-radius: 26px; box-shadow: 0 30px 90px rgba(24,64,58,.16); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 38px; font-size: 18px; }
.login-card h1 { font-size: clamp(38px, 8vw, 54px); }
.login-copy { color: var(--muted); margin-bottom: 24px; }
.login-form { display: grid; gap: 14px; }
.login-form .primary { width: 100%; margin-top: 3px; }
.login-code { min-height: 62px; text-align: center; font: 600 34px/1 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .35em; padding-left: calc(.35em + 11px); }
.login-secondary-actions { display: flex; justify-content: space-between; gap: 12px; margin-top: 15px; }
.login-secondary-actions button { font-size: 12px; }
.login-secondary-actions button:disabled { opacity: .5; cursor: wait; }
.login-status { min-height: 24px; margin-top: 15px; color: var(--green); font-size: 13px; font-weight: 700; }
.login-status.error { color: var(--red); }
.login-security { display: grid; grid-template-columns: auto 1fr; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); }
.login-security > span { color: #2f9676; }
.login-security p { margin: 0; font-size: 12px; }
.login-security strong { color: var(--ink); }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: 1fr auto; padding: 0 18px; background: var(--cream); backdrop-filter: none; }
  nav { position: fixed; left: 0; right: 0; bottom: 0; height: 62px; background: var(--paper); justify-content: flex-start; align-items: center; overflow-x: auto; padding: 0 12px; border-top: 1px solid var(--line); z-index: 20; }
  .nav-more { display: contents; }
  .nav-more-toggle { display: none; }
  .nav-more-menu, .nav-more-menu[hidden] { display: contents !important; }
  .privacy-pill { display: none; }
  .account-controls { display: flex; }
  main { padding-top: 35px; padding-bottom: 90px; }
  .hero, .today-header, .page-title { align-items: flex-start; flex-direction: column; }
  .hero-actions, .button-row { justify-content: flex-start; }
  .indicator-grid { grid-template-columns: repeat(2, 1fr); }
  .two-column { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-attention { grid-row: auto; }
  .measurement-tools { grid-template-columns: 1fr 1fr; }
  .measurement-tools input { grid-column: 1 / -1; }
  .visit-toolbar { align-items: flex-start; flex-direction: column; }
  .visit-summary-grid { grid-template-columns: 1fr; }
  .consult-layout { grid-template-columns: 1fr; }
  .agent-layout { grid-template-columns: 1fr; }
  .agent-side { position: static; }
  .consult-sidebar { position: static; grid-template-columns: 1fr 1fr; }
  .consult-sidebar .eyebrow, .consult-privacy { grid-column: 1 / -1; }
  .indicator-summary { grid-template-columns: 1fr 1fr; }
  .watcher-layout { grid-template-columns: 1fr; }
  .watcher-priority, .reference-panel { grid-column: auto; }
  .audit-list { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  h1 { font-size: 42px; }
  .landing-page { padding: 12px; }
  .landing-shell { padding: 46px 22px; border-radius: 24px; }
  .landing-shell h1 { font-size: clamp(45px, 16vw, 64px); }
  .login-page { padding: 10px; }
  .login-card { padding: 26px 20px; border-radius: 20px; }
  .login-secondary-actions { align-items: flex-start; flex-direction: column; }
  .panel-header { min-width: 0; align-items: flex-start; flex-wrap: wrap; }
  .panel-header > * { min-width: 0; max-width: 100%; }
  .quiet-label { white-space: normal; }
  .stats { grid-template-columns: 1fr 1fr; }
  .indicator-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .journal-card { grid-template-columns: 1fr auto; }
  .journal-card > div:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .document-card { grid-template-columns: 1fr auto; }
  .medication-summary { grid-template-columns: 1fr; }
  .medication-chart-header { align-items: stretch; }
  .medication-chart-controls { display: grid; justify-content: stretch; width: 100%; }
  .medication-chart-controls > label { width: 100%; }
  .medication-custom-range { grid-template-columns: 1fr 1fr; }
  .medication-chart-axis, .medication-chart-row { grid-template-columns: 190px minmax(390px, 1fr); gap: 10px; }
  .medication-chart { overflow-x: auto; padding-bottom: 6px; }
  .medication-chart-scroll { max-height: 440px; overflow-y: visible; }
  .medication-card { grid-template-columns: 1fr; gap: 13px; padding: 17px 18px; }
  .medication-date { padding-right: 0; padding-bottom: 11px; border-right: 0; border-bottom: 1px solid var(--line); }
  .medication-title-row { align-items: flex-start; flex-direction: column-reverse; }
  .import-draft { grid-template-columns: 1fr auto; }
  .import-draft .draft-actions { grid-column: 1 / -1; justify-content: flex-start; }
  .document-card > div:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .nav-link { padding: 8px 7px; font-size: 12px; }
  .measurement-tools { grid-template-columns: 1fr; }
  .measurement-tools input { grid-column: auto; }
  .measurement-tools span { text-align: left; }
  .filter-menu, .filter-menu-options { width: 100%; }
  .alert-title { min-width: 0; max-width: 100%; align-items: flex-start; flex-direction: column; }
  .alert-title strong { width: 100%; min-width: 0; max-width: 100%; }
  .dashboard-grid .panel { padding: 18px; }
  .pagination { gap: 8px; font-size: 12px; }
  .document-card .doc-actions { grid-column: 1 / -1; text-align: center; }
  .duplicate-comparison { grid-template-columns: 1fr; }
  .visit-sheet { padding: 18px; }
  .visit-sheet-header { align-items: flex-start; flex-direction: column; }
  .visit-sheet-header > div:last-child { text-align: left; }
  .visit-documents, .visit-measurements { grid-template-columns: 1fr; }
  .visit-block .panel-header { align-items: flex-start; flex-direction: column; }
  .consult-sidebar { grid-template-columns: 1fr; }
  .consult-sidebar .eyebrow, .consult-privacy { grid-column: auto; }
  .consult-form { grid-template-columns: 1fr; }
  .voice-controls { flex-wrap: wrap; }
  .voice-status { flex-basis: calc(100% - 100px); }
  .voice-auto { order: 3; }
  .voice-stop { order: 4; }
  .agent-review-actions { align-items: stretch; flex-direction: column-reverse; }
  .chat-message { width: 94%; }
  .indicator-modal-card { padding: 18px 14px; }
  #document-import-modal { width: calc(100% - 8px); }
  .document-import-card { width: 100%; padding: 18px 12px; }
  .import-table-wrap table { min-width: 680px; }
  .import-review-head { align-items: flex-start; flex-direction: column; }
  .indicator-modal-header { gap: 10px; }
  .indicator-modal-header h2 { font-size: 27px; }
  .indicator-modal-header .button-row { flex-wrap: nowrap; }
  .indicator-summary { grid-template-columns: 1fr 1fr; }
  .indicator-summary > div { padding: 10px; }
  .indicator-summary strong { font-size: 18px; }
  .chart-toolbar { grid-template-columns: 1fr 1fr; }
  .chart-toolbar .check-label { grid-column: 1 / -1; }
  .chart-stage { height: 270px; }
  .health-impact-grid { grid-template-columns: 1fr; }
  .indicator-actions { align-items: stretch; flex-direction: column-reverse; }
  .indicator-actions .primary { width: 100%; }
  .indicator-actions a { text-align: center; }
  .audit-summary { grid-template-columns: 1fr 1fr; }
  .watch-item { grid-template-columns: 1fr auto; }
  .watch-item .watch-status { grid-column: 1 / -1; }
  .watch-item time { grid-column: 2; grid-row: 2; }
  .schedule-row { grid-template-columns: 1fr; }
  .schedule-row > span:last-child { text-align: left; }
  .audit-list button { grid-template-columns: 1fr; }
}

@media (min-width: 1101px) and (max-width: 1260px) {
  .topbar { gap: 12px; padding-left: 16px; padding-right: 16px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 32px; height: 32px; }
  .privacy-text { display: none; }
  .privacy-pill { width: 34px; height: 34px; justify-content: center; padding: 0; }
  .logout-button { padding-left: 5px; padding-right: 5px; }
}

@media print {
  @page { margin: 10mm; }
  body { background: white; font-size: 11px; }
  .topbar, .visit-toolbar, #toast { display: none !important; }
  main { max-width: none; padding: 0; }
  .view { display: none !important; }
  #visit { display: block !important; }
  .visit-sheet { border: 0; border-radius: 0; padding: 0; box-shadow: none; }
  .visit-summary-grid { gap: 18px; padding: 18px 0; }
  .visit-block { padding: 16px 0; break-inside: avoid; }
  .visit-block input { display: none; }
  .visit-documents, .visit-measurements { gap: 0 18px; }
  .visit-line, .visit-documents a, .visit-measure { padding: 6px 0; }
}
