* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    color: #1a1a2e;
    background: #f5f6fa;
}

/* No sharp-cornered form controls anywhere: a rounded fallback for every
   input/select/textarea that its own context rule doesn't already round
   (dates, months, plain selects, etc.). */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
select,
textarea {
    border-radius: 8px;
}

.topbar {
    background: linear-gradient(100deg, #16182b 0%, #23264d 60%, #2b3080 100%);
    color: #fff;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(20, 22, 43, .25);
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: #fff;
}
.logo-mark { display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.25)); }
.brand-name { font-size: 18px; font-weight: 500; letter-spacing: .2px; }
.brand-name strong { font-weight: 700; }

.topbar-nav {
    display: flex;
    gap: 4px;
    margin-left: 26px;
    margin-right: auto;
    align-items: center;
}

.topbar-nav > a, .nav-top {
    color: #cfd2e6;
    text-decoration: none;
    font-size: 14px;
    font-family: inherit;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 7px 11px;
    border-radius: 8px;
    transition: background .18s, color .18s;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.topbar-nav > a:hover, .nav-top:hover { color: #fff; background: rgba(255,255,255,.09); }
.caret { font-size: 10px; opacity: .7; }

.nav-group { position: relative; }
.nav-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 200px;
    background: #fff;
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 12px 34px rgba(20, 22, 43, .28);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .16s ease, transform .16s ease, visibility .16s;
    z-index: 60;
}
/* Hover-only: :focus-within kept a menu open after a click, so moving to the
   next group left two menus overlapping. */
.nav-group:hover .nav-menu {
    opacity: 1;
    visibility: visible;
    transform: none;
}
.nav-menu a {
    display: block;
    color: #2b2f45;
    text-decoration: none;
    font-size: 14px;
    padding: 9px 12px;
    border-radius: 7px;
    transition: background .14s, color .14s;
}
.nav-menu a:hover { background: #eef0ff; color: #3a44b0; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
}
.user-name { color: #e7e9f7; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
a.user-name:hover { text-decoration: underline; }
@media (max-width: 1360px) { .user-name { display: none; } }

/* Quick "Завести заявку" pill in the top bar (fast access, esp. on mobile). */
.quick-request {
    display: inline-flex; align-items: center; gap: 6px;
    background: #4a54c9; color: #fff; text-decoration: none;
    padding: 7px 13px; border-radius: 999px;
    font-size: 13px; font-weight: 600; white-space: nowrap;
    transition: background .15s, transform .05s;
}
.quick-request:hover { background: #3a44b0; }
.quick-request:active { transform: translateY(1px); }
.quick-request .ic-sm { width: 16px; height: 16px; }
@media (max-width: 560px) {
    .quick-request-text { display: none; }
    .quick-request { padding: 7px 10px; }
}

.logout-form {
    margin: 0;
}

.logout-form button {
    background: transparent;
    color: #cfd2e6;
    border: 1px solid #444a6b;
    border-radius: 6px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 13px;
}

.logout-form button:hover {
    background: #2a2f4a;
    color: #fff;
}

.login-wrap {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

/* Public presentation link under the login card (dark login background). */
.login-present {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin-top: 20px;
    color: #e2e5f6;
    text-decoration: none;
    font-size: 14.5px;
    font-weight: 600;
    padding: 11px 20px;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, .22);
    background: rgba(255, 255, 255, .06);
    transition: background .2s, border-color .2s, transform .05s;
}
.login-present:hover { background: rgba(255, 255, 255, .13); border-color: rgba(255, 255, 255, .42); }
.login-present:active { transform: translateY(1px); }
.login-present svg { width: 17px; height: 17px; }

.login-card {
    background: #fff;
    width: 100%;
    max-width: 360px;
    padding: 32px 28px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(26, 26, 46, 0.12);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-card h1 {
    margin: 0;
    font-size: 22px;
    text-align: center;
}

.login-sub {
    margin: 0 0 8px;
    text-align: center;
    color: #6b6f85;
    font-size: 14px;
}

.login-card label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: #444a6b;
}

.login-card input {
    padding: 10px 12px;
    border: 1px solid #cfd2e6;
    border-radius: 8px;
    font-size: 15px;
}

.login-card input:focus {
    outline: none;
    border-color: #4a54c9;
}

.login-card button[type="submit"] {
    margin-top: 6px;
    padding: 11px;
    background: #4a54c9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.login-card button[type="submit"]:hover {
    background: #3a44b0;
}

.login-error {
    background: #fdeaea;
    color: #b02a2a;
    border: 1px solid #f3c0c0;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
    text-align: center;
}

.content {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px;
}

/* --- Documents page --- */
.dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 36px 20px;
    margin: 16px 0 24px;
    border: 2px dashed #b8bcd8;
    border-radius: 12px;
    background: #fbfbfe;
    cursor: pointer;
    text-align: center;
    transition: border-color .15s, background .15s;
}

.dropzone:hover { border-color: #4a54c9; }

.dropzone-over {
    border-color: #4a54c9;
    background: #eef0ff;
}

.dropzone-title { font-size: 16px; font-weight: 600; }
.dropzone-hint { font-size: 13px; color: #6b6f85; }
.dropzone-file { font-size: 13px; color: #4a54c9; }

.msg {
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 14px;
}
.msg-ok   { background: #e8f6ec; color: #1f7a3d; border: 1px solid #b6e2c4; }
.msg-warn { background: #fdf4e3; color: #8a6100; border: 1px solid #f0d9a6; }
.msg-error{ background: #fdeaea; color: #b02a2a; border: 1px solid #f3c0c0; }
.msg-info { background: #eaf0fd; color: #2a4bb0; border: 1px solid #c3d2f3; }
.msg-info a { color: #2a4bb0; font-weight: 600; }

.docs-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(26,26,46,.06);
}

.docs-table th, .docs-table td {
    padding: 10px 14px;
    text-align: left;
    border-bottom: 1px solid #eef0f5;
    font-size: 14px;
}

.docs-table th {
    background: #f5f6fa;
    font-weight: 600;
    color: #444a6b;
}

.docs-table tr:last-child td { border-bottom: none; }
.doc-name { font-weight: 500; }
/* Числовые колонки. Общее правило `.num` (одна колонка ниже) проигрывало по
   специфичности правилу `.docs-table th, .docs-table td { text-align: left }`,
   поэтому суммы во всех таблицах стояли по левому краю. */
.docs-table th.num, .docs-table td.num, .docs-table .cell-num { text-align: right; }

/* Кликабельный заголовок-сортировка (список заседаний ФП). */
.sort-th {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
}
.sort-th:hover { color: #4c5bd4; text-decoration: underline; }
.sort-th.sort-active { color: #4c5bd4; font-weight: 700; }
html[data-theme="dark"] .sort-th:hover,
html[data-theme="dark"] .sort-th.sort-active { color: #8f9bff; }

.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    background: #eef0ff;
    color: #4a54c9;
    font-size: 12px;
}

.docs-empty {
    text-align: center;
    color: #9095a8;
    padding: 24px;
}

/* Friendly empty state (onboarding «first steps» instead of a bare table). */
.empty-state {
    display: flex; flex-direction: column; align-items: center; gap: 9px;
    padding: 34px 20px; text-align: center;
}
.empty-state > svg { width: 40px; height: 40px; color: #b3b8d6; }
.empty-title { font-weight: 600; color: #33374d; font-size: 15.5px; }
.empty-hint { color: #6b6f85; font-size: 13.5px; line-height: 1.5; max-width: 52ch; }
.empty-cta {
    margin-top: 5px; display: inline-flex; align-items: center; gap: 7px;
    background: #4a54c9; color: #fff; text-decoration: none;
    padding: 9px 17px; border-radius: 9px; font-size: 14px; font-weight: 600;
    transition: background .15s;
}
.empty-cta:hover { background: #3a44b0; }
html[data-theme="dark"] .empty-title { color: #e7e9f7; }
html[data-theme="dark"] .empty-hint { color: #a6abc9; }
html[data-theme="dark"] .empty-state > svg { color: #4a5170; }

/* --- Review screen --- */
.review-head { display: flex; align-items: baseline; gap: 12px; }
.review-file { color: #6b6f85; font-size: 14px; }
.msg-warn ul { margin: 6px 0 0; padding-left: 20px; }

.review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .review-grid { grid-template-columns: 1fr; }
}

.review-preview pre {
    background: #1a1a2e;
    color: #d6d9ee;
    padding: 14px;
    border-radius: 10px;
    font-size: 12px;
    line-height: 1.5;
    max-height: 640px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

.review-fields h2 { margin-top: 0; }
.review-fields h3 { margin: 18px 0 8px; font-size: 15px; color: #444a6b; }

.review-fields form { display: flex; flex-direction: column; gap: 10px; }
.review-fields label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #444a6b; }
.review-fields input, .review-fields select {
    padding: 8px 10px;
    border: 1px solid #cfd2e6;
    border-radius: 8px;
    font-size: 14px;
}
.field-row { display: flex; gap: 12px; }
.field-row label { flex: 1; }

.btn-primary {
    margin-top: 14px;
    padding: 11px;
    background: #4a54c9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.btn-primary:hover { background: #3a44b0; }
.btn-cancel {
    text-align: center;
    padding: 9px;
    color: #6b6f85;
    text-decoration: none;
    font-size: 14px;
}
.items-table { margin-top: 8px; }
.items-table td { font-size: 13px; }
.review-hint { font-size: 12px; color: #9095a8; margin-top: 8px; }
.doc-actions a { margin-right: 12px; }

/* --- Filters + editable items --- */
.filters {
    display: flex;
    gap: 10px;
    align-items: center;
    margin: 14px 0 20px;
    flex-wrap: wrap;
}
.filters input, .filters select {
    padding: 8px 10px;
    border: 1px solid #cfd2e6;
    border-radius: 8px;
    font-size: 14px;
}
.filters input[name="q"] { min-width: 240px; }
.filters button {
    padding: 8px 16px;
    background: #4a54c9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}
.filters-reset { font-size: 13px; color: #6b6f85; }
.num, .cell-num { text-align: right; }
.badge-dup { background: #fdeaea; color: #b02a2a; }

.items-edit input {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid #dfe2ef;
    border-radius: 6px;
    font-size: 13px;
}
.items-edit .cell-num input { text-align: right; max-width: 110px; }
.items-edit td { padding: 6px 6px; }

/* --- Expense items page --- */
.two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
}
/* Колонка не должна раздуваться под самое широкое содержимое (длинный пункт
   в <select>): без этого страница уезжает вбок на узком экране. */
.two-col > * { min-width: 0; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }
.inline-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.inline-form input, .inline-form select {
    padding: 8px 10px;
    border: 1px solid #cfd2e6;
    border-radius: 8px;
    font-size: 14px;
}
.inline-form input[name="name"], .inline-form input[name="pattern"] { min-width: 220px; }
.inline-form button {
    padding: 8px 16px;
    background: #4a54c9;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}
.rules-title { margin-top: 0; }

/* --- Панель управления заседаниями ФП: подпись над полем, кнопки в один ряд --- */
.fp-setup section { display: flex; flex-direction: column; }
.fp-setup h3 { margin-bottom: 2px; }
.fp-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 10px;
    margin-top: 10px;
}
.fp-controls label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    color: #6b6f85;
    /* Без min-width:0 поле-список раздвигает строку под самый длинный пункт
       («№12 · Аренда склада за август · 180000.00 ₽») и уносит страницу
       вбок на телефоне. */
    min-width: 0;
}
.fp-controls label.grow { flex: 1 1 180px; }
.fp-controls input, .fp-controls select {
    padding: 8px 10px;
    border: 1px solid #cfd2e6;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: inherit;
    max-width: 100%;
    min-width: 0;
    /* Одна высота на все поля и кнопки: у input[type=date] своя внутренняя
       высота, из-за неё соседние поля различались на 2 px. */
    height: 38px;
}
.fp-controls button {
    padding: 0 16px;
    height: 38px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    background: #eef0fb;
    color: #3b4270;
    white-space: nowrap;
}
.fp-controls button:hover { background: #e2e5f8; }
.fp-controls .btn-primary { background: #4a54c9; color: #fff; }
.fp-controls .btn-no { background: #fdeceb; color: #b03024; }
.fp-autogen-row { align-items: center; margin-top: 12px; }
.fp-autogen-row .review-hint { margin: 0; flex: 1 1 220px; }
html[data-theme="dark"] .fp-controls label { color: #a7abc9; }
html[data-theme="dark"] .fp-controls input,
html[data-theme="dark"] .fp-controls select {
    background: #23264a; border-color: #3a3f6b; color: #e8eaf6;
}
html[data-theme="dark"] .fp-controls button { background: #2e3358; color: #d3d7f0; }
html[data-theme="dark"] .fp-controls button:hover { background: #383e6b; }
/* Общее тёмное правило выше перебивало по специфичности .btn-primary/.btn-no:
   в тёмной теме «Создать» и «Сгенерировать» теряли синий, а «Выключить» — красный. */
html[data-theme="dark"] .fp-controls .btn-primary { background: #4a54c9; color: #fff; }
html[data-theme="dark"] .fp-controls .btn-primary:hover { background: #5561e0; }
html[data-theme="dark"] .fp-controls .btn-no { background: #3a2023; color: #f0a0a2; }
html[data-theme="dark"] .fp-controls .btn-no:hover { background: #48282c; }

/* Вкладки-ссылки (действующие / закрытые ФП) — тот же вид, что и кнопки-вкладки. */
a.tab { text-decoration: none; }

/* ============ Схемы движения денег («Обучение») ============ */
.flow-block {
    background: #fff;
    border: 1px solid #e8eaf2;
    border-radius: 14px;
    padding: 18px 22px 22px;
    margin-bottom: 20px;
}
.flow-block h2 {
    display: flex; align-items: center; gap: 10px;
    font-size: 19px; margin: 0 0 6px;
}
.flow-block > p { color: #55597a; font-size: 14px; margin: 0 0 14px; }
.flow-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    font-size: 14px; font-weight: 700; color: #fff; background: #4a54c9;
}
.flow-badge.b-in { background: #1f7a3d; }
.flow-badge.b-out { background: #b03024; }
.flow-badge.b-rep { background: #4a54c9; }

.flow-tree, .flow-tree ul { list-style: none; margin: 0; padding: 0; }
.flow-tree ul { margin-left: 22px; }
.flow-tree li { position: relative; padding: 5px 0; }
/* Связи считаем от ВЕРХА узла, а не от его середины: узлы бывают в одну и в две
   строки, и «лапка» по центру не сходилась бы с вертикалью. 5px — отступ li. */
.flow-tree ul > li::before {
    content: ""; position: absolute; left: 0; top: 0; width: 2px; height: 25px;
    background: #dcdff0;
}
.flow-tree ul > li:not(:last-child)::after {
    content: ""; position: absolute; left: 0; top: 25px; bottom: 0; width: 2px;
    background: #dcdff0;
}
.flow-tree ul > li > .flow-node { margin-left: 22px; }
/* Горизонтальная «лапка» от вертикали к узлу — на уровне заголовка узла. */
.flow-tree ul > li > .flow-node::before {
    content: ""; position: absolute; left: -22px; top: 20px; width: 22px; height: 2px;
    background: #dcdff0;
}
.flow-node {
    position: relative;
    display: inline-flex; align-items: center; gap: 10px;
    background: #f7f8fc; border: 1px solid #e4e7f3; border-left: 3px solid #b9bee0;
    border-radius: 10px; padding: 9px 14px; max-width: 100%;
}
.flow-ico { font-size: 18px; line-height: 1; }
.flow-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.flow-text strong { font-size: 14px; font-weight: 600; }
.flow-text small { font-size: 12px; color: #6b6f85; }
.flow-node.n-in { border-left-color: #1f7a3d; background: #f1f9f3; }
.flow-node.n-out { border-left-color: #b03024; background: #fdf3f2; }
.flow-node.n-pay { border-left-color: #c07800; background: #fdf7ea; }
.flow-node.n-fund { border-left-color: #6b4ac9; background: #f5f2fd; }
.flow-node.n-rep { border-left-color: #4a54c9; background: #f2f4fd; }
.flow-note {
    margin: 14px 0 0; padding: 10px 14px; border-radius: 10px;
    background: #f5f6fa; color: #55597a; font-size: 13px;
}

html[data-theme="dark"] .flow-block { background: #1c1f3d; border-color: #2c3057; }
html[data-theme="dark"] .flow-block > p { color: #a7abc9; }
html[data-theme="dark"] .flow-tree ul > li::before,
html[data-theme="dark"] .flow-tree ul > li:not(:last-child)::after,
html[data-theme="dark"] .flow-tree ul > li > .flow-node::before { background: #3a3f6b; }
html[data-theme="dark"] .flow-node {
    background: #23264a; border-color: #333863; border-left-color: #545a94;
}
html[data-theme="dark"] .flow-text small { color: #a7abc9; }
html[data-theme="dark"] .flow-node.n-in { background: #16301f; border-left-color: #3fa564; }
html[data-theme="dark"] .flow-node.n-out { background: #331a1a; border-left-color: #d05a4c; }
html[data-theme="dark"] .flow-node.n-pay { background: #33290f; border-left-color: #d99a2b; }
html[data-theme="dark"] .flow-node.n-fund { background: #251f42; border-left-color: #9179e8; }
html[data-theme="dark"] .flow-node.n-rep { background: #1e2246; border-left-color: #6f7ae0; }
html[data-theme="dark"] .flow-note { background: #23264a; color: #a7abc9; }

@media (max-width: 720px) {
    .flow-block { padding: 14px 14px 18px; }
    .flow-tree ul { margin-left: 12px; }
    .flow-node { padding: 8px 11px; }
    /* Шпаргалка — таблица из предложений, а не из цифр: на телефоне общий
       мобильный `white-space: nowrap` превращал каждую строку в ленту на
       600+ px с боковой прокруткой. Здесь текст должен переноситься. */
    .flow-block .docs-table { white-space: normal; }
    .flow-block .docs-table th, .flow-block .docs-table td { padding: 9px 10px; }
}

/* --- Карта движения денег (вторая вкладка статьи) --- */
.mindmap-wrap { overflow-x: auto; }
.mindmap { display: block; width: 100%; min-width: 720px; height: auto; }
.mm-link { fill: none; stroke: #ccd1e8; stroke-width: 2; }
.mm-box { fill: #f7f8fc; stroke: #e2e6f2; stroke-width: 1.5; }
.mm-center { fill: #4a54c9; }
.mm-t {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: 13px; fill: #2b2f4a;
}
.mm-center-t { font-size: 17px; font-weight: 700; fill: #fff; }
.mm-center-sub { font-size: 12px; fill: #d5d8fb; }
.mm-branch-t { font-size: 15px; font-weight: 700; }
.mm-in   { fill: #e6f4ea; stroke: #1f7a3d; }
.mm-in-l { fill: #f1f9f3; stroke: #bfe0cb; }
.mm-out   { fill: #fbe9e7; stroke: #b03024; }
.mm-out-l { fill: #fdf3f2; stroke: #f0cbc6; }
.mm-fund   { fill: #ece6fb; stroke: #6b4ac9; }
.mm-fund-l { fill: #f5f2fd; stroke: #d8cdf5; }
.mm-rep   { fill: #e6e9fb; stroke: #4a54c9; }
.mm-rep-l { fill: #f2f4fd; stroke: #ccd2f3; }

html[data-theme="dark"] .mm-link { stroke: #3f456f; }
html[data-theme="dark"] .mm-box { fill: #23264a; stroke: #333863; }
html[data-theme="dark"] .mm-t { fill: #e7e9f7; }
html[data-theme="dark"] .mm-center { fill: #5561e0; }
html[data-theme="dark"] .mm-center-sub { fill: #c9cdf7; }
html[data-theme="dark"] .mm-in   { fill: #16301f; stroke: #3fa564; }
html[data-theme="dark"] .mm-in-l { fill: #12261a; stroke: #2c6b43; }
html[data-theme="dark"] .mm-out   { fill: #331a1a; stroke: #d05a4c; }
html[data-theme="dark"] .mm-out-l { fill: #2a1616; stroke: #8c3b33; }
html[data-theme="dark"] .mm-fund   { fill: #251f42; stroke: #9179e8; }
html[data-theme="dark"] .mm-fund-l { fill: #1f1b38; stroke: #5b4a9c; }
html[data-theme="dark"] .mm-rep   { fill: #1e2246; stroke: #6f7ae0; }
html[data-theme="dark"] .mm-rep-l { fill: #1a1d3c; stroke: #454c8f; }

/* --- Status badges + row actions --- */
.badge-ok   { background: #e8f6ec; color: #1f7a3d; }
.badge-wait { background: #fdf4e3; color: #8a6100; }
.row-action { display: inline-flex; gap: 6px; align-items: center; margin: 0 6px 4px 0; }
.row-action button {
    background: #f5f6fb;
    border: 1px solid #d7dae8;
    border-radius: 9px;
    padding: 5px 11px;
    font-size: 12.5px;
    cursor: pointer;
    color: #3a3f5c;
    transition: background .14s, border-color .14s, color .14s;
}
.row-action button:hover { background: #eef0ff; border-color: #b8bee8; color: #3a44b0; }
.row-action input {
    padding: 5px 10px;
    border: 1px solid #cfd2e6;
    border-radius: 9px;
    font-size: 13px;
}
.row-action .act-ok { border-color: #b6e2c4; color: #1f7a3d; }
.row-action .act-no { border-color: #f3c0c0; color: #b02a2a; }

/* Inline action buttons used inside page content (not the dark topbar). */
.content .logout-form button {
    background: #f5f6fb; border: 1px solid #d7dae8; border-radius: 9px;
    padding: 6px 12px; font-size: 13px; color: #3a3f5c; cursor: pointer;
    transition: background .14s, border-color .14s, color .14s;
}
.content .logout-form button:hover { background: #eef0ff; border-color: #b8bee8; color: #3a44b0; }
html[data-theme="dark"] .content .logout-form button {
    background: #262a4d; border-color: #3a3f68; color: #cfd3ee;
}
html[data-theme="dark"] .content .logout-form button:hover { background: #303663; color: #fff; }

/* --- Calendar + payables --- */
.calendar-total { font-size: 15px; }
.cal-overdue-title { color: #b02a2a; }
.row-overdue td { background: #fdf1f1; }
.row-warn td { background: #fdf8ec; }

/* Управленческий баланс: две колонки активы/пассивы */
.balance-cols { display: flex; gap: 24px; align-items: flex-start; flex-wrap: wrap; }
.balance-cols > section { flex: 1 1 320px; min-width: 0; }
.balance-cols > section > h3 { margin-top: 0; }
.muted-row td { color: #8a90ad; }
.balance-equity td { font-size: 15px; }
.debt-pos { color: #b02a2a; font-weight: 600; }
.pay-form { display: flex; gap: 6px; }
.pay-form input {
    padding: 4px 8px;
    border: 1px solid #cfd2e6;
    border-radius: 6px;
    font-size: 12px;
    width: 90px;
    text-align: right;
}
.pay-form button {
    background: #4a54c9;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

/* --- Dashboard --- */
.dash-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.dash-month { margin: 0; }
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 18px 0 26px;
}
.card {
    background: #fff;
    border-radius: 12px;
    padding: 18px 20px;
    box-shadow: 0 1px 4px rgba(26,26,46,.06);
}
.card-value { font-size: 22px; font-weight: 700; }
.card-label { font-size: 13px; color: #6b6f85; margin-top: 4px; }
.card-label a { color: inherit; text-decoration: none; }
.card-label a:hover { color: #4a54c9; text-decoration: underline; }
.card-alert { border: 1px solid #f3c0c0; }

/* Cockpit: income / expense / result headline for the month. */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin: 6px 0 22px;
}
@media (max-width: 640px) { .kpi-row { grid-template-columns: 1fr; } }
.kpi {
    background: #fff;
    border: 1px solid #e6e8f0;
    border-left: 4px solid #6b6f85;
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 1px 4px rgba(26,26,46,.06);
}
.kpi-label { color: #6b6f85; font-size: 13px; font-weight: 600; }
.kpi-value { font-size: 26px; font-weight: 800; letter-spacing: -.02em; margin-top: 6px; color: #1a1a2e; font-variant-numeric: tabular-nums; }
.kpi-income { border-left-color: #16a34a; }
.kpi-expense { border-left-color: #4a54c9; }
.kpi-pos { border-left-color: #16a34a; }
.kpi-neg { border-left-color: #c0504d; }
.kpi-pos .kpi-value { color: #15873c; }
.kpi-neg .kpi-value { color: #c0504d; }
.kpi-link { display: inline-block; margin-top: 8px; font-size: 13px; color: #4a54c9; text-decoration: none; }
.kpi-link:hover { text-decoration: underline; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.section-more { font-size: 13px; color: #4a54c9; text-decoration: none; white-space: nowrap; }
.section-more:hover { text-decoration: underline; }
.recent-docs { margin: 8px 0 6px; }

html[data-theme="dark"] .kpi { background: #1e2140; border-color: #33375f; }
html[data-theme="dark"] .kpi-value { color: #e7e9f7; }
html[data-theme="dark"] .kpi-label { color: #a6abc9; }
html[data-theme="dark"] .kpi-pos .kpi-value { color: #4ade80; }
html[data-theme="dark"] .kpi-neg .kpi-value { color: #f0a0a2; }
.card-alert .card-value { color: #b02a2a; }

.bar-row {
    display: grid;
    grid-template-columns: 160px 1fr 110px;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
}
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { background: #eef0f5; border-radius: 6px; height: 18px; }
.bar-fill { background: #4a54c9; height: 100%; border-radius: 6px; min-width: 2px; }
.bar-cash { background: #1f7a3d; }
.bar-value { text-align: right; }

/* --- Audit log page --- */
.audit-details {
    font-size: 12px;
    color: #667;
    max-width: 420px;
    word-break: break-all;
}
.pager { display: flex; gap: 18px; margin: 14px 0; }

/* --- Help page --- */
.help-toc {
    margin: 4px 0 18px;
    font-size: 14px;
    color: #667;
}
.help-toc a { white-space: nowrap; }
section[id] { margin-bottom: 26px; scroll-margin-top: 70px; }
section[id] ol, section[id] ul { padding-left: 22px; line-height: 1.55; }
section[id] li { margin-bottom: 6px; }

/* --- Справка: две панели (рубрики слева, один блок справа) --- */
.help-layout { display: flex; gap: 26px; align-items: flex-start; margin-top: 14px; }
.help-nav {
    flex: 0 0 236px;
    position: sticky;
    top: 70px;
    max-height: calc(100vh - 90px);
    overflow-y: auto;
    padding-right: 4px;
}
/* Each rubric is a faint, self-contained block so it's clear which items
   belong together; a tree line runs from the title down to its items. */
.help-nav-group {
    margin-bottom: 12px;
    padding: 9px 10px 10px;
    background: rgba(74, 84, 201, .04);
    border: 1px solid rgba(74, 84, 201, .12);
    border-radius: 11px;
}
.help-nav-title {
    font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
    color: #1b1e33; font-weight: 800; margin: 0 0 8px 2px;
}
.help-nav-items {
    margin: 0 0 0 7px;
    padding-left: 13px;
    border-left: 1.5px solid rgba(74, 84, 201, .30);  /* tree trunk */
}
.help-nav-item {
    position: relative;
    display: block; width: 100%; text-align: left;
    background: transparent; border: none; border-radius: 9px;
    padding: 8px 11px; margin-bottom: 2px;
    color: #33374d; cursor: pointer; font-size: 14px; font-family: inherit;
    transition: background .15s, color .15s;
}
.help-nav-item::before {  /* branch from trunk to item */
    content: ""; position: absolute; left: -13px; top: 50%;
    width: 12px; height: 1.5px; background: rgba(74, 84, 201, .30);
}
.help-nav-item:hover { background: #f2f3fb; color: #4a54c9; }
.help-nav-item.active { background: #eaecfb; color: #4a54c9; font-weight: 600; }
.help-content { flex: 1 1 auto; min-width: 0; }
.help-topic { display: none; }
.help-topic.active { display: block; animation: help-fade .18s ease; }
.help-topic h3 { margin-top: 0; }
.help-topic ol, .help-topic ul { padding-left: 22px; line-height: 1.55; }
.help-topic li { margin-bottom: 6px; }
@keyframes help-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (max-width: 760px) {
    .help-layout { flex-direction: column; gap: 12px; }
    .help-nav {
        position: static; flex-basis: auto; width: 100%; max-height: none;
        display: flex; flex-wrap: wrap; gap: 4px; overflow: visible;
    }
    .help-nav-group {
        margin-bottom: 0; display: contents;
        background: transparent; border: none; padding: 0;
    }
    .help-nav-items { display: contents; border-left: none; margin: 0; padding: 0; }
    .help-nav-title { display: none; }
    .help-nav-item {
        width: auto; border: 1px solid #e0e3f0; border-radius: 999px; padding: 6px 12px;
    }
    .help-nav-item::before { display: none; }
}

/* Dark theme: readable white bold rubric titles, subtle blocks and tree lines. */
html[data-theme="dark"] .help-nav-group {
    background: rgba(255, 255, 255, .035); border-color: #363b64;
}
html[data-theme="dark"] .help-nav-title { color: #ffffff; }
html[data-theme="dark"] .help-nav-items { border-left-color: #4a54c9; }
html[data-theme="dark"] .help-nav-item::before { background: #4a54c9; }
html[data-theme="dark"] .help-nav-item { color: #c7cbe6; }
html[data-theme="dark"] .help-nav-item:hover { background: #262a4d; color: #aeb5ee; }
html[data-theme="dark"] .help-nav-item.active { background: #2c3160; color: #c3c9ff; }
html[data-theme="dark"] .help-nav-item { border-color: #3a3f68; }

/* --- Requests and permissions --- */
.muted { color: #778; font-size: 12px; }
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; white-space: nowrap; cursor: pointer; }
.check-inline input { width: auto; margin: 0; }
.req-form input[name="title"] { min-width: 260px; }
.perm-row { display: block; margin: 6px 0; font-size: 14px; }
.perm-row input { margin-right: 8px; }
.perm-admin { font-weight: 600; }
.perm-form button[type="submit"] { margin-top: 14px; }
.btn-cancel { margin-left: 14px; }

/* ============ Tooltips (hover hints) ============ */
[data-tip] { position: relative; cursor: help; }
/* Lift the hovered element above its siblings so its tooltip is never covered
   by a neighbouring card (cards create a stacking context via hover transform). */
[data-tip]:hover { z-index: 20; }
[data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    left: 0;
    top: calc(100% + 6px);
    z-index: 100;
    width: max-content;
    max-width: 300px;
    background: #1a1a2e;
    color: #eef0ff;
    padding: 8px 11px;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
    box-shadow: 0 8px 24px rgba(26, 26, 46, .28);
    pointer-events: none;
    animation: tip-in .14s ease both;
}
[data-tip]:hover::before {
    content: "";
    position: absolute;
    left: 14px;
    top: calc(100% + 1px);
    border: 5px solid transparent;
    border-bottom-color: #1a1a2e;
    z-index: 100;
    pointer-events: none;
}
@keyframes tip-in { from { opacity: 0; transform: translateY(-3px); } to { opacity: 1; transform: none; } }

/* ============ Page head + generic helpers ============ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin-bottom: 4px; }
.btn-inline { margin-top: 0; }
.crumb { margin: 0 0 14px; font-size: 14px; }
.crumb a { color: #6b6f85; text-decoration: none; }
.crumb a:hover { color: #4a54c9; }
.row-link { cursor: pointer; transition: background .12s; }
.row-link:hover { background: #f5f6ff; }
.clip { margin-left: 6px; }
.req-star { color: #b02a2a; }

/* ============ Modal dialog ============ */
.modal {
    border: none;
    padding: 0;
    border-radius: 14px;
    width: min(680px, 94vw);
    max-height: 92vh;
    box-shadow: 0 24px 60px rgba(26, 26, 46, .35);
    overflow: hidden;
}
.modal::backdrop { background: rgba(20, 20, 40, .5); }
.modal[open] { animation: modal-in .18s ease both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 22px;
    background: linear-gradient(135deg, #2b3080, #4a54c9);
    color: #fff;
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-close {
    background: rgba(255,255,255,.15); color: #fff; border: none;
    width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 15px;
}
.modal-close:hover { background: rgba(255,255,255,.3); }
.modal-body { padding: 20px 22px; overflow-y: auto; max-height: calc(92vh - 128px); }
.modal-foot {
    display: flex; justify-content: flex-end; gap: 12px; align-items: center;
    padding: 14px 22px; border-top: 1px solid #eef0f5; background: #fbfbfe;
}

/* ============ Card-style form (Manajet look) ============ */
.card-form { margin: 0; }
.card-row { display: grid; grid-template-columns: 175px 1fr; gap: 14px; align-items: center; margin-bottom: 13px; }
.card-row > label { font-size: 13px; color: #444a6b; font-weight: 500; }
.card-row > input, .card-row > select, .card-row > textarea,
.card-row-split input, .card-row-split select {
    width: 100%; padding: 8px 11px; border: 1px solid #cfd2e6;
    border-radius: 8px; font-size: 14px; font-family: inherit; background: #fff;
}
.card-row textarea { resize: vertical; line-height: 1.5; }
.card-row input:focus, .card-row select:focus, .card-row textarea:focus,
.card-row-split input:focus { outline: none; border-color: #4a54c9; box-shadow: 0 0 0 3px rgba(74,84,201,.12); }
.card-row-split { grid-template-columns: 1fr 1fr; align-items: start; }
.card-row-split > div { display: flex; flex-direction: column; gap: 5px; }
.card-row-split label { font-size: 13px; color: #444a6b; font-weight: 500; }
@media (max-width: 620px) {
    .card-row, .card-row-split { grid-template-columns: 1fr; gap: 5px; }
}

/* ============ Request detail card ============ */
/* No overflow:hidden — it would clip hover tooltips inside the card. */
.req-card { background: #fff; border-radius: 12px; box-shadow: 0 2px 12px rgba(26,26,46,.08); }
.req-card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 15px 22px; background: linear-gradient(135deg, #2b3080, #4a54c9); color: #fff;
    font-size: 16px; font-weight: 600; border-radius: 12px 12px 0 0;
}
.req-card-head .status-badge { background: rgba(255,255,255,.9); }
.req-card-body { padding: 6px 22px 18px; }
.req-field { display: grid; grid-template-columns: 190px 1fr; gap: 18px; padding: 11px 0; border-bottom: 1px solid #f1f2f7; }
.req-field:last-of-type { border-bottom: none; }
.req-field-split { grid-template-columns: 1fr 1fr; }
.req-label { color: #6b6f85; font-size: 13px; }
.req-value { font-size: 14px; color: #1a1a2e; }
.req-text { white-space: pre-wrap; line-height: 1.55; }
.req-scroll { max-height: 240px; overflow: auto; background: #f8f9fc; padding: 11px 13px; border-radius: 8px; }
.req-amount { font-weight: 700; font-size: 16px; }
.req-meta { margin-top: 14px; font-size: 13px; color: #6b6f85; }
.att-list { margin: 0; padding-left: 18px; line-height: 1.7; }
.att-list a { color: #4a54c9; text-decoration: none; }
.att-list a:hover { text-decoration: underline; }
.req-card-foot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 16px 22px; border-top: 1px solid #eef0f5; background: #fbfbfe; border-radius: 0 0 12px 12px; }
/* Foot-button tooltips open upward so they are never cut off at page bottom. */
.req-card-foot [data-tip]:hover::after { top: auto; bottom: calc(100% + 6px); }
.req-card-foot [data-tip]:hover::before { top: auto; bottom: calc(100% + 1px); border-bottom-color: transparent; border-top-color: #1a1a2e; }
.decide-form { display: flex; gap: 8px; align-items: center; margin: 0; }
.decide-form input { padding: 8px 11px; border: 1px solid #cfd2e6; border-radius: 8px; font-size: 14px; min-width: 220px; }
.btn-ok { background: #1f7a3d; color: #fff; border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-ok:hover { background: #196531; }
.btn-no { background: #fff; color: #b02a2a; border: 1px solid #e5b7b7; border-radius: 8px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-no:hover { background: #fdeaea; }

/* ============ Global polish & motion ============ */
.content { animation: page-in .26s ease both; }
@keyframes page-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { font-size: 24px; letter-spacing: -.3px; }
h3 { color: #2b2f45; }
.num, .cell-num, .req-amount, .card-value, .bar-value { font-variant-numeric: tabular-nums; }

.docs-table { transition: box-shadow .18s; }
.docs-table tbody tr { transition: background .12s; }

/* Inline SVG icons */
.ic { width: 16px; height: 16px; vertical-align: -3px; flex: none; }
.ic-sm { width: 14px; height: 14px; vertical-align: -2px; }
.btn-ok .ic, .btn-no .ic, .btn-primary .ic { vertical-align: -2px; margin-right: 5px; }
.att-list .ic { margin-right: 4px; color: #6b6f85; }

/* Cards lift on hover (shadow only — no layout shift) */
.card { transition: box-shadow .18s, transform .18s; }
.card:hover { box-shadow: 0 8px 24px rgba(26,26,46,.12); }

/* Clickable cards — drill down into the number behind them */
a.card { cursor: pointer; color: inherit; text-decoration: none; display: block; }
a.card:hover { box-shadow: 0 8px 24px rgba(26,26,46,.12); transform: translateY(-1px); }
a.card .card-go { float: right; color: #4a54c9; font-weight: 700; opacity: 0; transition: opacity .15s; }
a.card:hover .card-go { opacity: 1; }
.donut-legend a { color: inherit; text-decoration: none; }
.donut-legend a:hover { color: #4a54c9; text-decoration: underline; }

/* Buttons: consistent transitions */
.btn-primary, .filters button, .inline-form button, .btn-ok, .btn-no, .modal-close {
    transition: background .16s, box-shadow .16s, transform .05s;
}
.btn-primary:active, .btn-ok:active, .btn-no:active { transform: translateY(1px); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

/* ============ Dashboard charts ============ */
.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 8px 0 22px; }
@media (max-width: 860px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-card {
    background: #fff; border-radius: 12px; padding: 18px 20px;
    box-shadow: 0 1px 4px rgba(26,26,46,.06);
}
.chart-card h3 { margin: 0 0 14px; font-size: 15px; }
.chart-legend { display: flex; gap: 16px; font-size: 12.5px; color: #6b6f85; margin-top: 10px; flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.dot-inc { background: #16a34a; }
.dot-exp { background: #4a54c9; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart-svg .bar-in { animation: grow-y .5s ease both; transform-box: fill-box; transform-origin: bottom; }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.chart-empty { color: #9095a8; font-size: 13px; padding: 20px 0; text-align: center; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut-wrap .chart-svg { width: 150px; height: 150px; flex: none; }
.donut-legend { font-size: 13px; color: #444a6b; line-height: 1.8; }
.donut-legend .dot { margin-right: 7px; }
.result-pos { color: #16a34a; }
.result-neg { color: #b02a2a; }

/* ============ Login polish ============ */
.login-body { background: radial-gradient(1200px 600px at 50% -10%, #2b3080 0%, #1a1a2e 45%, #14152a 100%); }
.login-logo { display: flex; justify-content: center; }
.login-card { animation: page-in .3s ease both; }
.login-card h1 strong { color: #4a54c9; font-weight: 800; }

/* ============ Tabs ============ */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #e5e7f0; margin: 8px 0 18px; flex-wrap: wrap; }
.tab {
    background: transparent; border: none; font-family: inherit; font-size: 14px;
    color: #6b6f85; cursor: pointer; padding: 10px 16px; border-radius: 8px 8px 0 0;
    margin-bottom: -2px; border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s, background .15s;
    display: inline-flex; align-items: center; gap: 8px;
}
.tab:hover { color: #4a54c9; background: #f2f3fb; }
.tab.active { color: #4a54c9; font-weight: 600; border-bottom-color: #4a54c9; }
.tab-count {
    background: #eef0f5; color: #6b6f85; font-size: 12px; font-weight: 600;
    border-radius: 20px; padding: 1px 8px; min-width: 20px; text-align: center;
}
.tab.active .tab-count { background: #4a54c9; color: #fff; }
.tab-panel { animation: page-in .2s ease both; }
.hidden { display: none; }

/* ============ Onboarding tour ============ */
.tour-overlay { position: fixed; inset: 0; z-index: 9000; background: transparent; }
.tour-highlight {
    position: relative; z-index: 9500;
    box-shadow: 0 0 0 4px rgba(74,84,201,.9), 0 0 0 9999px rgba(18, 20, 40, .68);
    border-radius: 8px; transition: box-shadow .2s;
}
.tour-pop {
    position: fixed; z-index: 9600; width: 320px; max-width: calc(100vw - 24px);
    background: #fff; border-radius: 12px; padding: 16px 18px;
    box-shadow: 0 18px 50px rgba(18, 20, 40, .4); animation: tip-in .16s ease both;
}
.tour-title { font-weight: 700; font-size: 15px; margin-bottom: 6px; color: #1a1a2e; }
.tour-text { font-size: 13.5px; line-height: 1.5; color: #444a6b; }
.tour-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.tour-count { font-size: 12px; color: #9095a8; }
.tour-btns { display: flex; gap: 8px; }
.tour-btns button { font-family: inherit; font-size: 13px; border-radius: 7px; padding: 7px 13px; cursor: pointer; border: 1px solid transparent; transition: background .15s; }
.tour-skip { background: transparent; color: #6b6f85; }
.tour-skip:hover { color: #b02a2a; }
.tour-prev { background: #eef0f5; color: #444a6b; }
.tour-prev:hover { background: #e2e5ef; }
.tour-next { background: #4a54c9; color: #fff; font-weight: 600; }
.tour-next:hover { background: #3a44b0; }
.nav-help-btn { color: #7ef0ac !important; }

/* ============ Danger button ============ */
.row-action .btn-danger, .btn-danger { color: #b02a2a; border-color: #e5b7b7; background: #fff; }
.row-action .btn-danger:hover, .btn-danger:hover { background: #fdeaea; border-color: #e5b7b7; color: #b02a2a; }

/* ============ Mobile hamburger + responsive ============ */
.nav-toggle {
    display: none;
    background: rgba(255,255,255,.1); color: #fff; border: none;
    border-radius: 8px; padding: 7px 9px; cursor: pointer; margin-left: auto;
}
.nav-toggle:hover { background: rgba(255,255,255,.2); }

@media (max-width: 1360px) {
    .topbar { flex-wrap: wrap; padding: 10px 16px; }
    .nav-toggle { display: inline-flex; }
    .topbar-user { order: 3; }

    .topbar-nav {
        display: none;
        order: 4;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        margin: 10px 0 2px;
        max-height: 70vh;
        overflow-y: auto;
    }
    .topbar-nav.open { display: flex; }
    .topbar-nav > a, .nav-top { width: 100%; text-align: left; padding: 11px 12px; }

    /* Flatten dropdowns: show their items inline on touch devices. */
    .nav-group { position: static; }
    .nav-top { font-weight: 600; color: #fff; pointer-events: none; }
    .caret { display: none; }
    .nav-menu {
        position: static; opacity: 1; visibility: visible; transform: none;
        box-shadow: none; background: transparent; padding: 0 0 6px 10px; min-width: 0;
    }
    .nav-menu a { color: #cfd2e6; padding: 9px 12px; }
    .nav-menu a:hover { background: rgba(255,255,255,.09); color: #fff; }
}

@media (max-width: 720px) {
    .content { margin: 16px auto; padding: 0 12px; }
    h1 { font-size: 20px; }
    /* Top bar: brand + hamburger on row 1; the action buttons drop to their
       own right-aligned row so they never overflow and stretch the page. */
    .topbar { padding: 10px 12px; }
    .topbar-user { order: 2; flex: 0 0 100%; justify-content: flex-end; gap: 8px; margin-top: 8px; }
    .topbar-nav { order: 3; }
    /* Wide tables scroll horizontally instead of breaking the layout. */
    .docs-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
    .two-col { grid-template-columns: 1fr; }
    .dash-head { align-items: stretch; }
    .dash-month { width: 100%; }
    .dash-month input[type="month"] { flex: 1; min-width: 0; }
    .page-head { flex-direction: column; align-items: stretch; }
    .req-field, .req-field-split { grid-template-columns: 1fr; gap: 4px; }
    .modal { width: 96vw; max-height: 94vh; }
    .decide-form { flex-wrap: wrap; }
    .decide-form input { min-width: 0; width: 100%; }
    .filters { flex-direction: column; align-items: stretch; }
}

/* ============ Export button ============ */
.btn-export {
    display: inline-flex; align-items: center; gap: 6px;
    background: #16a34a; color: #fff; text-decoration: none;
    padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 600;
    transition: background .16s;
}
.btn-export:hover { background: #128033; }

/* ============ Attachment gallery + lightbox ============ */
.att-gallery { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.att-thumb {
    padding: 0; border: 1px solid #dfe2ef; border-radius: 8px; background: #fff;
    cursor: pointer; overflow: hidden; width: 84px; height: 84px; transition: box-shadow .15s, border-color .15s;
}
.att-thumb:hover { border-color: #4a54c9; box-shadow: 0 4px 14px rgba(74,84,201,.25); }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lightbox {
    position: fixed; inset: 0; z-index: 9700; background: rgba(15, 16, 34, .85);
    display: flex; align-items: center; justify-content: center; padding: 24px;
    cursor: zoom-out; animation: tip-in .14s ease both;
}
.lightbox figure { margin: 0; max-width: 92vw; max-height: 92vh; text-align: center; }
.lightbox img { max-width: 92vw; max-height: 84vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox figcaption { color: #e7e9f7; font-size: 13px; margin-top: 10px; }

/* ============ Copy button ============ */
.btn-copy {
    display: inline-flex; align-items: center; gap: 6px;
    background: #eef0ff; color: #3a44b0; text-decoration: none;
    padding: 8px 14px; border-radius: 8px; font-size: 14px; font-weight: 600;
    transition: background .16s;
}
.btn-copy:hover { background: #e0e3ff; }

/* ============ Floating help button ============ */
.help-fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 8000;
    height: 48px; padding: 0 18px 0 14px; border-radius: 26px; border: none; cursor: pointer;
    background: linear-gradient(135deg, #3a44b0, #5b64d6); color: #fff;
    box-shadow: 0 8px 24px rgba(58, 68, 176, .45);
    display: inline-flex; align-items: center; gap: 9px;
    font-family: inherit; font-size: 14.5px; font-weight: 600;
    transition: transform .15s, box-shadow .15s;
}
.help-fab svg { width: 22px; height: 22px; flex: none; }
.help-fab:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(58, 68, 176, .55); }
@media (max-width: 720px) {
    .help-fab { right: 14px; bottom: 14px; padding: 0; width: 46px; height: 46px; border-radius: 50%; justify-content: center; }
    .help-fab-label { display: none; }
}

.head-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* ============ Notifications ============ */
.notif-bell { position: relative; color: #cfd2e6; display: inline-flex; transition: color .15s; }
.notif-bell:hover { color: #fff; }
.notif-bell svg { width: 21px; height: 21px; }
.notif-badge {
    position: absolute; top: -6px; right: -7px; min-width: 17px; height: 17px;
    padding: 0 4px; border-radius: 9px; background: #e5484d; color: #fff;
    font-size: 11px; font-weight: 700; line-height: 17px; text-align: center;
}
.notif-list { display: flex; flex-direction: column; gap: 8px; }
.notif-item {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    background: #fff; border-radius: 10px; padding: 13px 16px; text-decoration: none;
    color: #1a1a2e; box-shadow: 0 1px 4px rgba(26,26,46,.06); transition: box-shadow .15s;
}
.notif-item:hover { box-shadow: 0 4px 14px rgba(26,26,46,.12); }
.notif-unread { border-left: 3px solid #4a54c9; background: #f5f6ff; }
.notif-text { font-size: 14px; }
.notif-time { font-size: 12px; color: #9095a8; white-space: nowrap; }

/* ============ Theme toggle ============ */
.theme-toggle {
    background: rgba(255,255,255,.1); color: #cfd2e6; border: none; cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s;
}
.theme-toggle:hover { background: rgba(255,255,255,.2); color: #fff; }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .ic-sun { display: none; }
html[data-theme="dark"] .theme-toggle .ic-moon { display: none; }
html[data-theme="dark"] .theme-toggle .ic-sun { display: inline; }

/* ============ Dark theme ============ */
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] body { background: #14162e; color: #e7e9f7; }
html[data-theme="dark"] .login-body { background: radial-gradient(1200px 600px at 50% -10%, #2b3080 0%, #0f1022 55%, #0b0c1c 100%); }

html[data-theme="dark"] .card,
html[data-theme="dark"] .docs-table,
html[data-theme="dark"] .chart-card,
html[data-theme="dark"] .req-card,
html[data-theme="dark"] .login-card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .nav-menu,
html[data-theme="dark"] .notif-item,
html[data-theme="dark"] .tour-pop { background: #1e2140; color: #e7e9f7; }
/* Tour popover text must stay readable on the dark popover background */
html[data-theme="dark"] .tour-title { color: #e7e9f7; }
html[data-theme="dark"] .tour-text { color: #c9cce6; }
html[data-theme="dark"] .tour-count { color: #a6abc9; }
html[data-theme="dark"] .tour-skip { color: #c9cce6; }
html[data-theme="dark"] .tour-prev { background: #2c3157; color: #e7e9f7; }
html[data-theme="dark"] .tour-prev:hover { background: #363c6b; }

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] .card-value,
html[data-theme="dark"] .req-value,
html[data-theme="dark"] .doc-name { color: #e7e9f7; }

html[data-theme="dark"] .review-hint,
html[data-theme="dark"] .muted,
html[data-theme="dark"] .card-label,
html[data-theme="dark"] .notif-time,
html[data-theme="dark"] .docs-empty,
html[data-theme="dark"] .req-label,
html[data-theme="dark"] .chart-card h3,
html[data-theme="dark"] .chart-legend,
html[data-theme="dark"] .donut-legend { color: #a6abc9; }

html[data-theme="dark"] .docs-table th { background: #262a4d; color: #b9bde0; }
html[data-theme="dark"] .docs-table th,
html[data-theme="dark"] .docs-table td { border-color: #33375f; }
html[data-theme="dark"] .row-link:hover,
html[data-theme="dark"] .docs-table tbody tr:hover { background: #262a4d; }

html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .card-row input,
html[data-theme="dark"] .card-row select,
html[data-theme="dark"] .card-row textarea,
html[data-theme="dark"] .decide-form input,
html[data-theme="dark"] .filters input,
html[data-theme="dark"] .filters select { background: #14162e; color: #e7e9f7; border-color: #3a3f68; }

html[data-theme="dark"] .dropzone { background: #191c38; border-color: #3a3f68; }
html[data-theme="dark"] .req-scroll,
html[data-theme="dark"] .review-preview pre { background: #12142c; }
html[data-theme="dark"] .modal-foot,
html[data-theme="dark"] .req-card-foot { background: #191c38; border-color: #33375f; }
html[data-theme="dark"] .req-field { border-color: #2a2e52; }
html[data-theme="dark"] .tabs { border-color: #2a2e52; }
/* Вкладки на тёмном: светлая подсветка ховера выглядела белым пятном, а синий
   #4a54c9 у активной вкладки почти сливался с фоном (контраст 2.9). */
html[data-theme="dark"] .tab { color: #a6abc9; }
html[data-theme="dark"] .tab:hover { color: #c3c9ff; background: #23264a; }
html[data-theme="dark"] .tab.active { color: #9aa2ee; border-bottom-color: #6f7ae0; }
html[data-theme="dark"] .bar-track,
html[data-theme="dark"] .tab-count,
html[data-theme="dark"] .status-badge,
html[data-theme="dark"] .btn-copy { background: #2a2e52; color: #b9bde0; }
html[data-theme="dark"] .tab.active .tab-count { background: #4a54c9; color: #fff; }
html[data-theme="dark"] .notif-unread { background: #24284a; }
html[data-theme="dark"] .att-thumb { background: #14162e; border-color: #3a3f68; }
html[data-theme="dark"] .btn-cancel,
html[data-theme="dark"] .filters-reset { color: #a6abc9; }

/* Coloured message boxes — keep meaning, darker surfaces */
html[data-theme="dark"] .msg-ok  { background: #12321f; color: #8fe0aa; border-color: #1f5a37; }
html[data-theme="dark"] .msg-warn{ background: #332a12; color: #e8cf8a; border-color: #5a4a1f; }
html[data-theme="dark"] .msg-info{ background: #16204a; color: #a9c1f5; border-color: #2f4488; }
html[data-theme="dark"] .msg-info a { color: #a9c1f5; }
html[data-theme="dark"] .msg-error,
html[data-theme="dark"] .login-error { background: #331617; color: #f0a0a2; border-color: #5a2224; }
html[data-theme="dark"] .row-overdue td { background: #331a1b; }
html[data-theme="dark"] .row-warn td { background: #332c17; }

/* Chart text (inline fills) must stay readable on dark cards */
html[data-theme="dark"] .chart-svg text { fill: #cfd3ee; }
html[data-theme="dark"] .chart-svg line { stroke: #33375f; }

/* Content links a touch lighter on dark surfaces */
html[data-theme="dark"] .doc-actions a,
html[data-theme="dark"] .att-list a,
html[data-theme="dark"] .crumb a,
html[data-theme="dark"] .req-value a { color: #9aa2ee; }

/* Dropdown items must stay readable on the dark menu surface. */
html[data-theme="dark"] .nav-menu a { color: #cfd3ee; }
html[data-theme="dark"] .nav-menu a:hover { background: #2a2e52; color: #fff; }

/* Small row-action buttons/inputs: readable on dark, softer look. */
html[data-theme="dark"] .row-action button {
    background: #262a4d; border-color: #3a3f68; color: #cfd3ee;
}
html[data-theme="dark"] .row-action button:hover { background: #303663; border-color: #4a4f80; color: #fff; }
html[data-theme="dark"] .row-action input { background: #14162e; color: #e7e9f7; border-color: #3a3f68; }
html[data-theme="dark"] .row-action .btn-danger,
html[data-theme="dark"] .btn-danger { color: #f0a0a2; border-color: #5a2224; background: #2a1a1d; }
html[data-theme="dark"] .row-action .btn-danger:hover,
html[data-theme="dark"] .btn-danger:hover { background: #3a2023; }
html[data-theme="dark"] .row-action .act-ok { color: #8fe0aa; border-color: #1f5a37; }
html[data-theme="dark"] .row-action .act-no { color: #f0a0a2; border-color: #5a2224; }

/* ============ Обучение (курсы) ============ */
.learn-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 16px; }
.learn-card { display: flex; gap: 14px; background: #fff; border: 1px solid #e6e8f0; border-radius: 12px; padding: 18px; text-decoration: none; color: inherit; transition: box-shadow .18s, transform .18s; }
.learn-card:hover { box-shadow: 0 8px 24px rgba(26,26,46,.12); transform: translateY(-1px); }
.learn-ico { font-size: 30px; line-height: 1; }
.learn-card-body h3 { margin: 0 0 4px; font-size: 16px; }
.learn-aud { font-size: 12px; color: #6b6f85; margin-bottom: 6px; }
.learn-card-body p { margin: 0 0 8px; font-size: 13px; color: #444a6b; line-height: 1.5; }
.learn-meta { font-size: 13px; color: #4a54c9; font-weight: 600; }
.learn-head { margin-bottom: 8px; }
.learn-back { color: #4a54c9; text-decoration: none; font-size: 14px; }
.learn-back:hover { text-decoration: underline; }
.learn-steps { display: flex; flex-direction: column; gap: 18px; margin-top: 16px; }
.learn-step { display: flex; gap: 16px; background: #fff; border: 1px solid #e6e8f0; border-radius: 12px; padding: 18px 20px; }
.learn-step-num { flex: 0 0 34px; height: 34px; width: 34px; border-radius: 50%; background: #4a54c9; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; }
.learn-step-content { flex: 1; min-width: 0; }
.learn-step-content h3 { margin: 4px 0 10px; font-size: 17px; }
.learn-step-content p { margin: 10px 0 0; line-height: 1.55; color: #333; }
.learn-shot { max-width: 100%; border-radius: 8px; border: 1px solid #e0e2ee; display: block; }
.learn-shot-placeholder { border: 2px dashed #cdd1e6; border-radius: 8px; padding: 34px; text-align: center; color: #9aa0bd; font-size: 14px; background: #f6f7fb; }
.learn-foot { margin-top: 18px; }
@media (max-width: 620px) { .learn-step { flex-direction: column; gap: 10px; } }
.learn-lead { margin: 12px 0 0; line-height: 1.55; color: #333; font-weight: 500; }
.learn-actions { margin: 10px 0 0; padding-left: 22px; }
.learn-actions li { margin: 5px 0; line-height: 1.5; color: #333; }
.learn-note { margin: 12px 0 0; padding: 10px 12px; background: #f2f4fb; border-left: 3px solid #4a54c9; border-radius: 6px; font-size: 13.5px; line-height: 1.5; color: #444a6b; }
.learn-links { margin: 10px 0 0; font-size: 13.5px; color: #6b6f85; }
.learn-links a { color: #4a54c9; text-decoration: none; font-weight: 600; }
.learn-links a:hover { text-decoration: underline; }
.learn-admin { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 12px 0 2px; }
.learn-upload { display: flex; gap: 8px; align-items: center; margin: 0; flex-wrap: wrap; }
.learn-file { position: relative; overflow: hidden; display: inline-flex; }
.learn-file input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.learn-file span { display: inline-block; padding: 7px 12px; border: 1px dashed #b9bdd6; border-radius: 8px; font-size: 13px; color: #4a54c9; background: #f6f7fb; }
.learn-upload button { padding: 7px 13px; border-radius: 8px; border: none; background: #4a54c9; color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; }
.learn-del { margin: 0; }
html[data-theme="dark"] .learn-card, html[data-theme="dark"] .learn-step { background: #1e2140; border-color: #33375f; }
html[data-theme="dark"] .learn-card-body p, html[data-theme="dark"] .learn-step-content p,
html[data-theme="dark"] .learn-lead, html[data-theme="dark"] .learn-actions li { color: #c9cce6; }
/* Подписи карточек курса на тёмной подложке: синий #4a54c9 давал контраст 2.5,
   серый #6b6f85 — 3.1; строка «открыть →» практически не читалась. */
html[data-theme="dark"] .learn-meta, html[data-theme="dark"] .learn-links a,
html[data-theme="dark"] .learn-back { color: #9aa2ee; }
html[data-theme="dark"] .learn-aud, html[data-theme="dark"] .learn-links { color: #a6abc9; }
html[data-theme="dark"] .learn-shot-placeholder { background: #14162e; border-color: #3a3f68; color: #7b80a6; }
html[data-theme="dark"] .learn-note { background: #191c38; color: #b9bee0; }
html[data-theme="dark"] .learn-file span { background: #14162e; border-color: #3a3f68; color: #a9b3ef; }

/* ============ Фонды ============ */
.table-scroll { overflow-x: auto; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: #444a6b; white-space: nowrap; }
.fund-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.fund-edit { margin: 0; }
.fund-del { margin: 0; }
html[data-theme="dark"] .chk { color: #c9cce6; }

/* ============ Видеоурок в «Обучении» ============ */
.learn-video {
    background: #fff;
    border: 1px solid #e8eaf2;
    border-radius: 14px;
    padding: 18px 22px 22px;
    margin: 0 0 22px;
}
.learn-video h3 { margin: 0 0 4px; }
.learn-video .review-hint { margin: 0 0 14px; }
.learn-video video {
    width: 100%;
    max-height: 70vh;
    border-radius: 10px;
    background: #14162e;
    display: block;
}
html[data-theme="dark"] .learn-video { background: #1e2140; border-color: #33375f; }
