/* Тонус: спокойная медицинская гамма, мягкие карточки, крупные цифры. Сначала телефон. */
:root {
  --bg: #eff5f3; --surface: #ffffff; --surface-2: #e3eeea; --line: #d3e2dd;
  --ink: #12302b; --muted: #5d7570; --accent: #0d8a7a; --accent-ink: #ffffff; --accent-soft: #d5efe9;
  --danger: #c2413b; --danger-soft: #fbe2df; --warn: #9a6400; --warn-soft: #fbefd2; --ok: #18805a; --ok-soft: #d9f2e5;
  --c-weight: #0d8a7a; --c-waist: #2f6f9f; --c-sys: #d0574f; --c-dia: #5a7fd6; --c-pulse: #c2477a; --c-activity: #2f9a52;
  --c-sleep: #6a5acd; --c-stress: #c98a0b;
  --radius: 14px; --shadow: 0 1px 2px rgb(18 48 43 / 6%), 0 6px 20px rgb(18 48 43 / 7%);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1715; --surface: #16221f; --surface-2: #1f2e2a; --line: #2b3d38;
    --ink: #e5f0ed; --muted: #93aaa4; --accent: #3cc3ad; --accent-ink: #062520; --accent-soft: #163a33;
    --danger: #f08a80; --danger-soft: #45201d; --warn: #e6b456; --warn-soft: #3b2f14; --ok: #6fd3a2; --ok-soft: #173a2a;
    --c-weight: #3cc3ad; --c-waist: #6aa8d8; --c-sys: #f0857c; --c-dia: #8ea9f0; --c-pulse: #e57fa9; --c-activity: #6fd38a;
    --c-sleep: #a397f0; --c-stress: #e6b456;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 6px 20px rgb(0 0 0 / 30%);
  }
}

body { font-size: 15.5px; }
.small { font-size: 13.5px; }
.wide { width: 100%; }
.btn { min-height: 44px; border-radius: 12px; white-space: normal; text-align: center; line-height: 1.25; }
input:not([type=checkbox]), select, textarea { min-height: 44px; font-size: 16px; border-radius: 12px; }
h1 { overflow-wrap: break-word; }
h3 { margin: 0; font-size: 16px; font-weight: 800; }

.shell { max-width: 760px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
.top { position: sticky; top: 0; z-index: 30; display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 19px; text-decoration: none; letter-spacing: -0.01em; }
.brand.big { font-size: 26px; }
.bell { position: relative; display: inline-flex; align-items: center; gap: 7px; min-height: 40px; font-weight: 700; font-size: 14px; text-decoration: none; color: var(--muted); }
.badge { min-width: 22px; height: 22px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 11px; background: var(--danger); color: #fff; font-size: 12.5px; font-weight: 800; }
.page-in { display: grid; gap: 16px; padding: 8px 16px 28px; min-width: 0; }
.page-in > * { min-width: 0; }

.tabs {
  position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(var(--tabs, 4), 1fr); gap: 2px;
  max-width: 760px; margin: 0 auto; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line);
}
.tab { display: grid; justify-items: center; gap: 2px; min-height: 52px; padding: 5px 1px 4px; border-radius: 12px; font-size: 12px; font-weight: 800; color: var(--muted); text-decoration: none; text-align: center; }
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--accent); background: var(--accent-soft); }

