:root {
  --ink: #26332f;
  --muted: #74807b;
  --paper: #fffefa;
  --canvas: #f4f1e9;
  --sage: #52796f;
  --sage-dark: #315e55;
  --sage-soft: #dfeae3;
  --coral: #e88972;
  --coral-soft: #f9e5de;
  --amber: #e5ad57;
  --danger: #ba5b55;
  --line: #e6e2d8;
  --shadow: 0 14px 40px rgba(42, 65, 57, .09);
  --radius: 22px;
}

* { box-sizing: border-box; }
[hidden] { display:none !important; }
html { background: var(--canvas); color: var(--ink); font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif; }
body { margin: 0; min-width: 320px; }
button, input, select, textarea { min-width:0; max-width:100%; font:inherit; }
button { color: inherit; }
.app-shell { min-height: 100vh; padding-bottom: 92px; }
.topbar { height: 76px; padding: 12px max(20px, calc((100vw - 1180px)/2)); display:flex; align-items:center; justify-content:space-between; background:rgba(244,241,233,.88); backdrop-filter:blur(16px); position:sticky; top:0; z-index:10; border-bottom:1px solid rgba(230,226,216,.7); }
.brand { display:flex; gap:11px; align-items:center; border:0; background:transparent; text-align:left; cursor:pointer; padding:0; }
.brand-mark { width:44px; height:44px; display:grid; place-items:center; border-radius:15px; color:white; background:var(--sage); font-weight:800; box-shadow:0 7px 18px rgba(49,94,85,.2); }
.brand-mark svg { width:29px; height:29px; overflow:visible; }
.sprout-stem,.sprout-ground { fill:none; stroke:#fff; stroke-width:2.2; stroke-linecap:round; }
.sprout-leaf { fill:#fff; stroke:#fff; stroke-width:.7; stroke-linejoin:round; }
.brand strong, .brand small { display:block; }
.brand strong { font-size:16px; letter-spacing:.03em; }
.brand small { margin-top:3px; font-size:11px; color:var(--muted); }
.top-actions { display:flex; align-items:center; gap:12px; }
.save-status { font-size:12px; color:var(--muted); }
.icon-button { width:36px; height:36px; border-radius:50%; border:1px solid var(--line); background:var(--paper); cursor:pointer; }
main { max-width:1180px; margin:0 auto; padding:32px 24px 48px; outline:none; }
.page-head { display:flex; justify-content:space-between; align-items:flex-end; gap:20px; margin-bottom:24px; }
.eyebrow { margin:0 0 7px; color:var(--coral); font-size:12px; font-weight:800; letter-spacing:.16em; }
h1,h2,h3,p { margin-top:0; }
h1 { margin-bottom:6px; font-size:clamp(27px,4vw,42px); letter-spacing:-.04em; }
h2 { font-size:20px; }
h3 { font-size:16px; }
.subtle { color:var(--muted); line-height:1.7; }
.grid { display:grid; gap:20px; }
.grid > *, .card, .metric,.field,.form-grid > *,.section-title > *,.manage-panel { min-width:0; }
.grid-2 { grid-template-columns:minmax(0,1.45fr) minmax(280px,.75fr); }
.card { background:var(--paper); border:1px solid rgba(230,226,216,.9); border-radius:var(--radius); padding:22px; box-shadow:var(--shadow); }
.card-flat { box-shadow:none; }
.hero { padding:30px; background:linear-gradient(135deg,#fffefa 0%,#edf4ef 100%); position:relative; overflow:hidden; }
.hero:after { content:""; position:absolute; width:210px; height:210px; right:-80px; top:-95px; border:30px solid rgba(82,121,111,.09); border-radius:50%; }
.hero-content { position:relative; z-index:1; max-width:660px; }
.hero h1 { max-width:560px; }
.hero-actions,.row-actions { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
.btn { min-height:44px; max-width:100%; padding:0 18px; border-radius:14px; border:1px solid transparent; background:var(--sage); color:white; font-weight:700; cursor:pointer; display:inline-flex; align-items:center; justify-content:center; gap:7px; text-align:center; white-space:normal; text-decoration:none; }
.btn:hover { background:var(--sage-dark); }
.btn.secondary { color:var(--sage-dark); background:var(--sage-soft); }
.btn.ghost { color:var(--ink); background:transparent; border-color:var(--line); }
.btn.danger { background:var(--coral-soft); color:var(--danger); }
.btn.small { min-height:34px; padding:0 12px; border-radius:10px; font-size:13px; }
.metric-row { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-top:26px; }
.metric { padding:15px; border-radius:16px; background:rgba(255,255,255,.62); border:1px solid rgba(255,255,255,.8); }
.metric strong,.metric span { display:block; }
.metric strong { font-size:22px; }
.metric span { color:var(--muted); font-size:12px; margin-top:3px; }
.metric span, .subtle { overflow-wrap:anywhere; }
.section-title { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:16px; }
.section-title h2 { margin:0; }
.case-list { display:grid; gap:12px; }
.case-card { padding:17px; border:1px solid var(--line); border-radius:17px; background:#fff; cursor:pointer; transition:.18s ease; }
.case-card:hover { transform:translateY(-1px); border-color:#b8cfc5; }
.case-top { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.case-name { font-weight:800; }
.case-meta { margin-top:8px; font-size:13px; color:var(--muted); line-height:1.6; }
.case-card .case-meta { display:-webkit-box; -webkit-line-clamp:3; -webkit-box-orient:vertical; overflow:hidden; }
.case-summary { display:block; margin-top:3px; color:var(--ink); }
.active-case-choice { width:100%; text-align:left; }
.pill { display:inline-flex; align-items:center; min-height:26px; padding:3px 9px; border-radius:999px; font-size:12px; font-weight:700; line-height:1.2; white-space:nowrap; background:var(--sage-soft); color:var(--sage-dark); }
.pill.coral { color:#97513f; background:var(--coral-soft); }
.pill.amber { color:#7f5b22; background:#f8ebd2; }
.pill.gray { color:#68706c; background:#edf0ee; }
.empty { text-align:center; padding:34px 16px; color:var(--muted); }
.empty-icon { width:62px; height:62px; display:grid; place-items:center; margin:0 auto 12px; border-radius:21px; background:var(--sage-soft); font-size:27px; color:var(--sage); }
.reminder { display:flex; gap:13px; align-items:flex-start; padding:16px; margin-bottom:20px; border-radius:17px; background:#fff4dd; border:1px solid #f0dbad; }
.reminder strong { display:block; margin-bottom:4px; }
.reminder p { margin:0; font-size:13px; color:#755c2d; }
.form-card { max-width:760px; margin:0 auto; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:18px; }
.field { display:grid; gap:8px; margin-bottom:18px; }
.field.full { grid-column:1/-1; }
label { font-size:14px; font-weight:700; }
.required:after { content:" *"; color:var(--coral); }
input,select,textarea { width:100%; border:1px solid var(--line); border-radius:13px; background:white; padding:12px 13px; color:var(--ink); outline:none; }
input[type="date"] { min-width:0; width:100%; }
.birthday-field { width:100%; min-width:0; overflow:hidden; }
.birthday-control { contain:inline-size; width:100%; min-width:0; max-width:100%; overflow:hidden; border:1px solid var(--line); border-radius:13px; background:#fff; }
.birthday-control:focus-within { border-color:var(--sage); box-shadow:0 0 0 3px rgba(82,121,111,.12); }
.birthday-control input[type="date"] { display:block; inline-size:100%; min-inline-size:0; max-inline-size:100%; margin:0; border:0; border-radius:0; box-shadow:none; }
.nowrap-action { flex:0 0 auto; white-space:nowrap; }
input:focus,select:focus,textarea:focus { border-color:var(--sage); box-shadow:0 0 0 3px rgba(82,121,111,.12); }
textarea { min-height:104px; resize:vertical; line-height:1.6; }
.hint { color:var(--muted); font-size:12px; line-height:1.5; }
.custom-item-panel { margin:-4px 0 4px; padding:16px; border:1px dashed #b8cfc5; border-radius:15px; background:#f7faf8; }
.new-item-finder { margin-bottom:22px; padding:16px; border:1px solid #cbdad3; border-radius:16px; background:#f5f9f6; }
.new-item-finder .field { position:relative; margin-bottom:11px; }
.new-item-finder > .hint { display:block; margin:10px 0 0; }
.new-item-suggestions { position:absolute; z-index:25; left:0; right:0; top:100%; display:grid; max-height:270px; overflow:auto; border-radius:13px; background:#fff; box-shadow:var(--shadow); }
.new-item-suggestions:empty { display:none; }
.new-item-suggestions button { display:flex; justify-content:space-between; gap:10px; padding:11px 12px; border:0; border-bottom:1px solid var(--line); background:#fff; text-align:left; cursor:pointer; }
.new-item-suggestions button:last-child { border-bottom:0; }
.new-item-suggestions button:hover { background:var(--sage-soft); }
.new-item-suggestions small { color:var(--muted); }
.new-item-suggestions > .hint { padding:12px; }
.recent-items { display:grid; gap:7px; }
.recent-items > div { display:flex; flex-wrap:wrap; gap:7px; }
.recent-items button { min-height:34px; padding:0 11px; border:1px solid var(--line); border-radius:11px; background:#fff; color:var(--sage-dark); font-weight:700; cursor:pointer; }
.recent-items button:hover { background:var(--sage-soft); }
.custom-item-panel .field { margin-bottom:0; }
.item-history-indicator { margin:-4px 0 18px; }
.prior-record-label { display:flex; align-items:center; flex-wrap:wrap; gap:8px; padding:12px 13px; border:1px solid var(--line); border-radius:13px; background:#faf9f5; color:var(--muted); font-size:12px; }
.reuse-notice { display:flex; justify-content:space-between; gap:10px; margin-bottom:8px; padding:11px 13px; border-radius:13px; background:var(--sage-soft); color:var(--sage-dark); font-size:12px; }
.reuse-notice strong,.reuse-notice span { overflow-wrap:anywhere; }
.segmented { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; }
.segmented label { position:relative; }
.segmented input { position:absolute; opacity:0; }
.segmented span { display:grid; min-height:42px; place-items:center; border:1px solid var(--line); border-radius:12px; cursor:pointer; font-size:13px; }
.segmented input:checked + span { background:var(--sage-soft); border-color:var(--sage); color:var(--sage-dark); }
.med-list { display:grid; gap:10px; }
.med-row { position:relative; display:grid; grid-template-columns:minmax(0,1fr) auto; gap:10px; align-items:end; padding:14px; background:#f8f7f2; border-radius:14px; }
.med-row .field { margin:0; }
.med-name-field { position:relative; }
.med-fields { grid-column:1/-1; display:grid; grid-template-columns:1fr 1.35fr .8fr; gap:10px; }
.dose-pair { display:grid; grid-template-columns:1fr .8fr; gap:7px; }
.med-more { grid-column:1/-1; color:var(--muted); font-size:12px; }
.med-more summary { cursor:pointer; padding:5px 0; }
.med-more .form-grid { margin-top:9px; }
.legacy-instruction { grid-column:1/-1; padding:9px 11px; border-radius:10px; background:#fff4dd; color:#755c2d; font-size:12px; }
.med-suggestions { position:absolute; z-index:30; left:0; right:0; top:100%; margin-top:4px; display:grid; max-height:250px; overflow:auto; background:#fff; border:1px solid var(--line); border-radius:12px; box-shadow:var(--shadow); }
.med-suggestions:empty { display:none; }
.med-suggestions button { display:block; width:100%; border:0; border-bottom:1px solid var(--line); padding:11px; background:#fff; text-align:left; cursor:pointer; }
.med-suggestions button:last-child { border-bottom:0; }
.med-suggestions button:hover { background:var(--sage-soft); }
.med-suggestions button span,.med-suggestions button strong,.med-suggestions button small,.med-suggestions button em { display:block; }
.med-suggestions button strong { margin-bottom:3px; }
.med-suggestions small { color:var(--muted); }
.med-suggestions em { margin-top:4px; color:var(--muted); font-size:12px; line-height:1.45; font-style:normal; }
.timeline { position:relative; display:grid; gap:14px; }
.timeline:before { content:""; position:absolute; top:12px; bottom:12px; left:13px; width:2px; background:var(--line); }
.timeline-entry { position:relative; padding-left:40px; }
.timeline-dot { position:absolute; left:5px; top:6px; width:18px; height:18px; border:5px solid var(--paper); border-radius:50%; background:var(--sage); box-shadow:0 0 0 1px var(--line); }
.timeline-card { padding:17px; border-radius:16px; border:1px solid var(--line); background:white; }
.timeline-date { display:flex; justify-content:space-between; gap:10px; margin-bottom:10px; }
.timeline-date strong { font-size:14px; }
.timeline-card p { margin:7px 0 0; line-height:1.7; }
.med-chip { display:inline-block; margin:8px 6px 0 0; padding:6px 9px; border-radius:9px; background:#eef4f0; font-size:12px; }
.detail-summary { display:grid; grid-template-columns:repeat(4,1fr); gap:10px; margin:18px 0; }
.summary-cell { padding:13px; border-radius:14px; background:#f8f7f2; }
.summary-cell span,.summary-cell strong { display:block; }
.summary-cell span { font-size:11px; color:var(--muted); margin-bottom:4px; }
.toolbar { display:flex; align-items:end; gap:10px; flex-wrap:wrap; margin-bottom:20px; }
.toolbar .field { margin:0; min-width:150px; flex:1; }
.history-tabs { display:grid; grid-template-columns:1fr 1fr; gap:8px; max-width:430px; margin-bottom:14px; padding:5px; border:1px solid var(--line); border-radius:16px; background:#ebe9e2; }
.history-tabs button { min-height:42px; border:0; border-radius:12px; background:transparent; color:var(--muted); font-weight:800; cursor:pointer; }
.history-tabs button.active { color:var(--sage-dark); background:#fff; box-shadow:0 3px 12px rgba(42,65,57,.08); }
.history-search-card { padding-top:18px; }
.history-search-row { display:flex; align-items:flex-start; gap:10px; }
.history-search-field { flex:1; margin-bottom:10px; }
.history-search-row > .btn { margin-top:30px; }
.history-suggestions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:7px; }
.history-suggestions:empty { display:none; }
.history-suggestions button { min-width:0; display:flex; justify-content:space-between; align-items:center; gap:9px; padding:10px 12px; border:1px solid var(--line); border-radius:11px; background:#faf9f5; color:var(--ink); text-align:left; cursor:pointer; }
.history-suggestions button:hover { border-color:#b8cfc5; background:var(--sage-soft); }
.history-suggestions span { font-weight:800; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.history-suggestions small { color:var(--muted); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.history-date-filter { margin:12px 0 18px; padding-top:12px; border-top:1px solid var(--line); }
.history-date-filter summary { color:var(--muted); font-size:13px; font-weight:700; cursor:pointer; }
.history-date-filter .form-grid { max-width:560px; margin-top:14px; }
.history-date-filter .field { margin-bottom:0; }
.history-result-summary { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:8px 0 4px; color:var(--muted); font-size:13px; }
.form-error { margin:10px 0 0; color:var(--danger); font-size:13px; font-weight:700; }
.history-results { display:grid; gap:12px; }
.history-status-section { display:grid; gap:12px; }
.history-status-section + .history-status-section { margin-top:25px; padding-top:23px; border-top:1px solid var(--line); }
.history-status-head { display:flex; justify-content:space-between; align-items:center; gap:12px; }
.history-status-head h2 { margin:0 0 3px; font-size:18px; }
.history-status-head p { margin:0; color:var(--muted); font-size:12px; }
.history-status-section.active .history-status-head h2 { color:var(--danger); }
.history-group { overflow:hidden; border:1px solid var(--line); border-radius:17px; background:#fff; }
.history-group.open { border-color:#b8cfc5; }
.history-group-head { width:100%; display:flex; justify-content:space-between; align-items:center; gap:14px; padding:17px; border:0; background:#fff; text-align:left; cursor:pointer; }
.history-group-head:hover { background:#fafbf8; }
.history-group-head p { margin:7px 0 0; color:var(--muted); font-size:13px; }
.history-group-title { display:flex; align-items:center; flex-wrap:wrap; gap:8px; }
.history-group-title strong { font-size:17px; }
.history-chevron { color:var(--sage); font-size:22px; transition:transform .18s ease; }
.history-group.open .history-chevron { transform:rotate(180deg); }
.history-episodes { display:grid; border-top:1px solid var(--line); }
.history-episodes button { width:100%; display:flex; justify-content:space-between; align-items:center; gap:14px; padding:14px 17px; border:0; border-bottom:1px solid var(--line); background:#faf9f5; text-align:left; cursor:pointer; }
.history-episodes button:last-child { border-bottom:0; }
.history-episodes button:hover { background:var(--sage-soft); }
.history-episodes button > div { min-width:0; display:grid; gap:5px; }
.history-episodes button > .pill { flex:0 0 auto; align-self:flex-start; }
.history-episodes button strong,.history-episodes button span { overflow-wrap:anywhere; }
.history-episodes button > div > span { color:var(--muted); font-size:12px; line-height:1.5; }
.management { display:grid; grid-template-columns:280px 1fr; gap:18px; }
.manage-tabs,.stats-range { display:flex; gap:7px; margin-bottom:20px; padding:5px; overflow-x:auto; border:1px solid var(--line); border-radius:16px; background:#ebe9e2; }
.manage-tabs button,.stats-range button { flex:1; min-width:max-content; min-height:42px; padding:0 15px; border:0; border-radius:12px; background:transparent; color:var(--muted); font-weight:800; cursor:pointer; }
.manage-tabs button.active,.stats-range button.active { color:var(--sage-dark); background:#fff; box-shadow:0 3px 12px rgba(42,65,57,.08); }
.manage-tabs { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); overflow:visible; }
.manage-tabs button { min-width:0; padding:0 6px; white-space:nowrap; font-size:13px; }
.manage-panel { min-height:360px; }
.manage-single-card { max-width:780px; }
.manage-section-head { display:flex; justify-content:space-between; align-items:flex-end; gap:18px; margin:4px 0 18px; }
.manage-section-head h2 { margin-bottom:5px; }
.manage-section-head p { margin-bottom:0; }
.stats-range { width:max-content; max-width:100%; }
.stats-range button { min-width:92px; }
.stats-scope-note { margin:-9px 0 18px; color:var(--muted); font-size:13px; line-height:1.6; }
.stats-scope-note strong { color:var(--ink); }
.stats-summary { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:12px; margin-bottom:20px; }
.stat-card { padding:18px; border:1px solid var(--line); border-radius:17px; background:var(--paper); }
.stat-card span,.stat-card strong { display:block; }
.stat-card span { color:var(--muted); font-size:12px; }
.stat-card strong { margin-top:7px; font-size:28px; }
.stat-card small { display:block; margin-top:4px; color:var(--muted); font-size:11px; }
.stats-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:20px; }
.stat-ranks { display:grid; gap:13px; }
.stat-rank { display:grid; grid-template-columns:25px minmax(0,1fr); gap:9px; align-items:center; }
.stat-index { width:25px; height:25px; display:grid; place-items:center; border-radius:9px; background:var(--sage-soft); color:var(--sage-dark); font-size:11px; font-weight:800; }
.stat-rank-label { display:flex; justify-content:space-between; gap:12px; margin-bottom:5px; font-size:13px; }
.stat-rank-label span { color:var(--muted); white-space:nowrap; }
.stat-bar { height:7px; overflow:hidden; border-radius:99px; background:#eeece6; }
.stat-bar i { display:block; height:100%; border-radius:inherit; background:var(--sage); }
.compact-empty { padding:25px 10px; }
.month-chart { height:220px; display:grid; grid-template-columns:repeat(12,minmax(18px,1fr)); gap:7px; align-items:end; padding-top:25px; overflow-x:auto; }
.chart-note { margin:-8px 0 0; color:var(--muted); font-size:12px; }
.month-column { height:180px; min-width:20px; display:grid; grid-template-rows:20px 1fr 22px; align-items:end; justify-items:center; color:var(--muted); font-size:10px; }
.month-column i { width:min(26px,70%); min-height:4px; border-radius:7px 7px 3px 3px; background:linear-gradient(180deg,var(--coral),#efb59f); }
.month-column small { margin-top:5px; white-space:nowrap; }
.weight-stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(150px,1fr)); gap:10px; }
.weight-stats button { display:grid; gap:4px; padding:14px; border:1px solid var(--line); border-radius:14px; background:#faf9f5; text-align:left; cursor:pointer; }
.weight-stats button:hover { background:var(--sage-soft); }
.weight-stats strong { font-size:18px; }
.weight-stats span,.weight-stats small { color:var(--muted); }
.medication-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); column-gap:26px; }
.compact-field { margin-bottom:12px; }
.manage-med-filters { display:grid; grid-template-columns:minmax(220px,1fr) minmax(180px,.55fr); gap:12px; margin-bottom:5px; }
.manage-empty { padding:16px 4px; text-align:center; }
.category-list { display:grid; gap:8px; }
.category-button { width:100%; display:flex; justify-content:space-between; gap:10px; border:0; padding:12px; border-radius:12px; background:transparent; text-align:left; cursor:pointer; }
.category-button.active { background:var(--sage-soft); color:var(--sage-dark); font-weight:800; }
.item-row { display:flex; justify-content:space-between; gap:15px; align-items:center; padding:14px 0; border-bottom:1px solid var(--line); }
.item-row:last-child { border:0; }
.item-row p { margin:4px 0 0; font-size:12px; color:var(--muted); }
.item-row .med-description { max-width:620px; line-height:1.55; }
.photo-placeholder { display:flex; gap:14px; padding:17px; border:1px dashed #bdc8c2; border-radius:15px; background:#fafbf8; color:var(--muted); }
.photo-placeholder span { font-size:25px; }
.attachment-list { display:grid; gap:12px; margin-top:16px; }
.daily-attachments { display:grid; gap:10px; margin-top:14px; }
.staged-files { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
.staged-file { min-width:0; padding:7px; border:1px solid var(--line); border-radius:12px; background:#fff; }
.staged-file img { width:100%; aspect-ratio:1; object-fit:cover; border-radius:8px; }
.staged-file span,.staged-file small { display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:11px; }
.staged-file small { color:var(--muted); margin-top:2px; }
.record-divider { margin-top:8px; padding-top:22px; border-top:1px solid var(--line); }
.attachment-card { display:grid; grid-template-columns:92px minmax(0,1fr); gap:12px; padding:10px; border:1px solid var(--line); border-radius:15px; background:#fff; }
.attachment-card img { width:92px; height:92px; object-fit:cover; display:block; border-radius:11px; background:#eef0ed; }
.attachment-info { min-width:0; }
.attachment-info p { margin:7px 0; color:var(--muted); font-size:11px; overflow-wrap:anywhere; }
.attachment-info p span { display:block; }
.attachment-file-name { margin-top:3px; display:-webkit-box !important; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden; }
.bottom-nav { position:fixed; z-index:20; left:50%; bottom:16px; transform:translateX(-50%); width:min(620px,calc(100% - 28px)); height:66px; display:grid; grid-template-columns:repeat(5,1fr); align-items:center; padding:6px; background:rgba(255,254,250,.94); backdrop-filter:blur(18px); border:1px solid rgba(220,217,207,.9); border-radius:22px; box-shadow:0 14px 45px rgba(38,51,47,.16); }
.bottom-nav button { height:54px; border:0; border-radius:17px; background:transparent; color:var(--muted); font-size:11px; cursor:pointer; display:grid; place-items:center; align-content:center; gap:2px; }
.bottom-nav button span { font-size:21px; line-height:1; }
.bottom-nav button.active { color:var(--sage-dark); background:var(--sage-soft); font-weight:800; }
.bottom-nav .nav-add { width:56px; height:56px; margin:-22px auto 0; border-radius:20px; background:var(--coral); color:white; box-shadow:0 8px 20px rgba(232,137,114,.35); }
.bottom-nav .nav-add:hover { background:#d97861; }
.site-footer { padding:14px 16px 104px; color:var(--muted); font-size:12px; line-height:1.6; text-align:center; }
.site-footer a { color:inherit; text-decoration:none; }
.site-footer a:hover,.site-footer a:focus-visible { color:var(--sage-dark); text-decoration:underline; }
.toast { position:fixed; z-index:100; left:50%; bottom:98px; transform:translate(-50%,15px); padding:11px 17px; border-radius:12px; background:#26332f; color:white; opacity:0; pointer-events:none; transition:.2s; font-size:13px; box-shadow:var(--shadow); }
.toast.show { opacity:1; transform:translate(-50%,0); }
dialog { border:0; border-radius:22px; padding:0; width:min(600px,calc(100% - 28px)); color:var(--ink); box-shadow:0 30px 100px rgba(20,33,29,.28); }
dialog::backdrop { background:rgba(30,42,38,.46); backdrop-filter:blur(3px); }
.modal-content { padding:24px; }
.modal-head { display:flex; justify-content:space-between; gap:20px; align-items:center; margin-bottom:18px; }
.modal-head h2 { margin:0; }
.modal-close { border:0; background:#f0f1ed; border-radius:50%; width:34px; height:34px; cursor:pointer; }
.modal-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:22px; }
.danger-zone { margin-top:26px; padding-top:18px; border-top:1px solid var(--line); }
.access-box { padding:14px; border-radius:14px; background:#f2f6f3; word-break:break-all; font-size:13px; }
.loading { min-height:50vh; display:grid; place-items:center; color:var(--muted); }
.access-locked .topbar,.access-locked .bottom-nav { display:none; }
.access-locked .app-shell { padding-bottom:0; }
.access-locked main { max-width:none; min-height:100vh; padding:0; }
.access-locked .site-footer { position:fixed; z-index:2; right:0; bottom:max(12px,env(safe-area-inset-bottom)); left:0; padding:0 16px; }
.login-screen { min-height:100vh; padding:32px 18px max(68px,env(safe-area-inset-bottom)); display:grid; place-content:center; background:radial-gradient(circle at 50% 15%,#fffefa 0,#f4f1e9 58%,#e7eee9 100%); }
.login-card { width:min(100%,430px); padding:32px 28px; border:1px solid rgba(230,226,216,.9); border-radius:28px; background:rgba(255,254,250,.96); box-shadow:0 24px 70px rgba(42,65,57,.14); }
.login-mark { width:62px; height:62px; display:grid; place-items:center; margin-bottom:22px; border-radius:21px; background:var(--sage); box-shadow:0 10px 25px rgba(49,94,85,.22); }
.login-mark svg { width:40px; height:40px; }
.login-card h1 { font-size:32px; }
.password-field { display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; border:1px solid var(--line); border-radius:14px; background:#fff; overflow:hidden; }
.password-field:focus-within { border-color:var(--sage); box-shadow:0 0 0 3px rgba(82,121,111,.12); }
.password-field input { width:100%; border:0; box-shadow:none; outline:0; }
.password-field button { height:44px; padding:0 14px; border:0; background:transparent; color:var(--sage-dark); font-size:13px; font-weight:700; cursor:pointer; }
.login-submit { width:100%; }
.login-submit:disabled { opacity:.65; cursor:wait; }
.login-message { min-height:21px; margin:-6px 0 10px; color:var(--danger); font-size:13px; }
.login-note,.login-privacy { color:var(--muted); font-size:12px; line-height:1.6; text-align:center; }
.login-note { margin:14px 0 0; }
.login-privacy { margin:18px 0 0; }

@media (max-width: 760px) {
  .topbar { height:66px; padding:10px 16px; }
  .brand small,.save-status { display:none; }
  .brand-mark { width:40px; height:40px; }
  main { padding:23px 15px 40px; }
  .page-head { align-items:flex-start; flex-direction:column; margin-bottom:18px; }
  .grid-2,.management { grid-template-columns:1fr; }
  .stats-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .stats-grid { grid-template-columns:1fr; }
  .manage-section-head { align-items:flex-start; flex-direction:column; }
  .medication-section-title { align-items:flex-start; flex-direction:column; }
  .medication-section-title .nowrap-action { align-self:flex-start; }
  .manage-tabs button { min-width:0; }
  .manage-med-filters { grid-template-columns:1fr; gap:0; }
  .medication-grid { grid-template-columns:1fr; }
  .form-grid { grid-template-columns:1fr; gap:0; }
  .history-tabs { max-width:none; }
  .history-suggestions { grid-template-columns:1fr; }
  .history-suggestions button { align-items:flex-start; flex-direction:column; gap:3px; }
  .history-episodes button { align-items:flex-start; }
  .field.full { grid-column:auto; }
  .metric-row { grid-template-columns:repeat(3,1fr); }
  .metric span { font-size:11px; }
  .hero { padding:23px; }
  .detail-summary { grid-template-columns:1fr 1fr; }
  .med-row { grid-template-columns:1fr; }
  .med-fields { grid-template-columns:1fr 1fr; }
  .med-fields .field:last-child { grid-column:1/-1; }
  .attachment-upload { grid-template-columns:1fr 1fr; gap:10px; }
  .attachment-card { grid-template-columns:72px minmax(0,1fr); }
  .attachment-card img { width:72px; height:72px; }
  .attachment-card .row-actions { gap:6px; }
  .attachment-card .btn.small { min-height:32px; padding:0 10px; }
  .med-row .remove-med { justify-self:end; }
  .category-list { grid-template-columns:repeat(2,1fr); }
  .item-row { align-items:flex-start; flex-direction:column; }
  .item-row .row-actions { width:100%; }
  .bottom-nav { bottom:9px; }
}

@media (max-width: 410px) {
  .login-card { padding:27px 21px; }
  .metric { padding:11px 8px; }
  .metric strong { font-size:18px; }
  .hero-actions .btn { width:100%; }
  .segmented { grid-template-columns:1fr; }
  .staged-files { grid-template-columns:1fr 1fr; }
}
