/* ===========================================================================
   Оформление приложения «Dozima».
   Цвета описаны переменными, поэтому тёмная тема — это один блок переопределений,
   а не вторая копия стилей.
   =========================================================================== */

:root {
    --bg: #f2f5fb;
    --bg-glow: #e4e9ff;
    --surface: #ffffff;
    --surface-2: #f6f8fd;
    --line: #dde4f1;
    --line-soft: #e9eefa;
    --ink: #131824;
    --ink-2: #5c687d;
    --ink-3: #8b96a9;

    --accent: #5b6cff;
    --accent-soft: #eceeff;
    --accent-ink: #ffffff;
    --taken: #12a37a;
    --taken-soft: #e2f6ef;
    --warn: #b8791b;
    --warn-soft: #fbf1de;
    --alert: #d24a5e;
    --alert-soft: #fdeaed;

    /* Цвет формы выпуска. По умолчанию — акцент, карточка переопределяет его
       своим классом; всё внутри (значок, полоса, крупные числа) берёт --tone
       по наследству, поэтому цвет задаётся ровно в одном месте. */
    --tone: #5b6cff;
    --tone-tablet: #5b6cff;
    --tone-capsule: #12a37a;
    --tone-injection: #d24a5e;
    --tone-drops: #2b8fd0;
    --tone-powder: #b8791b;
    --tone-other: #7b86a0;

    /* Тон типа события — та же механика, что у форм выпуска: один класс на
       карточку, дальше цвет расходится по наследству. */
    --tone-doctor: #5b6cff;
    --tone-analysis: #12a37a;
    --tone-procedure: #b8791b;

    --shadow-1: 0 1px 2px rgba(19, 24, 36, .05), 0 6px 20px rgba(19, 24, 36, .05);
    --shadow-2: 0 12px 40px rgba(19, 24, 36, .14);

    --radius: 16px;
    --radius-sm: 10px;
    --gap: 18px;

    /* Высота поля ввода: строка при межстрочном 1.55, отступы по 9px и рамка.
       Держим её переменной, потому что select и переключатели сами такой
       высоты не получаются, а стоять в ряду они должны вровень. */
    --control-h: 43px;

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", "Roboto", "Helvetica Neue", Arial, sans-serif;
}

:root[data-theme="dark"] {
    --bg: #0e1219;
    --bg-glow: #172033;
    --surface: #161c26;
    --surface-2: #1d2531;
    --line: #2a3341;
    --line-soft: #222a37;
    --ink: #e9eef7;
    --ink-2: #9aa6ba;
    --ink-3: #6f7d92;

    --accent: #8993ff;
    --accent-soft: #232a45;
    --accent-ink: #0e1219;
    --taken: #3ecfa1;
    --taken-soft: #16302a;
    --warn: #e0a84f;
    --warn-soft: #322718;
    --alert: #f2798b;
    --alert-soft: #33191f;

    --tone: #8993ff;
    --tone-tablet: #8993ff;
    --tone-capsule: #3ecfa1;
    --tone-injection: #f2798b;
    --tone-drops: #5cb8ee;
    --tone-powder: #e0a84f;
    --tone-other: #97a3b8;

    --tone-doctor: #8993ff;
    --tone-analysis: #3ecfa1;
    --tone-procedure: #e0a84f;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .32);
    --shadow-2: 0 16px 48px rgba(0, 0, 0, .55);
}

@media (prefers-color-scheme: dark) {
    :root[data-theme="system"] {
        --bg: #0e1219;
        --bg-glow: #172033;
        --surface: #161c26;
        --surface-2: #1d2531;
        --line: #2a3341;
        --line-soft: #222a37;
        --ink: #e9eef7;
        --ink-2: #9aa6ba;
        --ink-3: #6f7d92;
        --accent: #8993ff;
        --accent-soft: #232a45;
        --accent-ink: #0e1219;
        --taken: #3ecfa1;
        --taken-soft: #16302a;
        --warn: #e0a84f;
        --warn-soft: #322718;
        --alert: #f2798b;
        --alert-soft: #33191f;
        --tone: #8993ff;
        --tone-tablet: #8993ff;
        --tone-capsule: #3ecfa1;
        --tone-injection: #f2798b;
        --tone-drops: #5cb8ee;
        --tone-powder: #e0a84f;
        --tone-other: #97a3b8;
        --tone-doctor: #8993ff;
        --tone-analysis: #3ecfa1;
        --tone-procedure: #e0a84f;
        --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .32);
        --shadow-2: 0 16px 48px rgba(0, 0, 0, .55);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    background:
        radial-gradient(1100px 520px at 78% -10%, var(--bg-glow), transparent 60%),
        var(--bg);
    color: var(--ink);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    font-variant-numeric: tabular-nums;
}