.card { display: grid; gap: 10px; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.list { display: grid; gap: 10px; }
.plain { text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--accent); }
.top-row { align-items: flex-start; flex-wrap: nowrap; }
.top-row > :first-child { min-width: 0; overflow-wrap: break-word; }
.chips { gap: 6px; }
.chip { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 800; background: var(--surface-2); overflow-wrap: break-word; max-width: 100%; flex: none; }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn, .chip-low { background: var(--warn-soft); color: var(--warn); }
.chip-bad { background: var(--danger-soft); color: var(--danger); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.note { padding: 11px 14px; border-radius: 12px; background: var(--warn-soft); font-size: 14px; }
.note-calm { background: var(--accent-soft); }
.back { font-weight: 700; color: var(--muted); text-decoration: none; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.three { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.pre { white-space: pre-wrap; overflow-wrap: break-word; }
.clamp { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.section-title { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-top: 6px; }

/* Крупные цифры */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { display: grid; gap: 2px; align-content: start; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; text-decoration: none; color: inherit; }
.tile span { font-size: 12.5px; font-weight: 700; color: var(--muted); }
.tile b { font-size: 22px; font-weight: 800; line-height: 1.15; overflow-wrap: anywhere; }
.tile small { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.tiles-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Дневник */
.entry { display: grid; gap: 12px; }
.entry-row { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 10px; align-items: center; }
.entry-row > .field-label { font-size: 14px; color: var(--ink); }
.entry-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
.entry-pair .sep { color: var(--muted); font-weight: 800; }
.unit-input { position: relative; }
.unit-input.with-unit input { padding-right: 58px; }
.unit-input .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 13px; color: var(--muted); font-weight: 700; pointer-events: none; }
.picker { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
.picker button { min-height: 40px; padding: 0; background: var(--surface-2); border: 0; border-radius: 9px; font-weight: 800; color: var(--muted); cursor: pointer; }
.picker button.on { background: var(--accent); color: var(--accent-ink); }
.more-fields summary { cursor: pointer; font-weight: 800; color: var(--accent); }
.more-fields[open] summary { margin-bottom: 12px; }

/* Лекарства и цели */
.dose { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.dose:first-of-type { border-top: 0; }
.dose-time { font-weight: 800; font-size: 16px; }
.dose-name { font-weight: 700; overflow-wrap: break-word; }
.take { min-width: 104px; }
.take.done { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.goal { display: grid; gap: 6px; }
.bar { height: 9px; border-radius: 9px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--accent); border-radius: 9px; }
.goal.reached .bar i { background: var(--ok); }
.days-pick { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.days-pick button { min-height: 40px; padding: 0; background: var(--surface-2); border: 0; border-radius: 9px; font-weight: 800; color: var(--muted); cursor: pointer; }
.days-pick button.on { background: var(--accent); color: var(--accent-ink); }
.times { display: grid; gap: 6px; }
.time-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px; }

/* Графики */
.metric-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.metric-chips::-webkit-scrollbar { display: none; }
.metric-chips a { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 800; font-size: 14px; text-decoration: none; color: var(--muted); }
.metric-chips a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 3px; padding: 3px; background: var(--surface-2); border-radius: 12px; }
.segmented button, .segmented a { display: grid; place-items: center; min-height: 40px; padding: 4px; background: none; border: 0; border-radius: 9px; font-size: 14px; font-weight: 800; color: var(--muted); cursor: pointer; text-decoration: none; }
.segmented .active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 10px; font-family: inherit; font-weight: 600; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .ref { stroke: var(--danger); stroke-width: 1; stroke-dasharray: 3 3; opacity: .55; }
.chart .goal-line { stroke: var(--ok); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .goal-label { fill: var(--ok); font-weight: 800; }
.chart .line { fill: none; stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { stroke: var(--surface); stroke-width: 1.5; }
.chart .empty-text { font-size: 12px; }
.mini .chart text { font-size: 9px; }
.compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.trend { font-weight: 800; }
.trend.up::before { content: '↑ '; }
.trend.down::before { content: '↓ '; }
.history { display: grid; }
.history-row { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.history-row:first-child { border-top: 0; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 13px; color: var(--muted); font-weight: 700; }
.legend i { display: inline-block; width: 12px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }

/* Анализы */
.lab-value { display: grid; gap: 4px; padding: 10px 0; border-top: 1px solid var(--line); }
.lab-value:first-of-type { border-top: 0; }
.lab-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.lab-num { font-size: 20px; font-weight: 800; }
.lab-text { font-size: 14px; }
.disclaimer { font-size: 13px; color: var(--muted); }
.files { display: flex; gap: 8px; flex-wrap: wrap; }
.file-link { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 10px; background: var(--surface-2); font-weight: 700; font-size: 14px; text-decoration: none; cursor: pointer; border: 0; overflow-wrap: anywhere; }
.photo-full { display: block; width: 100%; max-height: calc(100dvh - 110px); object-fit: contain; border-radius: 8px; background: #fff; }
.dialog-photo { width: min(900px, calc(100vw - 16px)); padding: 10px; }

/* Запросы и расписание */
.status-new { background: var(--accent-soft); color: var(--accent); }
.status-work { background: var(--warn-soft); color: var(--warn); }
.status-done { background: var(--ok-soft); color: var(--ok); }
.status-rejected, .status-cancelled { background: var(--surface-2); color: var(--muted); }
.answer { padding: 12px 14px; border-radius: 12px; background: var(--surface-2); }
.day-head { margin-top: 4px; font-size: 14px; font-weight: 800; color: var(--muted); }
.slot { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 12px; align-items: start; }
.slot-time { font-size: 18px; font-weight: 800; }
.slot-body { display: grid; gap: 6px; min-width: 0; }
.slot-full { opacity: .75; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.check input { width: 20px; height: 20px; margin-top: 1px; flex: none; accent-color: var(--accent); }
.person { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.person.off { opacity: .6; }
.menu-list { display: grid; }
.menu-list a, .menu-list button { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 52px; padding: 10px 2px; border: 0; border-top: 1px solid var(--line); background: none; font-weight: 700; text-decoration: none; color: inherit; cursor: pointer; text-align: left; font-size: 15.5px; }
.menu-list > :first-child { border-top: 0; }
.menu-list a::after { content: '›'; color: var(--muted); font-size: 20px; }
.notice.unread { border-color: var(--accent); }
.notice-alert.unread { border-color: var(--danger); }

/* Материалы и главная без входа */
.landing { max-width: 760px; margin: 0 auto; padding: 0 16px 40px; display: grid; gap: 18px; }
.landing-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; }
.hero { display: grid; gap: 12px; padding: 22px 18px; border-radius: 20px; background: linear-gradient(140deg, var(--accent) 0%, #11a08c 55%, #57c2a6 100%); color: #fff; }
.hero h1 { font-size: 27px; }
.hero p { opacity: .95; }
.hero .btn { background: #fff; color: #0a5f54; border-color: #fff; }
.hero .btn-ghost-light { background: transparent; color: #fff; border-color: rgb(255 255 255 / 60%); }
.roles { display: grid; gap: 8px; }
.role-btn { display: grid; gap: 2px; justify-content: stretch; justify-items: start; text-align: left; padding: 12px 14px; min-height: 0; }
.role-btn small { font-weight: 600; color: var(--muted); }
.mat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.mat { display: grid; gap: 6px; align-content: start; }
.mat h3 { overflow-wrap: break-word; }
.kind { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--accent); }
.rich { display: grid; gap: 10px; }
.rich p, .rich li { line-height: 1.6; }
.rich h3 { margin-top: 8px; }
.rich ul { margin: 0; padding-left: 20px; display: grid; gap: 4px; }
.auth { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.auth-card { width: min(440px, 100%); }
.footer { color: var(--muted); font-size: 13px; text-align: center; }

@media (min-width: 640px) {
  .page-in { padding: 12px 20px 32px; }
  .compare { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .entry-row { grid-template-columns: 150px minmax(0, 1fr); }
}
