/*
 * Инвестиции — единая таблица стилей (релиз 2.0)
 *
 * Порядок: шрифт → токены → база → каркас (боковая панель, верхняя и нижняя
 * навигация) → компоненты → страницы → утилиты.
 *
 * Правила, на которых держится вёрстка:
 *  - карточка сама задаёт внутренние отступы через .card-head / .card-body,
 *    вложенные блоки отступов наружу не добавляют;
 *  - три радиуса: карточка 16, плитка внутри карточки 12, элемент управления 10;
 *  - все суммы — класс .num (цифры одинаковой ширины, без переноса);
 *  - таблицы с классом .cards на телефоне превращаются в список карточек.
 */

/* ------------------------------------------------------------------ Шрифт */
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/manrope-cyrillic-ext-wght-normal.woff2") format("woff2");
    unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/manrope-cyrillic-wght-normal.woff2") format("woff2");
    unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/manrope-latin-ext-wght-normal.woff2") format("woff2");
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: "Manrope";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/manrope-latin-wght-normal.woff2") format("woff2");
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* Запасной шрифт с подогнанными метриками: пока Manrope грузится, строки не прыгают. */
@font-face {
    font-family: "Manrope Fallback";
    src: local("Arial"), local("Helvetica Neue"), local("Roboto");
    size-adjust: 103.5%;
    ascent-override: 103%;
    descent-override: 29%;
    line-gap-override: 0%;
}

/* ----------------------------------------------------------------- Токены */
:root {
    color-scheme: light;

    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f6f7f9;
    --surface-3: #eceef2;
    --line: #e3e6eb;
    --line-soft: #eef0f3;

    --ink: #14171c;
    --ink-2: #4a5362;
    --ink-3: #7b8493;
    --ink-inv: #ffffff;

    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-ink: #4338ca;
    --accent-soft: #eef0ff;

    --ok: #0b8a5f;
    --ok-soft: #e5f6ee;
    --warn: #b45309;
    --warn-soft: #fdf2dd;
    --bad: #cf2f2f;
    --bad-soft: #fdebeb;
    --info: #2460d8;
    --info-soft: #e8effd;

    /* Цвета серий на графиках */
    --series-paid: #12a174;
    --series-pending: #e59a1a;
    --series-overdue: #dc4545;
    --series-th: #4f46e5;
    --series-ru: #0e9aa7;

    --shadow-card: 0 1px 2px rgba(18, 24, 38, 0.04);
    --shadow-pop: 0 12px 32px -8px rgba(18, 24, 38, 0.18), 0 2px 6px rgba(18, 24, 38, 0.06);
    --shadow-modal: 0 24px 64px -12px rgba(18, 24, 38, 0.32);

    --r-card: 16px;
    --r-tile: 12px;
    --r-ctl: 10px;
    --r-pill: 999px;

    --gap: 20px;
    --pad: 20px;
    --sidebar-w: 248px;
    --sidebar-w-collapsed: 72px;
    --topbar-h: 56px;
    --tabbar-h: 60px;

    --font: "Manrope", "Manrope Fallback", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --ease: cubic-bezier(0.2, 0.7, 0.3, 1);

    /* Совместимость со старыми именами переменных */
    --bg-card: var(--surface);
    --bg-secondary: var(--surface-2);
    --bg-tertiary: var(--surface-3);
    --border-color: var(--line);
    --border-light: var(--line-soft);
    --text-primary: var(--ink);
    --text-secondary: var(--ink-2);
    --text-tertiary: var(--ink-3);
    --accent-primary: var(--accent);
    --success: var(--ok);
    --warning: var(--warn);
    --error: var(--bad);
}

[data-theme="dark"] {
    color-scheme: dark;

    --bg: #0d0f13;
    --surface: #16191f;
    --surface-2: #1c2028;
    --surface-3: #252a34;
    --line: #2a2f3a;
    --line-soft: #222731;

    --ink: #eef0f4;
    --ink-2: #aab2c0;
    --ink-3: #7c8595;
    --ink-inv: #0d0f13;

    --accent: #6f76f7;
    --accent-hover: #858bff;
    --accent-ink: #a5aaff;
    --accent-soft: rgba(124, 131, 255, 0.16);

    --ok: #37c892;
    --ok-soft: rgba(55, 200, 146, 0.14);
    --warn: #f0b23e;
    --warn-soft: rgba(240, 178, 62, 0.14);
    --bad: #f47575;
    --bad-soft: rgba(244, 117, 117, 0.14);
    --info: #6ea3ff;
    --info-soft: rgba(110, 163, 255, 0.14);

    --series-paid: #2fbf8b;
    --series-pending: #eeb040;
    --series-overdue: #ef6b6b;
    --series-th: #8187ff;
    --series-ru: #3cc3cf;

    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-pop: 0 12px 32px -8px rgba(0, 0, 0, 0.6), 0 2px 6px rgba(0, 0, 0, 0.3);
    --shadow-modal: 0 24px 64px -12px rgba(0, 0, 0, 0.7);
}

