/* «Домашняя аптечка» — стили. Язык иконки серии: тёплая слоновая кость, бирюза группы «Быт»,
   тёмно-бирюзовый — для всего, что делает помощник. Тёмная тема — data-theme="dark". */

:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #f1eadb;
  --seg: #ece4d4;
  --text: #14302f;
  --muted: #5e6f6d;
  --line: #e7decd;
  --line-soft: #efe7d8;
  --ivory: #fff4df;
  --ivory-line: #eadfc8;
  --primary: #0b6f78;
  --primary-hover: #0a5e66;
  --primary-ink: #0a4f57;
  --primary-soft: #dcefee;
  --on-primary: #ffffff;
  --bad: #a3302a;
  --bad-ink: #7e2620;
  --bad-soft: #fbe3df;
  --warn: #8a5300;
  --warn-ink: #6e4300;
  --warn-soft: #fdebc8;
  --ai: #14302f;
  --ai-text: #f7f0e1;
  --ai-muted: #b9c9c6;
  --ai-line: rgba(255, 244, 223, .16);
  --ai-teal: #8fd9d3;
  --ai-rose: #f2b8a8;
  --ai-amber: #f3cf8e;
  --filled: #e9f5f3;
  --filled-line: #6fbfba;
  --shadow: 0 2px 8px rgba(80, 60, 20, .05);
  --shadow-md: 0 6px 18px rgba(80, 60, 20, .08);
  --shadow-lg: 0 18px 50px rgba(40, 30, 10, .22);
  --radius: 20px;
  --radius-sm: 14px;
  --tabbar-h: 76px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0f1716;
  --surface: #172220;
  --surface-2: #1f2c2a;
  --seg: #1b2725;
  --text: #e9f0ed;
  --muted: #9cb0ac;
  --line: #2a3a37;
  --line-soft: #233230;
  --ivory: #23302d;
  --ivory-line: #33443f;
  --primary: #3fb8b2;
  --primary-hover: #57c9c3;
  --primary-ink: #8fd9d3;
  --primary-soft: #133b3b;
  --on-primary: #06201f;
  --bad: #ff8a7e;
  --bad-ink: #ffb2a8;
  --bad-soft: #3a1e1b;
  --warn: #f3b44a;
  --warn-ink: #f6c773;
  --warn-soft: #362913;
  --ai: #102b2a;
  --ai-line: rgba(143, 217, 211, .18);
  --filled: #123533;
  --filled-line: #3fb8b2;
  --shadow: 0 2px 8px rgba(0, 0, 0, .25);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .3);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.45 'Golos Text', system-ui, -apple-system, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 24px);
  min-height: 100vh;
}
body.no-scroll { overflow: hidden; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { line-height: 1.2; margin: 0; }
p { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.bad-text { color: var(--bad); }
.grow { flex: 1; }

.mock-banner { background: var(--ai); color: var(--ai-text); text-align: center; font-size: 13px; padding: 6px 16px; }

/* ---------- разделы ---------- */

.view { max-width: 640px; margin: 0 auto; padding: calc(16px + env(safe-area-inset-top, 0px)) 20px 16px; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 8px 0 6px; }
.view-title { font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.view-lead { color: var(--muted); font-size: 14.5px; margin-bottom: 16px; }

.home-head { display: flex; align-items: center; gap: 12px; margin-top: 4px; }
.brand-mark { width: 44px; height: 44px; flex: none; border-radius: 12px; display: block; box-shadow: 0 4px 12px rgba(1, 85, 104, .22); }
.home-title { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.home-title h1 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.home-title p { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.add-btn {
  width: 48px; height: 48px; flex: none; border: 0; border-radius: 16px;
  background: var(--primary); color: var(--on-primary);
  display: grid; place-items: center; box-shadow: 0 6px 16px rgba(11, 111, 120, .3);
}
.add-btn:hover { background: var(--primary-hover); }
.add-btn .ico { width: 24px; height: 24px; stroke-width: 2.2; }

/* ---------- вкладки ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  padding: 8px max(12px, calc((100vw - 640px) / 2)) calc(8px + var(--safe-b));
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  backdrop-filter: saturate(1.3) blur(14px);
  -webkit-backdrop-filter: saturate(1.3) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  position: relative; flex: 1; max-width: 160px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 500;
}
.tabbar a .ico { width: 22px; height: 22px; stroke-width: 2; }
.tabbar a.active { color: var(--primary); font-weight: 600; }
.tab-icon { display: grid; place-items: center; width: 56px; height: 30px; border-radius: 15px; transition: background .2s; }
.tabbar a.active .tab-icon { background: var(--primary-soft); }
.tabbar .badge, .tabbar .badge-dot { position: absolute; top: -2px; left: calc(50% + 8px); }
.badge-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); border: 2px solid var(--surface); top: 2px !important; }
.tabbar .badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--primary); color: var(--on-primary); font-size: 11px; font-weight: 700; display: grid; place-items: center; }

/* ---------- кнопки и поля ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 15px; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; pointer-events: none; }
.btn .ico { width: 19px; height: 19px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); box-shadow: 0 6px 16px rgba(11, 111, 120, .22); }
.btn.primary:hover { background: var(--primary-hover); color: var(--on-primary); }
.btn.dark, .btn.ai { background: var(--ai); border-color: var(--ai); color: var(--ai-text); }
.btn.dark:hover, .btn.ai:hover { background: #1e403f; color: var(--ai-text); }
.btn.ivory { background: #fff4df; border-color: #fff4df; color: #14302f; }
.btn.ivory:hover { background: #fffaf0; color: #14302f; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger-ghost { background: transparent; border-color: currentColor; color: inherit; }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 12px; gap: 6px; }
.btn.sm .ico { width: 17px; height: 17px; }
.btn.xl { min-height: 54px; font-size: 16px; padding: 0 22px; border-radius: 16px; }
.btn.wide { width: 100%; }
.btn.icon-only { padding: 0; width: 50px; flex: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.icon-btn {
  display: grid; place-items: center; flex: none;
  width: 44px; height: 44px; border-radius: 14px; border: 0;
  background: transparent; color: var(--text);
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.sm { width: 36px; height: 36px; color: var(--muted); }
.icon-btn.sm .ico { width: 18px; height: 18px; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--primary); font-weight: 600; font-size: 14px; padding: 8px 0; }
.link-btn .ico { width: 17px; height: 17px; }

.field {
  width: 100%; min-height: 50px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 16px;
  transition: border-color .15s, box-shadow .15s, background .3s;
}
.field:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
.field.invalid { border-color: var(--bad); }
.field.ai-filled { background: var(--filled); border: 1.5px solid var(--filled-line); }
textarea.field { resize: vertical; min-height: 0; line-height: 1.45; }
select.field { appearance: none; 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: 34px; }
.lbl { display: block; font-size: 14px; font-weight: 600; margin: 16px 0 6px; }
.lbl .muted { font-weight: 400; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.form-error { color: var(--bad); font-size: 14px; margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; }
.with-btn { display: flex; gap: 8px; }
.with-btn .btn { flex: none; min-height: 50px; }

.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none;
  height: 38px; padding: 0 14px; border-radius: 19px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 13.5px; font-weight: 500;
}
.chip:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); }

.seg { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--seg); gap: 2px; }
.seg button, .seg label span {
  display: block; border: 0; background: transparent; color: var(--muted);
  padding: 6px 10px; border-radius: 9px; font-size: 13px; font-weight: 600; white-space: nowrap; text-align: center;
}
.seg button.active, .seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(80, 60, 20, .12); }
.seg.wide { display: flex; }
.seg.wide > * { flex: 1; }
.seg.wide button, .seg.radio label span { padding: 9px 10px; font-size: 14px; }
.seg.radio label { flex: 1; cursor: pointer; }
.seg.radio input { position: absolute; opacity: 0; pointer-events: none; }

/* ---------- значки ---------- */

.st {
  display: inline-flex; align-items: center; gap: 4px; flex: none;
  padding: 5px 9px; border-radius: 9px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
.st .ico { width: 13px; height: 13px; stroke-width: 2.6; }
.st.bad { background: var(--bad-soft); color: var(--bad); }
.st.warn { background: var(--warn-soft); color: var(--warn); }
.st.ok { background: var(--primary-soft); color: var(--primary-ink); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 8px; background: var(--surface-2); font-size: 13.5px; }

/* ---------- главный экран ---------- */

.search {
  position: relative; display: flex; align-items: center; gap: 8px;
  margin-top: 18px; height: 56px; padding: 0 6px 0 16px;
  border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.search:focus-within { border-color: var(--primary); }
.search-icon { display: grid; color: var(--muted); }
.search input { flex: 1; min-width: 0; height: 100%; border: 0; outline: none; background: transparent; font-size: 16px; }
.search input::-webkit-search-cancel-button { display: none; }
.search-clear { width: 36px; height: 36px; border: 0; background: none; color: var(--muted); display: grid; place-items: center; border-radius: 10px; flex: none; }
.search-clear .ico { width: 18px; height: 18px; }
.ask-chip {
  display: flex; align-items: center; gap: 6px; flex: none; height: 44px; padding: 0 14px;
  border: 0; border-radius: 13px; background: var(--ai); color: var(--ai-text);
  font-size: 14px; font-weight: 600;
}
.ask-chip .ico { width: 16px; height: 16px; stroke-width: 2; }
.ask-chip.strong { box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 35%, transparent); }
:root[data-theme="dark"] .ask-chip, :root[data-theme="dark"] .q-bubble, :root[data-theme="dark"] .ai-note, :root[data-theme="dark"] .btn.dark { border: 1px solid var(--ai-line); }

.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 16px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0;
  padding: 12px 11px; border-radius: 16px; border: 1px solid transparent; text-align: left;
  font-size: 13px; font-weight: 600; transition: box-shadow .15s, transform .05s;
}
.tile:active { transform: scale(.98); }
.tile .ico { width: 18px; height: 18px; stroke-width: 2.2; }
.tile b { font-size: 26px; font-weight: 700; line-height: 1; }
.tile span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tile.bad { background: var(--bad-soft); color: var(--bad); }
.tile.warn { background: var(--warn-soft); color: var(--warn); }
.tile.plain { background: var(--surface); border-color: var(--line); color: var(--text); }
.tile.plain .ico, .tile.plain span { color: var(--muted); }
.tile.zero { background: var(--surface); border-color: var(--line); color: var(--muted); opacity: .75; cursor: default; }
.tile[aria-pressed="true"] { box-shadow: 0 0 0 2px currentColor; }

.list-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 22px 0 10px; flex-wrap: wrap; }
.list-head h2 { font-size: 17px; font-weight: 700; display: flex; align-items: baseline; gap: 10px; }
.list-head .link-btn { padding: 0; font-size: 13.5px; }

.med-list { border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.med-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 14px; border: 0; border-bottom: 1px solid var(--line-soft);
  background: transparent; color: var(--text); text-align: left;
}
.med-row:last-child { border-bottom: 0; }
.med-row:hover { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.med-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.med-title { font-weight: 600; font-size: 16px; line-height: 1.25; }
.med-dose { font-weight: 500; color: var(--muted); font-size: 14px; white-space: nowrap; }
.med-purpose { font-size: 13.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.med-meta { font-size: 13px; color: var(--muted); }
.med-meta .low { color: var(--warn); font-weight: 600; }
.chev { color: var(--muted); width: 18px; height: 18px; }

.med-tile {
  width: 46px; height: 46px; flex: none; border-radius: 14px;
  background: var(--ivory); border: 1px solid var(--ivory-line); color: var(--primary);
  display: grid; place-items: center;
}
.med-tile .ico { width: 24px; height: 24px; stroke-width: 1.9; }
.med-tile.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }
.med-tile.sm { width: 44px; height: 44px; border-radius: 13px; }
.med-tile.sm .ico { width: 22px; height: 22px; }
.med-tile.xl { width: 72px; height: 72px; border-radius: 22px; box-shadow: var(--shadow-md); }
.med-tile.xl .ico { width: 36px; height: 36px; stroke-width: 1.7; }

.group-title { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--muted); margin: 18px 4px 8px; }
.group-title .ico { width: 16px; height: 16px; }
.group-title span { margin-left: auto; font-weight: 600; }
.loading { color: var(--muted); text-align: center; padding: 40px 0; }

.empty { text-align: center; padding: 36px 12px 12px; }
.empty-art { width: 96px; height: 96px; margin: 0 auto 18px; border-radius: 26px; display: block; box-shadow: 0 10px 30px rgba(1, 85, 104, .25); }
.empty h2 { font-size: 22px; margin-bottom: 8px; }
.empty p { color: var(--muted); max-width: 420px; margin: 0 auto 20px; }
.nothing { text-align: center; padding: 26px 12px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ---------- плашки ---------- */

.banner { display: flex; align-items: flex-start; gap: 10px; padding: 14px; border-radius: 16px; font-size: 14.5px; line-height: 1.4; margin-bottom: 12px; }
.banner > div { flex: 1; }
.banner .ico { margin-top: 1px; }
.banner .btn { flex: none; align-self: center; }
.banner.bad { background: var(--bad-soft); color: var(--bad-ink); }
.banner.bad .ico { color: var(--bad); }
.banner.warn { background: var(--warn-soft); color: var(--warn-ink); }
.banner.info { background: var(--primary-soft); color: var(--primary-ink); }
.banner a { color: inherit; font-weight: 700; }

.urgent { display: flex; gap: 12px; padding: 14px; border-radius: 16px; background: #a3302a; color: #fff; margin: 4px 0 10px; }
.urgent > .ico { width: 26px; height: 26px; margin-top: 2px; }
.urgent b { font-size: 16px; }
.urgent p { margin: 4px 0 10px; }
.urgent-btns { display: flex; gap: 8px; flex-wrap: wrap; }
.urgent .btn.danger { background: #fff; color: #a3302a; border-color: #fff; }
.urgent .btn.danger-ghost { border-color: #fff; color: #fff; }

.fineprint { display: flex; gap: 6px; align-items: flex-start; font-size: 12.5px; color: var(--muted); }
.fineprint .ico { width: 14px; height: 14px; margin-top: 2px; }

.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid color-mix(in srgb, currentColor 25%, transparent); border-top-color: currentColor; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.ai-wait { display: flex; align-items: center; gap: 10px; font-weight: 500; padding: 4px 0; color: var(--ai-teal); }
.ai-wait.light { color: var(--primary-ink); }

/* ---------- помощник ---------- */

.ask-form { display: flex; gap: 8px; align-items: flex-end; }
.ask-form textarea {
  flex: 1; min-width: 0; min-height: 56px; max-height: 160px; padding: 14px 16px; border-radius: 18px; resize: none;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); font-size: 16px; line-height: 1.4;
}
.ask-form textarea:focus { outline: none; border-color: var(--primary); }
.ask-form .btn { height: 56px; width: 56px; border-radius: 18px; }
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
@media (max-width: 600px) {
  .examples { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-left: -20px; margin-right: -20px; padding: 0 20px 4px; }
  .examples::-webkit-scrollbar { display: none; }
}

.qa { margin-top: 22px; display: flex; flex-direction: column; gap: 10px; }
.q-bubble { align-self: flex-end; max-width: 85%; padding: 12px 16px; border-radius: 20px 20px 6px 20px; background: var(--ai); color: var(--ai-text); font-size: 15.5px; line-height: 1.4; }
.answer { padding: 16px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md); display: flex; flex-direction: column; gap: 12px; }
.a-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--primary-ink); }
.a-label .ico { width: 16px; height: 16px; }
.a-label .icon-btn { margin: -10px -8px -10px auto; }
.answer .a { font-size: 16px; line-height: 1.45; }
.match-list { display: flex; flex-direction: column; gap: 8px; }
.match {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px;
  border-radius: 16px; border: 0; background: var(--bg); color: var(--text); text-align: left;
}
.match:hover { background: var(--surface-2); }
.match.bad { background: var(--bad-soft); }
.match.bad .med-title { color: var(--bad-ink); }
.match.bad .med-tile { background: var(--surface); }
.rel { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 7px; vertical-align: 1px; }
.rel.ok { background: var(--primary-soft); color: var(--primary-ink); }
.rel.maybe { background: var(--seg); color: var(--muted); }
.caution { display: flex; align-items: flex-start; gap: 5px; font-size: 13px; color: var(--warn); font-weight: 600; }
.match.bad .caution { color: var(--bad); }
.caution .ico { width: 14px; height: 14px; margin-top: 2px; stroke-width: 2.4; }
.doctor { display: flex; gap: 8px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--primary-soft); color: var(--primary-ink); font-size: 14px; line-height: 1.4; }
.doctor .ico { width: 18px; height: 18px; margin-top: 1px; }

/* ---------- слои: карточка и редактор ---------- */

.sheet-layer { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(20, 30, 28, .45); opacity: 0; transition: opacity .2s; }
.sheet {
  position: relative; width: 100%; max-width: 600px; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px);
  overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 26px 26px 0 0; box-shadow: var(--shadow-lg);
  transform: translateY(40px); opacity: 0; transition: transform .22s cubic-bezier(.2, .8, .2, 1), opacity .18s;
  padding-bottom: var(--safe-b);
}
.sheet-layer.open .sheet-backdrop { opacity: 1; }
.sheet-layer.open .sheet { transform: none; opacity: 1; }
@media (min-width: 720px) {
  .sheet-layer { align-items: center; padding: 24px; }
  .sheet { border-radius: 26px; max-height: calc(100vh - 48px); }
}
.sheet-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 8px; background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.sheet-title { flex: 1; min-width: 0; }
.sheet-title h2 { font-size: 20px; font-weight: 700; overflow-wrap: anywhere; }
.sheet-body { padding: 4px 20px 28px; }

.hero { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.hero h2 { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; overflow-wrap: anywhere; }
.hero p { font-size: 15px; color: var(--muted); margin-top: 4px; }

.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 16px; }
.fact { padding: 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.fact span { font-size: 12px; font-weight: 600; color: var(--muted); }
.fact b { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; line-height: 1.2; }
.fact small { font-size: 12px; font-weight: 600; }
.fact.ok { background: var(--primary-soft); border-color: transparent; }
.fact.ok span, .fact.ok small { color: var(--primary-hover); }
.fact.ok b { color: var(--primary-ink); }
.fact.warn { background: var(--warn-soft); border-color: transparent; }
.fact.warn span, .fact.warn small, .fact.warn b { color: var(--warn-ink); }
.fact.bad { background: var(--bad-soft); border-color: transparent; }
.fact.bad span, .fact.bad small, .fact.bad b { color: var(--bad); }

.actions { display: flex; flex-direction: column; gap: 8px; }
.actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.last-taken { display: flex; align-items: center; gap: 8px; margin: 12px 4px 4px; font-size: 13.5px; color: var(--muted); }
.last-taken:empty { display: none; }
.last-taken .ico { width: 16px; height: 16px; }
.actions + .last-taken + .banner { margin-top: 16px; }

.info { margin: 16px 0; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.info-row { display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border-top: 1px solid var(--line-soft); }
.info-row:first-child { border-top: 0; }
.info-row dt { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.info-row dd { margin: 0; font-size: 15px; overflow-wrap: anywhere; }

.ai-card { margin: 16px 0; padding: 16px; border-radius: 22px; background: var(--ai); color: var(--ai-text); display: flex; flex-direction: column; gap: 14px; }
:root[data-theme="dark"] .ai-card { border: 1px solid var(--ai-line); }
.ai-head { display: flex; align-items: center; gap: 10px; }
.ai-head h3 { font-size: 17px; font-weight: 700; }
.ai-mark { width: 32px; height: 32px; flex: none; border-radius: 10px; background: rgba(255, 244, 223, .12); color: var(--ai-teal); display: grid; place-items: center; }
.ai-mark .ico { width: 18px; height: 18px; stroke-width: 2; }
.ai-lead { color: var(--ai-muted); font-size: 14.5px; }
.ai-summary { font-size: 15.5px; line-height: 1.45; }
.ai-source { display: flex; gap: 8px; font-size: 13.5px; color: var(--ai-amber); }
.ai-source .ico { width: 16px; height: 16px; margin-top: 1px; }
.ai-sec h4 { font-size: 12.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; margin-bottom: 6px; }
.ai-sec.teal h4 { color: var(--ai-teal); }
.ai-sec.rose h4 { color: var(--ai-rose); }
.ai-sec.amber h4 { color: var(--ai-amber); }
.ai-sec.plain h4 { color: var(--ai-muted); }
.ai-sec ul { margin: 0; padding-left: 18px; }
.ai-sec li { margin: 4px 0; font-size: 15px; line-height: 1.45; }
.ai-card .fineprint { color: var(--ai-muted); }
.ai-card .link-btn { color: var(--ai-teal); align-self: flex-start; padding: 0; }
.ai-card .urgent { margin: 0; }
.mini-ask { display: flex; gap: 8px; }
.mini-ask .field { background: rgba(255, 244, 223, .08); border-color: var(--ai-line); color: var(--ai-text); min-height: 48px; }
.mini-ask .field::placeholder { color: var(--ai-muted); }
.mini-ask .field:focus { border-color: var(--ai-teal); box-shadow: none; }
.mini-ask .btn { height: 48px; width: 48px; min-height: 48px; }
.mini-answer { padding: 12px 14px; border-radius: 14px; background: rgba(255, 244, 223, .08); display: flex; flex-direction: column; gap: 4px; font-size: 15px; line-height: 1.45; }
.mini-answer b { color: var(--ai-teal); }
.mini-answer .err { color: var(--ai-rose); }

.raw-instr { margin: 16px 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.raw-instr summary { display: flex; align-items: center; gap: 8px; padding: 13px 16px; cursor: pointer; font-weight: 600; font-size: 14.5px; }
.raw-instr summary .ico { width: 18px; height: 18px; color: var(--primary); }
.instr-text { padding: 0 16px 16px; font-size: 14px; color: var(--muted); max-height: 420px; overflow-y: auto; }
.no-instr { margin: 12px 4px; }

.journal { margin-top: 20px; }
.journal h3 { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.events { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; }
.events li { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; padding: 12px 14px; border-top: 1px solid var(--line-soft); font-size: 14px; }
.events li:first-child { border-top: 0; }
.events time { grid-column: 1 / -1; color: var(--muted); font-size: 12.5px; }
.ev-kind { font-weight: 650; }
.ev-kind.k-take { color: var(--primary); }
.ev-kind.k-archive { color: var(--bad); }

/* редактор */
.ai-fill { margin-bottom: 4px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.thumb { position: relative; height: 104px; border-radius: 16px; overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; display: grid; place-items: center; padding: 0; }
.thumb button .ico { width: 15px; height: 15px; stroke-width: 2.4; }
.photo-add {
  height: 104px; border-radius: 16px; border: 1.5px dashed color-mix(in srgb, var(--muted) 55%, transparent);
  color: var(--primary); font-size: 13px; font-weight: 600; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; cursor: pointer;
}
.photo-add:hover { background: var(--surface); }
.photo-add .ico { width: 24px; height: 24px; }
.photo-grid:has(.thumb) + .hint { display: none; }
.ai-fill .btn.dark { margin-top: 10px; }
.ai-note { margin-top: 12px; padding: 14px; border-radius: 18px; background: var(--ai); color: var(--ai-text); display: flex; gap: 12px; align-items: flex-start; font-size: 14.5px; line-height: 1.4; }
.ai-note > span:last-child { display: flex; flex-direction: column; gap: 3px; color: var(--ai-muted); }
.ai-note b { color: var(--ai-text); font-size: 15px; }
.ai-note small { font-size: 13px; }
.ai-note .spinner { color: var(--ai-teal); margin-top: 2px; }
.more-fields { margin-top: 18px; border: 1px solid var(--line); border-radius: 14px; padding: 0 14px; background: var(--surface); }
.more-fields summary { padding: 13px 0; font-weight: 600; cursor: pointer; font-size: 15px; }
.more-fields[open] { padding-bottom: 14px; }
.more-fields .hint { margin: 0 0 4px; }
.editor-btns {
  position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end;
  margin: 24px -20px -28px; padding: 12px 20px calc(12px + var(--safe-b));
  background: color-mix(in srgb, var(--bg) 94%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.editor-btns .btn { flex: 1; min-height: 52px; }
.editor-btns .btn.primary { flex: 2; }
@media (max-width: 480px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 > :last-child { grid-column: 1 / -1; }
  .with-btn .btn span { display: none; }
  .with-btn .btn { width: 50px; padding: 0; }
}

/* всплывающие окна */
.popup-layer { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(20, 30, 28, .45); opacity: 0; transition: opacity .16s; }
.popup-layer.open { opacity: 1; }
.popup { width: 100%; max-width: 440px; max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--bg); border-radius: 22px; padding: 20px; box-shadow: var(--shadow-lg); transform: scale(.97); transition: transform .16s; }
.popup-layer.open .popup { transform: none; }
.popup h3 { font-size: 19px; font-weight: 700; margin-bottom: 8px; overflow-wrap: anywhere; }
.popup-body > p { color: var(--muted); }
.popup-body .lbl:first-child { margin-top: 6px; }
.popup-body .banner { margin: 8px 0 0; }
.popup-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }
.popup-btns .btn { flex: 1; }
.unit-hint { color: var(--muted); font-size: 14px; padding-top: 14px; }
.radio-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 12px; }
.radio-list label, .check { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); cursor: pointer; }
.radio-list input, .check input { width: 18px; height: 18px; accent-color: var(--primary); }

.toast {
  position: fixed; z-index: 90; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px); transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 32px);
  padding: 12px 16px; border-radius: 14px; background: var(--ai); color: var(--ai-text); box-shadow: var(--shadow-lg); font-size: 15px;
}
.toast button { border: 0; background: none; color: var(--ai-teal); font-weight: 700; padding: 0; white-space: nowrap; }

/* ---------- покупки ---------- */

.add-row { display: flex; gap: 8px; margin: 8px 0 18px; }
.add-row .btn { height: 50px; min-height: 50px; width: 50px; border-radius: 16px; }
.add-row .field { border-radius: 16px; }
.suggest { padding: 14px 14px 6px; border-radius: var(--radius); background: var(--warn-soft); margin-bottom: 20px; }
.suggest h2 { font-size: 15px; font-weight: 700; color: var(--warn-ink); margin-bottom: 4px; }
.suggest-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-top: 1px solid color-mix(in srgb, var(--warn) 18%, transparent); }
.suggest h2 + .suggest-row { border-top: 0; }
.suggest-row > span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.suggest-row b { font-size: 15px; font-weight: 600; }
.suggest-row small { font-size: 13px; color: var(--warn); }
.suggest-row .btn { background: var(--surface); border-color: transparent; }
.list-title { font-size: 17px; font-weight: 700; margin: 4px 0 10px; }
.shop-list { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.shop-item { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 14px; border-top: 1px solid var(--line-soft); }
.shop-item:first-child { border-top: 0; }
.shop-item label { flex: 1; display: flex; align-items: center; gap: 12px; padding: 10px 0; cursor: pointer; min-width: 0; }
.shop-item input { position: absolute; opacity: 0; pointer-events: none; }
.shop-item .box { display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 8px; border: 2px solid var(--line); color: transparent; background: var(--surface); }
.shop-item .box .ico { width: 16px; height: 16px; stroke-width: 3; }
.shop-item input:checked + .box { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.shop-item input:focus-visible + .box { outline: 2px solid var(--primary); outline-offset: 2px; }
.shop-text { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.shop-text b { font-weight: 600; font-size: 15.5px; overflow-wrap: anywhere; }
.shop-text small { color: var(--muted); font-size: 13px; }
.shop-item.done .shop-text b { text-decoration: line-through; color: var(--muted); font-weight: 500; }

/* ---------- настройки ---------- */

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.card h3 { display: flex; align-items: center; gap: 8px; font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.card h3 .ico { color: var(--primary); }
.card h3 .icon-btn { margin-left: auto; color: var(--muted); }
.card > p.muted { margin-bottom: 12px; }
.card .btn.wide { margin-top: 10px; }
.card > .btn.primary.wide { margin-bottom: 4px; }
.user-card { display: flex; align-items: center; gap: 14px; }
.avatar { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); font-weight: 700; font-size: 20px; flex: none; }
.plain-list { list-style: none; margin: 0 0 8px; padding: 0; }
.plain-list li { display: flex; align-items: center; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line-soft); }
.plain-list li:first-child { border-top: 0; }
.plain-list li > span:first-child { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.plain-list li > span:first-child .muted { font-weight: 400; }
.plain-list.archive li { gap: 8px; }
.usage { margin-top: 12px; }
.about p + p { margin-top: 8px; }
.ok-line { display: flex; align-items: center; gap: 8px; color: var(--primary); font-weight: 600; }
.seg.period { margin: 14px 0 12px; }

.audit { list-style: none; margin: 0 0 6px; padding: 0; }
.audit li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line-soft); }
.audit li:first-child { border-top: 0; }
.audit li > div { flex: 1; min-width: 0; }
.audit li small { font-weight: 600; font-size: 12.5px; }
.audit p { margin-top: 2px; }
.audit a { color: var(--text); }
.a-ico { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; flex: none; }
.a-ico .ico { width: 15px; height: 15px; stroke-width: 2.6; }
.a-ok .a-ico { background: var(--primary-soft); color: var(--primary); }
.a-warn .a-ico { background: var(--warn-soft); color: var(--warn); }
.a-warn small { color: var(--warn); }
.a-bad .a-ico { background: var(--bad-soft); color: var(--bad); }
.a-bad small { color: var(--bad); }
.in-list { display: inline-flex; align-items: center; gap: 4px; flex: none; font-size: 13px; font-weight: 600; color: var(--primary-ink); padding-top: 4px; }
.in-list .ico { width: 15px; height: 15px; stroke-width: 2.6; }
.answer .audit { margin: 0; }
.answer .notes { margin: 0; }
.audit + .btn.wide { margin: 4px 0 10px; }
.notes { margin: 8px 0 0; padding-left: 20px; font-size: 14px; }
.notes li { margin: 4px 0; }

.usage-total { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.usage-total > div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; }
.usage-total b { font-size: 20px; font-weight: 700; letter-spacing: -.01em; }
.usage-total span { font-size: 12.5px; color: var(--muted); }
.fam-list { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.fam { border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.fam.gone { opacity: .75; }
.fam-head { display: flex; align-items: center; gap: 8px; padding: 10px 6px 10px 12px; background: var(--surface-2); }
.fam-head > div:first-child { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fam-head b { overflow-wrap: anywhere; }
.fam-users { list-style: none; margin: 0; padding: 0; }
.fam-users > li { display: flex; align-items: center; gap: 6px; padding: 9px 6px 9px 12px; border-top: 1px solid var(--line-soft); }
.fu-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.fu-main b { font-weight: 600; }
.fu-main small { font-size: 12.5px; margin-top: 2px; }
.money { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; flex-direction: column; align-items: flex-end; }
.money small { font-weight: 500; font-size: 12px; color: var(--muted); }
.pill { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 6px; background: var(--primary-soft); color: var(--primary-ink); vertical-align: 2px; }
.icon-spacer { width: 36px; flex: none; }
.icon-spacer.two { width: 78px; }
.dev { display: flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--primary-ink); margin-top: 2px; }
.dev .ico { width: 13px; height: 13px; flex: none; }
.fam-toggle { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-top: 1px solid var(--line-soft); font-size: 14px; cursor: pointer; }
.fam-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 11px; background: var(--line); flex: none; transition: background .15s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); transition: transform .15s; }
.fam-toggle input:checked + .switch { background: var(--primary); }
.fam-toggle input:checked + .switch::after { transform: translateX(16px); }
.fam-toggle input:focus-visible + .switch { outline: 2px solid var(--primary); outline-offset: 2px; }

.link-field { margin: 12px 0; font-size: 14px; color: var(--muted); }
.share-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.share-btns .btn.primary { grid-column: 1 / -1; }
.share-btns .btn:not(.primary) { padding: 0 6px; font-size: 14px; }
.share-btns .ico { width: 18px; height: 18px; }
.popup .small .ico { width: 15px; height: 15px; vertical-align: -3px; }
.steps { margin: 4px 0 8px; padding-left: 22px; }
.steps li { margin: 6px 0; }
.transfer-code { font-size: 40px; font-weight: 700; letter-spacing: .12em; text-align: center; margin: 6px 0 12px; font-variant-numeric: tabular-nums; color: var(--primary); }

/* ---------- вход ---------- */

.gate { padding: 0; display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; background: var(--bg); }
.gate-wrap { width: 100%; padding: 24px 16px; display: grid; place-items: center; }
.gate-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 26px; padding: 28px 24px; box-shadow: var(--shadow-lg); text-align: center; }
.gate-card .brand-mark { width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 20px; box-shadow: 0 8px 22px rgba(1, 85, 104, .28); }
.gate-card h1 { font-size: 24px; font-weight: 700; margin-bottom: 8px; letter-spacing: -.01em; }
.gate-card > p { margin-bottom: 8px; }
.gate-form { text-align: left; margin: 14px 0 12px; }
.gate-form .lbl, .gate-form label { display: block; font-size: 14px; font-weight: 600; margin: 14px 0 6px; }
.gate-form .btn { width: 100%; margin-top: 18px; }
.gate-error { color: var(--bad); font-size: 14px; margin-top: 10px; }
.gate-note { text-align: left; font-size: 14px; background: var(--warn-soft); color: var(--warn-ink); border-radius: 16px; padding: 12px 14px; margin: 14px 0 4px; }
.gate-note ul { margin: 8px 0 0; padding-left: 18px; }
.gate-note li { margin: 4px 0; }
.code-box .muted { margin-top: 6px; }
.code-field { font-size: 24px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

.noscript { text-align: center; padding: 40px; }

/* ---------- печать ---------- */

#print-area { display: none; }
@media print {
  body { background: #fff; color: #000; padding: 0; font-size: 11pt; }
  body > *:not(#print-area) { display: none !important; }
  #print-area { display: block !important; }
  #print-area h1 { font-size: 18pt; margin-bottom: 4pt; }
  #print-area table { width: 100%; border-collapse: collapse; margin-top: 10pt; }
  #print-area th, #print-area td { border: 1px solid #999; padding: 4pt 6pt; text-align: left; vertical-align: top; }
  #print-area th { background: #eee; }
  #print-area tr.exp td { background: #fde3e0; }
  #print-area .foot { margin-top: 10pt; font-size: 10pt; }
}

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