h1, h2, h3 { margin: 0; letter-spacing: -.02em; font-weight: 650; }
h1 { font-size: 26px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
p { margin: 0; }

/* --- Служебные --------------------------------------------------------- */

/* width: 100% обязателен: оболочка приложения — flex-столбец, а в нём боковые
   margin: auto отменяют растягивание, и колонка сжимается по содержимому.
   Именно так экраны и «похудели», когда под ними появился общий подвал. */
.layout { width: 100%; max-width: 1000px; margin: 0 auto; padding: 0 20px 96px; }
.stack { display: flex; flex-direction: column; gap: var(--gap); }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

.eyebrow {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .09em;
    font-weight: 650;
    color: var(--ink-3);
}

/* --- Шапка -------------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    border-bottom: 1px solid var(--line-soft);
}

.topbar-inner {
    max-width: 1000px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.wordmark {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    letter-spacing: -.03em;
    font-size: 18px;
}

.wordmark-dot {
    width: 11px;
    height: 22px;
    border-radius: 999px;
    background: linear-gradient(180deg, var(--accent) 50%, var(--taken) 50%);
}

.tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--surface-2);
    border: 1px solid var(--line-soft);
    border-radius: 999px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

/* Кружок с аватаркой в шапке и меню под ним — вместо отдельной вкладки настроек. */
.user-menu { position: relative; flex: none; }

.avatar {
    flex: none;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-2);
    cursor: pointer;
    transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.avatar:hover { color: var(--ink); border-color: var(--accent); }
.avatar[aria-current="page"] {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}

/*
 * Силуэт лежит отдельным файлом, но цвет ему задаёт страница: файл работает
 * маской, а видимым остаётся фон элемента, то есть currentColor кнопки.
 * Обычным <img> так нельзя — картинка рисуется своим документом, куда стили
 * страницы не попадают.
 *
 * Здесь только развёрнутые свойства: сокращённая запись -webkit-mask не
 * принимает размер через «/» и отбрасывается WebKit целиком, а вместе с ней
 * пропадала бы и вся маска.
 */
.avatar-icon {
    display: block;
    width: 22px;
    height: 22px;
    /* Если маски нет — остаётся обычная картинка в цвете из файла. */
    background-image: url("/icons/person.svg");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 22px 22px;
}

@supports (mask-image: url("/icons/person.svg")) or (-webkit-mask-image: url("/icons/person.svg")) {
    .avatar-icon {
        background-image: none;
        background-color: currentColor;
        -webkit-mask-image: url("/icons/person.svg");
        mask-image: url("/icons/person.svg");
        -webkit-mask-position: center;
        mask-position: center;
        -webkit-mask-repeat: no-repeat;
        mask-repeat: no-repeat;
        -webkit-mask-size: 22px 22px;
        mask-size: 22px 22px;
    }
}

/* Всплывающее меню под аватаркой. */
.menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 30;
    min-width: 264px;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-2);
    animation: rise .14s ease-out;
}

.menu-head {
    padding: 8px 10px 10px;
    margin-bottom: 6px;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Почта обычно влезает в строку, но бывает длинной — тогда переносим её
   по любому месту, лишь бы не расталкивала меню. */
.menu-email { font-weight: 600; font-size: 13px; overflow-wrap: anywhere; }

/* Когда имя есть, главная строка — оно, а почта под ним теряет насыщенность:
   .small и .muted перебивают собственный вес .menu-email. */
.menu-name { font-weight: 650; overflow-wrap: anywhere; }
.menu-email.small { font-weight: 400; }

.menu-item {
    display: block;
    width: 100%;
    padding: 9px 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.is-danger { color: var(--alert); }
.menu-item.is-danger:hover { background: var(--alert-soft); }

.tab {
    border: 0;
    background: transparent;
    color: var(--ink-2);
    font: inherit;
    font-size: 14px;
    font-weight: 550;
    padding: 7px 15px;
    border-radius: 999px;
    cursor: pointer;
    white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: var(--shadow-1);
}

/* --- Карточки ----------------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow-1);
    padding: 20px;
}

.card-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 14px;
}

/* Счётчики в заголовке раздела на узком экране уходят на свою строку целиком:
   перенос внутри чипа рвал бы «3 события» посередине. */
.section-title { display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; flex-wrap: wrap; }
.section-title .chip { white-space: nowrap; }

/* --- Кнопки ------------------------------------------------------------- */

.btn {
    font: inherit;
    font-weight: 550;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    padding: 9px 16px;
    cursor: pointer;
    transition: transform .12s ease, background .12s ease, border-color .12s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: default; }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-ink);
}
.btn-primary:hover { filter: brightness(1.06); }

.btn-quiet { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--surface-2); color: var(--ink); border-color: transparent; }

.btn-danger { color: var(--alert); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--alert-soft); border-color: transparent; }

.btn-sm { padding: 5px 11px; font-size: 13px; }

.icon-btn {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-2);
    cursor: pointer;
    font-size: 15px;
    font-family: var(--font);
}
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }

/* --- Поля ввода --------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }

.label {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    letter-spacing: .01em;
}

.input, .select, .textarea {
    font: inherit;
    color: var(--ink);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    width: 100%;
    min-width: 0;
}
/* Межстрочное расстояние в select задаёт сам браузер и переопределить не даёт,
   поэтому по высоте он не дотягивает до поля ввода. Возвращаем разницу. */
.select { min-height: var(--control-h); }

.textarea { resize: vertical; min-height: 66px; }
.input:focus, .select:focus, .textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
    border-color: transparent;
}

/* Подсказка и ошибка под полем — одна и та же строка, меняется только цвет. */
.hint { font-size: 12px; color: var(--ink-3); }
.hint-error { color: var(--alert); }
.hint-ok { color: var(--taken); }

.input.is-invalid { border-color: var(--alert); }

/*
 * Кнопка «показать пароль» внутри поля. Иконка — настоящий SVG со stroke:
 * currentColor, поэтому цвет задаётся кнопке, а не картинке, и сам меняется
 * при наведении и в тёмной теме.
 */
.input-peek { position: relative; display: block; }
.input-peek .input { padding-right: 42px; }

.peek {
    position: absolute;
    top: 50%;
    right: 5px;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    padding: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--ink-3);
    cursor: pointer;
}
.peek:hover { color: var(--ink); }
.peek.is-on { color: var(--accent); }