/* ------------------------------------------------------------------- База */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    /* Место под полосу прокрутки зарезервировано: страница не сдвигается,
       когда открывается окно или меняется высота содержимого. */
    scrollbar-gutter: stable;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: hidden;
}

/* Открыто окно: страница зафиксирована, полоса прокрутки остаётся на месте (см. Modal.lock в app.js). */
html.is-locked { overflow-y: scroll; }
html.is-locked body { position: fixed; left: 0; right: 0; width: 100%; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; border-spacing: 0; width: 100%; }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
ul { padding: 0; list-style: none; }

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

::selection { background: var(--accent-soft); }

.icon { flex: none; }
.flag {
    flex: none;
    border-radius: 2px;
    box-shadow: 0 0 0 1px rgba(18, 24, 38, 0.12);
    display: inline-block;
    vertical-align: -1px;
}
[data-theme="dark"] .flag { box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14); }

.num {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    white-space: nowrap;
    word-spacing: -0.08em; /* разряды разделены неразрывным пробелом — чуть сужаем его */
}
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.muted { color: var(--ink-3); }
.hidden { display: none !important; }
.sr-only {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap;
}

/* ----------------------------------------------------------------- Каркас */
.app { min-height: 100dvh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--line);
    z-index: 40;
}

.sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    height: 68px;
    padding: 0 16px 0 20px;
    flex: none;
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; font-weight: 750; font-size: 17px; letter-spacing: -0.01em; }
.brand-mark {
    width: 34px; height: 34px; flex: none;
    display: grid; place-items: center;
    border-radius: 10px;
    background: var(--accent);
    color: #fff;
}
.brand-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-toggle {
    width: 30px; height: 30px; flex: none;
    display: grid; place-items: center;
    border-radius: 8px;
    color: var(--ink-3);
}
.sidebar-toggle:hover { background: var(--surface-3); color: var(--ink); }
.sidebar-toggle .icon { transition: transform 0.2s var(--ease); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 12px; }
.nav-group + .nav-group { margin-top: 18px; }
.nav-title { display: block; padding: 0 12px 6px; font-size: 12px; font-weight: 600; color: var(--ink-3); }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 40px;
    padding: 0 12px;
    border-radius: var(--r-ctl);
    color: var(--ink-2);
    font-weight: 550;
    font-size: 14.5px;
    white-space: nowrap;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 650; }
.nav-item .nav-count {
    margin-left: auto;
    min-width: 20px; height: 20px; padding: 0 6px;
    display: grid; place-items: center;
    border-radius: var(--r-pill);
    background: var(--bad);
    color: #fff;
    font-size: 11.5px; font-weight: 700;
}

.sidebar-foot { flex: none; padding: 12px; border-top: 1px solid var(--line-soft); display: grid; gap: 8px; }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px; min-width: 0; }
.avatar {
    width: 32px; height: 32px; flex: none;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--ink-2);
    font-size: 12.5px; font-weight: 700;
}
.user-chip-name { font-weight: 650; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip-role { font-size: 12px; color: var(--ink-3); }

/* Сегментированный переключатель: валюта, тема, фильтры */
.seg {
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 2px;
    padding: 3px;
    border-radius: var(--r-ctl);
    background: var(--surface-3);
}
.seg-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 30px;
    padding: 0 12px;
    border-radius: 7px;
    font-size: 13.5px; font-weight: 600;
    color: var(--ink-2);
    white-space: nowrap;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active, .seg-btn[aria-pressed="true"], .seg-btn[aria-selected="true"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 2px rgba(18, 24, 38, 0.12);
}
[data-theme="dark"] .seg-btn.active,
[data-theme="dark"] .seg-btn[aria-pressed="true"],
[data-theme="dark"] .seg-btn[aria-selected="true"] { background: var(--surface-2); box-shadow: 0 0 0 1px var(--line); }
.seg { max-width: 100%; }
.seg-btn { min-width: 0; }
.seg.block { display: grid; width: 100%; grid-auto-columns: minmax(0, 1fr); }
/* Сегменты по ширине подписей, а не равные: длинные подписи не раздувают короткие */
.seg.fit { display: inline-flex; }
.seg.fit .seg-btn { flex: 1 1 auto; }
@media (max-width: 639px) {
    .seg-btn { padding: 0 8px; font-size: 13px; gap: 5px; }
    .seg-count { font-size: 11.5px; }
    /* В шапке карточки переключатель занимает всю строку */
    .card-tools.wide-sm { width: 100%; }
    .card-tools.wide-sm .seg { display: flex; width: 100%; }
}
@media (max-width: 380px) {
    .seg.fit .seg-btn { padding: 0 6px; }
    .seg.icon-text .icon { display: none; }
}
.seg-count { font-size: 12px; font-weight: 600; color: var(--ink-3); }

/* Свёрнутая боковая панель (только десктоп) */
@media (min-width: 1024px) {
    html.sidebar-collapsed { --sidebar-w: var(--sidebar-w-collapsed); }
    html.sidebar-collapsed .brand-name,
    html.sidebar-collapsed .nav-title,
    html.sidebar-collapsed .nav-item span,
    html.sidebar-collapsed .user-chip > div:last-child,
    html.sidebar-collapsed .sidebar-foot .seg { display: none; }
    html.sidebar-collapsed .sidebar-head { flex-direction: column; justify-content: center; height: 96px; padding: 12px 0 0; }
    html.sidebar-collapsed .sidebar-toggle .icon { transform: rotate(180deg); }
    html.sidebar-collapsed .nav-item { justify-content: center; padding: 0; }
    html.sidebar-collapsed .nav-item .nav-count { position: absolute; margin: -18px 0 0 22px; min-width: 16px; height: 16px; font-size: 10px; }
    html.sidebar-collapsed .user-chip { justify-content: center; padding: 6px 0; }
    html.sidebar-collapsed .nav-group + .nav-group { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-soft); }
}

