/* ==========================================================================
   Личный кабинет клиента ООО «Первая правовая помощь»
   Стилизация под lk-ppp.ru: синий #1a3a6b, золотой #f5b342
   ========================================================================== */

:root {
    /* Цвета бренда */
    --primary:        #1a3a6b;
    --primary-dark:   #142d54;
    --primary-light:  #2a4f8a;
    --primary-soft:   #eef3fa;
    --accent:         #f5b342;
    --accent-dark:    #e09a26;
    --accent-soft:    #fff6e6;

    /* Нейтральные */
    --bg:             #f4f6fa;
    --surface:        #ffffff;
    --border:         #e5e9f0;
    --text:           #1f2937;
    --text-muted:     #6b7280;
    --text-light:     #9ca3af;

    /* Семантика */
    --green:          #16a34a;
    --green-soft:     #dcfce7;
    --yellow:         #ca8a04;
    --yellow-soft:    #fef3c7;
    --red:            #dc2626;
    --red-soft:       #fee2e2;
    --blue:           #2563eb;
    --blue-soft:      #dbeafe;
    --gray:           #6b7280;
    --gray-soft:      #f3f4f6;
    --dark:           #374151;
    --dark-soft:      #d1d5db;

    /* Тени */
    --shadow-sm:      0 1px 2px rgba(16, 32, 64, .06);
    --shadow:         0 4px 14px rgba(16, 32, 64, .08);
    --shadow-lg:      0 10px 30px rgba(16, 32, 64, .12);

    /* Радиусы */
    --r-sm:           8px;
    --r:              12px;
    --r-lg:           16px;
    --r-xl:           22px;

    --sidebar-w:      268px;
    --topbar-h:       68px;
    --maxw:           1180px;

    /* Safe area (iPhone notch и др.) */
    --safe-top:    env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left:   env(safe-area-inset-left, 0px);
    --safe-right:  env(safe-area-inset-right, 0px);

    --bottomnav-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; }
html { overflow-x: clip; }
body {
    margin: 0; padding: 0;
    overflow-x: clip;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }
img { max-width: 100%; display: block; }
code { background: var(--gray-soft); padding: 1px 6px; border-radius: 4px; font-size: 13px; }

/* ---- Lucide SVG icons ---- */
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.nav__icon .icon { transition: transform .2s ease; }
.nav__item:hover .nav__icon .icon,
.nav__item--active .nav__icon .icon { transform: scale(1.15); }
.bottom-nav__icon .icon { transition: transform .2s ease; }
.bottom-nav__item:active .bottom-nav__icon .icon,
.bottom-nav__item--active .bottom-nav__icon .icon { transform: scale(1.2) translateY(-2px); }
.card__title .icon { vertical-align: -3px; }
.btn .icon { vertical-align: -3px; margin-right: 2px; }

