:root {
  color-scheme: light;
  --ink: #172f42;
  --muted: #718394;
  --line: #e7edf1;
  --surface: #fff;
  --wash: #f5f8fc;
  --blue: #2778a8;
  --blue-dark: #175b83;
  --mint: #28a28d;
  --red: #c94f57;
  --amber: #be8124;
  --shadow: 0 12px 35px rgba(32, 63, 84, .055);
  font-family: "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--wash);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--wash); }
button, input, select, textarea { font: inherit; }
button, summary, .file-button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, .file-button:focus-within { outline: 3px solid rgba(39, 120, 168, .35); outline-offset: 3px; }
a { color: var(--blue-dark); }
[hidden] { display: none !important; }
.skip-link { position: absolute; top: -50px; left: 16px; z-index: 20; padding: 10px 14px; background: white; border-radius: 8px; }
.skip-link:focus { top: 12px; }
.topbar { height: 72px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(calc((100vw - 1180px) / 2), 32px); background: rgba(255,255,255,.82); border-bottom: 1px solid #eaf0f3; }
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-family: "Segoe UI", sans-serif; font-size: 15px; letter-spacing: -.3px; }
.brand strong { font-weight: 800; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 10px; color: white; background: var(--mint); font-weight: 700; font-size: 24px; line-height: 1; }
.topbar-actions { display: flex; align-items: center; gap: 23px; }
.privacy-note { color: #647d8e; font-size: 12px; display: inline-flex; align-items: center; gap: 8px; }
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: #42aa8d; box-shadow: 0 0 0 3px #e6f5f0; }
.page-shell { max-width: 1180px; margin: 0 auto; padding: 45px 28px 22px; }
.welcome-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 27px; }
.eyebrow { margin: 0 0 9px; color: #6d8b9b; font-size: 10px; letter-spacing: 1.65px; font-weight: 700; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { font-family: "Segoe UI", sans-serif; }
h1 { margin-bottom: 8px; font-size: clamp(29px, 3.2vw, 39px); line-height: 1.18; letter-spacing: -1.6px; font-weight: 700; }
h1 span { color: var(--blue); }
.intro { margin: 0; color: var(--muted); font-size: 14px; }
.welcome-icon { width: 73px; height: 73px; display: grid; place-items: center; color: var(--mint); background: #e9f6f2; border-radius: 24px; transform: rotate(4deg); }
.welcome-icon svg { width: 48px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 41px; border: 1px solid transparent; border-radius: 9px; padding: 0 15px; cursor: pointer; font-size: 12px; font-weight: 700; text-decoration: none; transition: background .16s, border-color .16s, transform .16s; }
.button:active { transform: translateY(1px); }
.button-primary { background: var(--blue); color: white; box-shadow: 0 5px 12px rgba(39,120,168,.16); }
.button-primary:hover { background: var(--blue-dark); }
.button-quiet { color: #3d647d; border-color: #e2eaf0; background: white; }
.button-quiet:hover, .button-outline:hover { background: #f3f8fa; border-color: #c9dbe5; }
.button-outline { min-height: 36px; border-color: #dce6ec; background: white; color: #43667c; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 19px; }
.summary-card { min-height: 124px; padding: 19px 21px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.summary-primary { background: linear-gradient(120deg, #eaf7f3, #f8fbfb 87%); border-color: #dcefe9; }
.summary-heading { display: flex; justify-content: space-between; align-items: center; color: #698092; font-size: 12px; font-weight: 600; }
.summary-icon { font-size: 17px; color: #63a995; }
.summary-value { margin: 10px 0 3px; font-family: "Segoe UI", sans-serif; font-size: 27px; font-weight: 700; letter-spacing: -.8px; }
.summary-value small { color: #7d929e; font-size: 19px; font-weight: 500; }
.summary-meta { color: #8394a0; font-size: 11px; }
.content-grid { display: grid; grid-template-columns: minmax(330px, .87fr) minmax(440px, 1.35fr); gap: 18px; margin-bottom: 19px; align-items: stretch; }
.panel { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.entry-panel { padding: 22px 23px 15px; }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.panel-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.55px; }
.panel-heading .eyebrow { margin-bottom: 5px; }
.form-step { color: #b4c6cf; font-family: "Segoe UI", sans-serif; font-size: 12px; font-weight: 700; }
.field-label { display: block; margin: 16px 0 6px; color: #50697a; font-size: 11px; font-weight: 700; }
.field-label span { color: #93a2ac; font-weight: 400; }
.text-input { width: 100%; min-height: 40px; padding: 9px 11px; border: 1px solid #e2e9ed; border-radius: 8px; background: #fcfdfe; color: var(--ink); font-size: 12px; }
.text-input::placeholder { color: #a7b3bb; }
.text-input:focus { border-color: #78b1c9; outline: 3px solid rgba(39,120,168,.1); }
.field-hint { margin: 5px 0 0; color: #8a9aa4; font-size: 10px; line-height: 1.4; }
.measurement-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.measurement-fields .field-label { margin-top: 14px; }
.unit-input { position: relative; }
.unit-input .text-input { padding-right: 47px; }
.unit-input > span { position: absolute; right: 9px; top: 50%; transform: translateY(-50%); color: #9aa8b1; font-size: 9px; pointer-events: none; }
.notes-input { resize: vertical; min-height: 55px; }
.form-actions { display: flex; gap: 9px; margin-top: 15px; }
.form-actions .button-primary { min-width: 145px; }
.form-divider { height: 1px; margin: 18px 0 13px; background: #edf1f3; }
.photo-import summary { color: #4f7487; cursor: pointer; font-size: 11px; font-weight: 700; }
.photo-import summary span { margin-right: 5px; color: var(--mint); }
.photo-import p { margin: 10px 0; color: #82929d; font-size: 11px; line-height: 1.55; }
.photo-import code { color: #4d6978; font-size: 10px; }
.file-button { cursor: pointer; }
.small-status { overflow-wrap: anywhere; }
.ocr-text-details { margin-top: 12px; }
.ocr-text-details summary { color: #4f7487; cursor: pointer; font-size: 10px; font-weight: 700; }
.ocr-text-details pre { max-height: 180px; overflow: auto; padding: 10px; border-radius: 7px; background: #f5f8fa; color: #5c707d; font: 10px/1.5 Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.ocr-review { margin-top: 14px; padding-top: 12px; border-top: 1px solid #e8eef1; }
.ocr-review h3 { margin: 0 0 4px; font-size: 13px; }
.ocr-review > p { margin: 0 0 10px; color: #82929d; font-size: 10px; line-height: 1.45; }
.ocr-table { min-width: 700px; }
.ocr-table th, .ocr-table td { padding: 7px 5px; }
.ocr-input { min-width: 78px; min-height: 35px; padding: 6px; font-size: 10px; }
.ocr-table td:first-child { text-align: center; }
.ocr-table input[type="checkbox"] { accent-color: var(--blue); }
.ocr-review > .button { margin-top: 10px; }
.form-error { margin: 10px 0 0; color: #b83943; font-size: 11px; line-height: 1.4; }
.right-column { display: grid; grid-template-rows: minmax(245px, 1fr) auto; gap: 14px; }
.chart-panel { min-height: 244px; padding: 21px 22px 14px; }
.chart-heading { align-items: center; }
.chart-key { display: flex; align-items: center; gap: 6px; color: #81919b; font-size: 9px; }
.chart-key i { width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; }
.key-systolic { background: #4b9ab2; }
.key-diastolic { background: #72c4ac; }
.chart-wrap { position: relative; height: 154px; margin-top: 8px; }
#reading-chart { display: block; width: 100%; height: 100%; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: #9aa8b0; font-size: 11px; pointer-events: none; }
.chart-caption { margin: 0; color: #9aa8b0; font-size: 9px; }
.guidance-card { display: flex; gap: 12px; padding: 15px 18px; border: 1px solid #dfece8; border-radius: 13px; background: #f0f8f5; }
.guidance-mark { flex: 0 0 21px; width: 21px; height: 21px; display: grid; place-items: center; border-radius: 50%; background: #d9eee7; color: #328d7b; font-family: serif; font-weight: 700; }
.guidance-card h3 { margin: 1px 0 5px; font-size: 12px; }
.guidance-card p { margin: 0 0 7px; color: #718992; font-size: 10px; line-height: 1.5; }
.guidance-card a { color: #358574; font-size: 10px; font-weight: 700; text-decoration: none; }
.guidance-card a:hover { text-decoration: underline; }
.history-panel { padding: 21px 22px 13px; }
.history-heading { align-items: center; margin-bottom: 16px; }
.history-tools { display: flex; align-items: center; gap: 9px; }
.search-wrap { display: flex; align-items: center; gap: 7px; width: 175px; min-height: 36px; padding: 0 9px; border: 1px solid #e3eaee; border-radius: 8px; color: #8195a2; }
.search-wrap input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 11px; }
.search-wrap input::placeholder { color: #9cabb4; }
.search-wrap:focus-within { border-color: #78b1c9; outline: 3px solid rgba(39,120,168,.1); }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { background: #f7f9fa; }
th { padding: 10px 9px; color: #82929d; font-size: 9px; font-weight: 700; white-space: nowrap; }
th:first-child { border-radius: 7px 0 0 7px; }
th:last-child { border-radius: 0 7px 7px 0; }
td { padding: 12px 9px; border-bottom: 1px solid #eff2f4; color: #536d7d; font-size: 10px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
.reading-value { color: var(--ink); font-weight: 700; white-space: nowrap; }
.reading-value span { color: #9aa9b2; font-weight: 400; }
.category { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 20px; font-size: 9px; font-weight: 700; white-space: nowrap; }
.category-normal { color: #36816e; background: #eaf6f0; }
.category-elevated { color: #9d7425; background: #fbf3dd; }
.category-stage-1 { color: #a66c24; background: #fff0dd; }
.category-stage-2 { color: #b8563b; background: #ffebe4; }
.category-crisis { color: #a8333b; background: #fde7e9; }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; white-space: nowrap; }
.icon-button { min-width: 29px; min-height: 29px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: #728997; cursor: pointer; font-size: 11px; }
.icon-button:hover { border-color: #e2eaee; background: #f7f9fa; }
.icon-button.delete:hover { color: #b73942; background: #fff3f3; }
.history-empty { min-height: 130px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #9aa8b0; font-size: 10px; }
.empty-icon { color: #6eb6a1; font-size: 21px; }
.history-empty strong { color: #617989; font-size: 12px; }
.table-footnote { margin: 9px 0 0; color: #9aa8b0; font-size: 9px; line-height: 1.45; }
.urgent-notice { display: grid; gap: 5px; margin-top: 17px; padding: 14px 17px; border: 1px solid #efb5b7; border-radius: 10px; background: #fff1f1; color: #7e2930; font-size: 12px; line-height: 1.5; }
.urgent-notice strong { font-size: 13px; }
.app-message { margin: 0 0 15px; padding: 11px 14px; border: 1px solid #d1e8dd; border-radius: 9px; background: #f0f8f3; color: #2e745d; font-size: 12px; }
.app-message.error { border-color: #efc8c8; background: #fff5f5; color: #a33b43; }
.footer { display: flex; justify-content: space-between; gap: 12px; padding: 22px 2px 6px; color: #99a6ae; font-size: 9px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 760px) {
  .topbar { height: 62px; padding: 0 18px; }
  .topbar-actions { gap: 10px; }
  .privacy-note { font-size: 0; }
  .privacy-dot { width: 8px; height: 8px; }
  .page-shell { padding: 30px 17px 18px; }
  .welcome-icon { width: 54px; height: 54px; border-radius: 18px; }
  .welcome-icon svg { width: 37px; }
  .summary-grid { gap: 9px; }
  .summary-card { min-height: 108px; padding: 14px 12px; }
  .summary-heading { font-size: 10px; }
  .summary-value { font-size: 22px; }
  .summary-value small { font-size: 15px; }
  .content-grid { grid-template-columns: 1fr; }
  .right-column { grid-template-rows: auto auto; }
}
@media (max-width: 480px) {
  .welcome-row { align-items: flex-start; }
  .welcome-icon { display: none; }
  .intro { max-width: 330px; line-height: 1.5; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .summary-card:last-child { grid-column: 1 / -1; min-height: 85px; }
  .entry-panel, .chart-panel, .history-panel { padding-left: 15px; padding-right: 15px; }
  .history-heading { align-items: flex-start; flex-direction: column; gap: 13px; }
  .history-tools { width: 100%; }
  .search-wrap { flex: 1; }
  .table-scroll { margin: 0 -3px; }
  th, td { padding-left: 7px; padding-right: 7px; }
  .footer { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

@media print {
  @page { margin: 12mm; }
  body { min-width: 0; background: white; color: #172f42; }
  .topbar, .entry-panel, .history-tools, .row-actions, .footer, .app-message, .skip-link { display: none !important; }
  .page-shell { max-width: none; padding: 0; }
  .welcome-row { margin: 0 0 15px; }
  .welcome-icon { display: none; }
  .summary-grid { gap: 8px; }
  .summary-card, .panel, .guidance-card { box-shadow: none; break-inside: avoid; }
  .content-grid { grid-template-columns: 1fr 1.4fr; }
  .right-column { grid-template-rows: auto auto; }
  .chart-panel, .history-panel { padding: 13px; }
  .history-panel { margin-top: 10px; }
  .table-scroll { overflow: visible; }
  table { width: 100%; }
  th, td { padding: 6px; font-size: 8px; }
  .urgent-notice { display: grid !important; }
  a { color: inherit; text-decoration: none; }
}
