/* ═══════════════════════════════════════════════════════════════════════════
   КАБИНЕТ ВРАЧА МедПлан · оболочка и базовые компоненты (17.09.2026)
   ───────────────────────────────────────────────────────────────────────────
   Дизайн-система medchat.tech (см. DESIGN.md проекта и medchat-web/ds/README.md):
   мятный фон приложения, белые карточки с радиусом 30, модалки 40,
   основная кнопка — градиентная пилюля, вторичная — белая с бирюзовой обводкой.

   Кабинет — рабочий инструмент: плотность и читаемость важнее декора.
   Текст не мельче 14 px, основной 15–16; цели нажатия ≥ 40 (≤ 640 px — ≥ 44).

   Подключают: login.html, password-reset*.html, treatment-plans.html.
   В файле оставлены только селекторы, которые встречаются в этих шаблонах
   (разбор 17.09: 190 правил прежней РАКЕТЫ — чаты, мастер бота, тарифы,
   бейджи, скелетоны — ни в одном шаблоне МедПлана не использовались).
   Цвета — только var(--…) из tokens.css.
   ═══════════════════════════════════════════════════════════════════════════ */

@import url("tokens.css");

/* ───── База ───── */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; overflow-x: clip; }
body {
    margin: 0;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: var(--text-body);
    line-height: var(--leading-body);
    letter-spacing: 0;
    color: var(--color-text);
    background-color: var(--color-canvas);
}
h1, h2, h3, h4 {
    font-family: var(--font-display);
    color: var(--color-text-strong);
    letter-spacing: var(--tracking-display);
    line-height: var(--leading-tight);
    margin: 0;
}
h1 { font-size: var(--text-page-title); font-weight: 800; }
h2 { font-size: var(--text-section-title); font-weight: 700; }
h3 { font-size: var(--text-h3); font-weight: 700; }
h4 { font-size: var(--text-h4); font-weight: 700; }
p  { margin: 0; }
a  { color: var(--teal-500); }   /* 5.20 на белом */
button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }

.muted-small { color: var(--color-text-muted); font-size: var(--text-sm); line-height: var(--lh-14); font-weight: 400; }
.row         { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.spacer      { flex: 1 1 auto; }

/* ───── Оболочка: левое меню + колонка ───── */
.shell {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}
.sidebar {
    grid-column: 1;
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    padding: var(--sidebar-pad);
    gap: var(--sidebar-group-gap);
    overflow-y: auto;
    z-index: var(--z-drawer);
}
/* Логотип «МедПлан» в меню: знак + слово + подпись. */
.brand {
    display: flex; align-items: center; gap: var(--space-3);
    min-height: 48px; padding: var(--space-1) var(--space-2);
    text-decoration: none;
    font-family: var(--font-display); font-weight: 800; font-size: 20px; line-height: 1.15;
    letter-spacing: -0.01em; color: var(--ink);
}
.brand-tile {
    width: 40px; height: 40px;
    flex: 0 0 40px;
    border-radius: var(--radius-lg);
    background-image: var(--gradient-brand);
    display: grid; place-items: center;
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 20px;
    color: #fff;
    position: relative;
}
.brand-tile::after {
    content: "";
    position: absolute; right: -3px; top: -3px;
    width: 12px; height: 12px; border-radius: var(--radius-circle);
    background-color: var(--teal-300);
    box-shadow: 0 0 0 2px #fff;
}
.brand-word {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 24px;
    letter-spacing: -0.01em;
    color: var(--ink);
}
.brand-sub {
    display: block; margin-top: 2px;
    font-family: var(--font-body); font-size: 14px; font-weight: 400; line-height: 1.3;
    letter-spacing: 0; text-transform: none;
    color: var(--muted-ui);
}

.nav-group { display: grid; gap: var(--sidebar-item-gap); }
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--sidebar-item-h);
    padding: 0 var(--space-3);
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--sidebar-item-color);
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    position: relative;
    transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
button.nav-item {
    appearance: none;
    -webkit-appearance: none;
    border: 0;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}