.main {
    margin-left: var(--sidebar-w);
    padding: 28px 32px 48px;
    min-width: 0;
}
.main-inner { max-width: 1280px; margin: 0 auto; }

/* Верхняя и нижняя панели — только телефон и планшет */
.topbar, .tabbar { display: none; }

@media (max-width: 1023px) {
    .sidebar { display: none; }

    .topbar {
        position: sticky; top: 0; z-index: 30;
        display: flex; align-items: center; gap: 12px;
        height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
        padding: env(safe-area-inset-top, 0px) 16px 0;
        background: color-mix(in srgb, var(--bg) 88%, transparent);
        -webkit-backdrop-filter: saturate(1.4) blur(14px);
        backdrop-filter: saturate(1.4) blur(14px);
        border-bottom: 1px solid var(--line-soft);
    }
    .topbar .brand { font-size: 16px; flex: 1; }
    .topbar .brand-mark { width: 30px; height: 30px; border-radius: 9px; }
    .topbar-btn {
        display: inline-flex; align-items: center; gap: 6px;
        height: 34px; padding: 0 10px;
        border-radius: var(--r-ctl);
        background: var(--surface);
        border: 1px solid var(--line);
        font-size: 13.5px; font-weight: 650;
    }

    .tabbar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
        display: grid; grid-template-columns: repeat(5, 1fr);
        height: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px));
        padding: 0 4px env(safe-area-inset-bottom, 0px);
        background: color-mix(in srgb, var(--surface) 94%, transparent);
        -webkit-backdrop-filter: saturate(1.4) blur(16px);
        backdrop-filter: saturate(1.4) blur(16px);
        border-top: 1px solid var(--line);
    }
    .tab {
        position: relative;
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        min-width: 0;
        color: var(--ink-3);
        font-size: 11px; font-weight: 600; line-height: 1.1;
    }
    .tab-ico {
        display: grid; place-items: center;
        width: 46px; height: 28px;
        border-radius: var(--r-pill);
        transition: background-color 0.15s var(--ease);
    }
    .tab.active { color: var(--accent-ink); }
    .tab.active .tab-ico { background: var(--accent-soft); }
    .tab .nav-count {
        position: absolute; top: 6px; left: calc(50% + 6px);
        min-width: 16px; height: 16px; padding: 0 4px;
        display: grid; place-items: center;
        border-radius: var(--r-pill);
        background: var(--bad); color: #fff;
        font-size: 10px; font-weight: 700;
    }

    .main {
        margin-left: 0;
        padding: 20px 16px calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 28px);
    }
}

@media (min-width: 640px) and (max-width: 1023px) {
    .main { padding-left: 24px; padding-right: 24px; }
}

/* ------------------------------------------------------- Заголовок страницы */
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 16px 24px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}
.page-head-main { min-width: 0; flex: 1 1 320px; }
.page-title { font-size: 28px; font-weight: 750; letter-spacing: -0.025em; line-height: 1.15; overflow-wrap: anywhere; }
.page-sub { margin-top: 6px; color: var(--ink-3); font-size: 14.5px; display: flex; align-items: center; gap: 6px 10px; flex-wrap: wrap; }
.page-sub .icon { color: var(--ink-3); margin-top: 3px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.crumbs { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 13.5px; color: var(--ink-3); flex-wrap: wrap; }
.crumbs a:hover { color: var(--ink); }
.crumbs .icon { opacity: 0.6; }

@media (max-width: 639px) {
    .page-head { margin-bottom: 18px; }
    .page-title { font-size: 23px; }
    .page-actions { width: 100%; }
    .page-actions > .btn { flex: 1 1 0; }
    .page-actions > .btn-icon { flex: none; }
}

/* ----------------------------------------------------------------- Кнопки */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--r-ctl);
    border: 1px solid transparent;
    font-size: 14.5px; font-weight: 650;
    white-space: nowrap;
    transition: background-color 0.12s var(--ease), border-color 0.12s var(--ease), color 0.12s var(--ease);
    user-select: none;
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.55; cursor: default; pointer-events: none; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-danger:hover { background: var(--bad); color: #fff; }
.btn-danger-solid { background: var(--bad); color: #fff; }
.btn-danger-solid:hover { filter: brightness(0.92); }

.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13.5px; border-radius: 9px; }
.btn-block { width: 100%; }
.btn-icon { width: 40px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }

.icon-btn {
    width: 34px; height: 34px; flex: none;
    display: inline-grid; place-items: center;
    border-radius: 9px;
    color: var(--ink-3);
    transition: background-color 0.12s var(--ease), color 0.12s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.ok:hover { background: var(--ok-soft); color: var(--ok); }
.icon-btn.bad:hover { background: var(--bad-soft); color: var(--bad); }

.link { color: var(--accent-ink); font-weight: 600; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

/* --------------------------------------------------------------- Карточки */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-card);
    min-width: 0;
}
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px 16px;
    flex-wrap: wrap;
    padding: 16px var(--pad) 0;
}
.card-head + .card-body { padding-top: 14px; }
.card-title { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-title .icon { color: var(--ink-3); }
.card-sub { font-size: 13.5px; color: var(--ink-3); margin-top: 2px; }
.card-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body { padding: var(--pad); }
.card-body.flush { padding: 0; }
.card-head + .card-body.flush { padding-top: 12px; }
.card-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 8px 16px; flex-wrap: wrap;
    padding: 12px var(--pad);
    border-top: 1px solid var(--line-soft);
    font-size: 13.5px; color: var(--ink-2);
}
.card-foot strong { color: var(--ink); font-weight: 700; }
/*
 * Блок с собственным фоном у края карточки (строка списка под курсором, шапка
 * или итог таблицы) повторяет её скругление, иначе фон вылезает за углы.
 * Радиус на 1px меньше: блок лежит внутри рамки карточки.
 */
