:root {
  --bg: #F7F4EF;
  --surface: #FFFFFF;
  --surface-2: #F2EDE5;
  --ink: #23201B;
  --muted: #6F685E;
  --line: #E7E0D5;
  --accent: #EE5F33;
  --accent-ink: #FFFFFF;
  --accent-soft: #FFE5DA;
  --c-vac: #0E9384;
  --c-heat: #D93F75;
  --c-med: #7653DA;
  --c-feed: #C98410;
  --c-test: #2A72D4;
  --c-allergy: #D23C3C;
  --c-weight: #3F8F24;
  --c-doc: #67707E;
  --ok: #24935A;
  --warn: #C27C06;
  --bad: #D23C3C;
  --shadow: 0 1px 2px rgba(60, 40, 20, .05), 0 10px 30px -14px rgba(60, 40, 20, .22);
  --shadow-lg: 0 20px 60px -20px rgba(40, 25, 10, .45);
  --radius: 22px;
  --font-display: "Nunito", "Manrope", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabbar-h: 68px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13110E; --surface: #1D1A16; --surface-2: #27231D; --ink: #F4EFE8; --muted: #A9A196; --line: #353029;
    --accent: #FF7A50; --accent-ink: #1A0E08; --accent-soft: #3A2218;
    --c-vac: #2BC3B0; --c-heat: #F2709E; --c-med: #A48BFF; --c-feed: #F0B040; --c-test: #6AA8FF; --c-allergy: #FF7272;
    --c-weight: #7CCB5C; --c-doc: #A3ABB8; --ok: #4CC983; --warn: #F0B040; --bad: #FF7272;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
    --shadow-lg: 0 20px 60px -20px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #13110E; --surface: #1D1A16; --surface-2: #27231D; --ink: #F4EFE8; --muted: #A9A196; --line: #353029;
  --accent: #FF7A50; --accent-ink: #1A0E08; --accent-soft: #3A2218;
  --c-vac: #2BC3B0; --c-heat: #F2709E; --c-med: #A48BFF; --c-feed: #F0B040; --c-test: #6AA8FF; --c-allergy: #FF7272;
  --c-weight: #7CCB5C; --c-doc: #A3ABB8; --ok: #4CC983; --warn: #F0B040; --bad: #FF7272;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px -14px rgba(0, 0, 0, .6);
  --shadow-lg: 0 20px 60px -20px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body);
  font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
img { max-width: 100%; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; }
input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 800; }
h3 { font-size: 16px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 20px; }
.between { justify-content: space-between; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.center { text-align: center; }
:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 10px; }