.peek-icon { display: block; width: 20px; height: 20px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* --- Переключатель дней недели ----------------------------------------- */

.days { display: flex; gap: 6px; flex-wrap: wrap; }

.day-toggle {
    width: 38px;
    height: 34px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--surface-2);
    color: var(--ink-2);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.day-toggle[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
    font-weight: 650;
}

/* --- Подпись-бирка ------------------------------------------------------ */

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 550;
    background: var(--surface-2);
    color: var(--ink-2);
    border: 1px solid var(--line-soft);
}
.chip-accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.chip-taken { background: var(--taken-soft); color: var(--taken); border-color: transparent; }
.chip-warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.chip-alert { background: var(--alert-soft); color: var(--alert); border-color: transparent; }

/* --- Фильтры списков ----------------------------------------------------- */

/* Полоса фильтров над списком. Поля тянутся, переключатели прижаты к правому
   краю; на узком экране всё переносится само, без второй раскладки. */
.filters {
    /* Отступ от стенок вынесен в переменную: кнопка сброса стоит в углу
       абсолютом, и её правый край должен совпадать с краем полей под ней. */
    --filters-pad: 14px;
    position: relative;      /* якорь для кнопки сброса в углу */
    display: flex;
    flex-wrap: wrap;
    /* Поля растягиваются на всю высоту полосы, а внутри каждого подпись прижата
       к верху, поле — к низу. Иначе список и поле ввода, у которых своя высота
       (line-height у select браузер задаёт сам и переопределить не даёт),
       разводили бы подписи над ними на разные уровни. */
    align-items: stretch;
    gap: 10px 12px;
    padding: 12px var(--filters-pad);
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.filters .field { flex: 1 1 150px; min-width: 0; justify-content: space-between; }
/* Поиск — первый и самый широкий: по нему сужают чаще всего. */
.filters .field:first-child { flex: 2 1 220px; }

.filters-extra {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
    /* Переключатели стоят на одной линии с полями, а не по центру полосы. */
    align-self: flex-end;
}

/* Сброс живёт в углу плашки и не участвует в раскладке ряда: появляясь и
   исчезая, он иначе двигал бы поля по ширине. Место над переключателем всё
   равно пустует — подписи там нет. */
.filters-reset {
    position: absolute;
    /* По вертикали — вровень со строкой подписей, по горизонтали — по краю
       полей: подложка при наведении не должна лезть ближе к стенке, чем они. */
    top: 7px;
    right: var(--filters-pad);
    padding: 3px 9px;
    font-size: 12.5px;
}

/* Переключатель-чип: выглядит как чип, ведёт себя как флажок. */
.chip-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    /* Стоит в одном ряду с полями — значит, и высота у него та же. */
    min-height: var(--control-h);
    padding: 7px 15px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-2);
    font: inherit;
    font-size: 13px;
    /* Начертание одно на оба состояния — то же, что у обычного чипа. Жирный
       текст шире обычного, и от переключения нажатый чип менял бы ширину,
       двигая всю строку фильтров. Нажатое состояние видно по цвету. */
    font-weight: 550;
    line-height: 1.2;
    cursor: pointer;
    transition: color .12s ease, border-color .12s ease, background .12s ease;
}
.chip-toggle:hover { color: var(--ink); border-color: var(--accent); }
.chip-toggle[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: transparent;
    color: var(--accent);
}

/* --- Лента приёмов: главный элемент интерфейса -------------------------- */

.rail { display: flex; flex-direction: column; gap: 2px; }

.rail-slot { display: grid; grid-template-columns: 62px 1fr; gap: 14px; }

.rail-time {
    padding-top: 14px;
    font-size: 14px;
    font-weight: 650;
    color: var(--ink-2);
    text-align: right;
}
.rail-slot.is-now .rail-time { color: var(--accent); }

.rail-doses {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 0 18px 20px;
    border-left: 2px solid var(--line-soft);
    position: relative;
}
.rail-slot:last-child .rail-doses { border-left-color: transparent; }

.rail-doses::before {
    content: "";
    position: absolute;
    left: -6px;
    top: 18px;
    width: 10px;
    height: 10px;
    border-radius: 999px;
    background: var(--line);
}
.rail-slot.is-now .rail-doses::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.rail-slot.is-complete .rail-doses::before { background: var(--taken); }

/* Капсула приёма — визуальная метафора блистера. */
.dose {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    text-align: left;
    font: inherit;
    padding: 12px 16px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition: border-color .15s ease, background .15s ease, transform .12s ease;
}
.dose:hover { border-color: var(--accent); }
.dose:active { transform: scale(.995); }

.dose.is-taken {
    background: var(--taken-soft);
    border-color: transparent;
}
.dose.is-taken .dose-name { color: var(--taken); }
.dose.is-missed { border-color: var(--alert); }

.dose-check {
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 2px solid var(--line);
    display: grid;
    place-items: center;
    font-size: 13px;
    color: transparent;
}
.dose.is-taken .dose-check {
    background: var(--taken);
    border-color: var(--taken);
    color: #fff;
}
.dose.is-missed .dose-check { border-color: var(--alert); }

.dose-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.dose-name { font-weight: 600; }
.dose-meta { font-size: 12.5px; color: var(--ink-2); }

/* --- Календарь ---------------------------------------------------------- */

.calendar-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.calendar-title { font-size: 17px; font-weight: 650; text-transform: capitalize; }

.weekdays, .month {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.weekdays { margin-bottom: 6px; }

.weekday {
    text-align: center;
    font-size: 11px;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: var(--ink-3);
    font-weight: 650;
}

.day {
    position: relative;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    border: 1px solid transparent;
    background: var(--surface-2);
    color: var(--ink);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 0 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 5px;
}
.day:hover { border-color: var(--accent); }
.day.is-outside { opacity: .35; }
.day.is-today { box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; }
.day.is-selected { background: var(--accent); color: var(--accent-ink); }
.day.is-selected .dot { background: currentColor; opacity: .7; }
.day.is-selected .dot.is-taken { background: currentColor; opacity: 1; }

.dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; max-width: 80%; }