.sidebar-foot button.nav-item { color: var(--muted-ui); }
.nav-item:hover { background-color: var(--sidebar-item-hover-bg); color: var(--teal-800); }
.nav-item[aria-current="page"] {
    background-color: var(--sidebar-item-active-bg);
    color: var(--sidebar-item-active-color);
    font-weight: 700;
}
/* Метка активного пункта — бирюзовая полоска слева. */
.nav-item[aria-current="page"]::before {
    content: "";
    position: absolute; left: 0; top: 10px; bottom: 10px;
    width: 3px;
    border-radius: var(--radius-round);
    background-color: var(--teal-500);
}
.nav-ico {
    width: var(--sidebar-icon); height: var(--sidebar-icon);
    flex: 0 0 var(--sidebar-icon);
    display: grid; place-items: center;
    color: var(--teal-500);
}
.nav-item[aria-current="page"] .nav-ico { color: var(--teal-800); }
.nav-item svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot { margin-top: auto; display: grid; gap: var(--space-3); padding-top: var(--space-4);
                border-top: 1px solid var(--line); }

.main { grid-column: 2; min-width: 0; display: flex; flex-direction: column; }
.main > * { min-width: 0; }
.appbar {
    position: sticky; top: 0; z-index: var(--z-sticky);
    min-height: var(--appbar-h);
    display: flex; align-items: center; gap: var(--space-4);
    padding: var(--space-3) var(--content-pad);
    background-color: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
}
.appbar-title { font-family: var(--font-display); font-weight: 700;
                font-size: var(--text-h3); color: var(--ink);
                letter-spacing: -0.01em;
                min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar .muted-small { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.burger { display: none; }

/* ───── Кнопки: пилюли МедЧата ───── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
    min-height: var(--btn-h);
    padding: 10px var(--space-6);
    border-radius: var(--radius-btn);
    border: 0;
    font-family: var(--font-display);
    font-size: 16px;
    line-height: 1.25;
    font-weight: 600;
    letter-spacing: 0;
    cursor: pointer;
    text-decoration: none;
    transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-fast) var(--ease-out),
                filter var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.btn-primary {
    background-image: var(--gradient-accent);
    background-color: var(--grad-b);
    color: #fff;
    box-shadow: none;
}
.btn-primary:hover { background-image: var(--gradient-accent-hover); box-shadow: var(--shadow-accent); }
.btn-primary:active { transform: scale(.97); }
.btn:disabled, .btn[aria-disabled="true"] {
    background-image: none; background-color: var(--color-disabled); color: var(--ink-2);
    box-shadow: none; cursor: not-allowed; transform: none;
}

/* ───── Поля ───── */
.field { display: grid; gap: var(--space-2); }
.field > label, .fld-label {
    font-family: var(--font-body);
    font-size: var(--text-sm); font-weight: 600; color: var(--ink);
}
.input, .textarea, .select {
    width: 100%;
    min-height: var(--control-h);
    padding: var(--field-pad-y) var(--field-pad-r) var(--field-pad-y) var(--field-pad-l);
    border-radius: var(--radius-md);
    background-color: #fff;
    border: 1px solid var(--color-field-border);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 400;
    line-height: var(--lh-16);
    transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--muted-ui); opacity: 1; }
.input:focus, .textarea:focus, .select:focus {
    outline: none; border-color: var(--accent); box-shadow: var(--ring-field);
}
.input:disabled, .textarea:disabled {
    background-color: var(--gray); color: var(--muted-ui);
    border-color: var(--line-h); cursor: not-allowed;
}

/* ───── Переключатель ───── */
.switch { display: inline-flex; align-items: center; gap: var(--space-3); cursor: pointer;
          min-height: var(--control-h-touch); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
    width: 44px; height: 24px; flex: 0 0 44px; border-radius: var(--radius-round);
    background-color: var(--line-h); position: relative;
    transition: background-color var(--dur-base) var(--ease-out);
}
.switch-track::after {
    content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
    border-radius: var(--radius-circle); background-color: #fff; box-shadow: var(--shadow-sm);
    transition: transform var(--dur-base) var(--ease-out);
}
.switch input:checked + .switch-track { background-color: var(--teal-500); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }

/* ───── Карточка: белая плашка МедЧата ───── */
.card {
    position: relative;
    border-radius: var(--radius-card);
    background-color: #fff;
    box-shadow: var(--shadow-card);
    padding: var(--space-8);
    display: grid; gap: var(--space-4);
    align-content: start;
    overflow: hidden;
}
.card > h3 { font-size: var(--text-h3); font-weight: 700; }
.card > p  { line-height: 1.5; }
.tiles > *, .kpi-grid > *, .plans > *, .cols2 > * { min-width: 0; }
.card > *, .card-dashed > *, .card-dark > * { min-width: 0; }

/* Модалка-карточка (страница планов переопределяет .modal как полноэкранный оверлей). */
.modal {
    width: min(560px, 100%); max-height: 88vh; overflow: auto;
    background-color: #fff; border-radius: var(--radius-modal);
    box-shadow: var(--shadow-xl); padding: var(--space-8); display: grid; gap: var(--space-5);
}

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

.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: var(--space-6); }