.card > .list, .card > .card-body.flush { overflow: hidden; }
.card > .table-wrap:first-child, .card > .list:first-child, .card > .card-body.flush:first-child {
    border-top-left-radius: calc(var(--r-card) - 1px);
    border-top-right-radius: calc(var(--r-card) - 1px);
}
.card > .table-wrap:last-child, .card > .list:last-child, .card > .card-body.flush:last-child {
    border-bottom-left-radius: calc(var(--r-card) - 1px);
    border-bottom-right-radius: calc(var(--r-card) - 1px);
}

.stack { display: grid; gap: var(--gap); align-content: start; min-width: 0; }
.stack > * { min-width: 0; }
.stack-sm { display: grid; gap: 12px; align-content: start; min-width: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--gap); align-items: start; }
@media (max-width: 1180px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 900px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 -6px; }
.section-title { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.section-meta { font-size: 13.5px; color: var(--ink-3); }

/* ------------------------------------------------------------- Показатели */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--gap); }
.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-card);
    padding: 16px 18px;
    min-width: 0;
}
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 550; color: var(--ink-3); }
.kpi-value { margin-top: 6px; font-size: 25px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.kpi-sub { margin-top: 4px; font-size: 13px; color: var(--ink-3); line-height: 1.45; }
.kpi-sub .num { color: var(--ink-2); font-weight: 600; }

@media (max-width: 1180px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) {
    .kpis { gap: 12px; }
    .kpi { padding: 14px; }
    .kpi-value { font-size: 20px; }
    .kpi-label { font-size: 12.5px; }
    .kpi-sub { font-size: 12px; }
}

/* Плитки с деталями внутри карточки */
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tiles.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tile { background: var(--surface-2); border-radius: var(--r-tile); padding: 12px 14px; min-width: 0; }
.tile-label { font-size: 12.5px; color: var(--ink-3); font-weight: 550; }
.tile-value { margin-top: 2px; font-size: 16px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.tile-sub { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
.tile.ok { background: var(--ok-soft); } .tile.ok .tile-value { color: var(--ok); }
.tile.warn { background: var(--warn-soft); } .tile.warn .tile-value { color: var(--warn); }
.tile.bad { background: var(--bad-soft); } .tile.bad .tile-value { color: var(--bad); }
.tile.accent { background: var(--accent-soft); } .tile.accent .tile-value { color: var(--accent-ink); }
@media (max-width: 900px) { .tiles.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) { .tiles.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 639px) { .tiles.wide { grid-template-columns: minmax(0, 1fr); } }

/* Пара «подпись — значение» в строку */
.rows { display: grid; }
.rows > .row-kv { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.rows > .row-kv:last-child { border-bottom: 0; padding-bottom: 0; }
.rows > .row-kv:first-child { padding-top: 0; }
.row-kv > :first-child { color: var(--ink-2); min-width: 0; }
.row-kv > :last-child { font-weight: 650; text-align: right; }
.row-kv.total > :first-child { color: var(--ink); font-weight: 700; }
.row-kv.total > :last-child { font-size: 17px; font-weight: 750; }
.row-kv .flag { margin-right: 6px; }
.row-kv small { display: block; color: var(--ink-3); font-size: 12.5px; font-weight: 500; }

/* ------------------------------------------------------------------ Метки */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    height: 24px; padding: 0 9px;
    border-radius: var(--r-pill);
    background: var(--surface-3);
    color: var(--ink-2);
    font-size: 12.5px; font-weight: 650;
    white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-ink); }
.badge.outline { background: none; box-shadow: inset 0 0 0 1px var(--line); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }

/* --------------------------------------------------------------- Прогресс */
.progress { height: 6px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; display: flex; }
.progress > span { display: block; height: 100%; background: var(--series-paid); }
.progress > span.pending { background: var(--series-pending); }
.progress > span.overdue { background: var(--series-overdue); }
.progress.lg { height: 10px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* ---------------------------------------------------------------- Таблицы */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { font-size: 14.5px; }
.table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 12.5px; font-weight: 600;
    color: var(--ink-3);
    background: var(--surface-2);
    border-bottom: 1px solid var(--line-soft);
    white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: var(--pad); }
.table th:last-child, .table td:last-child { padding-right: var(--pad); }
.table .right { text-align: right; }
.table tfoot td { background: var(--surface-2); font-weight: 700; border-top: 1px solid var(--line-soft); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover td { background: var(--surface-2); }
.table .cell-actions { text-align: right; white-space: nowrap; width: 1%; }
.table .cell-actions > * { vertical-align: middle; }
.table .cell-actions form { display: inline; }
.cell-title { font-weight: 650; }
.cell-sub { font-size: 13px; color: var(--ink-3); }
.cell-note { color: var(--ink-3); font-size: 13.5px; max-width: 28ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--ink); }
.th-sort[aria-sort="ascending"]::after { content: " ↑"; }
.th-sort[aria-sort="descending"]::after { content: " ↓"; }

.entity { display: flex; align-items: center; gap: 12px; min-width: 0; }
.entity-ico {
    width: 38px; height: 38px; flex: none;
    display: grid; place-items: center;
    border-radius: 11px;
    background: var(--surface-3);
    color: var(--ink-2);
}
.entity-name { font-weight: 650; overflow-wrap: anywhere; }
.entity-meta { margin-top: 2px; font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
/* Метка во второй строке под названием: компактнее обычной и с воздухом сверху, чтобы не липла к названию */
.entity-meta .badge, .list-meta .badge { height: 20px; padding: 0 8px; font-size: 11.5px; }
.entity-meta:has(.badge), .list-meta:has(.badge) { margin-top: 5px; }

/* Телефон: строки таблицы .cards становятся карточками «подпись — значение» */
@media (max-width: 760px) {
    .table.cards, .table.cards tbody, .table.cards tfoot, .table.cards tr { display: block; width: auto; }
    .table.cards thead { display: none; }
    .table.cards tr { padding: 12px var(--pad); border-bottom: 1px solid var(--line-soft); }
    .table.cards tbody tr:last-child { border-bottom: 0; }
    .table.cards td {
        display: grid; grid-template-columns: minmax(0, 40%) minmax(0, 1fr); gap: 0 12px;
        width: auto;
        padding: 3px 0 !important;
        border: 0;
        text-align: right;
        background: none !important;
        overflow-wrap: anywhere;
    }
    .table.cards td::before {
        content: attr(data-label);
        grid-column: 1; grid-row: 1 / span 3;
        color: var(--ink-3); font-size: 13px; font-weight: 500; text-align: left;
    }
    .table.cards td > * { grid-column: 2; justify-self: end; }
    .table.cards td.cell-main { display: block; text-align: left; padding-bottom: 6px !important; }
    .table.cards td.cell-main::before { content: none; }
    .table.cards td.cell-main > * { justify-self: start; }
    .table.cards td.cell-actions { display: flex; justify-content: flex-end; align-items: center; gap: 4px; padding-top: 6px !important; }
    .table.cards td.cell-actions::before { content: none; }
    .table.cards td.cell-empty { display: none; }
    .table.cards .cell-note { max-width: 100%; white-space: normal; }
    /* Компактный вариант для записей: дата и сумма в одной строке, детали и действия — под ними */
    .table.cards.compact tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; }
    .table.cards.compact td { display: block; grid-column: 1; text-align: left; padding: 0 !important; color: var(--ink-2); font-size: 14px; }
    .table.cards.compact td::before { content: none; }
    .table.cards.compact td > * { justify-self: auto; }
    .table.cards.compact td.cell-main { grid-row: 1; padding: 0 !important; color: var(--ink); font-size: 15px; }
    .table.cards.compact td.cell-amount { grid-column: 2; grid-row: 1; text-align: right; color: var(--ink); font-size: 15px; }
    .table.cards.compact td.cell-actions { grid-column: 2; grid-row: 2 / span 3; display: flex; align-self: end; padding: 0 !important; margin-right: -6px; }
    .table.cards.compact td.right { text-align: left; }
    .table.cards.compact td.cell-amount.right { text-align: right; }
    .table.cards tfoot { border-top: 1px solid var(--line-soft); background: var(--surface-2); }
    .table.cards tfoot tr { border-bottom: 0; }
}

/* ------------------------------------------------------------------ Формы */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

.field { display: grid; gap: 6px; align-content: start; min-width: 0; }
.label { font-size: 13.5px; font-weight: 600; color: var(--ink-2); }
.label .req { color: var(--bad); }
.hint { font-size: 12.5px; color: var(--ink-3); line-height: 1.4; }

.input, .select, .textarea {
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--r-ctl);
    background: var(--surface);
    color: var(--ink);
    font-size: 15px;
    transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease);
    appearance: none;
    -webkit-appearance: none;
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); opacity: 0.8; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.textarea { min-height: 84px; resize: vertical; line-height: 1.45; }
.select {
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237b8493' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}
.select.sm, .input.sm { min-height: 36px; padding-top: 6px; padding-bottom: 6px; font-size: 14px; width: auto; }
input[type="date"].input { min-width: 0; }
input[type="number"].input { -moz-appearance: textfield; }
input[type="number"].input::-webkit-outer-spin-button,
input[type="number"].input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Поле суммы с обозначением валюты */
.money { position: relative; }
.money .input { padding-right: 58px; font-variant-numeric: tabular-nums; }
.money-cur {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    padding: 3px 8px;
    border-radius: 7px;
    background: var(--surface-3);
    color: var(--ink-2);
    font-size: 12.5px; font-weight: 700;
    pointer-events: none;
}

.search { position: relative; flex: 1 1 220px; min-width: 0; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-3); pointer-events: none; }
.search .input { padding-left: 38px; }