.dot {
    width: 5px;
    height: 5px;
    border-radius: 999px;
    background: var(--line);
}
.dot.is-taken { background: var(--taken); }
.dot.is-missed { background: var(--alert); }
.dot.is-planned { background: var(--accent); }

.day-flag {
    position: absolute;
    top: 5px;
    right: 6px;
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: var(--warn);
}

.calendar-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }

/* --- Список препаратов -------------------------------------------------- */

/* Тон формы выпуска. Один класс на карточку — дальше цвет расходится по
   наследству, поэтому значок, полоса курса и крупные числа всегда согласованы. */
.is-tablet { --tone: var(--tone-tablet); }
.is-capsule { --tone: var(--tone-capsule); }
.is-injection { --tone: var(--tone-injection); }
.is-drops { --tone: var(--tone-drops); }
.is-powder { --tone: var(--tone-powder); }
.is-other { --tone: var(--tone-other); }

.med-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.med-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    overflow: hidden;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--tone) 6%, transparent), transparent 120px),
        var(--surface);
    transition: border-color .14s ease, box-shadow .14s ease, transform .14s ease;
}
.med-card:hover {
    border-color: color-mix(in srgb, var(--tone) 40%, var(--line));
    box-shadow: var(--shadow-1);
}

/* Цветная полоска сверху — единственное место, где тон виден крупно. */
.med-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--tone), transparent 85%);
}

.med-card.is-archived { opacity: .72; }
.med-card.is-low { border-color: color-mix(in srgb, var(--warn) 45%, var(--line-soft)); }

/* Шапка целиком — кнопка: в подробности попадают, не целясь в мелкую ссылку. */
.med-head {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.med-head:hover .chevron-icon { color: var(--tone); transform: translateX(2px); }
.med-head:hover .med-name { color: var(--tone); }

.med-icon {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    color: var(--tone);
    background: color-mix(in srgb, var(--tone) 13%, transparent);
}

.form-icon { display: block; width: 22px; height: 22px; }

.chevron-icon {
    flex: none;
    width: 18px;
    height: 18px;
    color: var(--ink-3);
    transition: transform .12s ease, color .12s ease;
}

.med-head-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.med-name { font-weight: 650; font-size: 16px; overflow-wrap: anywhere; transition: color .12s ease; }
.med-sub { font-size: 12.5px; color: var(--ink-2); }

.med-chips { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.med-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.med-meter { display: flex; flex-direction: column; gap: 6px; }
.med-meter-head { display: flex; align-items: baseline; gap: 8px; }
.med-meter-value { font-weight: 600; }
.med-meter-value.is-low { color: var(--warn); }
.med-meter-bar { display: flex; align-items: center; gap: 10px; }
.med-meter-bar .meter { flex: 1; }

/* Кнопки внизу прижаты к низу карточки, чтобы в ряду они шли на одной линии. */
.med-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--line-soft);
}

/* Полоса заполнения: и пройденный курс, и остаток в упаковке. */
.meter {
    appearance: none;
    -webkit-appearance: none;
    display: block;
    width: 100%;
    height: 8px;
    border: 0;
    border-radius: 999px;
    background: var(--line-soft);
    overflow: hidden;
}
.meter::-webkit-progress-bar { background: var(--line-soft); border-radius: 999px; }
.meter::-webkit-progress-value { background: var(--tone); border-radius: 999px; }
.meter::-moz-progress-bar { background: var(--tone); border-radius: 999px; }
.meter-stock.is-low::-webkit-progress-value { background: var(--warn); }
.meter-stock.is-low::-moz-progress-bar { background: var(--warn); }

/* --- Визиты, анализы и процедуры ---------------------------------------- */

/* Тон типа события. Дальше он расходится по наследству: листок календаря,
   значок и полоска сверху берут --tone и потому всегда согласованы. */
.is-doctor { --tone: var(--tone-doctor); }
.is-analysis { --tone: var(--tone-analysis); }
.is-procedure { --tone: var(--tone-procedure); }

.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 14px;
}

.plan-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    overflow: hidden;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background:
        linear-gradient(180deg, color-mix(in srgb, var(--tone) 6%, transparent), transparent 120px),
        var(--surface);
    transition: border-color .14s ease, box-shadow .14s ease;
}
.plan-card:hover {
    border-color: color-mix(in srgb, var(--tone) 40%, var(--line));
    box-shadow: var(--shadow-1);
}

.plan-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: linear-gradient(90deg, var(--tone), transparent 85%);
}

/* Состоявшееся событие приглушено, событие с идущей подготовкой — наоборот,
   обведено предупреждающим цветом: и то и другое видно, не читая текста. */
.plan-card.is-done { opacity: .72; }
.plan-card.is-prep { border-color: color-mix(in srgb, var(--warn) 45%, var(--line-soft)); }

.plan-head { display: flex; align-items: center; gap: 14px; }

/* Листок календаря. Число крупное: событие ищут глазами по дате. */
.plan-date {
    flex: none;
    width: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 7px 4px 6px;
    border: 1px solid color-mix(in srgb, var(--tone) 25%, var(--line-soft));
    border-radius: 12px;
    background: color-mix(in srgb, var(--tone) 10%, transparent);
    color: var(--tone);
}
.plan-date-day { font-size: 21px; font-weight: 700; letter-spacing: -.03em; line-height: 1.1; }
.plan-date-month { font-size: 11.5px; font-weight: 600; }
.plan-date-weekday { font-size: 11px; color: var(--ink-3); }