/* ---------- layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: calc(10px + var(--safe-t)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
}
.view { padding: 8px 16px calc(var(--tabbar-h) + var(--safe-b) + 28px); max-width: 720px; margin: 0 auto; }
.view-head { display: flex; align-items: center; gap: 12px; margin: 6px 0 16px; }
.view-head h1 { flex: 1; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tabbar-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.5) blur(18px); -webkit-backdrop-filter: saturate(1.5) blur(18px);
  border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 6px 0; }
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--accent); }
.tab-fab { display: grid; place-items: center; }
.tab-fab span {
  width: 58px; height: 58px; border-radius: 20px; display: grid; place-items: center; margin-top: -26px;
  background: linear-gradient(145deg, #FF8A5B, var(--accent)); color: #fff;
  box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--accent) 70%, transparent), 0 0 0 5px var(--bg);
  transition: transform .15s;
}
.tab-fab:active span { transform: scale(.94); }
.tab-fab svg { width: 28px; height: 28px; }

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 272px 1fr; }
  .topbar, .tabbar { display: none; }
  .sidebar {
    display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh;
    padding: 24px 18px; border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto;
  }
  .view { padding: 32px 40px 60px; max-width: 1120px; margin: 0; width: 100%; }
  .view-head { margin-top: 0; }
  h1 { font-size: 30px; }
}

.logo { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 22px; }
.logo-mark { width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(145deg, #FF8A5B, var(--accent)); display: grid; place-items: center; color: #fff; }
.logo-mark svg { width: 22px; height: 22px; }
.side-label { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 8px 6px; }
.side-pets { display: flex; flex-direction: column; gap: 4px; }
.side-pet { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 14px; text-align: left; width: 100%; }
.side-pet:hover { background: var(--surface-2); }
.side-pet.active { background: var(--accent-soft); }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-weight: 600; color: var(--ink); text-decoration: none; width: 100%; text-align: left; }
.side-link svg { width: 20px; height: 20px; color: var(--muted); }
.side-link:hover { background: var(--surface-2); }
.side-link.active { background: var(--surface-2); color: var(--accent); }
.side-link.active svg { color: var(--accent); }
.side-foot { margin-top: auto; }

/* ---------- avatar ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 14px; flex: none; overflow: hidden; display: grid; place-items: center;
  font-size: 22px; background: var(--accent-soft);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.lg { width: 84px; height: 84px; border-radius: 26px; font-size: 44px; }
.avatar.sm { width: 32px; height: 32px; border-radius: 11px; font-size: 18px; }
.pet-switch { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 16px; min-width: 0; }
.pet-switch:active { background: var(--surface-2); }
.pet-switch b { font-family: var(--font-display); font-size: 18px; font-weight: 800; }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; border: 1px solid var(--line); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { flex: 1; }
.link-btn { color: var(--accent); font-weight: 700; font-size: 14px; }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 900px) {
  .grid-2 { grid-template-columns: 1fr 1fr; align-items: start; }
  .span-2 { grid-column: 1 / -1; }
}

.hero {
  position: relative; overflow: hidden; color: #fff; padding: 20px;
  background: radial-gradient(120% 140% at 100% 0%, #FFB37A 0%, #FF7A4D 45%, #E2492A 100%);
}
:root[data-theme="dark"] .hero { background: radial-gradient(120% 140% at 100% 0%, #B9562F 0%, #8E3418 55%, #5C200E 100%); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hero { background: radial-gradient(120% 140% at 100% 0%, #B9562F 0%, #8E3418 55%, #5C200E 100%); } }
.hero .avatar { background: rgba(255, 255, 255, .22); box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
.hero h1 { color: #fff; }
.hero-paw { position: absolute; right: -20px; bottom: -30px; width: 170px; height: 170px; opacity: .13; color: #fff; pointer-events: none; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.hero-stat { background: rgba(255, 255, 255, .16); border-radius: 14px; padding: 10px 12px; }
.hero-stat b { display: block; font-family: var(--font-display); font-size: 18px; font-weight: 800; line-height: 1.2; }
.hero-stat span { font-size: 12px; opacity: .85; }
.hero .icon-btn { background: rgba(255, 255, 255, .2); color: #fff; }
.chip-light { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px; background: rgba(255, 255, 255, .2); font-size: 13px; font-weight: 600; }

.scan-card {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  background: var(--surface); border: 1.5px dashed color-mix(in srgb, var(--accent) 45%, var(--line));
}
.scan-card .bubble { width: 52px; height: 52px; border-radius: 18px; }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 600px) and (max-width: 899px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile {
  --c: var(--accent); text-align: left; background: var(--surface); border-radius: 20px; padding: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; min-height: 120px; transition: transform .15s;
}
.tile:active { transform: scale(.98); }
.tile .bubble { width: 40px; height: 40px; border-radius: 14px; font-size: 20px; }
.tile b { font-family: var(--font-display); font-weight: 800; font-size: 16px; }
.tile small { color: var(--muted); font-size: 12.5px; line-height: 1.3; display: block; }

.bubble {
  --c: var(--accent); display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 14px;
  background: color-mix(in srgb, var(--c) 15%, var(--surface)); color: var(--c); font-size: 20px;
}
.bubble svg { width: 22px; height: 22px; }
.c-vac { --c: var(--c-vac); } .c-heat { --c: var(--c-heat); } .c-med { --c: var(--c-med); } .c-feed { --c: var(--c-feed); }
.c-test { --c: var(--c-test); } .c-allergy { --c: var(--c-allergy); } .c-weight { --c: var(--c-weight); } .c-doc { --c: var(--c-doc); }
.c-accent { --c: var(--accent); }

/* ---------- list items ---------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 4px; text-align: left; width: 100%; border-radius: 14px; }
.list > .item + .item { border-top: 1px solid var(--line); border-radius: 0; }
button.item:hover { background: color-mix(in srgb, var(--surface-2) 50%, transparent); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-weight: 700; display: block; }
button.item-main { display: block; }
.item-sub { font-size: 13px; color: var(--muted); display: block; }
.stack > .pill { align-self: flex-start; }
.item-meta { text-align: right; font-size: 13px; color: var(--muted); flex: none; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); }
.pill.ok { background: color-mix(in srgb, var(--ok) 14%, var(--surface)); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 16%, var(--surface)); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 14%, var(--surface)); color: var(--bad); }
.pill.info { background: color-mix(in srgb, var(--c-test) 14%, var(--surface)); color: var(--c-test); }
.pill.heat { background: color-mix(in srgb, var(--c-heat) 14%, var(--surface)); color: var(--c-heat); }

.alert { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: 18px; background: color-mix(in srgb, var(--bad) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--bad) 25%, transparent); }
.alert.warn { background: color-mix(in srgb, var(--warn) 10%, var(--surface)); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.alert.info { background: color-mix(in srgb, var(--c-test) 9%, var(--surface)); border-color: color-mix(in srgb, var(--c-test) 25%, transparent); }
.alert.heat { background: color-mix(in srgb, var(--c-heat) 10%, var(--surface)); border-color: color-mix(in srgb, var(--c-heat) 25%, transparent); }
.alert-icon { font-size: 20px; line-height: 1.2; }

.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: var(--c, var(--accent)); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 46px; padding: 0 18px; border-radius: 15px;
  font-weight: 700; background: var(--surface-2); color: var(--ink); transition: transform .12s, filter .12s; white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 20px -10px color-mix(in srgb, var(--accent) 80%, transparent); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-danger { background: color-mix(in srgb, var(--bad) 12%, var(--surface)); color: var(--bad); }
.btn-ghost { background: transparent; }
.btn-sm { height: 36px; padding: 0 12px; border-radius: 12px; font-size: 14px; }
.btn-block { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; background: var(--surface-2); flex: none; }
.icon-btn svg { width: 20px; height: 20px; }
.add-btn { width: 44px; height: 44px; border-radius: 15px; display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); flex: none; box-shadow: 0 8px 20px -10px var(--accent); }
.add-btn svg { width: 22px; height: 22px; }

/* ---------- segmented ---------- */
.seg { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 15px; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button, .seg label { flex: 1 0 auto; padding: 8px 12px; border-radius: 11px; font-weight: 700; font-size: 14px; color: var(--muted); text-align: center; cursor: pointer; white-space: nowrap; }
.seg .on, .seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.seg label { padding: 0; display: flex; }
.seg label span { flex: 1; padding: 8px 12px; border-radius: 11px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg.sticky { position: sticky; top: calc(60px + var(--safe-t)); z-index: 5; box-shadow: 0 0 0 6px var(--bg); }
@media (min-width: 900px) { .seg.sticky { top: 0; } }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; }
.fgrid > .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 700; color: var(--muted); }
.input, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; min-height: 46px; padding: 10px 13px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  outline: none; transition: border-color .15s; -webkit-appearance: none; appearance: none; font-size: 16px;
}
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
.field textarea { min-height: 84px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field input[type=date] { min-width: 0; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; padding: 6px 0; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); background: var(--surface-2); padding: 10px 12px; border-radius: 12px; }
.warnbox { font-size: 13.5px; background: color-mix(in srgb, var(--bad) 10%, var(--surface)); color: var(--bad); padding: 10px 12px; border-radius: 12px; font-weight: 600; }
.photo-pick { display: flex; align-items: center; gap: 14px; }