.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input {
    appearance: none; -webkit-appearance: none;
    width: 20px; height: 20px; flex: none; margin-top: 1px;
    border: 1.5px solid var(--ink-3);
    border-radius: 6px;
    background: var(--surface);
    display: grid; place-items: center;
    transition: background-color 0.12s var(--ease), border-color 0.12s var(--ease);
}
.check input[type="radio"] { border-radius: 50%; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after {
    content: ""; width: 10px; height: 6px;
    border: 2px solid #fff; border-top: 0; border-right: 0;
    transform: rotate(-45deg) translate(1px, -1px);
}
.check input[type="radio"]:checked::after { width: 8px; height: 8px; border: 0; border-radius: 50%; background: #fff; transform: none; }
.check-text { min-width: 0; }
.check-text strong { display: block; font-weight: 600; }
.check-text span { display: block; font-size: 13px; color: var(--ink-3); line-height: 1.4; }

.form-section { display: grid; gap: 14px; }
.form-section + .form-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--line-soft); }
.form-section-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.form-section-title .flag { margin-right: 8px; }

/* ------------------------------------------------------- Заметки и пустоты */
.note {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    border-radius: var(--r-tile);
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 14px; line-height: 1.45;
}
.note > .icon { margin-top: 1px; color: var(--ink-3); }
.note strong { color: var(--ink); font-weight: 650; }
.note.info { background: var(--info-soft); } .note.info > .icon { color: var(--info); }
.note.ok { background: var(--ok-soft); } .note.ok > .icon { color: var(--ok); }
.note.warn { background: var(--warn-soft); } .note.warn > .icon { color: var(--warn); }
.note.bad { background: var(--bad-soft); } .note.bad > .icon { color: var(--bad); }
.note-list { display: grid; gap: 6px; }