.plan-head-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.plan-title { font-weight: 650; font-size: 16px; overflow-wrap: anywhere; }
.plan-sub { font-size: 12.5px; color: var(--ink-2); }

.plan-icon {
    flex: none;
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--tone);
    background: color-mix(in srgb, var(--tone) 12%, transparent);
}

/* Подготовка отделена от остального: это единственная строка карточки,
   по которой нужно что-то сделать заранее. */
.plan-prep {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.plan-prep.is-active { background: var(--warn-soft); border-color: transparent; }
.plan-prep-mark { flex: none; font-size: 15px; line-height: 1.4; color: var(--ink-3); }
.plan-prep.is-active .plan-prep-mark { color: var(--warn); }
.plan-prep-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.plan-prep-title { font-weight: 600; }

.plan-notes { margin: 0; overflow-wrap: anywhere; }

/* Кнопки прижаты к низу, чтобы в ряду карточек они шли по одной линии. */
.plan-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 10px;
    border-top: 1px solid var(--line-soft);
}

/* --- Подробности препарата ---------------------------------------------- */

.detail-head { align-items: center; gap: 14px; }
.detail-head-text { min-width: 0; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.stat-value { font-size: 23px; font-weight: 700; letter-spacing: -.03em; line-height: 1.25; color: var(--tone); }
.stat-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.stat-note { font-size: 12px; color: var(--ink-3); }
.stat.is-ok .stat-value { color: var(--taken); }
.stat.is-warn .stat-value { color: var(--warn); }

.detail-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.detail-list { margin: 0; display: flex; flex-direction: column; }

.detail-row {
    display: flex;
    align-items: baseline;
    gap: 12px;
    padding: 5px 0;
    font-size: 13.5px;
    border-bottom: 1px solid var(--line-soft);
}
.detail-row:last-child { border-bottom: 0; }
.detail-row dt { color: var(--ink-2); }
.detail-row dd { margin: 0; margin-left: auto; text-align: right; font-weight: 600; }

.detail-schedule {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.detail-time { flex: none; min-width: 48px; font-size: 15px; font-weight: 700; color: var(--tone); }
.detail-schedule-text { min-width: 0; }

/* --- Напоминания -------------------------------------------------------- */

.reminder {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 13px 15px;
    border-radius: var(--radius-sm);
    background: var(--warn-soft);
    border: 1px solid transparent;
}
.reminder.is-alert { background: var(--alert-soft); }
.reminder.is-info { background: var(--accent-soft); }
.reminder-mark { font-size: 16px; line-height: 1.3; }
.reminder-text { font-size: 13.5px; }
.reminder-title { font-weight: 650; }

/* --- Модальные окна ----------------------------------------------------- */

.overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(10, 14, 22, .45);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 32px 16px;
    overflow-y: auto;
}

.modal {
    width: min(620px, 100%);
    background: var(--surface);
    border-radius: 20px;
    border: 1px solid var(--line-soft);
    box-shadow: var(--shadow-2);
    padding: 22px;
    animation: rise .18s ease-out;
}

/* Окно уже было на экране до перерисовки — появляться заново ему не нужно. */
.modal.is-kept { animation: none; }

@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }

.schedule-block {
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    padding: 14px;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* --- Вход и регистрация ------------------------------------------------- */

/* Карточка живёт в правой колонке приветственной страницы — её размеры и
   положение заданы там, в разделе .landing-hero. Здесь остаётся только то,
   что относится к самой форме. */

/* Экран загрузки — единственная надпись, ей центр по-прежнему идёт. */
.splash {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-card { width: min(420px, 100%); }
.auth-lead { color: var(--ink-2); font-size: 14px; margin-top: 6px; }

/* Сноска — приписка к кнопке, а не самостоятельный блок. */
.auth-note { margin-top: -6px; }

.switcher { display: flex; gap: 6px; padding: 4px; background: var(--surface-2); border-radius: 999px; }
.switcher .tab { flex: 1; text-align: center; }

/* Согласие при регистрации: текст в несколько строк, поэтому флажок держится
   у первой строки, а не съезжает к середине абзаца. */
.consent {
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 13px;
    line-height: 1.5;
    color: var(--ink-2);
    cursor: pointer;
}
.consent input { margin: 3px 0 0; flex: none; }

/* --- Уведомление -------------------------------------------------------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 90;
    padding: 11px 18px;
    border-radius: 999px;
    background: var(--ink);
    color: var(--bg);
    font-size: 14px;
    box-shadow: var(--shadow-2);
    max-width: min(520px, calc(100vw - 32px));
}
.toast.is-error { background: var(--alert); color: #fff; }

/* --- Пустые экраны ------------------------------------------------------ */

.empty {
    text-align: center;
    padding: 34px 16px;
    color: var(--ink-2);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.empty-mark { font-size: 26px; }

/* --- Админка ------------------------------------------------------------- */

.admin-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 8px 12px;
    padding: 12px 14px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.admin-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.admin-email { font-weight: 600; overflow-wrap: anywhere; }
.admin-marks { display: flex; gap: 6px; flex-wrap: wrap; justify-self: end; }
.admin-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* Временный пароль: моноширинный, крупный и выделяемый — его переписывают руками. */
.secret {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 20px;
    letter-spacing: .06em;
    text-align: center;
    padding: 14px;
    border: 1px dashed var(--accent);
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    color: var(--ink);
    user-select: all;
    overflow-wrap: anywhere;
}

/* --- Доступность и мобильные экраны ------------------------------------- */

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}

@media (max-width: 720px) {
    .layout { padding: 0 12px 96px; }
    .card { padding: 16px; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .rail-slot { grid-template-columns: 48px 1fr; gap: 8px; }
    .rail-doses { padding-left: 14px; }
    /* На узком экране вкладки уходят на свою строку, а кружок остаётся
       рядом с названием — иначе он переносился бы один. */
    .topbar-inner { flex-wrap: wrap; }
    .topbar-inner .user-menu { order: 2; }
    .topbar-inner .tabs { order: 3; flex-basis: 100%; }
    .day { font-size: 13px; }
    .med-grid, .plan-grid { grid-template-columns: 1fr; }
    /* На узком экране переключатели встают под поля, а не жмутся к краю. */
    .filters-extra { margin-left: 0; }
    /* Поля идут друг под другом, и угол плашки занят строкой с подписью
       первого поля — поэтому здесь «Сбросить» встаёт в общий поток.
       Двигать по ширине там уже нечего: в каждой строке своё содержимое.
       В ряду она стоит рядом с переключателем, значит и размером должна быть
       с него: мелкий вид нужен был только в углу. */
    .filters-reset {
        position: static;
        align-self: flex-end;
        min-height: var(--control-h);
        margin-left: auto;
        padding: 5px 15px;
        font-size: 13px;
    }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
    /* Кнопка правки не помещается третьей колонкой — она уходит под текст,
       а кружок остаётся рядом с именем, иначе он висел бы отдельной строкой. */
    .profile-hero { grid-template-columns: auto minmax(0, 1fr); gap: 14px; }
    .profile-hero-action { grid-column: 1 / -1; justify-self: stretch; }
    .profile-hero-action .btn { width: 100%; }
    .profile-name { font-size: 22px; }
    .detail-block { padding: 12px; }
    /* На узком экране отметки уходят под почту, а не жмутся к краю. */
    .admin-row { grid-template-columns: minmax(0, 1fr); }
    .admin-marks { justify-self: start; }
}

/* ===========================================================================
   Страница профиля.
   Не таблица, а рассказ: кто это, потом измерения крупными числами, потом то,
   о чём предупреждают врача. Отдельных цветов здесь нет — всё берётся из тех
   же переменных, что и остальные экраны.
   =========================================================================== */

.profile-hero {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: start;
    gap: 18px;
}

/* Кружок вдвое крупнее того, что в панели: здесь он не кнопка, а портрет. */
.profile-avatar {
    flex: none;
    width: 76px;
    height: 76px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--ink-3);
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -.02em;
}

/* Появилось имя — кружок перестаёт быть заглушкой и берёт цвет акцента. */
.profile-avatar.has-initials {
    border-color: transparent;
    background: var(--accent);
    color: var(--accent-ink);
}

.profile-avatar-icon {
    width: 38px;
    height: 38px;
    background-size: 38px 38px;
    -webkit-mask-size: 38px 38px;
    mask-size: 38px 38px;
}

.profile-name { font-size: 26px; line-height: 1.2; overflow-wrap: anywhere; }
.profile-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.profile-lead { max-width: 60ch; }
.profile-hero-action { justify-self: end; }

.profile-notes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: var(--gap);
}

/* Полоса слева отделяет предупреждение от обычной заметки быстрее подписи. */
.note-card {
    gap: 8px;
    border-left: 3px solid var(--line);
}

.note-card.is-alert { border-left-color: var(--alert); }
.note-card.is-warn { border-left-color: var(--warn); }
.note-card .eyebrow { margin: 0; }

.stat.is-alert .stat-value { color: var(--alert); }

/* Визитка экстренного контакта. Всё прижато влево и читается сверху вниз:
   строки «подпись — значение» разошлись бы по краям широкой карточки, оставив
   между собой пустоту, — на узкой они работают, на этой нет. */
.contact { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.contact-line { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.contact-name { font-size: 18px; font-weight: 650; overflow-wrap: anywhere; }

/* Номер — то единственное, ради чего в этот блок заглянут. Моноширинные цифры
   не дают ему дёргаться, если номер записан с разными разделителями. */
.contact-phone {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -.01em;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

/* ===========================================================================
   Лист для врача.
   На экране его нет: он появляется в разметке только на время печати и
   оформлен под лист A4 — чёрным по белому, без фонов и теней, которые принтер
   всё равно не воспроизведёт, а тонер потратит.
   =========================================================================== */

/* Многострочный текст, набранный человеком, сохраняет переносы: список
   аллергий в столбик набирают именно столбиком. */
.prewrap { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }

.sheet { display: none; }

@page {
    size: A4;
    margin: 14mm;
}

/* ===========================================================================
   Приветственная страница.
   Первое, что видит человек без сессии: рассказ о сервисе и форма входа рядом.
   Своих цветов здесь нет — всё те же переменные, поэтому тёмная тема
   получается сама собой.
   =========================================================================== */

.landing {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

/* Ссылка-кнопка. Внешне это кнопка, но прокрутку к форме делает сам браузер
   по якорю, и потому в разметке стоит именно ссылка. */
a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    white-space: nowrap;
}

.btn-lg { padding: 12px 22px; font-size: 16px; }

/* --- Шапка страницы ----------------------------------------------------- */

.landing-top {
    position: sticky;
    top: 0;
    z-index: 20;
    backdrop-filter: blur(14px);
    background: color-mix(in srgb, var(--bg) 82%, transparent);
    border-bottom: 1px solid var(--line-soft);
}

.landing-top-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 18px;
}

.landing-nav { display: flex; gap: 4px; }

.landing-nav-link {
    color: var(--ink-2);
    text-decoration: none;
    font-size: 14px;
    padding: 6px 10px;
    border-radius: 999px;
}
.landing-nav-link:hover { color: var(--ink); background: var(--surface-2); }

.landing-top-actions { margin-left: auto; display: flex; gap: 8px; }

.landing-main {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Прыжок по якорю не должен прятать заголовок под липкой шапкой. */
.landing-section, .auth-card { scroll-margin-top: 88px; }

/* --- Первый экран ------------------------------------------------------- */

.landing-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
    gap: 44px;
    align-items: start;
    padding: clamp(32px, 7vw, 76px) 0 clamp(28px, 5vw, 56px);
}

.hero-title {
    margin: 0;
    font-size: clamp(32px, 5.2vw, 52px);
    line-height: 1.06;
    letter-spacing: -.035em;
}

.hero-lead {
    margin: 0;
    font-size: 17px;
    line-height: 1.6;
    color: var(--ink-2);
    max-width: 46ch;
}

.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.hero-marks {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    font-size: 14px;
    color: var(--ink-2);
}
.hero-marks li { display: flex; align-items: center; gap: 8px; }

/* Галочка рисуется двумя гранями повёрнутого прямоугольника: ради трёх строк
   заводить ещё один SVG незачем. */
.hero-tick {
    position: relative;
    flex: none;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: var(--taken-soft);
}
.hero-tick::after {
    content: "";
    position: absolute;
    left: 6px;
    top: 4px;
    width: 5px;
    height: 9px;
    border-right: 2px solid var(--taken);
    border-bottom: 2px solid var(--taken);
    transform: rotate(45deg);
}

/* Правая колонка: форма, под ней — показ дня приёма. На широком экране она
   держится в поле зрения, пока человек читает страницу. */
.hero-side {
    position: sticky;
    top: 88px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-title { margin: 0; font-size: 20px; letter-spacing: -.02em; }

/* --- Показ вместо скриншота ---------------------------------------------
   Приставка demo-, а не peek-: класс .peek уже занят кнопкой «показать пароль»
   в поле ввода. Совпадение имён рассыпало и показ дня приёма, и саму кнопку —
   правила применились крест-накрест. Новое имя проверяй по всему файлу. */

/* Карточка и пояснения к ней стоят рядом: без подписи справа человек видел
   набор строк и не понимал, чей это экран и зачем он тут. */
.demo-grid {
    display: grid;
    grid-template-columns: minmax(0, 420px) minmax(0, 1fr);
    gap: 34px;
    align-items: center;
}

.demo {
    margin: 0;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius);
    background: linear-gradient(180deg, var(--surface), var(--surface-2));
    box-shadow: var(--shadow-1);
}

/* Подпись стоит внутри рамки сверху: снаружи она читалась бы как заголовок
   раздела, а её дело — сказать, что ниже пример, а не рабочий экран. */
.demo-caption { margin-bottom: 2px; }

.demo-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.demo-point { display: flex; flex-direction: column; gap: 3px; }
.demo-point strong { font-size: 15px; letter-spacing: -.01em; }
.demo-point span { font-size: 14px; }

.demo-head { display: flex; align-items: center; justify-content: space-between; }
.demo-day { font-weight: 650; }

.demo-row {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.demo-row.is-taken { background: var(--taken-soft); border-color: transparent; }

.demo-time { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.demo-body { display: flex; flex-direction: column; min-width: 0; }
.demo-name { font-weight: 600; }
.demo-note { font-size: 12px; color: var(--ink-3); }

.demo-mark {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 13px;
    border: 1px solid var(--line);
    color: transparent;
}
.demo-row.is-taken .demo-mark {
    background: var(--taken);
    border-color: transparent;
    color: #fff;
}

.demo-foot { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--ink-2); }
.demo-bar { display: block; height: 6px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.demo-bar-fill {
    display: block;
    height: 100%;
    width: 62%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--taken));
}

/* --- Разделы рассказа --------------------------------------------------- */

.landing-section {
    padding: clamp(30px, 6vw, 60px) 0;
    border-top: 1px solid var(--line-soft);
}

.landing-h2 {
    margin: 0 0 6px;
    font-size: clamp(24px, 3.4vw, 34px);
    letter-spacing: -.028em;
    line-height: 1.15;
}

.landing-sub { margin: 0 0 26px; color: var(--ink-2); max-width: 62ch; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(258px, 1fr));
    gap: 16px;
}

.feature { display: flex; flex-direction: column; gap: 10px; }

.feature-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
}

.feature-title { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.feature-text { margin: 0; font-size: 14px; }

.step-grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
}

.step { display: flex; flex-direction: column; gap: 10px; }
.step p { margin: 0; font-size: 14px; }

.step-number {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-weight: 700;
    background: var(--accent);
    color: var(--accent-ink);
}

.step-title { margin: 0; font-size: 16px; }

.privacy-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(244px, 1fr));
    gap: 18px 26px;
}