.li-table { display: flex; flex-direction: column; gap: 8px; }
.li-row { display: grid; grid-template-columns: 1.6fr 1fr .9fr 32px; gap: 6px; align-items: center; }
.li-row .li-range { display: flex; gap: 4px; }
.li-row input { min-height: 40px !important; padding: 8px 9px !important; font-size: 15px !important; border-radius: 11px !important; }
.li-row .li-unit { grid-column: 1; }
.li-head { font-size: 11.5px; color: var(--muted); font-weight: 700; }
.li-del { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: var(--muted); }

/* ---------- sheets ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20, 12, 5, .45); opacity: 0; transition: opacity .25s; }
.sheet {
  position: relative; width: 100%; max-height: 92vh; max-height: 92dvh; background: var(--bg); border-radius: 26px 26px 0 0;
  display: flex; flex-direction: column; transform: translateY(100%); transition: transform .3s cubic-bezier(.2, .9, .3, 1);
  box-shadow: var(--shadow-lg);
}
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.open .sheet-backdrop { opacity: 1; }
.sheet-grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 8px auto 0; flex: none; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 10px 18px 8px; flex: none; }
.sheet-head h2 { flex: 1; }
.sheet-body { overflow-y: auto; padding: 6px 18px 18px; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 10px; padding: 12px 18px calc(12px + var(--safe-b)); border-top: 1px solid var(--line); flex: none; background: var(--bg); border-radius: 0 0 26px 26px; }
.sheet-foot .btn { flex: 1; }
@media (min-width: 700px) {
  .sheet-wrap { align-items: center; padding: 24px; }
  .sheet { max-width: 560px; border-radius: 26px; transform: translateY(24px) scale(.97); opacity: 0; transition: transform .25s, opacity .2s; max-height: 88vh; }
  .sheet.wide { max-width: 760px; }
  .sheet-wrap.open .sheet { opacity: 1; }
  .sheet-grab { display: none; }
  .sheet-head { padding-top: 18px; }
}

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 36px); transform: translate(-50%, 20px); z-index: 200;
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 16px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: all .25s; display: flex; gap: 14px; align-items: center; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { color: var(--accent); font-weight: 800; }
@media (min-width: 900px) { .toast { bottom: 28px; left: calc(50% + 136px); } }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-head h2 { flex: 1; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal-dow { text-align: center; font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 4px 0; }
.cal-day {
  position: relative; aspect-ratio: 1 / 1.05; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding-top: 6px; font-weight: 700; font-size: 14px; min-height: 42px;
}
.cal-day.out { color: color-mix(in srgb, var(--muted) 55%, transparent); }
.cal-day.today .num { background: var(--accent); color: var(--accent-ink); }
.cal-day .num { width: 28px; height: 28px; border-radius: 10px; display: grid; place-items: center; position: relative; z-index: 1; }
.cal-day.sel { box-shadow: inset 0 0 0 2px var(--ink); }
.cal-day.heat { background: color-mix(in srgb, var(--c-heat) 20%, transparent); }
.cal-day.heat-pred { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c-heat) 16%, transparent) 0 5px, transparent 5px 10px); }
.cal-day.fertile { background: color-mix(in srgb, var(--c-heat) 38%, transparent); }
.cal-day.fertile.heat-pred { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c-heat) 34%, transparent) 0 5px, color-mix(in srgb, var(--c-heat) 10%, transparent) 5px 10px); }
.cal-dots { display: flex; gap: 3px; margin-top: auto; margin-bottom: 6px; height: 7px; }
.cal-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.cal-dots i.ring { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }
.cal-medline { position: absolute; left: 4px; right: 4px; bottom: 2px; height: 3px; border-radius: 3px; background: var(--c-med); opacity: .7; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12.5px; color: var(--muted); margin-top: 14px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); display: inline-block; }
.legend i.ring { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }
.legend i.band { width: 16px; height: 10px; border-radius: 4px; background: color-mix(in srgb, var(--c-heat) 22%, transparent); }
.legend i.band.pred { background: repeating-linear-gradient(135deg, color-mix(in srgb, var(--c-heat) 30%, transparent) 0 3px, transparent 3px 6px); }
.legend i.band.fert { background: color-mix(in srgb, var(--c-heat) 45%, transparent); }
.legend i.bar { width: 16px; height: 3px; border-radius: 3px; background: var(--c-med); }

/* ---------- heat ---------- */
.ring-wrap { position: relative; width: 150px; height: 150px; flex: none; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-wrap .ring-label { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; }
.ring-label b { font-family: var(--font-display); font-size: 34px; font-weight: 800; line-height: 1; display: block; }
.ring-label span { font-size: 12px; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { background: var(--surface-2); border-radius: 16px; padding: 12px; }
.stat b { font-family: var(--font-display); font-weight: 800; font-size: 20px; display: block; line-height: 1.2; }
.stat span { font-size: 12px; color: var(--muted); }

/* ---------- lab ---------- */
.lab-row { display: grid; grid-template-columns: minmax(0, 1.3fr) 92px minmax(96px, 1fr); gap: 12px; align-items: center; padding: 11px 2px; }
.lab-row + .lab-row { border-top: 1px solid var(--line); }
.lab-val { font-family: var(--font-display); font-weight: 800; font-size: 17px; text-align: right; white-space: nowrap; }
.lab-val small { font-family: var(--font-body); font-weight: 500; font-size: 11.5px; color: var(--muted); margin-left: 3px; }
.lab-val.high, .lab-val.low { color: var(--bad); }
.range { position: relative; height: 22px; }
.range .track { position: absolute; left: 0; right: 0; top: 9px; height: 4px; border-radius: 4px; background: var(--surface-2); }
.range .norm { position: absolute; top: 9px; height: 4px; border-radius: 4px; background: color-mix(in srgb, var(--ok) 55%, transparent); }
.range .mark { position: absolute; top: 4px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 2.5px var(--surface); }
.range .mark.high, .range .mark.low { background: var(--bad); }
.range-lbl { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--muted); margin-top: -2px; }

/* ---------- docs ---------- */
.doc-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 600px) { .doc-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1100px) { .doc-grid { grid-template-columns: repeat(4, 1fr); } }
.doc { background: var(--surface); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); text-align: left; display: flex; flex-direction: column; }
.doc-img { aspect-ratio: 4 / 3; background: var(--surface-2); display: grid; place-items: center; font-size: 34px; }
.doc-img img { width: 100%; height: 100%; object-fit: cover; }
.doc-cap { padding: 10px 12px; }
.doc-cap b { display: block; font-size: 14px; }
.viewer-img { border-radius: 16px; overflow: hidden; background: var(--surface-2); }
.viewer-img img { width: 100%; }
pre.ocr { white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 12.5px; background: var(--surface-2); padding: 12px; border-radius: 12px; max-height: 260px; overflow: auto; margin: 0; }