.empty { display: grid; justify-items: center; gap: 6px; padding: 40px 20px; text-align: center; }
.empty-ico {
    width: 52px; height: 52px; margin-bottom: 6px;
    display: grid; place-items: center;
    border-radius: 16px;
    background: var(--surface-3);
    color: var(--ink-3);
}
.empty-title { font-size: 16px; font-weight: 700; }
.empty-text { color: var(--ink-3); font-size: 14px; max-width: 42ch; }
.empty .btn { margin-top: 10px; }

/* ----------------------------------------------------------------- Списки */
.list { display: grid; }
.list-row {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 12px var(--pad);
    border-bottom: 1px solid var(--line-soft);
    min-width: 0;
}
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--surface-2); }
.list-main { min-width: 0; }
.list-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-meta { margin-top: 2px; font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; }
.list-meta.one-line { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-title .flag { margin-right: 4px; }
.list-side { text-align: right; flex: none; }
.list-side .num { font-weight: 700; }
.list-side small { display: block; font-size: 12.5px; color: var(--ink-3); }

.datechip {
    width: 44px; flex: none;
    display: grid; justify-items: center;
    padding: 5px 0 6px;
    border-radius: 10px;
    background: var(--surface-3);
    line-height: 1.15;
}
.datechip b { font-size: 16px; font-weight: 750; }
.datechip span { font-size: 11px; font-weight: 600; color: var(--ink-3); }
.datechip.bad { background: var(--bad-soft); color: var(--bad); }
.datechip.bad span { color: var(--bad); }

/* ------------------------------------------------------------------ Вкладки */
.tabs { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line-soft); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs-btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 38px; padding: 0 14px;
    border-radius: var(--r-ctl);
    color: var(--ink-2);
    font-weight: 650; font-size: 14.5px;
    white-space: nowrap;
}
.tabs-btn:hover { background: var(--surface-2); color: var(--ink); }
.tabs-btn[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.tabs-count { font-size: 12.5px; font-weight: 650; color: var(--ink-3); }
.tabs-btn[aria-selected="true"] .tabs-count { color: inherit; opacity: 0.75; }
.tab-panel[hidden] { display: none; }
@media (max-width: 520px) {
    .tabs { gap: 2px; padding: 6px 8px; }
    .tabs-btn { padding: 0 4px; font-size: 13.5px; gap: 5px; flex: 1 1 0; min-width: 0; justify-content: center; }
    .tabs-count { font-size: 12px; }
    .tabs-btn .icon { display: none; }
}
.tab-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px var(--pad); }
.tab-bar-total { font-size: 14px; color: var(--ink-2); }
.tab-bar-total strong { font-weight: 750; font-size: 16px; }