/* ───── Экран входа и сброса пароля ─────
   Мятный фон, белая карточка радиус 40, логотип «МедПлан», кнопка-пилюля. */
.auth-shell {
    min-height: 100vh; display: grid; place-items: center;
    padding: var(--space-6) var(--space-4);
    background-color: var(--teal-100);
}
.card.auth-card {
    width: min(420px, 100%);
    display: grid; gap: var(--space-5);
    padding: 40px;
    border-radius: var(--radius-modal);
    background-color: #fff;
    box-shadow: 0 23px 43px rgba(0, 57, 58, 0.08);
}
.auth-brand { display: flex; align-items: center; gap: var(--space-3); }
.auth-title { font-family: var(--font-display); font-weight: 800; font-size: 26px; line-height: 1.15; color: var(--ink); }
.auth-sub { font-size: 16px; line-height: 1.5; color: var(--ink-2); }
.auth-card .btn { width: 100%; }
.auth-link { font-size: 15px; font-weight: 500; }
.auth-link a { color: var(--teal-500); text-decoration: underline; text-underline-offset: 3px;
               display: inline-flex; align-items: center; min-height: var(--tap); }
.auth-card .error { color: var(--err); font-size: var(--text-sm); font-weight: 500; }
.auth-card .info  { color: var(--teal-800); font-size: var(--text-sm); font-weight: 500; }
.auth-card .error:empty, .auth-card .info:empty { display: none; }

/* ───── Узкие экраны ───── */
@media (max-width: 900px) {
    .shell { grid-template-columns: minmax(0, 1fr); }
    .sidebar {
        position: fixed; inset: 0 auto 0 0; width: min(var(--sidebar-w), 86vw);
        transform: translateX(-102%);
        transition: transform var(--dur-slow) var(--ease-out);
        box-shadow: var(--shadow-lg);
    }
    /* Меню открывает openNav() из fragments/sidebar.html: он ставит body.nav-open.
       Раньше здесь ждали .shell[data-nav="open"], которого скрипт не ставит, —
       на телефоне бургер ничего не открывал. Оставлены оба признака. */
    .shell[data-nav="open"] .sidebar,
    .nav-open .sidebar { transform: none; }
    .scrim { position: fixed; inset: 0; background-color: var(--color-overlay-soft); z-index: calc(var(--z-drawer) - 1);
             opacity: 0; pointer-events: none; transition: opacity var(--dur-base) var(--ease-out); }
    .shell[data-nav="open"] .scrim,
    .nav-open .scrim { opacity: 1; pointer-events: auto; }
    .main { grid-column: 1; }
    .appbar { min-height: var(--appbar-h-mobile); padding: var(--space-2) var(--content-pad-mobile); }
    .burger {
        display: grid; place-items: center; width: var(--control-h-touch); height: var(--control-h-touch);
        flex: 0 0 var(--control-h-touch); border: 1px solid var(--teal-400); border-radius: var(--radius-round);
        background-color: #fff; cursor: pointer; color: var(--teal-800);
    }
    .burger svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
    .card, .card-dashed, .card-dark, .plan { padding: var(--space-5); }
}
@media (max-width: 720px) {
    h1 { font-size: var(--text-h2); }
    .card > h3 { font-size: var(--text-h3); }
    .card > p, .page-head p { font-size: 15px; line-height: var(--lh-16); }
    .btn { width: 100%; }
    .row .btn, .bubble-actions .btn, .modal-foot .btn { width: auto; }
}
@media (max-width: 640px) {
    .card.auth-card { padding: 28px 20px; border-radius: var(--radius-card); }
}