/* ---------- scan ---------- */
.scan-kinds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.scan-kind { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 6px; border-radius: 16px; background: var(--surface); border: 2px solid transparent; font-size: 12.5px; font-weight: 700; text-align: center; }
.scan-kind .e { font-size: 24px; }
.scan-kind.on { border-color: var(--accent); background: var(--accent-soft); }
.scan-progress { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 10px 0 20px; }
.scan-preview { position: relative; width: 100%; max-width: 320px; border-radius: 18px; overflow: hidden; }
.scan-preview img { width: 100%; }
.scan-preview::after {
  content: ""; position: absolute; left: 0; right: 0; height: 30%; top: -30%;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--accent) 45%, transparent), transparent);
  animation: scanline 1.8s ease-in-out infinite;
}
@keyframes scanline { to { top: 100%; } }
.review-block { background: var(--surface); border-radius: 18px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.review-item { display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; padding: 8px 0; }
.review-item + .review-item { border-top: 1px solid var(--line); }
.review-item > input[type=checkbox] { width: 22px; height: 22px; margin-top: 12px; accent-color: var(--accent); }
.review-item .fgrid { gap: 8px; }
.review-item .field input, .review-item .field select { min-height: 40px; padding: 8px 10px; font-size: 15px; border-radius: 11px; }

/* ---------- chart ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--font-body); }
.chart .line { fill: none; stroke: var(--c-weight); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: color-mix(in srgb, var(--c-weight) 12%, transparent); }
.chart .pt { fill: var(--c-weight); stroke: var(--surface); stroke-width: 2; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--bg); font-size: 12.5px; font-weight: 600; padding: 6px 9px; border-radius: 9px; transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; }

/* ---------- empty / welcome ---------- */
.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty .e { font-size: 42px; margin-bottom: 6px; }
.welcome { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.welcome-card { max-width: 460px; width: 100%; text-align: center; }
.welcome-art { width: 150px; height: 150px; margin: 0 auto 18px; border-radius: 44px; display: grid; place-items: center; color: #fff; background: radial-gradient(120% 140% at 100% 0%, #FFB37A 0%, #FF7A4D 50%, #E2492A 100%); box-shadow: 0 30px 60px -25px #E2492A; }
.feature-list { text-align: left; display: grid; gap: 10px; margin: 22px 0; }
.feature-list div { display: flex; gap: 12px; align-items: center; background: var(--surface); padding: 12px 14px; border-radius: 16px; box-shadow: var(--shadow); font-weight: 600; font-size: 14px; }

.section-title { display: flex; align-items: center; gap: 10px; margin: 4px 0 10px; }
.section-title h2 { flex: 1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 4px 0; }
.spin { width: 36px; height: 36px; border-radius: 50%; border: 3.5px solid var(--surface-2); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.bar { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; width: 100%; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }

/* ---------- режим без навигации (приветствие) ---------- */
.app.bare { display: block; }
.app.bare .sidebar, .app.bare .topbar, .app.bare .tabbar { display: none; }
.app.bare .view { padding: 0; max-width: none; }

.welcome-art svg { width: 84px; height: 84px; }

/* элементы сетки не должны растягиваться длинным текстом */
.grid-2 > *, .stack > *, .stack-lg > *, .tiles > * { min-width: 0; }
body { overflow-x: clip; }

.review-item > *, .review-block > * { min-width: 0; }
.li-row > * { min-width: 0; }
.li-row input, .li-range input { width: 100%; min-width: 0; }
.li-range > * { flex: 1 1 0; }

/* строка показателя: на телефоне — в две строки, на широком экране — в одну */
.li-row { grid-template-columns: 1fr 1fr 1fr 32px; }
.li-row .li-range { display: contents; }
.li-row [data-k=name] { grid-column: 1 / 4; }
.li-row .li-del { grid-column: 4; grid-row: 1; }
.li-row:not(.li-head) { padding-bottom: 8px; border-bottom: 1px dashed var(--line); }
.li-head { display: none; }
@media (min-width: 560px) {
  .li-row { grid-template-columns: 1.6fr 1fr .8fr .8fr 32px; }
  .li-row [data-k=name] { grid-column: auto; }
  .li-row .li-del { grid-column: 5; grid-row: auto; }
  .li-row:not(.li-head) { padding-bottom: 0; border-bottom: 0; }
  .li-head { display: grid; }
  .li-head > div:nth-child(3) { grid-column: span 2; }
}