/* ----------------------------------------------------------------- Графики */
.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 200px; }
.chart-box.donut { height: 220px; max-width: 220px; margin: 0 auto; }
.chart-box canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.donut-wrap { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 24px; align-items: center; }
@media (max-width: 560px) { .donut-wrap { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------------------- Окна */
.modal {
    position: fixed; inset: 0; z-index: 100;
    display: none;
    align-items: center; justify-content: center;
    padding: 24px;
}
.modal.open { display: flex; }
.modal-backdrop {
    position: absolute; inset: 0;
    background: rgba(12, 15, 22, 0.52);
    animation: fade-in 0.16s ease both;
}
.modal-dialog {
    position: relative;
    width: 100%; max-width: 520px;
    max-height: min(88vh, 860px);
    display: flex; flex-direction: column;
    background: var(--surface);
    border-radius: 18px;
    box-shadow: var(--shadow-modal);
    animation: pop-in 0.2s var(--ease) both;
}
.modal-dialog.lg { max-width: 720px; }
.modal-dialog.sm { max-width: 420px; }
.modal-dialog > form { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px 22px; flex: none; }
.modal-title { font-size: 18px; font-weight: 750; }
.modal-body { padding: 12px 22px 20px; overflow-y: auto; overscroll-behavior: contain; flex: 1 1 auto; min-height: 0; }
.modal-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 14px 22px;
    border-top: 1px solid var(--line-soft);
    flex: none;
}
.modal-grip { display: none; }

@media (max-width: 639px) {
    .modal { padding: 0; align-items: flex-end; }
    .modal-dialog, .modal-dialog.lg, .modal-dialog.sm {
        max-width: none;
        max-height: 92dvh;
        border-radius: 20px 20px 0 0;
        animation-name: sheet-in;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    .modal-grip { display: block; width: 36px; height: 4px; margin: 8px auto 0; border-radius: 2px; background: var(--line); flex: none; }
    .modal-head { padding: 10px 14px 4px 18px; }
    .modal-body { padding: 10px 18px 18px; }
    .modal-foot { padding: 12px 18px; }
    .modal-foot { flex-wrap: wrap; }
    .modal-foot .btn { flex: 1 1 auto; }
}

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } }
@keyframes sheet-in { from { transform: translateY(100%); } }

.confirm-text { color: var(--ink-2); line-height: 1.5; }
.confirm-text strong { color: var(--ink); }

/* Меню «Ещё» на телефоне */
.sheet-list { display: grid; gap: 2px; }
.sheet-list .nav-item { height: 48px; font-size: 15.5px; }
.sheet-block { display: grid; gap: 8px; padding: 14px 0; border-top: 1px solid var(--line-soft); }
.sheet-block:first-child { border-top: 0; padding-top: 0; }
.sheet-label { font-size: 13px; font-weight: 600; color: var(--ink-3); }