.privacy-item { border-left: 2px solid var(--accent); padding-left: 14px; }
.privacy-title { margin: 0 0 4px; font-size: 15px; }
.privacy-item p { margin: 0; font-size: 14px; }

.faq-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px 30px;
}

.faq-question { margin: 0 0 4px; font-size: 15px; }
.faq-item p { margin: 0; font-size: 14px; }

/* --- Подвал -------------------------------------------------------------
   Общий для приветственной страницы, экранов приложения и privacy.html. */

/* Экраны после входа — тоже столбец во всю высоту: подвал прижимается к низу
   окна, а на длинной странице просто идёт за содержимым. */
.app-shell {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

.site-foot {
    margin-top: auto;
    border-top: 1px solid var(--line-soft);
    background: var(--surface);
}

.site-foot-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 22px 20px 40px;
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.site-foot p { margin: 0; max-width: 62ch; }

.foot-link { margin-left: auto; color: var(--ink-3); font-size: 13px; text-decoration: none; }
.foot-link:hover { color: var(--ink-2); text-decoration: underline; }

/* --- Полоска про куки --------------------------------------------------- */

.cookie-note {
    position: fixed;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 80;
    width: min(720px, calc(100vw - 24px));
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-2);
}

.cookie-text { margin: 0; font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.cookie-note .btn { flex: none; }
.cookie-link { color: var(--accent); text-decoration: none; white-space: nowrap; }
.cookie-link:hover { text-decoration: underline; }

/* --- Отдельная страница с текстом (политика конфиденциальности) ---------- */

.doc {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: clamp(28px, 6vw, 56px) 20px 72px;
}

/* Название в шапке текстовой страницы — ссылка домой, но выглядит как логотип. */
.doc-home { color: inherit; text-decoration: none; }

.doc h1 { font-size: clamp(28px, 4vw, 38px); letter-spacing: -.03em; line-height: 1.15; margin: 0 0 8px; }
.doc h2 { font-size: 19px; letter-spacing: -.015em; margin: 34px 0 8px; }
.doc p, .doc li { color: var(--ink-2); }
.doc p { margin: 0 0 12px; }
.doc ul { margin: 0 0 12px; padding-left: 20px; }
.doc li { margin-bottom: 6px; }
.doc a { color: var(--accent); }
.doc-date { color: var(--ink-3); font-size: 13px; margin-bottom: 4px; }

/* Оговорка в конце: тот же тон, что у согласия при регистрации. */
.doc-note {
    margin-top: 32px;
    padding: 14px 16px;
    border: 1px solid var(--line-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    font-size: 13px;
}

/* Прокрутка к форме плавная, но не у тех, кто просил обойтись без движения. */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

@media (max-width: 980px) {
    /* Форма встаёт под рассказ: в одну колонку липкость только мешала бы. */
    .landing-hero { grid-template-columns: minmax(0, 1fr); gap: 28px; }
    .hero-side { position: static; max-width: 460px; }
    .landing-nav { display: none; }
    /* Пояснения уходят под карточку, а не жмутся к ней узкой колонкой. */
    .demo-grid { grid-template-columns: minmax(0, 1fr); gap: 24px; max-width: 460px; }
}

@media (max-width: 720px) {
    .landing-main { padding: 0 14px; }
    .landing-top-inner { padding: 12px 14px; gap: 10px; }
    .site-foot-inner { padding: 20px 14px 32px; }
    .hero-actions .btn { width: 100%; }
    .privacy-grid, .faq-grid { gap: 16px; }
    /* Ссылка на политику встаёт под текст: справа для неё места уже нет. */
    .foot-link { margin-left: 0; }
    /* Полоска про куки на узком экране — в столбик, кнопка во всю ширину. */
    .cookie-note { flex-direction: column; align-items: stretch; gap: 10px; }
}
@media print {
    /* Экран прячется только тогда, когда печатают лист для врача. Обычный
       Ctrl+P к листу отношения не имеет и печатает то, что человек видит, —
       безусловное правило здесь выдавало бы ему пустую страницу. */
    :root[data-printing="sheet"] .topbar,
    :root[data-printing="sheet"] .layout,
    :root[data-printing="sheet"] .overlay,
    :root[data-printing="sheet"] .site-foot,
    :root[data-printing="sheet"] .toast { display: none !important; }

    /* Цвета листа заданы значениями, а не переменными темы: тёмная тема на
       бумаге превратилась бы в чёрную страницу. */
    html, body { background: #fff; color: #000; }

    .sheet {
        display: block;
        max-width: 100%;
        font-size: 11pt;
        line-height: 1.45;
        color: #000;
    }

    .sheet-head {
        display: flex;
        align-items: flex-start;
        justify-content: space-between;
        gap: 16px;
        padding-bottom: 10px;
        border-bottom: 1.5pt solid #000;
    }

    .sheet-head h1 { margin: 0; font-size: 19pt; line-height: 1.2; }
    .sheet-facts { margin: 4px 0 0; font-size: 11pt; }

    .sheet-stamp {
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 2px;
        font-size: 9pt;
        text-align: right;
        white-space: nowrap;
    }

    /* Заголовок не должен оставаться внизу страницы без своего блока. */
    .sheet-block { margin-top: 14px; break-inside: avoid; }
    .sheet-block h2 {
        margin: 0 0 6px;
        font-size: 11pt;
        text-transform: uppercase;
        letter-spacing: .06em;
    }

    .sheet-facts-grid {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 2px 24px;
        margin: 0;
    }

    .sheet-fact { display: flex; gap: 8px; align-items: baseline; }
    .sheet-fact dt { min-width: 46mm; }
    .sheet-fact dd { margin: 0; font-weight: 700; }

    .sheet-empty { margin: 0; font-style: italic; }

    .sheet-table {
        width: 100%;
        border-collapse: collapse;
        font-size: 10pt;
    }

    .sheet-table th,
    .sheet-table td {
        padding: 5px 8px 5px 0;
        text-align: left;
        vertical-align: top;
        border-bottom: .5pt solid #999;
    }

    .sheet-table th {
        font-size: 9pt;
        text-transform: uppercase;
        letter-spacing: .05em;
        border-bottom-width: 1pt;
        border-bottom-color: #000;
    }

    /* Строка препарата не разрывается между страницами: расписание, оторванное
       от названия, читается как чужое. */
    .sheet-table tr { break-inside: avoid; }

    .sheet-list { margin: 0; padding-left: 14px; }
    .sheet-list li { break-inside: avoid; }
    .sheet-small { font-size: 9pt; }

    .sheet-foot {
        margin-top: 18px;
        padding-top: 8px;
        border-top: .5pt solid #999;
        font-size: 8.5pt;
    }

    .sheet-foot p { margin: 0 0 2px; }
}