/* =================== APP SHELL =================== */
.app { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.sidebar {
    width: var(--sidebar-w);
    background: #262626;
    color: #fff;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: 4px 0 24px rgba(16, 32, 64, .12);
}
.sidebar__brand {
    display: flex; align-items: center; gap: 12px;
    padding: 22px 22px 18px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar__logo {
    width: 44px; height: 44px;
    background: var(--accent);
    color: var(--primary-dark);
    border-radius: 12px;
    display: grid; place-items: center;
    font-weight: 800; font-size: 14px;
    letter-spacing: .5px;
    box-shadow: 0 4px 12px rgba(245, 179, 66, .35);
}
.sidebar__logo-img {
    width: 44px; height: 44px;
    border-radius: 10px;
    object-fit: contain;
    flex-shrink: 0;
}
.sidebar__brand-title { font-weight: 700; font-size: 14px; line-height: 1.25; text-transform: uppercase; letter-spacing: .5px; }
.sidebar__brand-sub   { font-size: 12px; opacity: .65; margin-top: 2px; }

.nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.nav__item {
    display: flex; align-items: center; gap: 14px;
    padding: 12px 14px;
    color: rgba(255,255,255,.78);
    border-radius: var(--r-sm);
    font-weight: 500; font-size: 15px;
    margin-bottom: 4px;
    transition: background .15s, color .15s;
    position: relative;
}
.nav__item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav__item--active {
    background: rgba(255,255,255,.13);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--accent);
}
.nav__item--danger:hover { background: rgba(220, 38, 38, .18); color: #fecaca; }
.nav__icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav__label { flex: 1; }
.nav__badge {
    background: var(--accent);
    color: var(--primary-dark);
    font-weight: 700; font-size: 12px;
    padding: 1px 8px;
    border-radius: 99px;
    min-width: 20px; text-align: center;
}

.sidebar__footer {
    padding: 16px 22px;
    border-top: 1px solid rgba(255,255,255,.08);
    font-size: 13px;
}
.sidebar__site, .sidebar__phone { display: block; color: rgba(255,255,255,.75); }
.sidebar__phone { font-weight: 600; color: #fff; margin-top: 4px; }
.sidebar__version { display: block; margin-top: 6px; font-size: 11px; color: rgba(255,255,255,.3); }

/* ---- Main + Topbar ---- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px;
    padding: 0 28px;
    position: sticky; top: 0; z-index: 30;
}
.topbar__title { margin: 0; font-size: 20px; font-weight: 700; flex: 1; }
.topbar__burger { display: none; background: none; border: 0; cursor: pointer; padding: 8px; color: var(--primary); align-items: center; }
.topbar__user { display: flex; align-items: center; gap: 12px; }
.topbar__user-name { font-weight: 600; text-align: right; }
.topbar__user-sub  { font-size: 12px; color: var(--text-muted); text-align: right; }
.topbar__avatar {
    width: 40px; height: 40px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 50%;
    display: grid; place-items: center;
    font-weight: 700;
}
.app__overlay { display: none; }

.content {
    padding: 28px;
    max-width: var(--maxw);
    width: 100%;
    margin: 0 auto;
    flex: 1;
}
.content--narrow { max-width: 880px; }

/* =================== CARDS / GRID =================== */
.card {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 22px;
    margin-bottom: 20px;
}
.card__title {
    font-size: 16px; font-weight: 700; margin: 0 0 16px;
    color: var(--primary);
    display: flex; align-items: center; gap: 8px;
}
.card__title-badge { margin-left: auto; }

.grid { display: grid; gap: 18px; }
.grid--2 { grid-template-columns: 1fr 1fr; }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }
.grid--sidebar { grid-template-columns: 2fr 1fr; }
@media (max-width: 980px) {
    .grid--2, .grid--3, .grid--4, .grid--sidebar { grid-template-columns: 1fr; }
}

/* =================== INFO ROWS =================== */
.info {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 8px 16px;
    font-size: 15px;
}
.info__dt { color: var(--text-muted); }
.info__dd { font-weight: 500; margin: 0; word-break: break-word; }
@media (max-width: 560px) { .info { grid-template-columns: 1fr; gap: 2px; } .info__dt { font-size: 13px; } }

/* =================== CLIENT CARD =================== */
.client-rows {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.client-rows__item {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 0;
}
.client-rows__item + .client-rows__item {
    border-top: 1px solid var(--border);
}
.client-rows__icon {
    width: 40px; height: 40px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.client-rows__label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.client-rows__value {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    word-break: break-word;
}
.client-rows__link {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}
.client-rows__link:hover { text-decoration: underline; }

/* =================== STAT WIDGETS =================== */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 980px) { .stats { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .stats { grid-template-columns: 1fr; } }

.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    padding: 18px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.stat__label { color: var(--text-muted); font-size: 13px; font-weight: 500; }
.stat__value { font-size: 24px; font-weight: 800; margin-top: 6px; color: var(--primary); }
.stat--green .stat__value { color: var(--green); }
.stat--red   .stat__value { color: var(--red); }
.stat--yellow .stat__value { color: var(--yellow); }
.stat--gray   .stat__value { color: var(--text-muted); }
.stat--orange .stat__value { color: #e67e22; }
.stat__bar { height: 4px; border-radius: 4px; background: var(--gray-soft); margin-top: 12px; overflow: hidden; }
.stat__bar-fill { height: 100%; background: var(--green); border-radius: 4px; transition: width .4s; }

/* =================== BADGES =================== */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 13px; font-weight: 600;
    background: var(--gray-soft);
    color: var(--gray);
    white-space: nowrap;
}
.badge--green  { background: var(--green-soft);  color: var(--green); }
.badge--yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge--orange { background: #fff3e0;            color: #e67e22; }
.badge--red    { background: var(--red-soft);    color: var(--red); }
.badge--blue   { background: var(--blue-soft);   color: var(--blue); }
.badge--gray   { background: var(--gray-soft);   color: var(--gray); }
.badge--dark   { background: var(--dark-soft);   color: var(--dark); }
.badge--purple { background: #f3e8ff;            color: #7e22ce; }
.badge--teal   { background: #ccfbf1;            color: #0d9488; }
.badge--lg { padding: 8px 14px; font-size: 14px; }

/* =================== TABLE =================== */
.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid var(--border); }
table.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 14px;
}
.table th, .table td { padding: 14px 16px; text-align: left; }
.table thead th {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .3px;
    border-bottom: 1px solid var(--border);
}
.table tbody tr { border-bottom: 1px solid var(--border); }
.table tbody tr:last-child { border-bottom: 0; }
.table tbody tr:hover { background: var(--primary-soft); }
.table .num { text-align: center; width: 40px; color: var(--text-muted); }
.table .money { font-weight: 700; white-space: nowrap; }
.table .money--paid { color: var(--green); }
.invoice-row { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.invoice-row:hover { background: var(--primary-soft); }

/* =================== PROGRESS BAR =================== */
.progress { height: 14px; background: var(--gray-soft); border-radius: 99px; overflow: hidden; }
.progress__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--green), #4ade80);
    border-radius: 99px;
    transition: width .6s ease;
}
.progress__head { display: flex; justify-content: space-between; margin-bottom: 8px; font-size: 13px; }

/* =================== BUTTONS =================== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-light); color: #fff; }
.btn--accent  { background: var(--accent); color: var(--primary-dark); }
.btn--accent:hover { background: var(--accent-dark); color: var(--primary-dark); }
.btn--ghost   { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--gray-soft); }
.btn--success { background: var(--green); color: #fff; border-color: var(--green); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn--success:hover { background: #15803d; color: #fff; }
.btn--gold    { background: var(--accent); color: var(--primary-dark); border-color: var(--accent); }
.btn--gold:hover { background: var(--accent-dark); color: var(--primary-dark); }
.btn--block { width: 100%; }
.btn--lg { padding: 13px 22px; font-size: 15px; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

.btn__badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px;
    background: #fff;
    color: var(--primary);
    font-size: 11px; font-weight: 700; line-height: 1;
    margin-left: 6px;
}
.btn--success .btn__badge { background: rgba(255,255,255,.3); color: #fff; }
[data-theme="dark"] .btn--primary .btn__badge { background: rgba(0,0,0,.25); color: #fff; }

/* Chat notification banner (dashboard) */
.chat-notify {
    display: flex; align-items: center; gap: 12px;
    max-width: var(--content-max, 1140px);
    margin: 0 auto 16px;
    padding: 12px 16px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark, #14305a));
    color: #fff;
    border-radius: 12px;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(26,58,107,.18);
    transition: transform .15s, box-shadow .15s;
}
.chat-notify:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(26,58,107,.25); }
.chat-notify__icon {
    width: 42px; height: 42px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.chat-notify__body { flex: 1; min-width: 0; }
.chat-notify__title { display: block; font-weight: 700; font-size: 15px; }
.chat-notify__text {
    display: block; font-size: 13px; opacity: .9;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-notify__arrow { opacity: .7; flex-shrink: 0; }

/* =================== FORMS =================== */
.field { margin-bottom: 14px; }
.field__label {
    display: block; font-size: 13px; font-weight: 500;
    margin-bottom: 6px; color: var(--text);
}
.input, .textarea, .select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 15px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(42, 79, 138, .12);
}
.input--lg { padding: 13px 16px; font-size: 16px; }
.textarea { min-height: 96px; resize: vertical; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }

/* =================== ALERTS =================== */
.alert {
    padding: 12px 16px;
    border-radius: var(--r-sm);
    margin-bottom: 14px;
    font-size: 14px;
    border: 1px solid transparent;
}
.alert--error { background: var(--red-soft); color: var(--red); border-color: #fecaca; }
.alert--info  { background: var(--blue-soft); color: var(--blue); border-color: #bfdbfe; }
.alert--success { background: var(--green-soft); color: var(--green); border-color: #bbf7d0; }
.alert--floating { position: sticky; top: 84px; z-index: 20; }

/* Служебный баннер под шапкой ЛК */
.lk-banner {
    padding: 8px 20px;
    background: var(--red-soft);
    color: var(--red);
    font-size: 13px;
    font-weight: 700;
    line-height: 1.45;
    text-align: center;
    position: sticky;
    top: var(--topbar-h);
    z-index: 25;
}

/* =================== AUTH PAGE =================== */
.auth {
    min-height: 100vh;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--primary-dark), var(--primary) 60%, var(--primary-light));
    padding: 24px;
}
.auth__card {
    background: var(--surface);
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    padding: 36px;
    max-width: 420px;
    width: 100%;
}
.auth__logo { display: flex; justify-content: center; margin-bottom: 18px; }
.auth__logo-mark {
    width: 64px; height: 64px;
    background: var(--accent);
    color: var(--primary-dark);
    border-radius: 16px;
    display: grid; place-items: center;
    font-weight: 800; font-size: 20px;
    box-shadow: 0 8px 24px rgba(245, 179, 66, .4);
}
.auth__logo-img {
    width: 72px; height: 72px;
    border-radius: 16px;
    object-fit: contain;
    background: #fff;
    padding: 6px;
    box-shadow: 0 8px 24px rgba(0,0,0,.1);
}
.auth__title { text-align: center; font-size: 22px; font-weight: 800; color: var(--primary); margin: 0 0 4px; }
.auth__subtitle { text-align: center; color: var(--text-muted); margin: 0 0 22px; font-size: 14px; }
.auth__hint { margin-top: 18px; font-size: 13px; color: var(--text-muted); text-align: center; line-height: 1.6; }

/* Demo login block */
.auth__demo { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.auth__demo-panel { text-align: center; }
.auth__demo-text { font-size: 13px; color: var(--text-muted); margin: 0 0 10px; }
.demo-login-info { display: flex; flex-direction: column; gap: 6px; }
.demo-login-info__item { font-size: 13px; color: var(--text-muted); }
.demo-login-info__label { font-weight: 600; color: var(--text); }
.demo-login-info code { background: var(--bg); padding: 2px 8px; border-radius: 6px; font-size: 13px; color: var(--primary); }

/* Checkbox "Запомнить меня" */
.checkbox-row { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; color: var(--text-muted); user-select: none; }
.checkbox-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--primary); cursor: pointer; }

/* =================== SKELETONS =================== */
.skel {
    background: linear-gradient(90deg, var(--gray-soft) 25%, #e5e9f0 50%, var(--gray-soft) 75%);
    background-size: 200% 100%;
    animation: skel 1.4s ease infinite;
    border-radius: var(--r-sm);
    display: inline-block;
}
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel--line { display: block; height: 14px; margin-bottom: 8px; }
.skel--title { height: 22px; width: 60%; }
.skel--card { height: 120px; }

/* =================== MISC =================== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state__icon { font-size: 48px; margin-bottom: 12px; opacity: .6; }
.empty-state__title { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 6px; }

.masked { font-variant-numeric: tabular-nums; letter-spacing: 2px; }
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }

/* =================== NEWS MEDIA =================== */
.news-media { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.news-media__video { width: 100%; max-height: 480px; border-radius: 12px; background: #000; }
.news-media__img { max-width: 100%; height: auto; border-radius: 12px; display: block; }
.news-thumb { margin-top: 10px; }
.news-thumb img { max-width: 100%; max-height: 180px; border-radius: 10px; object-fit: cover; display: block; }

/* =================== CHAT (Telegram-style) =================== */
.page-chat .content { padding: 0; max-width: 100%; overflow: hidden; }
.page-chat .topbar { display: none; }

/* Мобайл: фиксируем body/app/main/content чтобы не скроллились.
   iOS: position: fixed на body блокирует скролл; компенсация клавиатуры — через JS (visualViewport top/height). */
@media (max-width: 860px) {
    html, .page-chat { overscroll-behavior-y: none; }
    .page-chat { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; }
    .page-chat .app { height: 100%; overflow: hidden; }
    .page-chat .main { height: 100%; overflow: hidden; }
    .page-chat .content { height: 100%; overflow: hidden; }
}

.chat {
    display: flex;
    flex-direction: column;
    max-width: 760px;
    margin: 0 auto;
    background: var(--surface);
}

[data-theme="dark"] .chat { background: #0e1621; }

/* Мобайл: контейнер фиксирован, скроллит только .chat__body */
@media (max-width: 860px) {
    .chat {
        position: fixed;
        top: 0; left: 0; right: 0; bottom: 0;
        max-width: 100%;
        height: 100vh;
        height: 100dvh;
        z-index: 100;
    }
}

/* Десктоп: flex-раскладка с фиксированной высотой */
@media (min-width: 861px) {
    .chat {
        height: calc(100dvh - var(--topbar-h));
        margin-top: var(--topbar-h);
    }
}

/* ===== Header ===== */
.chat__header {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 56px;
    padding: 0 8px 0 4px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
[data-theme="dark"] .chat__header {
    background: #17212b;
    border-bottom-color: #0e1621;
}

.chat__back {
    width: 42px; height: 42px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--primary);
    text-decoration: none;
    flex-shrink: 0;
    transition: background .15s;
}
.chat__back:hover { background: var(--gray-soft); }
[data-theme="dark"] .chat__back { color: #6ab3f3; }

.chat__peer {
    display: flex; align-items: center; gap: 10px;
    flex: 1; min-width: 0;
}
.chat__peer-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark, #14305a));
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 16px;
    flex-shrink: 0;
    text-transform: uppercase;
}
.chat__peer-info { min-width: 0; }
.chat__peer-name {
    font-weight: 600; font-size: 16px;
    color: var(--text);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
[data-theme="dark"] .chat__peer-name { color: #e9edef; }
.chat__peer-status {
    font-size: 13px; color: var(--text-muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat__header-actions { display: flex; gap: 4px; }
.chat__header-btn {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    text-decoration: none;
    transition: background .15s, color .15s;
}
.chat__header-btn:hover { background: var(--gray-soft); color: var(--primary); }

/* ===== Messages area (scrollable) ===== */
.chat__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    background:
        radial-gradient(circle at 20% 30%, rgba(26,58,107,.02) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(245,179,66,.02) 0%, transparent 50%),
        var(--gray-soft);
}
[data-theme="dark"] .chat__body {
    background: #0e1621;
}

.chat__messages {
    min-height: 100%;
    padding: 8px 0 12px;
    display: flex;
    flex-direction: column;
}

.chat__loading {
    display: flex; justify-content: center; align-items: center;
    padding: 60px 20px;
}
.spinner {
    width: 28px; height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.chat__empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
}
.chat__empty p { margin: 12px 0 0; font-size: 16px; font-weight: 600; }
.chat__empty-hint { font-size: 14px !important; font-weight: 400 !important; margin-top: 4px !important; }

.chat__date-sep {
    text-align: center;
    margin: 12px 0 8px;
}
.chat__date-sep::after {
    content: attr(data-date);
}
.chat__messages > .chat__date-sep {
    display: none;
}
.chat__messages .chat__date-sep {
    display: block;
}
.chat__date-sep {
    position: relative;
    overflow: visible;
    text-align: center;
}
.chat__date-sep {
    color: var(--text-light);
    font-size: 12px;
    background: rgba(0,0,0,.05);
    border-radius: 12px;
    padding: 3px 12px;
    display: inline-block;
    align-self: center;
    margin: 10px auto 6px;
}
[data-theme="dark"] .chat__date-sep {
    background: rgba(255,255,255,.08);
    color: #8696a9;
}

/* ===== Message bubbles ===== */
.chat__b {
    display: flex;
    padding: 1px 12px;
    max-width: 100%;
    animation: chatBubbleIn .2s ease-out;
}
@keyframes chatBubbleIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat__b--out { justify-content: flex-end; }
.chat__b--in { justify-content: flex-start; }

.chat__bubble {
    position: relative;
    max-width: min(75%, 520px);
    padding: 7px 11px 6px;
    border-radius: 16px;
    font-size: 15px;
    line-height: 1.38;
    word-wrap: break-word;
    overflow-wrap: anywhere;
    box-shadow: 0 1px 1.5px rgba(0,0,0,.06);
}
.chat__bubble--out {
    background: #effdde;
    color: #111b21;
    border-bottom-right-radius: 5px;
    margin-left: auto;
}
.chat__bubble--in {
    background: #fff;
    color: #111b21;
    border-bottom-left-radius: 5px;
    margin-right: auto;
}
[data-theme="dark"] .chat__bubble--out { background: #2b5278; color: #e9edef; }
[data-theme="dark"] .chat__bubble--in { background: #182533; color: #e9edef; }

.chat__bubble-text { white-space: pre-wrap; }

.chat__bubble-time {
    float: right;
    margin: 3px -3px -2px 8px;
    font-size: 11px;
    color: var(--text-light);
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    user-select: none;
}
.chat__bubble--out .chat__bubble-time { color: #667781; }
[data-theme="dark"] .chat__bubble--out .chat__bubble-time { color: #ffffff80; }
.chat__check { color: #34b7f1; flex-shrink: 0; }

/* ===== Attachments ===== */
.chat__bubble-img {
    margin: 2px -5px 3px;
    border-radius: 10px;
    overflow: hidden;
    cursor: zoom-in;
    max-width: 280px;
}
.chat__bubble-img img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 320px;
    object-fit: cover;
}

.chat__voice {
    display: flex; align-items: center; gap: 10px;
    margin: 2px 0;
    min-width: 200px;
    padding: 6px 4px;
}

/* Кастомный плеер как в WhatsApp/Telegram Web */
.chat__voice-play {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: transform .1s, opacity .15s;
    padding: 0;
}
.chat__voice-play:active { transform: scale(.92); }
.chat__bubble--out .chat__voice-play { background: #fff; color: var(--primary); }
[data-theme="dark"] .chat__bubble--in .chat__voice-play { background: #6ab3f3; }
[data-theme="dark"] .chat__bubble--out .chat__voice-play { background: #e9edef; color: #2b5278; }

.chat__voice-wave {
    flex: 1;
    height: 28px;
    display: flex;
    align-items: center;
    gap: 2px;
    position: relative;
    cursor: pointer;
    min-width: 0;
}
.chat__voice-bar {
    flex: 1;
    background: rgba(255,255,255,.5);
    border-radius: 2px;
    min-width: 2px;
    max-width: 3px;
    transition: background .15s;
}
.chat__bubble--in .chat__voice-bar { background: rgba(26,58,107,.22); }
[data-theme="dark"] .chat__bubble--in .chat__voice-bar { background: rgba(255,255,255,.18); }
.chat__voice-bar--active { background: rgba(255,255,255,.95) !important; }
.chat__bubble--in .chat__voice-bar--active { background: var(--primary) !important; }
[data-theme="dark"] .chat__bubble--in .chat__voice-bar--active { background: #6ab3f3 !important; }

.chat__voice-time {
    font-size: 12px;
    color: inherit;
    opacity: .7;
    flex-shrink: 0;
    min-width: 32px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.chat__voice-missing {
    font-size: 13px; color: var(--text-muted);
    font-style: italic;
}

.chat__file {
    display: flex; align-items: center; gap: 8px;
    margin: 4px 0 2px;
    padding: 8px 10px;
    background: rgba(0,0,0,.06);
    border-radius: 10px;
    text-decoration: none;
    color: inherit;
    transition: background .15s;
    min-width: 180px;
}
.chat__bubble--out .chat__file { background: rgba(255,255,255,.3); }
.chat__bubble--in .chat__file { background: rgba(0,0,0,.04); }
.chat__file:hover { background: rgba(0,0,0,.1); }
[data-theme="dark"] .chat__file { background: rgba(255,255,255,.06); }
.chat__file-icon { flex-shrink: 0; color: var(--primary); }
[data-theme="dark"] .chat__file-icon { color: #6ab3f3; }
.chat__file-body { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.chat__file-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__file-size { font-size: 12px; color: var(--text-muted); }
.chat__file-dl { flex-shrink: 0; color: var(--text-muted); }
.chat__file--pending { opacity: .5; }

/* ===== File preview (pending attach) ===== */
.chat__preview {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px;
    background: var(--primary-soft);
    border-radius: 10px;
    margin: 4px 14px 0;
    font-size: 13px;
}
.chat__preview-img { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; }
.chat__preview-icon { font-size: 18px; }
.chat__preview-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat__preview-x {
    border: none; background: rgba(0,0,0,.1);
    width: 24px; height: 24px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; color: var(--text-muted); flex-shrink: 0;
}
.chat__preview-x:hover { background: rgba(0,0,0,.2); }

/* ===== Recording bar ===== */
.chat__rec {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px;
    background: #fee2e2;
    border-top: 1px solid #fecaca;
    flex-shrink: 0;
    animation: chatRecSlide .2s ease-out;
}
[data-theme="dark"] .chat__rec { background: #3b1d1d; border-top-color: #5a2828; }
@keyframes chatRecSlide {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.chat__rec-dot {
    width: 10px; height: 10px; border-radius: 50%;
    background: #ef4444;
    animation: chatRecPulse 1s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes chatRecPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: .4; transform: scale(.8); }
}
.chat__rec-text { font-weight: 600; color: #ef4444; font-size: 14px; }
.chat__rec-timer { font-weight: 700; color: #ef4444; font-size: 15px; font-variant-numeric: tabular-nums; }
.chat__rec-hint {
    margin-left: auto;
    font-size: 12px; color: var(--text-muted);
}

/* ===== Composer ===== */
.chat__composer {
    flex-shrink: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 8px;
    padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
}
[data-theme="dark"] .chat__composer {
    background: #17212b;
    border-top-color: #0e1621;
}

.chat__form {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    max-width: 740px;
    margin: 0 auto;
}

.chat__attach {
    width: 44px; height: 44px;
    border: none; background: none;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}
.chat__attach:hover { background: var(--gray-soft); color: var(--primary); }
[data-theme="dark"] .chat__attach:hover { color: #6ab3f3; }

.chat__field {
    flex: 1;
    min-width: 0;
    background: var(--gray-soft);
    border-radius: 22px;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    transition: background .15s;
}
[data-theme="dark"] .chat__field { background: #242f3d; }

.chat__input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 16px;
    line-height: 1.4;
    resize: none;
    outline: none;
    max-height: 120px;
    min-height: 22px;
    padding: 0;
}
[data-theme="dark"] .chat__input { color: #e9edef; }
.chat__input::placeholder { color: var(--text-muted); }

.chat__action-btn {
    width: 44px; height: 44px;
    border: none;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all .2s cubic-bezier(.4,0,.2,1);
}

.chat__mic {
    background: transparent;
    color: var(--text-muted);
}
.chat__mic:hover { background: var(--gray-soft); color: var(--red); }
.chat__mic--rec {
    background: #ef4444 !important;
    color: #fff !important;
    animation: chatMicPulse 1.2s ease-in-out infinite;
}
@keyframes chatMicPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
    50% { box-shadow: 0 0 0 8px rgba(239,68,68,0); }
}
.chat__mic--sending {
    animation: chatMicSpin .8s linear infinite;
}
@keyframes chatMicSpin { to { transform: rotate(360deg); } }

.chat__send {
    background: var(--primary);
    color: #fff;
}
.chat__send:hover { background: var(--primary-dark, #14305a); }
[data-theme="dark"] .chat__send { background: #3390ec; }
.chat__send:disabled { opacity: .5; cursor: default; }

/* ===== Lightbox ===== */
.chat__lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0,0,0,.92);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    cursor: zoom-out;
    animation: chatFade .15s;
}
@keyframes chatFade { from { opacity: 0; } to { opacity: 1; } }
.chat__lightbox img {
    max-width: 95vw; max-height: 95vh;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0,0,0,.5);
}

/* ===== Mobile adjustments ===== */
@media (max-width: 860px) {
    .chat { max-width: 100%; }
    .chat__bubble { max-width: 80%; }
    .page-chat .app__overlay { display: none !important; }
    .page-chat .sidebar { display: none !important; }
    .page-chat .bottom-nav { display: none !important; }
    .page-chat .main { padding: 0; }
    .chat__rec-hint { display: none; }
    .chat__form { gap: 2px; }
    .chat__attach, .chat__action-btn { width: 42px; height: 42px; }
}

/* =================== MODAL =================== */
.modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 100;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal-overlay--show { display: flex; }
.modal {
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    max-width: 460px; width: 100%;
    padding: 28px;
    animation: modalIn .2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Стать партнёром — модалка подтверждения */
.become-agent__icon {
    width: 72px; height: 72px; margin: 0 auto 16px;
    display: grid; place-items: center;
    border-radius: 50%;
    background: #e8f7ef; color: #22c55e;
}
[data-theme="dark"] .become-agent__icon { background: rgba(34,197,94,.15); color: #4ade80; }
.become-agent__text { text-align: center; font-size: 15px; line-height: 1.6; color: var(--text); margin: 0 0 16px; }
.become-agent__list { list-style: none; padding: 0; margin: 0 0 16px; display: flex; flex-direction: column; gap: 10px; }
.become-agent__list li { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.become-agent__list svg { flex-shrink: 0; color: #22c55e; }
[data-theme="dark"] .become-agent__list svg { color: #4ade80; }
.become-agent__hint { text-align: center; font-size: 13px; color: var(--text-muted); margin: 0; padding-top: 12px; border-top: 1px solid var(--border); }

/* QR-оплата */
.qr-pay { text-align: center; }
.qr-pay__info { margin-bottom: 16px; }
.qr-pay__label { font-size: 13px; color: var(--text-muted); margin-bottom: 2px; }
.qr-pay__amount { font-size: 22px; font-weight: 800; color: var(--primary); }
.qr-pay__image { display: flex; justify-content: center; margin-bottom: 14px; }
.qr-pay__image img { width: 220px; height: 220px; object-fit: contain; border-radius: 12px; border: 1px solid var(--border); }
.qr-pay__hint { font-size: 13px; color: var(--text-muted); line-height: 1.5; }

.pay-details { padding: 0 4px; }
.pay-details__head { text-align: center; margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--border); }
.pay-details__label { font-size: 13px; color: var(--text-muted); margin-bottom: 2px; }
.pay-details__amount { font-size: 22px; font-weight: 800; color: var(--primary); }
.pay-details__card { display: flex; flex-direction: column; gap: 2px; }
.pay-details__hint { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .3px; }
.pay-details__row { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.pay-details__row:last-child { border-bottom: none; }
.pay-details__dt { font-size: 13px; color: var(--text-muted); white-space: nowrap; flex-shrink: 0; }
.pay-details__dd { font-size: 14px; font-weight: 600; text-align: right; word-break: break-word; }
.pay-details__dd--mono { font-family: 'Courier New', monospace; font-weight: 700; letter-spacing: .3px; }

.pay-notice { display: flex; align-items: flex-start; gap: 10px; margin-top: 16px; padding: 12px 14px; background: #eff6ff; border-radius: 10px; font-size: 13px; color: #1e40af; line-height: 1.5; }
.pay-notice svg { flex-shrink: 0; margin-top: 1px; }
[data-theme="dark"] .pay-notice { background: rgba(59,130,246,.15); color: #93c5fd; }

.step-modal { padding: 4px 0; }
.step-modal__badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 700; margin-bottom: 16px; }
.step-modal__badge--done { background: #e8f7ef; color: #22c55e; }
.step-modal__badge--active { background: rgba(26,58,107,.1); color: var(--primary); }
[data-theme="dark"] .step-modal__badge--done { background: rgba(34,197,94,.15); color: #4ade80; }
[data-theme="dark"] .step-modal__badge--active { background: rgba(59,130,246,.15); color: #93c5fd; }
.step-modal__desc { font-size: 15px; line-height: 1.7; color: var(--text); margin: 0; }

.modal__header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px;
}
.modal__title { font-size: 18px; font-weight: 700; margin: 0; }
.modal__close {
    background: none; border: none; cursor: pointer;
    font-size: 24px; color: var(--text-muted);
    width: 32px; height: 32px;
    display: grid; place-items: center;
    border-radius: var(--r-sm);
    transition: background .15s;
}
.modal__close:hover { background: var(--bg); color: var(--text); }
.modal__field { margin-bottom: 16px; }
.modal__field label {
    display: block; margin-bottom: 6px;
    font-size: 14px; font-weight: 600; color: var(--text);
}
.modal__field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
}
.modal__field input:focus {
    outline: none;
    border-color: var(--primary);
}
.modal__field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    resize: vertical;
    line-height: 1.5;
}
.modal__field textarea:focus {
    outline: none;
    border-color: var(--primary);
}
.modal__field select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    font-size: 15px;
    font-family: inherit;
    box-sizing: border-box;
    background: var(--surface);
    cursor: pointer;
}

/* Category chips for appeal form */
.chip-group {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 100px;
    background: var(--surface);
    font-size: 14px; font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip--active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.chip--active:hover { background: var(--primary-light); color: #fff; }

/* =================== NOTIFICATIONS =================== */
.topbar__right { display: flex; align-items: center; gap: 12px; }

.notif { position: relative; }
.notif__bell {
    position: relative;
    background: none; border: none; cursor: pointer;
    font-size: 22px; padding: 6px; border-radius: 50%;
    transition: background .15s;
}
.notif__bell:hover { background: var(--primary-soft); }
.notif__dot {
    position: absolute; top: 0; right: 0;
    background: var(--red); color: #fff;
    font-size: 10px; font-weight: 700;
    min-width: 17px; height: 17px;
    border-radius: 9px; padding: 0 4px;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}
.notif__dropdown {
    display: none;
    position: absolute; top: 100%; right: 0;
    width: 360px; max-width: calc(100vw - 24px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: 0 8px 30px rgba(0,0,0,.12);
    z-index: 50; overflow: hidden;
}
.notif__dropdown--show { display: block; }
.notif__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; font-weight: 700; font-size: 14px;
    border-bottom: 1px solid var(--border);
    background: var(--primary-soft);
}
.notif__read-all {
    font-size: 12px; color: var(--primary);
    text-decoration: none; font-weight: 600;
}
.notif__read-all:hover { text-decoration: underline; }
.notif__empty {
    padding: 32px 16px; text-align: center;
    color: var(--text-muted); font-size: 14px;
}
.notif__item {
    display: flex; gap: 12px; padding: 12px 16px;
    text-decoration: none; color: inherit;
    border-bottom: 1px solid var(--border);
    transition: background .12s;
}
.notif__item:hover { background: var(--primary-soft); }
.notif__item--unread { background: #f0f6ff; }
.notif__icon { font-size: 20px; flex-shrink: 0; padding-top: 2px; }
.notif__body { flex: 1; min-width: 0; }
.notif__title { font-weight: 600; font-size: 13px; color: var(--text); }
.notif__text { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.notif__time { font-size: 11px; color: var(--text-light); margin-top: 4px; }
.notif__all {
    display: block; text-align: center;
    padding: 12px; font-size: 13px; font-weight: 600;
    color: var(--primary); text-decoration: none;
    border-top: 1px solid var(--border);
}
.notif__all:hover { background: var(--primary-soft); }

/* Прогресс банкротства */
.bk-progress {
    display: flex; align-items: flex-start; justify-content: space-between;
    gap: 4px; margin-top: 8px;
}
.bk-step {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    flex: 1; min-width: 0;
    position: relative;
}
.bk-step__circle {
    width: 40px; height: 40px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700;
    background: var(--bg); color: var(--text-muted);
    border: 3px solid var(--border);
    transition: all .2s;
}
.bk-step--done .bk-step__circle {
    background: var(--green); color: #fff; border-color: var(--green);
}
.bk-step--active .bk-step__circle {
    background: var(--primary); color: #fff; border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(26,58,107,.15);
}
.bk-step__label {
    font-size: 12px; font-weight: 600; text-align: center;
    color: var(--text-muted);
}
.bk-step--active .bk-step__label { color: var(--primary); }
.bk-step--done .bk-step__label { color: var(--green); }
.bk-step--clickable { cursor: pointer; }
.bk-step__tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    background: #1a3a6b;
    color: #fff;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 10;
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.bk-step__tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1a3a6b;
}
.bk-step--clickable:hover .bk-step__tooltip { opacity: 1; transform: translateX(-50%) translateY(-2px); }
[data-theme="dark"] .bk-step__tooltip { background: #2a2a2a; border: 1px solid #444; }
[data-theme="dark"] .bk-step__tooltip::after { border-top-color: #2a2a2a; }
.bk-step--clickable .bk-step__circle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.bk-step--clickable .bk-step__circle:active { transform: scale(1.05); }
.bk-step__icon { font-size: 16px; display: block; margin-bottom: 2px; }
.bk-step__connector {
    flex: 1; height: 3px; background: var(--border);
    margin-top: 18px; border-radius: 2px;
}
.bk-step__connector--done { background: var(--green); }

/* Карточка заседания */
.card--hearing { border-left: 4px solid var(--primary); }
.card--hearing-today { border-left-color: var(--accent); background: #fffbf5; }
.card--hearing-past { opacity: .65; border-left-color: var(--text-light); }
.hearing {
    display: flex; align-items: center; gap: 18px;
}
.hearing__date {
    width: 64px; height: 64px; border-radius: 14px;
    background: var(--primary); color: #fff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.card--hearing-today .hearing__date { background: var(--accent); color: var(--primary); }
.hearing__day { font-size: 26px; font-weight: 800; line-height: 1; }
.hearing__month { font-size: 12px; font-weight: 600; text-transform: uppercase; }
.hearing__info { flex: 1; }
.hearing__badge {
    display: inline-block; padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 600;
    background: var(--primary-soft); color: var(--primary);
}
.hearing__badge--today { background: var(--accent); color: var(--primary); }
.hearing__badge--past { background: var(--bg); color: var(--text-muted); }
.hearing__full-date { font-size: 14px; color: var(--text-muted); margin-top: 4px; }

/* Карточка ближайшего платежа */
.card--next-payment {
    background: linear-gradient(135deg, #1a3a6b 0%, #2a5394 100%);
    color: #fff;
    border: none;
}
.next-payment {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.next-payment__label { font-size: 13px; opacity: .8; font-weight: 500; }
.next-payment__amount { font-size: 28px; font-weight: 800; margin: 4px 0; }
.next-payment__date { font-size: 14px; opacity: .9; }
.next-payment__overdue { color: #ffb3b3; font-weight: 600; }
.next-payment__today { color: #f5b342; font-weight: 600; }
.card--next-payment .btn--primary {
    background: #f5b342; color: #1a3a6b; border: none;
}
.card--next-payment .btn--primary:hover { background: #e6a532; }

/* Страница уведомлений */
.notif-list__item {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 14px 0; border-bottom: 1px solid var(--border);
}
.notif-list__item:last-child { border-bottom: none; }
.notif-list__item--unread { background: var(--primary-soft); margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-radius: var(--r-sm); }
.notif-list__icon { font-size: 24px; flex-shrink: 0; }
.notif-list__body { flex: 1; min-width: 0; }
.notif-list__title { font-weight: 700; font-size: 15px; }
.notif-list__text { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.notif-list__time { font-size: 12px; color: var(--text-light); margin-top: 6px; }

/* =================== RESPONSIVE =================== */

/* ---- Планшеты (≤1024) ---- */
@media (max-width: 1024px) {
    .grid--4 { grid-template-columns: repeat(2, 1fr); }
    .stats   { grid-template-columns: repeat(2, 1fr); }
    .grid--3 { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Моб/планшет (≤860) — sidebar → drawer, bottom-nav ---- */
@media (max-width: 860px) {
    .sidebar {
        position: fixed; left: 0; top: 0; bottom: 0;
        transform: translateX(-100%);
        transition: transform .25s ease;
        height: 100vh;
        height: 100dvh;
        padding-top: var(--safe-top);
        padding-bottom: var(--safe-bottom);
        z-index: 60;
    }
    .sidebar--open { transform: translateX(0); }
    .nav__item--mobile-hide { display: none; }
    .topbar__burger { display: flex; }
    .app__overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 55;
        backdrop-filter: blur(2px);
    }
    .app__overlay--show { display: block; }
    .topbar__user-info { display: none; }
    .content {
        padding: 16px 14px;
        padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 16px);
    }

    /* Topbar */
    .topbar {
        padding: 0 12px;
        padding-top: var(--safe-top);
        height: calc(var(--topbar-h) + var(--safe-top));
        gap: 8px;
    }
    .topbar__title { font-size: 17px; }
    .lk-banner { top: calc(var(--topbar-h) + var(--safe-top)); }

    /* Сетки → 1 колонка */
    .grid--2, .grid--3, .grid--4, .grid--sidebar { grid-template-columns: 1fr; }

    /* Bottom navigation */
    .bottom-nav {
        display: flex;
        position: fixed; bottom: 0; left: 0; right: 0;
        height: calc(var(--bottomnav-h) + var(--safe-bottom));
        padding-bottom: var(--safe-bottom);
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -2px 12px rgba(0,0,0,.06);
        z-index: 45;
        user-select: none;
    }
    .bottom-nav__item {
        flex: 1;
        display: flex; flex-direction: column; align-items: center; justify-content: center;
        gap: 3px;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 10px; font-weight: 600;
        min-height: 48px;
        position: relative;
        -webkit-tap-highlight-color: transparent;
        transition: color .12s;
    }
    .bottom-nav__item:active { color: var(--primary); }
    .bottom-nav__icon { font-size: 21px; line-height: 1; position: relative; }
    .bottom-nav__label { font-size: 10px; line-height: 1; }
    .bottom-nav__badge {
        position: absolute; top: -3px; right: -8px;
        background: var(--red); color: #fff;
        font-size: 10px; font-weight: 700;
        min-width: 17px; height: 17px;
        border-radius: 9px; padding: 0 4px;
        display: flex; align-items: center; justify-content: center;
        line-height: 1;
    }
    .bottom-nav__item--active { color: var(--primary); }
    .bottom-nav__item--active .bottom-nav__icon::after {
        content: ''; position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
        width: 24px; height: 3px; border-radius: 3px; background: var(--primary);
    }
    .bottom-nav__more {
        color: var(--text-muted);
    }
    .bottom-nav__more.sidebar-open { color: var(--primary); }
}

/* ---- Телефоны (≤520) ---- */
@media (max-width: 520px) {
    .card { padding: 14px; border-radius: var(--r); margin-bottom: 14px; }
    .card__title { font-size: 15px; flex-wrap: wrap; }
    .card__title-badge { margin-left: 0; width: 100%; margin-top: 4px; }
    .topbar { padding: 0 10px; }
    .topbar__title { font-size: 16px; }
    .stat { padding: 14px; }
    .stat__value { font-size: 20px; }
    .stat__label { font-size: 12px; }
    .auth__card { padding: 26px 20px; border-radius: var(--r-lg); }
    .auth__title { font-size: 19px; }
    .content { padding: 12px 10px; padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 16px); }

    /* Buttons — min 44px touch target */
    .btn { min-height: 44px; padding: 10px 16px; font-size: 14px; }
    .btn--sm { min-height: 38px; }

    /* Inputs — min 44px touch target */
    .input, .textarea, .select { min-height: 44px; font-size: 16px; }
    .modal__field input, .modal__field textarea { font-size: 16px; }

    /* Tables → horizontal scroll on mobile */
    .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .table-wrap table.table { min-width: 520px; }
    .table th, .table td { padding: 10px 12px; font-size: 13px; white-space: nowrap; }
    .table .num { width: 28px; }

    /* (mobile-specific overrides removed for chat) */

    /* Modal fullscreen */
    .modal-overlay { padding: 0; align-items: stretch; }
    .modal {
        max-width: 100%; width: 100%;
        height: 100dvh;
        border-radius: 0;
        overflow-y: auto;
        padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
    }

    /* BK progress */
    .bk-step { width: auto; flex: 1; }
    .bk-step__circle { width: 36px; height: 36px; font-size: 14px; }
    .bk-step__label { font-size: 11px; }

    /* Pagination touch */
    .pagination .btn { min-width: 44px; min-height: 44px; font-size: 14px; }

    /* Notif dropdown full width */
    .notif__dropdown {
        width: 100vw; max-width: 100vw;
        right: -12px; border-radius: 0 0 var(--r) var(--r);
        position: fixed; top: calc(var(--topbar-h) + var(--safe-top)); left: 0;
        max-height: calc(100dvh - var(--topbar-h) - var(--safe-top) - var(--bottomnav-h) - var(--safe-bottom));
        overflow-y: auto;
    }

    /* Hearing card */
    .hearing { gap: 12px; }
    .hearing__date { width: 52px; height: 52px; border-radius: 12px; }
    .hearing__day { font-size: 22px; }

    /* Next payment card */
    .next-payment { flex-direction: column; align-items: flex-start; gap: 12px; }
    .next-payment__amount { font-size: 24px; }

    /* Appeal header */
    .appeal-item__header { flex-direction: column; align-items: flex-start; }
}

/* ---- Очень маленькие (≤360) ---- */
@media (max-width: 360px) {
    body { font-size: 14px; }
    .stats { grid-template-columns: 1fr; }
    .bottom-nav__label { font-size: 9px; }
    .bottom-nav__icon { font-size: 19px; }
    .topbar__title { font-size: 15px; }
    .card { padding: 12px; }
}

/* ---- Десктоп: скрываем bottom-nav ---- */
@media (min-width: 861px) {
    .bottom-nav { display: none !important; }
}
}

/* =================== APPEALS =================== */
.appeal-list { display: flex; flex-direction: column; gap: 14px; }
.appeal-item {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    background: #fff;
}
.appeal-item__header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px; flex-wrap: wrap; gap: 8px;
}
.appeal-item__subject {
    font-weight: 700; font-size: 15px; margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.appeal-cat {
    display: inline-block;
    background: var(--gray-soft);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 8px;
    font-size: 12px; font-weight: 600;
    color: var(--text-muted);
}
.appeal-item__message {
    color: var(--text-muted);
    font-size: 14px; line-height: 1.5;
    white-space: pre-wrap;
}
.appeal-reply {
    margin-top: 12px;
    padding: 12px 14px;
    background: var(--gray-soft);
    border-left: 3px solid var(--accent);
    border-radius: 0 8px 8px 0;
    font-size: 14px; line-height: 1.5;
}
.appeal-reply__title {
    font-weight: 700; margin-bottom: 4px;
    color: var(--primary);
}

/* Pagination */
.pagination {
    display: flex; gap: 6px; justify-content: center;
    padding: 16px 0 4px; flex-wrap: wrap; align-items: center;
}
.pagination .btn { min-width: 38px; text-align: center; }

/* Agent list (compact) */
.agent-list { display: flex; flex-direction: column; gap: 0; }
.agent-list__item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-light, #eee);
}
.agent-list__item:last-child { border-bottom: none; }
.agent-list__avatar {
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary-soft, #e8eef5); font-size: 18px;
}
.agent-list__info { flex: 1; min-width: 0; }
.agent-list__name {
    font-weight: 600; font-size: 15px; color: var(--text, #222);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.agent-list__meta {
    font-size: 13px; color: var(--text-muted, #888); margin-top: 2px;
}

/* ==========================================================================
   TOAST / SNACKBAR
   ========================================================================== */
.toast-container {
    position: fixed;
    bottom: calc(var(--bottomnav-h) + 16px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
    width: 100%;
    max-width: 480px;
    padding: 0 16px;
}
@media (min-width: 861px) {
    .toast-container { bottom: 24px; }
}
.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--dark);
    color: #fff;
    border-radius: var(--r-sm);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 500;
    max-width: 100%;
    pointer-events: auto;
    transform: translateY(100px);
    opacity: 0;
    transition: transform .3s cubic-bezier(.2,.8,.2,1), opacity .3s;
}
.toast--show { transform: translateY(0); opacity: 1; }
.toast--ok     { background: var(--green); }
.toast--error  { background: var(--red); }
.toast--info   { background: var(--primary); }
.toast--warn   { background: var(--accent-dark); }
.toast__icon { flex-shrink: 0; display: flex; }
.toast__close {
    margin-left: auto;
    background: none; border: none; color: rgba(255,255,255,.7);
    cursor: pointer; font-size: 18px; padding: 0 0 0 8px; line-height: 1;
}
.toast__close:hover { color: #fff; }

/* ==========================================================================
   SKELETON LOADERS
   ========================================================================== */
.skeleton {
    background: linear-gradient(90deg, var(--gray-soft) 25%, #e8e8e8 50%, var(--gray-soft) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.5s infinite;
    border-radius: var(--r-sm);
    display: inline-block;
}
@keyframes skeleton-shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
.skeleton-line { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-line:last-child { margin-bottom: 0; width: 60%; }
.skeleton-card {
    padding: 20px;
    background: var(--surface);
    border-radius: var(--r);
    box-shadow: var(--shadow-sm);
}
.skeleton-circle { width: 40px; height: 40px; border-radius: 50%; }

/* Fade-in animation for cards on page load */
.card {
    animation: card-fade-in .35s ease-out both;
}
.card:nth-child(1) { animation-delay: 0s; }
.card:nth-child(2) { animation-delay: .06s; }
.card:nth-child(3) { animation-delay: .12s; }
.card:nth-child(4) { animation-delay: .18s; }
.card:nth-child(5) { animation-delay: .24s; }
.card:nth-child(6) { animation-delay: .3s; }
@keyframes card-fade-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    .card { animation: none; }
}

/* ==========================================================================
   DARK THEME
   ========================================================================== */
:root[data-theme="dark"] {
    --primary:        #3b6bb0;
    --primary-dark:   #2a4f8a;
    --primary-light:  #4f82c8;
    --primary-soft:   #1a2a44;
    --accent:         #f5b342;
    --accent-dark:    #e09a26;
    --accent-soft:    #3a2e1a;
    --bg:             #0f1419;
    --surface:        #1a1f28;
    --border:         #2a323e;
    --text:           #e2e8f0;
    --text-muted:     #94a3b8;
    --text-light:     #64748b;
    --green-soft:     #0f2e1a;
    --yellow-soft:    #2e2810;
    --red-soft:       #2e1010;
    --blue-soft:      #10202e;
    --gray-soft:      #1e242e;
    --dark:           #cbd5e1;
    --dark-soft:      #475569;
    --shadow-sm:      0 1px 2px rgba(0, 0, 0, .3);
    --shadow:         0 4px 14px rgba(0, 0, 0, .4);
    --shadow-lg:      0 10px 30px rgba(0, 0, 0, .5);
}
:root[data-theme="dark"] .sidebar { background: #262626; }
:root[data-theme="dark"] .badge--purple { background: #2e103a; color: #c084fc; }
:root[data-theme="dark"] .badge--teal   { background: #0f2e2a; color: #5eead4; }
:root[data-theme="dark"] .badge--orange { background: #3a2410; color: #f0a05a; }
:root[data-theme="dark"] .topbar { background: var(--surface); }
:root[data-theme="dark"] .notif__dropdown { background: var(--surface); border-color: var(--border); }
:root[data-theme="dark"] .bottom-nav { background: var(--surface); border-color: var(--border); }

/* Theme toggle button */
.theme-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    color: var(--text-muted);
    transition: all .2s;
}
.theme-toggle:hover { color: var(--primary); border-color: var(--primary); }

/* ==========================================================================
   AUTO-LOGOUT WARNING
   ========================================================================== */
.autologout-overlay {
    position: fixed; inset: 0;
    background: rgba(0, 0, 0, .6);
    z-index: 10001;
    display: none;
    align-items: center; justify-content: center;
    backdrop-filter: blur(4px);
}
.autologout-overlay--show { display: flex; }
.autologout-modal {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 28px 32px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    max-width: 360px; width: 90%;
}
.autologout-modal__title {
    font-size: 18px; font-weight: 700; margin-bottom: 8px; color: var(--text);
}
.autologout-modal__text {
    color: var(--text-muted); font-size: 14px; margin-bottom: 20px;
}
.autologout-modal__timer {
    font-size: 32px; font-weight: 800; color: var(--red); margin-bottom: 20px;
}
.autologout-modal__btns { display: flex; gap: 10px; justify-content: center; }

/* ==========================================================================
   PULL-TO-REFRESH
   ========================================================================== */
.ptr-indicator {
    position: fixed;
    top: var(--topbar-h);
    left: 50%;
    transform: translateX(-50%) translateY(-60px);
    width: 36px; height: 36px;
    background: var(--surface);
    border-radius: 50%;
    box-shadow: var(--shadow);
    display: flex; align-items: center; justify-content: center;
    z-index: 9999;
    transition: transform .2s ease;
    opacity: 0;
}
.ptr-indicator--visible { opacity: 1; }
.ptr-indicator--spin svg { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ==========================================================================
   WIZARD — Анкета ППП
   ========================================================================== */

.qwiz {
    max-width: 860px;
    margin: 0 auto;
    padding-bottom: 24px;
}

/* Прогресс */
.qwiz__progress-wrap {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    position: relative;
}
.qwiz__progress-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.qwiz__progress-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    flex: 1;
    min-width: 0;
}
.qwiz__progress-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--primary);
    white-space: nowrap;
}
.qwiz__pencil {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}
.qwiz__export-btns {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    margin-left: auto;
}
.qwiz__download {
    position: relative;
    flex-shrink: 0;
    margin-left: auto;
}
.qwiz__download-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 140px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r);
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    overflow: hidden;
    z-index: 20;
    opacity: 0;
    transform: translateY(-4px);
    transition: opacity .15s, transform .15s;
}
.qwiz__download--open .qwiz__download-menu {
    display: block;
    opacity: 1;
    transform: translateY(0);
}
.qwiz__download-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    transition: background .12s;
}
.qwiz__download-menu a:hover {
    background: var(--gray-soft);
    color: var(--primary);
}
.qwiz__status {
    /* inline badge, no longer absolute */
}
.qwiz__progress-bar {
    height: 8px;
    background: var(--gray-soft);
    border-radius: 8px;
    overflow: hidden;
}
.qwiz__progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 8px;
    transition: width .5s cubic-bezier(.4, 0, .2, 1);
}

/* Шаги (таблетки) */
.qwiz__steps {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
    background: var(--surface);
    padding: 10px;
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}
.qwiz__step {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 2px solid transparent;
    border-radius: var(--r);
    background: transparent;
    cursor: pointer;
    transition: all .2s;
    font: inherit;
    color: var(--text-muted);
}
.qwiz__step:hover:not(:disabled) { background: var(--primary-soft); }
.qwiz__step--active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 600;
}
.qwiz__step--done { color: var(--green); }
.qwiz__step--done .qwiz__step-num {
    background: var(--green);
    color: #fff;
}
.qwiz__step:disabled { opacity: .4; cursor: not-allowed; }
.qwiz__step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    border-radius: 50%;
    background: var(--gray-soft);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 14px;
    transition: all .2s;
}
.qwiz__step--active .qwiz__step-num {
    background: var(--primary);
    color: #fff;
}
.qwiz__step-label {
    font-size: 13px;
    line-height: 1.2;
}

/* Карточка шага */
.qwiz__step-card {
    background: var(--surface);
    border-radius: var(--r-lg);
    padding: 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
    animation: card-fade-in .25s ease-out;
    overflow: hidden;
}
.qwiz__section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}
.qwiz__section-title .icon { color: var(--accent); }

.qwiz__hint {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--blue-soft);
    border-radius: var(--r-sm);
    border-left: 3px solid var(--blue);
}

/* Grid */
.qw__grid {
    display: grid;
    gap: 0 16px;
    min-width: 0;
}
.qw__grid--2 { grid-template-columns: repeat(2, 1fr); }
.qw__grid--3 { grid-template-columns: repeat(3, 1fr); }
.qw__grid > .field { min-width: 0; }
input[type="date"],
input[type="month"] {
    width: auto;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
@media (max-width: 860px) {
    .qw__grid--2,
    .qw__grid--3 { grid-template-columns: 1fr; }
    input[type="date"],
    input[type="month"] { max-width: 200px; }
}

/* Combobox (select + custom input) */
.qw-combo__custom {
    display: flex;
    gap: 6px;
    align-items: center;
}
.qw-combo__back {
    flex-shrink: 0;
    width: 40px;
    height: 44px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--gray-soft);
    cursor: pointer;
    font-size: 18px;
    color: var(--text-muted);
    transition: all .15s;
}
.qw-combo__back:hover { background: var(--border); }

/* Radio group */
.qw-radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.qw-radio {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border: 2px solid var(--border);
    border-radius: var(--r);
    cursor: pointer;
    transition: all .15s;
    font-size: 14px;
}
.qw-radio:hover { border-color: var(--primary-light); }
.qw-radio input[type="radio"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}
.qw-radio input[type="radio"]:checked ~ span { font-weight: 600; }
.qw-radio:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* Checkbox */
.qw-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}
.qw-check input[type="checkbox"] {
    accent-color: var(--primary);
    width: 18px;
    height: 18px;
}

/* Динамические таблицы */
.qw-table { margin-bottom: 12px; }
.qw-row {
    border: 1px solid var(--border);
    border-radius: var(--r);
    margin-bottom: 12px;
    overflow: hidden;
    animation: card-fade-in .25s ease-out;
}
.qw-row__head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--gray-soft);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: rgba(0,0,0,.1);
    touch-action: manipulation;
    transition: background .15s;
}
.qw-row__head:hover { background: var(--border); }
.qw-row__num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    min-width: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
}
.qw-row__title {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
}
.qw-row__del {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--red);
    cursor: pointer;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .15s;
}
.qw-row__del:hover { background: var(--red-soft); }
.qw-row__body {
    padding: 16px;
}
.qw-row--collapsed .qw-row__body { display: none; }
.qw-f--custom { margin-top: 6px; }

/* Навигация */
.qwiz__nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-top: 8px;
    min-height: 48px;
}
.qwiz__nav-save {
    text-decoration: none;
}
.qwiz__nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}
.qwiz__nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s;
    text-decoration: none;
    box-sizing: border-box;
}
.qwiz__nav-btn--prev {
    width: 44px;
    min-width: 44px;
    padding: 0;
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}
.qwiz__nav-btn--prev:hover {
    background: var(--gray-soft);
    border-color: var(--primary);
    color: var(--primary);
}
.qwiz__nav-btn--next {
    background: var(--primary);
    color: #fff;
}
.qwiz__nav-btn--next:hover {
    background: var(--primary-light);
}
.qwiz__nav-btn--finish {
    background: var(--accent);
    color: var(--primary-dark);
}
.qwiz__nav-btn--finish:hover {
    background: var(--accent-dark);
}
.qwiz__nav-btn--placeholder {
    width: 44px;
    min-width: 44px;
    padding: 0;
    border: none;
    background: transparent;
}

/* Conditional fields */
.qw-cond {
    animation: qw-cond-in .25s ease-out;
}
.qw-cond--hidden {
    display: none;
}
@keyframes qw-cond-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Indicator сохранения */
.qw__save-indicator {
    position: fixed;
    bottom: 80px;
    right: 20px;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    font-size: 13px;
    color: var(--text-muted);
    z-index: 100;
    opacity: 0;
    transform: translateY(10px);
    transition: all .3s;
    pointer-events: none;
}
.qw__save-indicator--show {
    opacity: 1;
    transform: translateY(0);
}
.qw__save-indicator--saving { color: var(--yellow); }
.qw__save-indicator--saved { color: var(--green); }

/* Manager placement (iframe в Bitrix24) */
.qwiz--manager .qwiz__steps { flex-wrap: nowrap; overflow-x: auto; }
.qwiz--embedded { padding: 16px; max-width: 100%; }

@media (max-width: 680px) {
    .qwiz__step-label { display: none; }
    .qwiz__step { min-width: auto; flex: 0 0 auto; padding: 8px; }
    .qwiz__step-num { width: 32px; height: 32px; min-width: 32px; }
    .qwiz__nav { flex-wrap: wrap; }
    .qwiz__step-card { padding: 16px; }
    .qw-row__body { padding: 12px; }
}

/* Autocomplete (creditor) */
.qw-ac { position: relative; }
.qw-ac__list {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    max-height: 240px;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: none;
}
.qw-ac__list--open { display: block; }
.qw-ac__opt {
    padding: 8px 12px;
    font-size: 14px;
    cursor: pointer;
    transition: background .15s;
}
.qw-ac__opt:hover {
    background: var(--primary-soft, rgba(74, 108, 247, .1));
    color: var(--primary);
}
.qw-ac__empty {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-muted);
    font-style: italic;
}
.qw-ac__postal {
    color: var(--text-muted);
    font-size: 12px;
    white-space: nowrap;
}

/* Read-only / view mode */
@media (max-width: 680px) {
    .qwiz__progress-label { display: none; }
}
.qwiz-page--readonly .qw-row__del,
.qwiz-page--readonly .qw-table + .btn,
.qwiz-page--readonly .qw-combo__back {
    display: none !important;
}
.qwiz-page--readonly .qwiz__content input,
.qwiz-page--readonly .qwiz__content select,
.qwiz-page--readonly .qwiz__content textarea,
.qwiz-page--readonly .qwiz__content label {
    pointer-events: none;
}
.qwiz-page--readonly .qw-row__head {
    pointer-events: auto;
    cursor: pointer;
}
.qwiz-page--readonly .input,
.qwiz-page--readonly .textarea,
.qwiz-page--readonly .select {
    background: var(--gray-soft);
    color: var(--text);
    opacity: .85;
}
.qwiz-page--readonly .qw-row { cursor: default; }

/* ==========================================================================
   Этапы процедуры (stages.php)
   ========================================================================== */
.stages-hero {
    text-align: center;
    padding: 32px 20px 28px;
    margin-bottom: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: var(--r-lg);
    color: #fff;
}
.stages-hero__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    margin-bottom: 12px;
}
.stages-hero__icon .icon { color: #fff; }
.stages-hero__title {
    font-size: 22px;
    font-weight: 800;
    margin: 0 0 6px;
    color: #fff;
}
.stages-hero__subtitle {
    font-size: 14px;
    color: rgba(255,255,255,.8);
    margin: 0;
}

.stages-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 720px;
    margin: 0 auto;
    padding-bottom: 24px;
}

/* Карточка этапа */
.stage {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s;
}
.stage--done { border-color: var(--green-soft); }
.stage--active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary-soft), var(--shadow);
}
.stage--locked { opacity: .55; }

.stage__header { margin-bottom: 12px; }
.stage__num-block {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.stage__num {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 16px;
    font-weight: 700;
    background: var(--primary-soft);
    color: var(--primary);
}
.stage--done .stage__num {
    background: var(--green-soft);
    color: var(--green);
}
.stage--active .stage__num {
    background: var(--primary);
    color: #fff;
}
.stage--locked .stage__num {
    background: var(--gray-soft);
    color: var(--gray);
}
.stage__num-info { flex: 1; min-width: 0; }
.stage__title-line {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 2px;
}
.stage__step-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.stage__badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
}
.stage__badge--done { background: var(--green-soft); color: var(--green); }
.stage__badge--active { background: var(--primary-soft); color: var(--primary); }
.stage__badge--locked { background: var(--gray-soft); color: var(--gray); }
.stage__title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 4px;
    color: var(--text);
}
.stage__duration {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-muted);
}
.stage__short {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
    margin: 0 0 14px;
}
.stage__video-wrap {
    margin-bottom: 14px;
    border-radius: var(--r);
    overflow: hidden;
    background: #000;
}
.stage__video {
    width: 100%;
    max-height: 360px;
    display: block;
}
.stage__btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.stage__locked-notice {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-light);
}

/* Modal — wide variant */
.modal--wide {
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
}

/* Детали этапа — iframe с pdf2htmlEX */
.stage-modal { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.stage-modal .modal__header {
    flex-shrink: 0;
    padding: 16px 20px;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border);
}
.stage-modal__iframe {
    width: 100%;
    flex: 1;
    border: none;
    min-height: 60vh;
    background: #9e9e9e;
}

@media (max-width: 680px) {
    #modal-stage-detail {
        padding: 0;
        align-items: stretch;
    }
    .stage-modal {
        max-width: 100%;
        max-height: 100vh;
        height: 100dvh;
        border-radius: 0;
    }
    .stage-modal .modal__header { padding: 12px 16px; }
    .stage-modal__iframe { min-height: 0; flex: 1; }
}

@media (max-width: 680px) {
    .stages-hero { padding: 24px 16px 20px; }
    .stages-hero__title { font-size: 19px; }
    .stages-hero__subtitle { font-size: 13px; }
    .stage { padding: 16px; }
    .stage__num { width: 34px; height: 34px; font-size: 14px; }
    .stage__title { font-size: 15px; }
    .stage__short { font-size: 13px; }
}

[data-theme="dark"] .stages-hero {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}
[data-theme="dark"] .stage { background: var(--surface); }
[data-theme="dark"] .stage-detail__note { background: var(--bg); }