/* ------------------------------------------------------------- Уведомления */
.toasts {
    position: fixed; z-index: 120;
    right: 20px; bottom: 20px;
    display: grid; gap: 8px;
    width: min(380px, calc(100vw - 32px));
    pointer-events: none;
}
.toast {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 12px 12px 14px;
    border-radius: 14px;
    background: var(--ink);
    color: var(--ink-inv);
    box-shadow: var(--shadow-pop);
    font-size: 14px; line-height: 1.4;
    pointer-events: auto;
    animation: toast-in 0.22s var(--ease) both;
}
.toast > .icon { margin-top: 1px; }
.toast.success > .icon { color: #46d6a0; }
.toast.error > .icon { color: #ff8a8a; }
.toast.warning > .icon { color: #ffc65c; }
[data-theme="dark"] .toast.success > .icon { color: #0b8a5f; }
[data-theme="dark"] .toast.error > .icon { color: #cf2f2f; }
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-close { opacity: 0.6; padding: 2px; border-radius: 6px; color: inherit; }
.toast-close:hover { opacity: 1; }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@media (max-width: 1023px) {
    .toasts { right: 16px; left: 16px; width: auto; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px); }
}

/* ----------------------------------------------------------------- Фильтры */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .grow { flex: 1 1 auto; }

/* ----------------------------------------------------- Страница: обзор */
.hero { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; padding: 24px; }
.hero-label { font-size: 14px; font-weight: 600; color: var(--ink-3); }
.hero-value { margin-top: 4px; font-size: 40px; font-weight: 780; letter-spacing: -0.03em; line-height: 1.1; }
.hero-delta { margin-top: 10px; display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; font-size: 14.5px; color: var(--ink-2); }
.hero-delta .badge { height: 26px; font-size: 13.5px; }
.hero-split { margin-top: 22px; display: grid; gap: 10px; }
.splitbar { display: flex; height: 12px; border-radius: var(--r-pill); overflow: hidden; background: var(--surface-3); gap: 2px; }
.splitbar > span { display: block; min-width: 4px; }
.hero-side { display: grid; gap: 10px; align-content: center; }
.hero-side .tiles { gap: 10px; }
@media (max-width: 900px) {
    .hero { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 20px; }
    .hero-value { font-size: 32px; }
}

.country-card .card-head { padding-bottom: 0; }
.country-name { display: flex; align-items: center; gap: 10px; font-size: 17px; font-weight: 750; }
.country-name .flag { border-radius: 3px; }

/* ----------------------------------------------- Страница: недвижимость */
.prop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--gap); }
.prop-card { display: flex; flex-direction: column; transition: border-color 0.12s var(--ease), box-shadow 0.12s var(--ease); }
a.prop-card:hover { border-color: var(--ink-3); box-shadow: var(--shadow-pop); }
.prop-card-top { padding: 18px var(--pad) 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.prop-card-name { font-size: 16.5px; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.prop-card-meta { margin-top: 4px; font-size: 13px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.prop-card-body { padding: 16px var(--pad); display: grid; gap: 14px; flex: 1; align-content: start; }
.prop-card-value { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.prop-card-value .num { font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.prop-card-pay { display: grid; gap: 6px; font-size: 13px; color: var(--ink-3); }
.prop-card-pay-row { display: flex; justify-content: space-between; gap: 12px; }
.prop-card-pay-row .num { color: var(--ink-2); font-weight: 600; }
.prop-card.sold { background: var(--surface-2); box-shadow: none; }
@media (max-width: 420px) { .prop-grid { grid-template-columns: minmax(0, 1fr); } }

/* ------------------------------------------------------ Налоги и продажа */
.taxlines { display: grid; }
.taxline { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.taxline:first-child { padding-top: 0; }
.taxline-name { font-weight: 600; }
.taxline-rate { margin-left: 6px; font-size: 12.5px; font-weight: 650; color: var(--ink-3); white-space: nowrap; }
.taxline-amount { font-weight: 700; text-align: right; }
.taxline-note { grid-column: 1 / -1; font-size: 13px; color: var(--ink-3); line-height: 1.4; }
.taxline.total { border-bottom: 0; padding-bottom: 0; align-items: baseline; }
.taxline.total .taxline-name { font-weight: 750; }
.taxline.total .taxline-amount { font-size: 19px; font-weight: 780; color: var(--bad); }
.taxline.total.zero .taxline-amount { color: var(--ok); }

.timeline { display: grid; gap: 10px; }
.timeline-item { display: flex; gap: 12px; align-items: flex-start; }
.timeline-date {
    flex: none; min-width: 92px;
    padding: 4px 8px;
    border-radius: 8px;
    background: var(--accent-soft); color: var(--accent-ink);
    font-size: 13px; font-weight: 700; text-align: center;
}
.timeline-text { font-size: 14px; color: var(--ink-2); line-height: 1.4; padding-top: 3px; }
.timeline-text strong { color: var(--ok); font-weight: 700; }
.timeline-text strong.up { color: var(--warn); }

.sale-result { display: grid; gap: 0; }
.sale-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding: 20px var(--pad); }
.sale-banner-main .hero-label { display: flex; align-items: center; gap: 8px; }
.sale-banner-value { font-size: 30px; font-weight: 780; letter-spacing: -0.03em; line-height: 1.15; margin-top: 2px; }

details.more { border-top: 1px solid var(--line-soft); }
details.more > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 12px var(--pad);
    cursor: pointer; list-style: none;
    font-size: 14px; font-weight: 650; color: var(--ink-2);
}
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary .icon { transition: transform 0.15s var(--ease); }
details.more[open] > summary .icon { transform: rotate(180deg); }
details.more > .more-body { padding: 0 var(--pad) var(--pad); }
.card-body details.more { margin: 0 calc(var(--pad) * -1); }

/* Описание объекта: сохраняем переносы строк, не даём длинным строкам ломать вёрстку */
.prose { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink-2); font-size: 14.5px; line-height: 1.55; }
.prose a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; }

/* ------------------------------------------------------------------- Вход */
.auth {
    min-height: 100dvh;
    display: grid; place-items: center;
    padding: 24px 16px;
    background:
        radial-gradient(900px 500px at 12% -10%, var(--accent-soft), transparent 60%),
        var(--bg);
}
.auth-card { width: 100%; max-width: 400px; padding: 32px 28px; }
.auth-brand { display: flex; align-items: center; gap: 12px; font-size: 20px; font-weight: 780; letter-spacing: -0.02em; margin-bottom: 6px; }
.auth-brand .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
.auth-sub { color: var(--ink-3); margin-bottom: 24px; }
.auth form { display: grid; gap: 16px; }

/* -------------------------------------------------------------- Доступность */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

@media print {
    .sidebar, .topbar, .tabbar, .page-actions, .toasts, .cell-actions, .no-print { display: none !important; }
    .main { margin: 0; padding: 0; }
    .card, .kpi { box-shadow: none; break-inside: avoid; }
    body { background: #fff; }
}
