/* ============================================================ */
/*  DokiTheme — стили страниц (pages)                           */
/*  Все page-specific стили в одном файле.                      */
/*  Подключается после style.css и style-additional.css.        */
/*  Версия: 1.0                                                 */
/* ============================================================ */


/* ============================================================ */
/*  AUTH — Login и Register                                     */
/* ============================================================ */

.auth-wrap {
    min-height: calc(100vh - 80px);
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: var(--bg-primary);
    position: relative;
    overflow: hidden;
}
.auth-wrap::before {
    content: '';
    position: absolute;
    top: -30%; left: -20%;
    width: 800px; height: 800px;
    background: radial-gradient(circle, rgba(124,58,237,0.15), transparent 60%);
    pointer-events: none;
}

/* === ЛЕВАЯ ПАНЕЛЬ (брендинг) === */
.auth-side {
    position: relative;
    padding: 60px 56px;
    background: linear-gradient(160deg, #1a1f3a 0%, #0f172a 60%, #0a0f1f 100%);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    z-index: 1;
}
.auth-side::before {
    content: '';
    position: absolute;
    top: -100px; right: -100px;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(124,58,237,0.35), transparent 65%);
    pointer-events: none;
}
.auth-side::after {
    content: '';
    position: absolute;
    bottom: -150px; left: -80px;
    width: 400px; height: 400px;
    background: radial-gradient(circle, rgba(168,85,247,0.15), transparent 65%);
    pointer-events: none;
}
.auth-side > * { position: relative; z-index: 1; }

.auth-brand {
    display: flex; align-items: center; gap: 12px;
    text-decoration: none;
    margin-bottom: 60px;
    width: fit-content;
}
.auth-brand img { height: 32px; }
.auth-brand-text {
    font-family: 'Comfortaa', system-ui, sans-serif;
    font-weight: 100;
    font-size: 28px;
    letter-spacing: 3px;
    color: #ffffff;
    line-height: 1;
}

.auth-side h1 {
    font-size: 42px;
    line-height: 1.12;
    font-weight: 800;
    letter-spacing: -1px;
    margin: 0 0 20px;
    color: var(--text-primary);
}
.auth-side .auth-hl {
    background: linear-gradient(135deg, #a78bfa 0%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.auth-side-lead {
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-tertiary);
    max-width: 460px;
    margin: 0 0 40px;
}

.auth-side-points {
    list-style: none; padding: 0; margin: 0;
    display: flex; flex-direction: column; gap: 18px;
}
.auth-side-points li {
    display: flex; gap: 14px; align-items: flex-start;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text-secondary);
}
.auth-check {
    flex-shrink: 0;
    width: 26px; height: 26px;
    border-radius: 50%;
    background: rgba(16,185,129,0.15);
    border: 1px solid rgba(16,185,129,0.3);
    display: flex; align-items: center; justify-content: center;
    margin-top: 1px;
}
.auth-check svg { stroke: #34d399; }

.auth-side-footer {
    font-size: 13px;
    color: var(--text-muted);
    padding-top: 40px;
}

/* === ПРАВАЯ ПАНЕЛЬ (форма) === */
.auth-main {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 40px;
    position: relative;
    z-index: 1;
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px 36px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.35);
    position: relative;
}
.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, #7C3AED, #a855f7, #7C3AED);
    border-radius: 20px 20px 0 0;
}

.auth-card h2 {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 6px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}
.auth-card .auth-sub {
    font-size: 14px;
    color: var(--text-tertiary);
    margin: 0 0 28px;
}

/* === АЛЕРТЫ === */
.auth-alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.55;
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}
.auth-alert svg { flex-shrink: 0; margin-top: 2px; }
.auth-alert-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    color: #fca5a5;
}
.auth-alert-error svg { stroke: #fca5a5; }
.auth-alert-success {
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.3);
    color: #6ee7b7;
}
.auth-alert-success svg { stroke: #6ee7b7; }

.auth-alert button.auth-link-muted {
    display: inline-block;
    margin-top: 8px;
    color: #c4b5fd;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    text-decoration: underline;
}
.auth-alert button.auth-link-muted:hover { color: #a78bfa; }
.auth-alert button.auth-link-muted:disabled { opacity: 0.6; cursor: wait; text-decoration: none; }

/* === ПОЛЯ === */
.auth-field {
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 16px;
}
.auth-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}
.auth-input-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    transition: all 0.2s;
    overflow: hidden;
}
.auth-input-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(124,58,237,0.18);
}
.auth-input-icon {
    flex-shrink: 0;
    width: 46px; height: 46px;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
}
.auth-input-icon svg { stroke: currentColor; }
.auth-input-wrap:focus-within .auth-input-icon { color: var(--accent); }

.auth-input-wrap input {
    flex: 1;
    min-width: 0;
    padding: 13px 0;
    font-size: 15px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: inherit;
}
.auth-input-wrap input::placeholder { color: var(--text-muted); }

.auth-toggle-pass {
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 14px;
    height: 46px;
    display: flex; align-items: center;
    transition: color 0.2s;
}
.auth-toggle-pass:hover { color: var(--accent); }

/* === ROW (запомнить / условия) === */
.auth-row {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 12px;
    margin: 8px 0 24px;
    font-size: 13px;
}
.auth-row.auth-row--login {
    justify-content: space-between;
    align-items: center;
    margin: 4px 0 24px;
}
.auth-checkbox {
    display: flex; align-items: flex-start; gap: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
    line-height: 1.5;
}
.auth-checkbox input[type="checkbox"] {
    width: 16px; height: 16px;
    margin-top: 2px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.auth-checkbox a {
    color: var(--accent);
    text-decoration: none;
}
.auth-checkbox a:hover { text-decoration: underline; }

.auth-link-muted {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.auth-link-muted:hover { color: #c084fc; text-decoration: underline; }

/* === КНОПКА ОТПРАВКИ === */
.auth-submit {
    width: 100%;
    padding: 15px 24px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    color: white;
    background: linear-gradient(135deg, #7C3AED 0%, #a855f7 100%);
    box-shadow: 0 8px 24px rgba(124,58,237,0.35);
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
    display: inline-flex; align-items: center; justify-content: center;
    gap: 10px;
    font-family: inherit;
}
.auth-submit:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(124,58,237,0.5);
}
.auth-submit:active:not(:disabled) { transform: translateY(0); }
.auth-submit:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

/* === РАЗДЕЛИТЕЛЬ === */
.auth-divider {
    display: flex; align-items: center;
    gap: 14px;
    margin: 26px 0 20px;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.auth-divider::before, .auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* === НИЖНИЕ ССЫЛКИ === */
.auth-alt {
    text-align: center;
    font-size: 14px;
    color: var(--text-tertiary);
}
.auth-alt a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}
.auth-alt a:hover { color: #c084fc; text-decoration: underline; }

.auth-back-home {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 24px;
    font-size: 13px;
    color: var(--text-muted);
    text-decoration: none;
    justify-content: center;
    width: 100%;
}
.auth-back-home:hover { color: var(--accent); }

/* === СИЛА ПАРОЛЯ (Register) === */
.auth-strength {
    height: 4px;
    border-radius: 2px;
    background: var(--bg-tertiary);
    margin-top: 6px;
    overflow: hidden;
    position: relative;
}
.auth-strength-bar {
    height: 100%;
    width: 0;
    border-radius: 2px;
    transition: all 0.3s ease;
    background: #ef4444;
}
.auth-strength-bar.weak   { width: 33%;  background: #ef4444; }
.auth-strength-bar.mid    { width: 66%;  background: #f59e0b; }
.auth-strength-bar.strong { width: 100%; background: #10b981; }
.auth-strength-text {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    text-align: right;
}

/* === МОБИЛЬНАЯ АДАПТАЦИЯ === */
@media (max-width: 900px) {
    .auth-wrap {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    .auth-side {
        padding: 40px 32px;
        text-align: center;
    }
    .auth-side::before, .auth-side::after { display: none; }
    .auth-brand { margin: 0 auto 32px; justify-content: center; }
    .auth-side h1 { font-size: 28px; }
    .auth-side-lead { font-size: 15px; margin: 0 auto 24px; }
    .auth-side-points { display: none; }
    .auth-side-footer { display: none; }
    .auth-main { padding: 40px 20px 60px; }
}
@media (max-width: 500px) {
    .auth-card { padding: 32px 22px; border-radius: 16px; }
    .auth-card h2 { font-size: 22px; }
    .auth-side { padding: 32px 22px; }
}


/* ============================================================ */
/*  IMPORT — Импорт реестра                                     */
/* ============================================================ */

.import-report {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 16px;
    border-radius: var(--radius);
    overflow: auto;
    max-height: 400px;
    font-size: 13px;
    font-family: ui-monospace, 'SF Mono', Consolas, monospace;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    margin-bottom: 20px;
    border: 1px solid var(--border);
}

.import-block {
    background: var(--bg-secondary);
    padding: 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-top: 20px;
}
.import-block-title {
    color: var(--text-primary);
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 600;
}
.import-block-desc {
    color: var(--text-tertiary);
    line-height: 1.6;
    font-size: 14px;
    margin: 0 0 20px;
}
.import-form { margin: 0; }
.import-form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.import-file {
    flex: 1;
    min-width: 250px;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    transition: border-color 0.15s;
}
.import-file:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}
.import-file::file-selector-button {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 13px;
    cursor: pointer;
    margin-right: 12px;
    transition: var(--transition);
}
.import-file::file-selector-button:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}
.import-submit-btn {
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    color: white;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.import-submit-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
}

@media (max-width: 900px) {
    .import-form-row {
        flex-direction: column;
        align-items: stretch;
    }
    .import-file {
        min-width: 0;
        width: 100%;
        font-size: 16px;
    }
    .import-submit-btn {
        width: 100%;
        min-height: 44px;
    }
}


/* ============================================================ */
/*  DASHBOARD                                                   */
/* ============================================================ */

.dash-hello { margin-bottom: 20px; }
.dash-hello h1 { margin: 0 0 4px 0; font-size: 24px; line-height: 1.2; }
.dash-hello-date { color: var(--text-tertiary); font-size: 13px; margin: 0; }

.dash-finance { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.dash-fin-card {
    padding: 16px 18px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: var(--radius);
    position: relative; overflow: hidden;
    text-decoration: none; color: inherit;
    display: block;
}
.dash-fin-card::before {
    content: ''; position: absolute; top: 0; left: 0;
    width: 3px; height: 100%;
}
.dash-fin-income::before  { background: var(--success); }
.dash-fin-expense::before { background: var(--danger); }
.dash-fin-saldo::before   { background: var(--accent); }
.dash-fin-debt::before    { background: var(--warning); }

.dash-fin-clickable {
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.dash-fin-clickable:hover {
    border-color: var(--warning);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245,158,11,0.15);
}
.dash-fin-clickable .dash-fin-arrow {
    display: inline-block;
    margin-left: 4px;
    color: var(--warning);
    transition: transform 0.15s;
}
.dash-fin-clickable:hover .dash-fin-arrow {
    transform: translateX(3px);
}

.dash-fin-label {
    font-size: 11px; color: var(--text-tertiary);
    text-transform: uppercase; letter-spacing: 0.5px;
    font-weight: 600; margin-bottom: 6px;
}
.dash-fin-value {
    font-size: 22px; font-weight: 700; color: var(--text-primary);
    line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.dash-fin-cur { font-size: 14px; color: var(--text-tertiary); font-weight: 500; }
.dash-fin-income .dash-fin-value  { color: var(--success); }
.dash-fin-expense .dash-fin-value { color: var(--danger); }
.dash-fin-saldo.is-positive .dash-fin-value { color: var(--success); }
.dash-fin-saldo.is-negative .dash-fin-value { color: var(--danger); }
.dash-fin-debt .dash-fin-value    { color: var(--warning); }
.dash-fin-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.dash-quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 20px; }
.dash-qa {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 14px; background: var(--bg-secondary);
    border: 1px solid var(--border); border-radius: var(--radius);
    text-decoration: none; color: var(--text-primary);
    transition: all 0.2s ease; min-width: 0;
}
.dash-qa:hover { border-color: var(--accent); background: rgba(124,58,237,0.05); transform: translateY(-1px); }
.dash-qa-icon {
    width: 36px; height: 36px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.dash-qa-icon-violet { background: rgba(124,58,237,0.15); color: #a78bfa; }
.dash-qa-icon-blue   { background: rgba(59,130,246,0.15); color: #60a5fa; }
.dash-qa-icon-green  { background: rgba(16,185,129,0.15); color: #34d399; }
.dash-qa-icon-orange { background: rgba(245,158,11,0.15); color: #fbbf24; }
.dash-qa-text {
    font-size: 13px; font-weight: 600; color: var(--text-secondary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.dash-stats-strip {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 0;
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); margin-bottom: 20px; overflow: hidden;
}
.dash-stat {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; padding: 14px 8px; text-decoration: none; color: var(--text-primary);
    border-right: 1px solid var(--border); transition: background 0.15s; min-width: 0;
}
.dash-stat:last-child { border-right: none; }
.dash-stat:hover { background: var(--bg-tertiary); }
.dash-stat-num { font-size: 22px; font-weight: 700; color: var(--text-primary); line-height: 1; font-variant-numeric: tabular-nums; }
.dash-stat-label { font-size: 11px; color: var(--text-tertiary); text-transform: lowercase; white-space: nowrap; }

.dash-panel {
    background: var(--bg-secondary); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 20px; margin-top: 16px;
}
.dash-panel-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 14px; padding-bottom: 12px;
    border-bottom: 1px solid var(--border); gap: 12px; flex-wrap: wrap;
}
.dash-panel-header h2 { margin: 0; font-size: 15px; font-weight: 600; color: var(--text-primary); }
.dash-panel-link { font-size: 13px; color: var(--accent); font-weight: 500; text-decoration: none; white-space: nowrap; }
.dash-panel-link:hover { color: var(--primary-light); }
.dash-chart-wrap { position: relative; height: 240px; }

.dash-tabs { display: inline-flex; background: var(--bg-primary); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.dash-tab {
    padding: 6px 14px; font-size: 12px; font-weight: 600;
    color: var(--text-tertiary); background: transparent; border: none;
    border-radius: 6px; cursor: pointer; transition: all 0.15s;
    font-family: inherit; white-space: nowrap;
}
.dash-tab:hover:not(.active) { color: var(--text-secondary); }
.dash-tab.active { background: var(--accent); color: white; }

.dash-list { list-style: none; padding: 0; margin: 0; }
.dash-list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0; border-bottom: 1px solid var(--border);
}
.dash-list-item:last-child { border-bottom: none; }
.dash-list-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dash-list-dot.status-new { background: #ef4444; }
.dash-list-dot.status-in_progress { background: #f59e0b; }
.dash-list-dot.status-completed { background: #10b981; }
.dash-list-dot.payment-paid { background: #10b981; }
.dash-list-dot.payment-partial { background: #f59e0b; }
.dash-list-dot.payment-unpaid { background: #ef4444; }

.dash-list-content { flex: 1; min-width: 0; }
.dash-list-title {
    font-size: 14px; font-weight: 500; color: var(--text-primary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dash-list-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.dash-list-action {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 8px;
    background: var(--bg-tertiary); color: var(--text-tertiary);
    text-decoration: none; flex-shrink: 0; transition: all 0.15s;
}
.dash-list-action:hover { background: var(--accent); color: white; }
.dash-list-empty {
    padding: 20px; text-align: center; color: var(--text-tertiary);
    font-size: 13px; font-style: italic;
}

@media (max-width: 900px) {
    .dash-hello h1 { font-size: 20px; }
    .dash-finance { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .dash-fin-card { padding: 12px 14px; }
    .dash-fin-value { font-size: 18px; }
    .dash-quick-actions { grid-template-columns: repeat(2, 1fr); gap: 8px; }
    .dash-qa { padding: 10px 12px; gap: 8px; }
    .dash-qa-icon { width: 32px; height: 32px; border-radius: 8px; }
    .dash-qa-icon svg { width: 18px; height: 18px; }
    .dash-qa-text { font-size: 12px; }
    .dash-stats-strip { grid-template-columns: repeat(2, 1fr); }
    .dash-stat { border-right: none; }
    .dash-stat:nth-child(odd) { border-right: 1px solid var(--border); }
    .dash-stat:nth-child(1),
    .dash-stat:nth-child(2) { border-bottom: 1px solid var(--border); }
    .dash-panel { padding: 14px 16px; }
    .dash-chart-wrap { height: 200px; }
    .dash-panel-header h2 { font-size: 14px; }
}

@media (max-width: 480px) {
    .dash-fin-value { font-size: 16px; }
    .dash-fin-cur { font-size: 12px; }
    .dash-stat-num { font-size: 18px; }
    .dash-stat-label { font-size: 10px; }
    .dash-tabs { width: 100%; }
    .dash-tab { flex: 1; text-align: center; }
}


/* ============================================================ */
/*  DEBTS — Задолженность                                       */
/* ============================================================ */

.debts-subtitle {
    color: var(--text-tertiary);
    font-size: 14px;
    line-height: 1.5;
    margin: 0 0 20px;
}

.debts-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 22px;
}
.debts-summary-card {
    padding: 16px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    position: relative;
    overflow: hidden;
    min-width: 0;
}
.debts-summary-main {
    border-left: 3px solid var(--danger);
}
.debts-summary-main::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(239,68,68,0.04) 100%);
    pointer-events: none;
}
.debts-summary-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.debts-summary-value {
    font-size: clamp(16px, 2vw, 24px);
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.debts-summary-main .debts-summary-value {
    color: var(--danger);
}
.debts-summary-cur {
    font-size: 0.7em;
    color: var(--text-tertiary);
    font-weight: 500;
    margin-left: 2px;
}

.debts-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.debts-search-icon { color: var(--text-tertiary); flex-shrink: 0; }
#debts-search-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 16px;
    font-family: inherit;
    padding: 0;
    -webkit-text-size-adjust: 100%;
}
#debts-search-input::placeholder { color: var(--text-muted); }
.debts-search-clear {
    flex-shrink: 0;
    width: 24px; height: 24px;
    display: none;
    align-items: center; justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}
.debts-search-clear:hover { background: var(--danger); color: white; }

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

details.debts-group {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid rgba(239,68,68,0.6);
    border-radius: var(--radius);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}
details.debts-group[open] {
    border-color: rgba(239,68,68,0.4);
    box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}
details.debts-group > summary {
    list-style: none;
    cursor: pointer;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    user-select: none;
    transition: background 0.15s;
}
details.debts-group > summary::-webkit-details-marker { display: none; }
details.debts-group > summary:hover {
    background: rgba(124,58,237,0.04);
}
details.debts-group[open] > summary {
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border);
}

.debts-group-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.debts-group-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.3;
    word-break: break-word;
}
.debts-group-count {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.3;
}

.debts-group-right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}
.debts-group-total {
    font-size: 18px;
    font-weight: 700;
    color: var(--danger);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.debts-group-chevron {
    display: inline-flex;
    color: var(--text-tertiary);
    transition: transform 0.2s ease;
}
details.debts-group[open] .debts-group-chevron {
    transform: rotate(180deg);
    color: var(--accent);
}

.debts-group-docs {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}
.debts-doc {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.debts-doc:last-child { border-bottom: none; }
.debts-doc:hover { background: rgba(124,58,237,0.04); }

.debts-doc-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.debts-doc-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    line-height: 1.35;
}
.debts-doc-title:hover { color: var(--primary-light); text-decoration: underline; }
.debts-doc-date {
    color: var(--text-tertiary);
    font-weight: 500;
    font-size: 13px;
    margin-left: 4px;
}
.debts-doc-contract {
    font-size: 12px;
    color: var(--text-tertiary);
    text-decoration: none;
    line-height: 1.35;
    width: fit-content;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.debts-doc-contract svg { stroke: currentColor; flex-shrink: 0; }
.debts-doc-contract:hover { color: var(--text-secondary); text-decoration: underline; }

.debts-doc-right {
    text-align: right;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-end;
}
.debts-doc-amount {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.debts-doc-status {
    font-size: 10px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 100px;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.debts-doc-status.status-unpaid {
    background: rgba(239,68,68,0.15);
    color: #f87171;
}
.debts-doc-status.status-partial {
    background: rgba(245,158,11,0.15);
    color: #fbbf24;
}

.debts-no-results {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
    font-style: italic;
    margin: 0;
}

.debts-empty {
    text-align: center;
    padding: 60px 24px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-top: 20px;
}
.debts-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: rgba(16,185,129,0.12);
    color: #10b981;
    margin-bottom: 16px;
}
.debts-empty-icon svg { stroke: currentColor; fill: none; }
.debts-empty-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 6px;
}
.debts-empty-text {
    font-size: 14px;
    color: var(--text-tertiary);
    margin: 0 0 20px;
}
.debts-empty-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent);
    color: white;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.15s;
}
.debts-empty-link:hover { background: var(--primary); color: white; }
.debts-empty-link svg { stroke: currentColor; fill: none; flex-shrink: 0; }

@media (max-width: 900px) {
    .debts-subtitle { font-size: 13px; margin-bottom: 14px; }
    .debts-summary {
        gap: 8px;
        margin-bottom: 14px;
    }
    .debts-summary-card {
        padding: 12px 14px;
    }
    .debts-summary-label {
        font-size: 10px;
        margin-bottom: 6px;
        letter-spacing: 0.3px;
    }
    .debts-summary-value {
        font-size: clamp(14px, 4vw, 20px);
    }
    details.debts-group > summary {
        padding: 14px 16px;
        gap: 12px;
    }
    .debts-group-name { font-size: 14px; }
    .debts-group-count { font-size: 11px; }
    .debts-group-total { font-size: 16px; }
    .debts-group-right { gap: 10px; }
    .debts-doc {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 12px 16px;
    }
    .debts-doc-right {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        text-align: left;
    }
    .debts-doc-amount { font-size: 16px; }
}

@media (max-width: 420px) {
    .debts-summary {
        gap: 6px;
    }
    .debts-summary-card {
        padding: 10px 10px;
    }
    .debts-summary-label {
        font-size: 9px;
        letter-spacing: 0.2px;
    }
    .debts-summary-value {
        font-size: 15px;
    }
    .debts-summary-cur {
        display: none;
    }
    .debts-group-name { font-size: 13px; }
    .debts-group-total { font-size: 15px; }
}


/* ============================================================ */
/*  DOCUMENTS + CONTRACTS-MANAGER — общая база                  */
/* ============================================================ */

/* ===== PAGE ACTIONS ===== */
.page-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
/* Documents: кнопки слева — рядом с чекбоксами */
.page-actions:has(.button-download) {
    justify-content: flex-start;
}

.page-actions .button-primary,
.page-actions .button-secondary,
.page-actions .button-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    font-family: inherit;
    box-sizing: border-box;
    white-space: nowrap;
    text-decoration: none;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.page-actions .button-primary svg,
.page-actions .button-secondary svg,
.page-actions .button-download svg {
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
}
.page-actions .button-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.page-actions .button-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.page-actions .button-secondary {
    background: transparent;
    color: var(--text-secondary);
}
.page-actions .button-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Кнопка "Скачать ZIP" — невидима, пока ничего не выбрано */
.page-actions .button-download {
    background: transparent;
    border-color: var(--accent);
    color: var(--accent);
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease,
                visibility 0s linear 0.15s,
                background 0.15s,
                color 0.15s,
                border-color 0.15s;
}
.page-actions .button-download.is-visible {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transition: opacity 0.15s ease,
                visibility 0s linear 0s,
                background 0.15s,
                color 0.15s,
                border-color 0.15s;
}
.page-actions .button-download:hover:not(:disabled) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.page-actions .button-download:disabled { cursor: wait; }
.page-actions .button-download.loading { opacity: 0.6; pointer-events: none; }

.page-actions .button-download .count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 100px;
    background: var(--accent);
    color: white;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}
.page-actions .button-download:hover:not(:disabled) .count-badge {
    background: white;
    color: var(--accent);
}

/* ===== БАЗА ДЛЯ .doki-table ===== */
.doki-table {
    width: 100%;
    border-collapse: collapse;
}
.doki-table th,
.doki-table td {
    padding: 12px 10px;
    vertical-align: middle;
    box-sizing: border-box;
    line-height: 1.4;
}
.doki-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.doki-table td {
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 14px;
}

/* ===== СОРТИРОВКА ===== */
.sortable {
    cursor: pointer;
    user-select: none;
}
.sortable:hover { background: #4a5a6a; }
.sortable::after { content: ' ↕'; font-size: 12px; color: #94a3b8; }
.sortable.asc::after { content: ' ↑'; }
.sortable.desc::after { content: ' ↓'; }

/* ===== ФИЛЬТР ПО КОЛОНКЕ ===== */
.doki-table th.filterable { min-width: 180px; }
.doki-table th.filterable .filter-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    user-select: none;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}
.doki-table th.filterable .filter-label:hover {
    background: rgba(124, 58, 237, 0.15);
    color: var(--accent);
}
.doki-table th.filterable .filter-icon {
    opacity: 0.5;
    transition: var(--transition);
}
.doki-table th.filterable .filter-label:hover .filter-icon { opacity: 1; }
.doki-table th.filterable.has-filter .filter-icon {
    opacity: 1;
    color: var(--accent);
}
.column-filter-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-primary);
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 2px 4px;
    box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}
.column-filter-input {
    flex: 1;
    min-width: 120px;
    padding: 5px 8px;
    font-size: 13px;
    color: var(--text-primary);
    background: transparent;
    border: none;
    outline: none;
    text-transform: none;
    font-weight: 400;
}
.column-filter-input::placeholder { color: var(--text-muted); }
.column-filter-clear {
    width: 22px;
    height: 22px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.column-filter-clear:hover { background: var(--danger); color: white; }

/* ===== КНОПКИ ДЕЙСТВИЙ В СТРОКАХ ===== */
#documents-table .actions-cell,
#contracts-table .actions-cell {
    display: table-cell;
    text-align: center;
    white-space: nowrap;
    vertical-align: middle;
}
.actions-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: nowrap;
    vertical-align: middle;
}
.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
    text-decoration: none;
    padding: 0;
    line-height: 0;
}
.action-btn svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
    stroke: #cbd5e1;
    fill: none;
    pointer-events: none;
}
.action-btn:hover { transform: scale(1.1); }
.action-btn:hover svg { stroke: #ffffff; }
.action-btn.edit:hover { background: var(--info); }
.action-btn.delete:hover { background: var(--danger); }
.action-btn.docx:hover { background: #2b579a; }
.action-btn.docx:disabled {
    cursor: wait;
    opacity: 0.9;
    transform: none;
    background: #2b579a;
}

/* ===== ПОПАП ДОКУМЕНТОВ (общий) ===== */
.contract-popover {
    position: absolute;
    z-index: 10000;
    min-width: 260px;
    max-width: 340px;
    max-height: 70vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    padding: 5px;
    font-size: 12px;
    animation: contractPopIn 0.15s ease;
    box-sizing: border-box;
    overscroll-behavior: contain;
}
@keyframes contractPopIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.contract-popover::-webkit-scrollbar { width: 6px; }
.contract-popover::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.contract-popover::-webkit-scrollbar-thumb:hover { background: var(--accent); }

.contract-popover-header {
    padding: 4px 8px 6px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}
.contract-popover-header span {
    color: var(--accent);
    font-weight: 800;
    margin-left: 2px;
}
.contract-popover-section { padding: 2px 0; }
.contract-popover-section + .contract-popover-section {
    border-top: 1px dashed var(--border);
    margin-top: 3px;
    padding-top: 5px;
}
.contract-popover-section-title {
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 1px;
}
.contract-popover-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 5px 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    text-align: left;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-family: inherit;
    transition: background 0.12s ease;
    text-decoration: none;
    box-sizing: border-box;
    line-height: 1.3;
}
.contract-popover-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.doc-type-badge {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 5px;
}
.badge-contract { background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.35); color: #fbbf24; }
.badge-invoice  { background: rgba(124,58,237,0.15); border: 1px solid rgba(124,58,237,0.3); color: #c4b5fd; }
.badge-act      { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: #6ee7b7; }
.badge-file     { background: rgba(59,130,246,0.15); border: 1px solid rgba(59,130,246,0.3); color: #93c5fd; }
.doc-type-badge svg { stroke: currentColor; fill: none; }
.doc-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}
.doc-num {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.25;
}
.doc-date {
    font-size: 10px;
    color: var(--text-tertiary);
    line-height: 1.25;
}
.doc-download {
    flex-shrink: 0;
    color: var(--text-tertiary);
    display: inline-flex;
    align-items: center;
    transition: color 0.15s;
}
.contract-popover-item:hover .doc-download { color: var(--accent); }


/* ============================================================ */
/*  DOCUMENTS — страница «Счета и акты»                         */
/* ============================================================ */

/* Пагинация по месяцам */
.months-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 18px;
    margin: 0 0 22px;
    padding: 14px 0 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    line-height: 1.4;
}
.month-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 2px;
    color: var(--text-tertiary);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
    cursor: pointer;
    white-space: nowrap;
}
.month-link:hover { color: var(--accent); border-bottom-color: rgba(124,58,237,0.4); }
.month-link.month-link-empty { color: var(--text-muted); opacity: 0.7; }
.month-link.month-link-empty:hover { color: var(--text-secondary); border-bottom-color: rgba(148,163,184,0.3); }
.month-link.active {
    color: var(--accent);
    font-weight: 700;
    border-bottom-color: var(--accent);
    cursor: default;
}
.month-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 100px;
    background: var(--bg-tertiary);
    color: var(--text-tertiary);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.2px;
    line-height: 1;
}
.month-link.active .month-count {
    background: rgba(124,58,237,0.2);
    color: #c4b5fd;
}
.month-link:hover:not(.active) .month-count {
    background: rgba(124,58,237,0.15);
    color: #c4b5fd;
}

/* Чекбоксы в таблице */
.doc-select-th,
.doc-select-cell {
    width: 40px;
    text-align: center;
    padding-left: 14px;
    padding-right: 4px;
}
.doc-select-th input[type="checkbox"],
.doc-select-cell input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
    vertical-align: middle;
}
.invoice-row.is-selected {
    background: rgba(124, 58, 237, 0.08) !important;
}
.invoice-row.is-selected:hover {
    background: rgba(124, 58, 237, 0.12) !important;
}

/* Чип акта */
.doc-number-cell { white-space: nowrap; }
.doc-number-cell strong {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}
.act-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid rgba(124,58,237,0.3);
    border-radius: 5px;
    background: rgba(124,58,237,0.12);
    color: var(--accent);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    vertical-align: middle;
}
.act-chip svg {
    stroke: currentColor;
    fill: none;
    pointer-events: none;
}
.act-chip:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: scale(1.08);
}
.act-chip.act-chip-no-act {
    border-color: rgba(124,58,237,0.2);
    background: rgba(124,58,237,0.06);
    color: rgba(167,139,250,0.85);
}
.act-chip.act-chip-no-act:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Ячейка "Оплата" */
.payment-cell { text-align: center; }

/* Панель файлов под строкой счёта */
.invoice-files-row { display: none; }
.invoice-files-panel {
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-top: 1px dashed var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
}
.invoice-files-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.invoice-files-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.invoice-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
    box-sizing: border-box;
}
.invoice-file-item:hover {
    border-color: var(--accent);
    background: rgba(124,58,237,0.06);
}
.invoice-file-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
}
.icon-invoice { background: rgba(124,58,237,0.15); color: #c4b5fd; }
.icon-act     { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.invoice-file-icon svg { stroke: currentColor; fill: none; }
.invoice-file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.invoice-file-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.invoice-file-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.invoice-file-download {
    flex-shrink: 0;
    color: var(--text-tertiary);
    display: inline-flex;
    transition: color 0.15s;
}
.invoice-file-item:hover .invoice-file-download { color: var(--accent); }
.invoice-files-download-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 14px;
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
    box-sizing: border-box;
}
.invoice-files-download-all:hover { background: var(--primary); }
.invoice-files-download-all svg {
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
}

/* Мобильный поиск */
.documents-mobile-search { display: none; }
.documents-no-results {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
    font-style: italic;
    margin: 0;
}

/* Мобильные карточки документов */
@media (max-width: 900px) {
    .page-actions {
        gap: 6px;
        margin-bottom: 14px;
    }
    .page-actions .button-primary,
    .page-actions .button-secondary,
    .page-actions .button-download {
        height: 36px;
        padding: 0 12px;
        font-size: 12px;
        gap: 6px;
    }
    .page-actions .button-primary svg,
    .page-actions .button-secondary svg,
    .page-actions .button-download svg {
        width: 14px;
        height: 14px;
    }
    .page-actions .button-download .count-badge {
        min-width: 18px;
        height: 16px;
        font-size: 10px;
        padding: 0 5px;
    }

    .months-pagination {
        display: flex;
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        gap: 6px;
        padding: 4px 0 12px;
        margin-bottom: 16px;
        border-bottom: 1px solid var(--border);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
    }
    .months-pagination::-webkit-scrollbar { display: none; }
    .month-link {
        flex-shrink: 0;
        padding: 7px 12px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: 100px;
        font-size: 13px;
        font-weight: 500;
        color: var(--text-secondary);
        border-bottom: 1px solid var(--border);
        scroll-snap-align: start;
    }
    .month-link:hover { color: var(--accent); border-color: rgba(124,58,237,0.4); border-bottom-color: rgba(124,58,237,0.4); }
    .month-link.month-link-empty { opacity: 0.5; }
    .month-link.active {
        background: var(--accent);
        color: #ffffff;
        border-color: var(--accent);
        border-bottom-color: var(--accent);
        font-weight: 700;
        cursor: default;
    }
    .month-link.active:hover { color: #ffffff; }
    .month-count { min-width: 16px; height: 16px; padding: 0 4px; font-size: 9px; }
    .month-link.active .month-count { background: rgba(255,255,255,0.25); color: #ffffff; }
    .month-link:hover:not(.active) .month-count { background: rgba(124,58,237,0.15); color: #c4b5fd; }

    .documents-mobile-search {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 14px;
    }
    .documents-mobile-search-icon { color: var(--text-tertiary); flex-shrink: 0; }
    #documents-mobile-search-input {
        flex: 1;
        min-width: 0;
        background: transparent;
        border: none;
        outline: none;
        color: var(--text-primary);
        font-size: 16px;
        font-family: inherit;
        padding: 0;
        -webkit-text-size-adjust: 100%;
    }
    #documents-mobile-search-input::placeholder { color: var(--text-muted); }
    .documents-mobile-search-clear {
        flex-shrink: 0;
        width: 24px;
        height: 24px;
        display: none;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        border-radius: 50%;
        color: var(--text-tertiary);
        cursor: pointer;
        padding: 0;
        transition: background 0.15s, color 0.15s;
    }
    .documents-mobile-search-clear:hover { background: var(--danger); color: white; }

    #documents-table { display: block; width: 100%; background: transparent; border: none; }
    #documents-table thead { display: none; }
    #documents-table tbody { display: block; width: 100%; }

    #documents-table tr.invoice-row {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-template-areas:
            "select  number   payment"
            "date    date     date"
            "counterparty  counterparty  counterparty"
            "contract      contract      contract"
            "amount        amount        amount"
            "actions       actions       actions";
        gap: 3px 10px;
        padding: 14px 16px;
        margin-bottom: 10px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        min-height: 0;
        transition: border-color 0.15s, border-radius 0.15s, margin 0.15s;
    }
    #documents-table tr.invoice-row:hover { border-color: rgba(124,58,237,0.35); }
    #documents-table tr.invoice-row.is-selected {
        border-color: var(--accent);
        background: rgba(124,58,237,0.08) !important;
    }
    #documents-table tr.invoice-row.is-expanded {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-bottom-color: transparent;
        margin-bottom: 0;
    }
    #documents-table tr.invoice-row td {
        display: block;
        padding: 0;
        border: none;
        background: transparent;
        text-align: left;
        vertical-align: top;
        font-size: 14px;
        color: var(--text-secondary);
        min-width: 0;
    }
    #documents-table .doc-select-cell {
        grid-area: select;
        width: auto;
        padding: 0;
        display: flex;
        align-items: flex-start;
        padding-top: 2px;
    }
    #documents-table .doc-select-cell input[type="checkbox"] {
        width: 22px;
        height: 22px;
        margin: 0;
        touch-action: manipulation;
    }
    #documents-table .doc-number-cell { grid-area: number; }
    #documents-table .doc-date-cell { grid-area: date; }
    #documents-table .contract-amount-cell { grid-area: amount; }
    #documents-table .doc-counterparty-cell { grid-area: counterparty; }
    #documents-table .doc-contract-cell { grid-area: contract; }
    #documents-table .payment-cell { grid-area: payment; }
    #documents-table .actions-cell { grid-area: actions; }

    #documents-table .doc-number-cell {
        font-size: 15px;
        font-weight: 700;
        color: var(--text-primary);
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
    }
    #documents-table .doc-number-cell strong { font-size: 15px; }
    #documents-table .act-chip { display: none; }
    #documents-table .doc-date-cell {
        font-size: 12px;
        color: var(--text-tertiary);
        margin-bottom: 6px;
    }
    #documents-table .doc-counterparty-cell {
        font-size: 14px;
        font-weight: 500;
        color: var(--text-primary);
        margin-bottom: 2px;
    }
    #documents-table .doc-contract-cell {
        font-size: 12px;
        color: var(--text-tertiary);
        margin-bottom: 6px;
    }
    #documents-table .doc-contract-cell.doc-cell-empty { display: none; }
    #documents-table .contract-amount-cell {
        font-size: 20px;
        font-weight: 700;
        color: var(--text-primary);
        margin-top: 4px;
        margin-bottom: 2px;
        white-space: nowrap;
    }
    #documents-table .contract-amount-cell strong { font-size: 20px; }
    #documents-table .payment-cell {
        align-self: start;
        justify-self: end;
        padding-top: 2px;
    }
    #documents-table .payment-dot {
        width: 22px;
        height: 22px;
        position: relative;
        touch-action: manipulation;
    }
    #documents-table .payment-dot::before {
        content: '';
        position: absolute;
        top: -12px;
        left: -12px;
        right: -12px;
        bottom: -12px;
    }
    #documents-table .actions-cell {
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        margin-top: 8px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
    }
    #documents-table .actions-wrap {
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        width: 100%;
    }
    #documents-table .action-btn { width: 38px; height: 38px; border-radius: 10px; }
    #documents-table .action-btn svg { width: 18px; height: 18px; }

    .invoice-files-row { display: none; }
    .invoice-files-row.is-open { display: block; margin-bottom: 10px; }
    .invoice-files-row td { display: block; padding: 0; border: none; }
    .invoice-files-panel { margin-top: 0; }

    .documents-no-results { padding: 24px 16px; font-size: 13px; }
}

@media (max-width: 420px) {
    #documents-table tr.invoice-row { padding: 12px 14px; }
    #documents-table .contract-amount-cell,
    #documents-table .contract-amount-cell strong { font-size: 18px; }
    #documents-table .doc-number-cell,
    #documents-table .doc-number-cell strong { font-size: 14px; }
    #documents-table .action-btn { width: 36px; height: 36px; }
    .page-actions .button-primary,
    .page-actions .button-secondary,
    .page-actions .button-download { font-size: 11px; padding: 0 10px; }
    .invoice-file-item { padding: 10px; gap: 10px; }
    .invoice-file-icon { width: 28px; height: 28px; }
}


/* ============================================================ */
/*  CONTRACTS-MANAGER — страница «Договоры»                     */
/* ============================================================ */

/* Чип документов в номере договора */
.doc-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid rgba(124,58,237,0.3);
    border-radius: 5px;
    background: rgba(124,58,237,0.12);
    color: var(--accent);
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    vertical-align: middle;
}
.doc-chip svg {
    stroke: currentColor;
    fill: none;
    pointer-events: none;
}
.doc-chip:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: scale(1.08);
}

/* Ячейки колонок договоров */
.contract-number-cell,
.contract-amount-cell,
.contract-date-cell,
.contract-purpose-cell { white-space: nowrap; }
.contract-number-cell { font-weight: 600; }
.contract-amount-cell { font-weight: 600; }
.contract-number-cell strong {
    display: inline-block;
    vertical-align: middle;
    margin-right: 6px;
}

/* Статус договора */
.status-dot {
    display: inline-block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s;
    border: 2px solid transparent;
    vertical-align: middle;
    touch-action: manipulation;
}
.status-dot:hover {
    transform: scale(1.25);
    border-color: #f8fafc;
}
.status-new         { background: #ef4444 !important; }
.status-in_progress { background: #f59e0b !important; }
.status-completed   { background: #10b981 !important; }

/* Панель файлов договора */
.contract-files-row { display: none; }
.contract-files-panel {
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-top: 1px dashed var(--border);
    border-radius: 0 0 var(--radius) var(--radius);
}
.contract-files-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.contract-files-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}
.contract-file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: border-color 0.15s, background 0.15s;
    box-sizing: border-box;
}
.contract-file-item:hover {
    border-color: var(--accent);
    background: rgba(124,58,237,0.06);
}
.contract-file-icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    flex-shrink: 0;
}
.icon-contract { background: rgba(245,158,11,0.15); color: #fbbf24; }
.icon-invoice  { background: rgba(124,58,237,0.15); color: #c4b5fd; }
.icon-act      { background: rgba(16,185,129,0.15); color: #6ee7b7; }
.icon-extra    { background: rgba(59,130,246,0.15); color: #93c5fd; }
.contract-file-icon svg { stroke: currentColor; fill: none; }
.contract-file-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.contract-file-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contract-file-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contract-file-download {
    flex-shrink: 0;
    color: var(--text-tertiary);
    display: inline-flex;
    transition: color 0.15s;
}
.contract-file-item:hover .contract-file-download { color: var(--accent); }
.contract-files-download-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 14px;
    background: var(--accent);
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s;
    box-sizing: border-box;
}
.contract-files-download-all:hover { background: var(--primary); }
.contract-files-download-all svg {
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
}
.contract-files-download-all:disabled {
    opacity: 0.85;
    cursor: wait;
}

/* Мобильный поиск */
.contracts-mobile-search { display: none; }
.contracts-no-results {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
    font-style: italic;
    margin: 0;
}

/* Мобильные карточки договоров */
@media (max-width: 900px) {
    /* Кнопки в action bar растягиваются на всю ширину */
    .page-actions:not(:has(.button-download)) {
        justify-content: stretch;
        gap: 8px;
        margin-bottom: 16px;
    }
    .page-actions:not(:has(.button-download)) .button-primary,
    .page-actions:not(:has(.button-download)) .button-secondary {
        flex: 1;
        justify-content: center;
        text-align: center;
        padding: 10px 14px;
        font-size: 13px;
        white-space: nowrap;
    }

    .contracts-mobile-search {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 14px;
    }
    .contracts-mobile-search-icon { color: var(--text-tertiary); flex-shrink: 0; }
    #contracts-mobile-search-input {
        flex: 1;
        min-width: 0;
        background: transparent;
        border: none;
        outline: none;
        color: var(--text-primary);
        font-size: 16px;
        font-family: inherit;
        padding: 0;
        -webkit-text-size-adjust: 100%;
    }
    #contracts-mobile-search-input::placeholder { color: var(--text-muted); }
    .contracts-mobile-search-clear {
        flex-shrink: 0;
        width: 24px;
        height: 24px;
        display: none;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        border-radius: 50%;
        color: var(--text-tertiary);
        cursor: pointer;
        padding: 0;
        transition: background 0.15s, color 0.15s;
    }
    .contracts-mobile-search-clear:hover { background: var(--danger); color: white; }

    #contracts-table { display: block; width: 100%; background: transparent; border: none; }
    #contracts-table thead { display: none; }
    #contracts-table tbody { display: block; width: 100%; }

    #contracts-table tr.contract-row {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "number        status"
            "purpose       status"
            "counterparty  counterparty"
            "date          date"
            "amount        amount"
            "actions       actions";
        gap: 3px 12px;
        padding: 14px 16px;
        margin-bottom: 10px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        min-height: 0;
        transition: border-color 0.15s, border-radius 0.15s, margin 0.15s;
    }
    #contracts-table tr.contract-row:hover { border-color: rgba(124,58,237,0.35); }
    #contracts-table tr.contract-row.is-expanded {
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
        border-bottom-color: transparent;
        margin-bottom: 0;
    }
    #contracts-table tr.contract-row td {
        display: block;
        padding: 0;
        border: none;
        background: transparent;
        text-align: left;
        vertical-align: top;
        font-size: 14px;
        color: var(--text-secondary);
        min-width: 0;
    }
    #contracts-table .contract-number-cell { grid-area: number; }
    #contracts-table .contract-purpose-cell { grid-area: purpose; }
    #contracts-table .contract-amount-cell { grid-area: amount; }
    #contracts-table .contract-counterparty-cell { grid-area: counterparty; }
    #contracts-table .contract-date-cell { grid-area: date; }
    #contracts-table .contract-status-cell { grid-area: status; }
    #contracts-table .actions-cell { grid-area: actions; }

    #contracts-table .contract-number-cell {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
        white-space: nowrap;
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;
    }
    #contracts-table .contract-number-cell strong { font-size: 16px; }
    #contracts-table .doc-chip { display: none; }
    #contracts-table .contract-purpose-cell {
        font-size: 12px;
        color: var(--text-tertiary);
        margin-bottom: 6px;
    }
    #contracts-table .contract-purpose-cell[data-cell-empty="1"] { display: none; }
    #contracts-table .contract-counterparty-cell {
        font-size: 14px;
        font-weight: 500;
        color: var(--text-primary);
        margin-bottom: 2px;
    }
    #contracts-table .contract-date-cell {
        font-size: 12px;
        color: var(--text-tertiary);
        margin-bottom: 6px;
    }
    #contracts-table .contract-amount-cell {
        font-size: 20px;
        font-weight: 700;
        color: var(--text-primary);
        margin-top: 4px;
        margin-bottom: 2px;
        white-space: nowrap;
    }
    #contracts-table .contract-amount-cell strong { font-size: 20px; }
    #contracts-table .contract-status-cell {
        align-self: start;
        justify-self: end;
        padding-top: 2px;
    }
    #contracts-table .status-dot {
        width: 22px;
        height: 22px;
        position: relative;
        touch-action: manipulation;
    }
    #contracts-table .status-dot::before {
        content: '';
        position: absolute;
        top: -12px;
        left: -12px;
        right: -12px;
        bottom: -12px;
    }
    #contracts-table .actions-cell {
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        margin-top: 8px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
    }
    #contracts-table .actions-wrap {
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        width: 100%;
    }
    #contracts-table .action-btn { width: 38px; height: 38px; border-radius: 10px; }
    #contracts-table .action-btn svg { width: 18px; height: 18px; }

    .contract-files-row { display: none; }
    .contract-files-row.is-open { display: block; margin-bottom: 10px; }
    .contract-files-row td { display: block; padding: 0; border: none; }
    .contract-files-panel { margin-top: 0; }

    .contracts-no-results { padding: 24px 16px; font-size: 13px; }
}

@media (max-width: 420px) {
    #contracts-table tr.contract-row { padding: 12px 14px; }
    #contracts-table .contract-amount-cell,
    #contracts-table .contract-amount-cell strong { font-size: 18px; }
    #contracts-table .contract-number-cell,
    #contracts-table .contract-number-cell strong { font-size: 15px; }
    #contracts-table .action-btn { width: 36px; height: 36px; }
    .page-actions:not(:has(.button-download)) .button-primary,
    .page-actions:not(:has(.button-download)) .button-secondary {
        font-size: 12px;
        padding: 9px 12px;
    }
    .contract-file-item { padding: 10px; gap: 10px; }
    .contract-file-icon { width: 28px; height: 28px; }
}

/* ============================================================ */
/*  COUNTERPARTIES-MANAGER — страница «Контрагенты»             */
/* ============================================================ */

/* ---- Таблица контрагентов ---- */
#counterparties-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
    margin: var(--space-lg) 0;
}
#counterparties-table th,
#counterparties-table td {
    padding: 12px 14px;
    vertical-align: middle;
    box-sizing: border-box;
    line-height: 1.4;
    border-bottom: 1px solid var(--border);
}
#counterparties-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 13px;
    white-space: nowrap;
}
#counterparties-table td {
    color: var(--text-secondary);
    font-size: 14px;
}
#counterparties-table tbody tr:hover { background: var(--bg-tertiary); }

.cp-name-cell {
    font-weight: 600;
    white-space: nowrap;
    text-align: left;
    padding-right: 40px;
}
.cp-th-right { text-align: right; }
.cp-th-debt { text-align: right; padding-right: 40px; }

.cp-income-cell {
    white-space: nowrap;
    font-weight: 700;
    text-align: right;
    color: var(--success) !important;
}
.cp-debt-cell {
    white-space: nowrap;
    font-weight: 700;
    text-align: right;
    padding-right: 40px;
    color: var(--danger) !important;
}

.cp-actions-cell { text-align: center; white-space: nowrap; }
.cp-actions-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
}
.cp-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
    text-decoration: none;
    padding: 0;
    line-height: 0;
}
.cp-action-btn svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
    stroke: #cbd5e1;
    fill: none;
    pointer-events: none;
}
.cp-action-btn:hover { transform: scale(1.1); }
.cp-action-btn:hover svg { stroke: #ffffff; }
.cp-action-btn.edit:hover { background: var(--info); }
.cp-action-btn.delete:hover { background: var(--danger); }

.counterparties-mobile-search { display: none; }
.counterparties-no-results {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
    font-style: italic;
    margin: 0;
}

/* ---- Мобильные карточки контрагентов ---- */
@media (max-width: 900px) {
    .counterparties-mobile-search {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 14px;
    }
    .counterparties-mobile-search-icon {
        color: var(--text-tertiary);
        flex-shrink: 0;
    }
    #counterparties-mobile-search-input {
        flex: 1;
        min-width: 0;
        background: transparent;
        border: none;
        outline: none;
        color: var(--text-primary);
        font-size: 16px;
        font-family: inherit;
        padding: 0;
        -webkit-text-size-adjust: 100%;
    }
    #counterparties-mobile-search-input::placeholder { color: var(--text-muted); }
    .counterparties-mobile-search-clear {
        flex-shrink: 0;
        width: 24px;
        height: 24px;
        display: none;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        border-radius: 50%;
        color: var(--text-tertiary);
        cursor: pointer;
        padding: 0;
        transition: background 0.15s, color 0.15s;
    }
    .counterparties-mobile-search-clear:hover { background: var(--danger); color: white; }

    #counterparties-table {
        display: block;
        width: 100%;
        background: transparent;
        border: none;
        border-radius: 0;
        overflow: visible;
        margin: 0;
    }
    #counterparties-table thead { display: none; }
    #counterparties-table tbody { display: block; width: 100%; }

    #counterparties-table tr.counterparty-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "name    name"
            "income  debt"
            "actions actions";
        gap: 6px 12px;
        padding: 14px 16px;
        margin-bottom: 10px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        min-height: 0;
        transition: border-color 0.15s;
    }
    #counterparties-table tr.counterparty-row:hover {
        border-color: rgba(124,58,237,0.35);
        background: var(--bg-secondary);
    }
    #counterparties-table tr.counterparty-row td {
        display: block;
        padding: 0;
        border: none;
        background: transparent;
        text-align: left;
        vertical-align: top;
        font-size: 14px;
        color: var(--text-secondary);
        min-width: 0;
    }
    #counterparties-table .cp-name-cell {
        grid-area: name;
        text-align: left;
        padding-right: 0;
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
        white-space: normal;
        word-break: break-word;
        margin-bottom: 4px;
    }
    #counterparties-table .cp-income-cell {
        grid-area: income;
        text-align: left;
        padding-right: 0;
        font-size: 16px;
        font-weight: 700;
        white-space: nowrap;
        position: relative;
    }
    #counterparties-table .cp-debt-cell {
        grid-area: debt;
        text-align: left;
        padding-right: 0;
        font-size: 16px;
        font-weight: 700;
        white-space: nowrap;
        position: relative;
    }
    #counterparties-table .cp-income-cell::before {
        content: 'Доход';
        color: var(--text-tertiary);
        font-weight: 500;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        display: block;
        margin-bottom: 2px;
    }
    #counterparties-table .cp-debt-cell::before {
        content: 'Долг';
        color: var(--text-tertiary);
        font-weight: 500;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        display: block;
        margin-bottom: 2px;
    }
    #counterparties-table .cp-actions-cell {
        grid-area: actions;
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        margin-top: 8px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
        text-align: right;
    }
    #counterparties-table .cp-actions-wrap {
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        width: 100%;
    }
    #counterparties-table .cp-action-btn {
        width: 38px;
        height: 38px;
        border-radius: 10px;
        touch-action: manipulation;
    }
    #counterparties-table .cp-action-btn svg {
        width: 18px;
        height: 18px;
    }
    .counterparties-no-results { padding: 24px 16px; font-size: 13px; }
}

@media (max-width: 420px) {
    #counterparties-table tr.counterparty-row { padding: 12px 14px; }
    #counterparties-table .cp-name-cell { font-size: 15px; }
    #counterparties-table .cp-income-cell,
    #counterparties-table .cp-debt-cell { font-size: 15px; }
    #counterparties-table .cp-action-btn { width: 36px; height: 36px; }
}

/* ============================================================ */
/*  COUNTERPARTIES-MANAGER — страница «Контрагенты»             */
/* ============================================================ */

/* Кнопки шапки — по левому краю (как на странице счетов) */
.page-actions.page-actions--left {
    justify-content: flex-start;
}

/* ---- Таблица контрагентов ---- */
#counterparties-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
    margin: var(--space-lg) 0;
}
#counterparties-table th,
#counterparties-table td {
    padding: 12px 14px;
    vertical-align: middle;
    box-sizing: border-box;
    line-height: 1.4;
    border-bottom: 1px solid var(--border);
}
#counterparties-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 13px;
    white-space: nowrap;
}
#counterparties-table td {
    color: var(--text-secondary);
    font-size: 14px;
}
#counterparties-table tbody tr:hover { background: var(--bg-tertiary); }

.cp-name-cell {
    font-weight: 600;
    white-space: nowrap;
    text-align: left;
    padding-right: 40px;
}
.cp-th-right { text-align: right; }
.cp-th-debt { text-align: right; padding-right: 40px; }

.cp-income-cell {
    white-space: nowrap;
    font-weight: 700;
    text-align: right;
    color: var(--success) !important;
}
.cp-debt-cell {
    white-space: nowrap;
    font-weight: 700;
    text-align: right;
    padding-right: 40px;
    color: var(--danger) !important;
}

.cp-actions-cell { text-align: center; white-space: nowrap; }
.cp-actions-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: nowrap;
}
.cp-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
    text-decoration: none;
    padding: 0;
    line-height: 0;
}
.cp-action-btn svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
    stroke: #cbd5e1;
    fill: none;
    pointer-events: none;
}
.cp-action-btn:hover { transform: scale(1.1); }
.cp-action-btn:hover svg { stroke: #ffffff; }
.cp-action-btn.edit:hover { background: var(--info); }
.cp-action-btn.delete:hover { background: var(--danger); }

.counterparties-mobile-search { display: none; }
.counterparties-no-results {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
    font-style: italic;
    margin: 0;
}

/* ---- Мобильные карточки контрагентов ---- */
@media (max-width: 900px) {
    .counterparties-mobile-search {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 14px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 14px;
    }
    .counterparties-mobile-search-icon {
        color: var(--text-tertiary);
        flex-shrink: 0;
    }
    #counterparties-mobile-search-input {
        flex: 1;
        min-width: 0;
        background: transparent;
        border: none;
        outline: none;
        color: var(--text-primary);
        font-size: 16px;
        font-family: inherit;
        padding: 0;
        -webkit-text-size-adjust: 100%;
    }
    #counterparties-mobile-search-input::placeholder { color: var(--text-muted); }
    .counterparties-mobile-search-clear {
        flex-shrink: 0;
        width: 24px;
        height: 24px;
        display: none;
        align-items: center;
        justify-content: center;
        background: transparent;
        border: none;
        border-radius: 50%;
        color: var(--text-tertiary);
        cursor: pointer;
        padding: 0;
        transition: background 0.15s, color 0.15s;
    }
    .counterparties-mobile-search-clear:hover { background: var(--danger); color: white; }

    #counterparties-table {
        display: block;
        width: 100%;
        background: transparent;
        border: none;
        border-radius: 0;
        overflow: visible;
        margin: 0;
    }
    #counterparties-table thead { display: none; }
    #counterparties-table tbody { display: block; width: 100%; }

    #counterparties-table tr.counterparty-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "name    name"
            "income  debt"
            "actions actions";
        gap: 6px 12px;
        padding: 14px 16px;
        margin-bottom: 10px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        min-height: 0;
        transition: border-color 0.15s;
    }
    #counterparties-table tr.counterparty-row:hover {
        border-color: rgba(124,58,237,0.35);
        background: var(--bg-secondary);
    }
    #counterparties-table tr.counterparty-row td {
        display: block;
        padding: 0;
        border: none;
        background: transparent;
        text-align: left;
        vertical-align: top;
        font-size: 14px;
        color: var(--text-secondary);
        min-width: 0;
    }
    #counterparties-table .cp-name-cell {
        grid-area: name;
        text-align: left;
        padding-right: 0;
        font-size: 16px;
        font-weight: 700;
        color: var(--text-primary);
        white-space: normal;
        word-break: break-word;
        margin-bottom: 4px;
    }
    #counterparties-table .cp-income-cell {
        grid-area: income;
        text-align: left;
        padding-right: 0;
        font-size: 16px;
        font-weight: 700;
        white-space: nowrap;
        position: relative;
    }
    #counterparties-table .cp-debt-cell {
        grid-area: debt;
        text-align: left;
        padding-right: 0;
        font-size: 16px;
        font-weight: 700;
        white-space: nowrap;
        position: relative;
    }
    #counterparties-table .cp-income-cell::before {
        content: 'Доход';
        color: var(--text-tertiary);
        font-weight: 500;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        display: block;
        margin-bottom: 2px;
    }
    #counterparties-table .cp-debt-cell::before {
        content: 'Долг';
        color: var(--text-tertiary);
        font-weight: 500;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        display: block;
        margin-bottom: 2px;
    }
    #counterparties-table .cp-actions-cell {
        grid-area: actions;
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        margin-top: 8px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
        text-align: right;
    }
    #counterparties-table .cp-actions-wrap {
        display: flex;
        justify-content: flex-end;
        gap: 6px;
        width: 100%;
    }
    #counterparties-table .cp-action-btn {
        width: 38px;
        height: 38px;
        border-radius: 10px;
        touch-action: manipulation;
    }
    #counterparties-table .cp-action-btn svg {
        width: 18px;
        height: 18px;
    }
    .counterparties-no-results { padding: 24px 16px; font-size: 13px; }
}

@media (max-width: 420px) {
    #counterparties-table tr.counterparty-row { padding: 12px 14px; }
    #counterparties-table .cp-name-cell { font-size: 15px; }
    #counterparties-table .cp-income-cell,
    #counterparties-table .cp-debt-cell { font-size: 15px; }
    #counterparties-table .cp-action-btn { width: 36px; height: 36px; }
}


/* ============================================================ */
/*  COUNTERPARTY-FORM — форма добавления/редактирования          */
/*  контрагента (отдельная страница)                             */
/* ============================================================ */

.counterparty-form-page .form-container {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.counterparty-form-page fieldset {
    padding: 20px;
    margin-bottom: 20px;
}
.counterparty-form-page .form-field input,
.counterparty-form-page .form-field select,
.counterparty-form-page .form-field textarea {
    width: 100%;
    box-sizing: border-box;
}
.counterparty-form-page .form-field input:focus,
.counterparty-form-page .form-field select:focus,
.counterparty-form-page .form-field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

/* Чекбокс "Совпадает с юридическим" */
.counterparty-form-page .checkbox-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}
.counterparty-form-page .checkbox-inline input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

/* Кнопки формы */
.counterparty-form-page .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

/* Поиск по ИНН (DaData) */
.counterparty-form-page .inn-search-container {
    display: flex;
    gap: 0;
    border-radius: 6px;
    overflow: hidden;
    background: var(--bg-primary);
    border: 1px solid var(--border);
}
.counterparty-form-page .inn-search-container input {
    flex: 1;
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: none;
    border-radius: 0;
    outline: none;
    font-family: inherit;
}
.counterparty-form-page .inn-search-container input::placeholder { color: var(--text-muted); }
.counterparty-form-page .inn-search-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    transition: var(--transition);
    white-space: nowrap;
}
.counterparty-form-page .inn-search-btn:hover { background: var(--primary); }
.counterparty-form-page .inn-search-btn svg { height: 20px; width: 20px; flex-shrink: 0; }

/* ============================================================ */
/*  Банковские счета — все поля в одну строку + иконка-корзина   */
/* ============================================================ */

.counterparty-form-page .bank-accounts-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}
.counterparty-form-page .bank-account-row {
    display: grid;
    grid-template-columns: minmax(140px, 1.5fr) minmax(90px, 1fr) minmax(160px, 2fr) minmax(140px, 1.5fr) 36px;
    gap: 8px;
    align-items: center;
    padding: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.counterparty-form-page .bank-account-row input {
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    font-family: inherit;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}
.counterparty-form-page .bank-account-row input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}
.counterparty-form-page .bank-acc-remove {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}
.counterparty-form-page .bank-acc-remove svg {
    stroke: currentColor;
    fill: none;
    pointer-events: none;
}
.counterparty-form-page .bank-acc-remove:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}
.counterparty-form-page .add-account-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    background: transparent;
    border: 1px dashed var(--accent);
    color: var(--accent);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.counterparty-form-page .add-account-btn:hover {
    background: rgba(124,58,237,0.1);
    border-style: solid;
}
.counterparty-form-page .add-account-btn svg { stroke: currentColor; fill: none; }

/* Мобильная адаптация формы контрагента */
@media (max-width: 900px) {
    .counterparty-form-page .form-container { padding: 14px; }
    .counterparty-form-page fieldset { padding: 14px; margin-bottom: 14px; }
    .counterparty-form-page .form-grid { grid-template-columns: 1fr; gap: 12px; }
    .counterparty-form-page .form-field input,
    .counterparty-form-page .form-field select,
    .counterparty-form-page .form-field textarea {
        padding: 12px 14px;
        font-size: 16px;
        min-height: 44px;
    }
    .counterparty-form-page .form-actions {
        flex-direction: column-reverse;
        gap: 10px;
        position: sticky;
        bottom: 66px;
        padding: 12px 0;
        background: var(--bg-primary);
        border-top: 1px solid var(--border);
        margin-top: 16px;
        z-index: 10;
    }
    .counterparty-form-page .form-actions .button-secondary,
    .counterparty-form-page .form-actions button[type="submit"] {
        width: 100%;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Мобильный вид строки счёта: 4 поля слева, корзина справа на всю высоту */
    .counterparty-form-page .bank-account-row {
        grid-template-columns: 1fr 40px;
        grid-template-areas:
            "account remove"
            "bic     remove"
            "name    remove"
            "corr    remove";
        gap: 6px 8px;
        align-items: stretch;
    }
    .counterparty-form-page .bank-acc-account { grid-area: account; }
    .counterparty-form-page .bank-acc-bic     { grid-area: bic; }
    .counterparty-form-page .bank-acc-name    { grid-area: name; }
    .counterparty-form-page .bank-acc-corr    { grid-area: corr; }
    .counterparty-form-page .bank-acc-remove {
        grid-area: remove;
        width: 40px;
        height: auto;
        min-height: 40px;
        align-self: stretch;
    }
    .counterparty-form-page .bank-account-row input {
        font-size: 16px;
        min-height: 42px;
    }
    .counterparty-form-page .add-account-btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }
}

/* ============================================================ */
/*  MONEY — страница «Платежи»                                  */
/* ============================================================ */

/* ---- Панель загрузки выписки ---- */
.upload-statement-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 24px;
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(124,58,237,0.08) 100%);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.upload-statement-left { flex: 1; min-width: 260px; }
.upload-statement-left h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 6px 0;
    font-size: 16px;
    color: var(--text-primary);
}
.upload-statement-left h3 svg { color: var(--accent); flex-shrink: 0; }
.upload-statement-left p {
    margin: 0;
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.5;
}
.upload-statement-right {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}
.upload-statement-right .button-primary,
.upload-statement-right .button-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 18px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition);
    box-sizing: border-box;
}
.upload-statement-right .button-primary {
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent);
}
.upload-statement-right .button-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
}
.upload-statement-right .button-secondary {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.upload-statement-right .button-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.upload-statement-right svg { stroke: currentColor; fill: none; flex-shrink: 0; }

/* ---- Результат загрузки ---- */
.upload-result {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.7;
}
.upload-result-loading {
    background: rgba(124,58,237,0.1);
    border-left: 3px solid var(--accent);
    color: var(--text-primary);
}
.upload-result-success {
    background: rgba(16,185,129,0.1);
    border-left: 3px solid var(--success);
    color: var(--text-primary);
}
.upload-result-error {
    background: rgba(239,68,68,0.1);
    border-left: 3px solid var(--danger);
    color: var(--text-primary);
}

/* ---- Спиннер загрузки (общий) ---- */
.match-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    padding: 30px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
}
.match-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-right-color: var(--accent);
    border-radius: 50%;
    animation: dokiSpin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes dokiSpin {
    to { transform: rotate(360deg); }
}
.match-loading-text {
    color: var(--text-secondary);
    font-weight: 500;
}

/* ---- Фильтры ---- */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.filters-form {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
    margin: 0;
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-tertiary);
    white-space: nowrap;
    user-select: none;
}
.filter-group select {
    min-width: 140px;
    padding: 8px 30px 8px 12px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 11px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
    text-overflow: ellipsis;
}
.filter-group select:hover {
    color: var(--text-primary);
    border-color: #475569;
    background-color: var(--bg-secondary);
}
.filter-group select:focus {
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}

/* ---- Поиск по выписке ---- */
.bank-search-wrap {
    position: relative;
    flex: 1;
    min-width: 260px;
    display: flex;
    align-items: center;
    margin-left: auto;
}
.bank-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
    transition: color 0.15s;
}
.bank-search-input {
    width: 100%;
    padding: 9px 38px 9px 38px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}
.bank-search-input::placeholder { color: var(--text-muted); }
.bank-search-input:hover { border-color: #475569; }
.bank-search-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}
.bank-search-wrap:focus-within .bank-search-icon { color: var(--accent); }
.bank-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    border-radius: 50%;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
}
.bank-search-clear:hover { background: var(--danger); color: white; }
.filter-result {
    font-size: 13px;
    color: var(--accent);
    font-weight: 600;
    white-space: nowrap;
}
.bt-no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 15px;
    font-style: italic;
}

/* ---- Итоги (поступления / списания) ---- */
.totals-bar {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
}
.total-item { display: flex; gap: 8px; align-items: baseline; }
.total-label { color: var(--text-tertiary); font-size: 13px; }
.total-value {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.total-income .total-value  { color: var(--success); }
.total-expense .total-value { color: var(--danger); }
.total-count { margin-left: auto; }

/* ---- Таблица банковских операций ---- */
.bank-table { width: 100%; border-collapse: collapse; }
.bank-table th,
.bank-table td {
    padding: 10px 12px;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}
.bank-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    white-space: nowrap;
    vertical-align: middle;
}
.bank-table td { color: var(--text-secondary); font-size: 13px; }
.bank-table tbody tr:hover { background: var(--bg-tertiary); }
.bt-date { white-space: nowrap; font-variant-numeric: tabular-nums; }
.bt-date-time {
    display: block;
    color: var(--text-tertiary);
    font-size: 11px;
    margin-top: 2px;
}
.bt-purpose { max-width: 400px; }

.bt-dir {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
}
.bt-dir-income  { background: rgba(16,185,129,0.15); color: #34d399; }
.bt-dir-expense { background: rgba(239,68,68,0.15);  color: #f87171; }

.bt-amount-cell {
    text-align: right;
    font-weight: 600;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}
.bt-cp-cell { max-width: 200px; word-break: break-word; }

.bt-actions-cell { text-align: center; width: 60px; }
.bt-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: var(--transition);
    padding: 0;
    line-height: 0;
    touch-action: manipulation;
}
.bt-delete svg { stroke: currentColor; fill: none; pointer-events: none; }
.bt-delete:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

/* ---- Привязка счетов к операциям ---- */
.bt-match-cell { min-width: 240px; }
.bt-match-slot { display: block; }
.bt-match-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 6px;
}
.bt-match-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    background: rgba(124,58,237,0.09);
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.4;
}
.bt-match-link {
    flex: 1;
    min-width: 0;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
}
.bt-match-link svg {
    flex-shrink: 0;
    stroke: currentColor;
    fill: none;
    opacity: 0.7;
}
.bt-match-link:hover {
    color: #e9d5ff;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.bt-match-link:hover svg { opacity: 1; }
.bt-match-link-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.bt-match-clear {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    padding: 0;
    margin-left: 2px;
    background: none;
    border: none;
    color: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    opacity: 0.5;
    user-select: none;
    touch-action: manipulation;
}
.bt-match-clear:hover { color: #ef4444; opacity: 1; }
.bt-match-amt {
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    font-weight: 500;
}
.bt-match-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 11px;
    color: var(--text-tertiary);
}
.bt-match-total {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.bt-match-total.bt-match-ok    { color: var(--success); }
.bt-match-total.bt-match-short { color: var(--warning); }
.bt-match-total.bt-match-over  { color: var(--danger); }
.bt-match-add {
    flex-shrink: 0;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    color: var(--accent);
    background: transparent;
    border: 1px dashed rgba(124,58,237,0.5);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    line-height: 1.5;
    min-height: 24px;
    touch-action: manipulation;
}
.bt-match-add:hover {
    background: rgba(124,58,237,0.15);
    border-color: var(--accent);
}
.bt-match-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px dashed var(--accent);
    color: var(--accent);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    touch-action: manipulation;
}
.bt-match-btn:hover { background: rgba(124,58,237,0.15); }

/* ---- Основание платежа для списаний ---- */
.bt-purpose-cell { min-width: 200px; }
.bt-purpose-label { display: none; }
.bt-purpose-select {
    width: 100%;
    max-width: 230px;
    padding: 6px 30px 6px 10px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 500;
    line-height: 1.4;
    color: var(--text-secondary);
    background-color: var(--bg-primary);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 9px center;
    background-size: 10px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s;
    text-overflow: ellipsis;
}
.bt-purpose-select:hover {
    color: var(--text-primary);
    border-color: #475569;
    background-color: var(--bg-secondary);
}
.bt-purpose-select:focus {
    color: var(--text-primary);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}
.bt-purpose-select:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* ---- Модалка привязки счёта ---- */
.match-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}
.match-modal-window {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 90%;
    max-width: 640px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.match-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    gap: 12px;
}
.match-modal-header h3 { margin: 0; font-size: 16px; color: var(--text-primary); }
.match-modal-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    touch-action: manipulation;
    padding: 0;
}
.match-modal-close svg { stroke: currentColor; fill: none; pointer-events: none; }
.match-modal-close:hover { background: var(--danger); color: white; }

.match-modal-body {
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}
.match-info-bar {
    padding: 10px 14px;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.match-info-bar strong { color: var(--text-primary); }
.match-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}
.match-search {
    padding: 10px 14px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    outline: none;
    font-family: inherit;
}
.match-search:focus { border-color: var(--accent); }
.match-list { flex: 1; overflow-y: auto; max-height: 480px; }
.match-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    gap: 12px;
}
.match-item:hover { background: var(--bg-tertiary); }
.match-item-exact { border-left: 3px solid var(--success); }
.match-item-linked { opacity: 0.55; }
.match-item-linked:hover { opacity: 0.75; background: rgba(124,58,237,0.08); }
.match-item-other {
    opacity: 0.55;
    border-left: 3px solid var(--border);
}
.match-item-other:hover {
    opacity: 0.75;
    background: rgba(124,58,237,0.05);
}
.match-item-num {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.match-item-badge {
    display: inline-block;
    padding: 1px 7px;
    font-size: 10px;
    font-weight: 700;
    background: rgba(16,185,129,0.2);
    color: #34d399;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.match-item-badge-other {
    background: rgba(148,163,184,0.15);
    color: var(--text-tertiary);
}
.match-item-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.match-item-other-info {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 3px;
    font-weight: 500;
}
.match-item-right { text-align: right; flex-shrink: 0; }
.match-item-amount {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13px;
}
.match-item-status { font-size: 11px; margin-top: 2px; }
.match-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* ---- Мобильная адаптация Money ---- */
@media (max-width: 900px) {
    /* Скрываем панель загрузки на мобильном */
    .upload-statement-panel { display: none; }

    /* Фильтры в столбик */
    .filters-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        padding: 12px 14px;
    }
    .filters-form {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        width: 100%;
    }
    .filter-group {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }
    .filter-group label {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
    }
    .filter-group select {
        width: 100%;
        min-width: 0;
        height: 40px;
        font-size: 16px;
        padding: 8px 30px 8px 12px;
    }
    .bank-search-wrap {
        min-width: 0;
        width: 100%;
        margin-left: 0;
    }
    .bank-search-input {
        font-size: 16px;
        padding: 10px 38px 10px 38px;
    }
    .filter-result {
        text-align: right;
        font-size: 12px;
    }

    /* Итоги 2×2 */
    .totals-bar {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px 16px;
        padding: 12px 14px;
        margin-bottom: 16px;
    }
    .total-item {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        min-width: 0;
    }
    .total-label {
        font-size: 10px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
    }
    .total-value {
        font-size: 15px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }
    .total-count { margin-left: 0; }

    /* Таблица -> карточки */
    .bank-table { display: block; width: 100%; background: transparent; }
    .bank-table thead { display: none; }
    .bank-table tbody { display: block; width: 100%; }

    /* Кнопка удаления скрыта (специфичность перебивает общее правило ниже) */
    .bank-table tr.bt-row td.bt-actions-cell {
        display: none !important;
    }

    .bank-table tr.bt-row {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "date     dir"
            "amount   amount"
            "cp       cp"
            "purpose  purpose"
            "match    match";
        gap: 6px 12px;
        padding: 14px 16px;
        margin-bottom: 10px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        transition: border-color 0.15s;
    }
    .bank-table tr.bt-row:hover {
        border-color: rgba(124,58,237,0.35);
        background: var(--bg-secondary);
    }
    .bank-table tr.bt-row td {
        display: block;
        padding: 0;
        border: none;
        background: transparent;
        text-align: left;
        vertical-align: top;
        font-size: 14px;
        color: var(--text-secondary);
        min-width: 0;
    }
    .bank-table .bt-date { grid-area: date; }
    .bank-table .bt-dir-cell { grid-area: dir; justify-self: end; align-self: start; }
    .bank-table .bt-amount-cell { grid-area: amount; }
    .bank-table .bt-cp-cell { grid-area: cp; }
    .bank-table .bt-purpose { grid-area: purpose; }
    .bank-table .bt-match-cell,
    .bank-table .bt-purpose-cell { grid-area: match; }

    .bank-table .bt-date {
        font-size: 12px;
        color: var(--text-tertiary);
        font-weight: 500;
    }
    .bank-table .bt-date-day { display: inline; }
    .bank-table .bt-date-time {
        display: inline;
        margin: 0 0 0 4px;
        font-size: 11px;
    }
    .bank-table .bt-amount-cell {
        font-size: 22px;
        font-weight: 700;
        margin-top: 4px;
        margin-bottom: 4px;
        white-space: nowrap;
    }
    .bank-table .bt-cp-cell {
        font-size: 14px;
        font-weight: 600;
        color: var(--text-primary);
        margin-bottom: 2px;
        max-width: 100%;
        word-break: break-word;
    }
    .bank-table .bt-purpose {
        font-size: 12px;
        color: var(--text-tertiary);
        line-height: 1.5;
        margin-bottom: 6px;
        max-width: 100%;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }
    .bank-table .bt-match-cell,
    .bank-table .bt-purpose-cell {
        min-width: 0;
        width: 100%;
        padding-top: 10px;
        border-top: 1px dashed var(--border);
        margin-top: 4px;
    }
    .bank-table .bt-purpose-select { display: none; }
    .bank-table .bt-purpose-label {
        display: inline-block;
        font-size: 13px;
        font-weight: 600;
        color: var(--accent);
        background: rgba(124,58,237,0.14);
        border: 1px solid rgba(124,58,237,0.3);
        border-radius: 100px;
        padding: 5px 14px;
        line-height: 1.3;
        letter-spacing: 0.2px;
    }

    /* Привязка счёта — крупнее */
    .bt-match-list { gap: 6px; }
    .bt-match-item {
        font-size: 14px;
        padding: 8px 12px;
        gap: 10px;
    }
    .bt-match-link { color: var(--text-primary); }
    .bt-match-link:hover { color: #e9d5ff; }
    .bt-match-link svg { width: 14px; height: 14px; opacity: 0.85; }
    .bt-match-link-text {
        font-size: 14px;
        font-weight: 500;
    }
    .bt-match-clear {
        width: 20px;
        height: 20px;
        font-size: 14px;
        opacity: 0.6;
    }
    .bt-match-amt {
        font-size: 13px;
        color: var(--text-secondary);
    }
    .bt-match-btn {
        font-size: 14px;
        padding: 10px 16px;
        min-height: 40px;
    }
    .bt-match-footer {
        font-size: 12px;
        margin-top: 6px;
    }
    .bt-match-add {
        font-size: 12px;
        padding: 6px 12px;
        min-height: 32px;
    }

    /* Модалка — fullscreen */
    .match-modal-window {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        padding-top: var(--doki-safe-top, env(safe-area-inset-top, 0px));
        padding-bottom: var(--doki-safe-bottom, env(safe-area-inset-bottom, 0px));
    }
    .match-modal-header {
        padding: 12px 16px;
        min-height: 56px;
    }
    .match-modal-header h3 {
        font-size: 16px;
        line-height: 1.3;
    }
    .match-modal-close {
        width: 40px;
        height: 40px;
    }
    .match-modal-close svg { width: 20px; height: 20px; }
    .match-modal-body { padding: 14px 16px; }
    .match-item { padding: 12px 14px; }
    .match-search { font-size: 16px; }
}

@media (max-width: 420px) {
    .totals-bar {
        grid-template-columns: 1fr 1fr;
        gap: 8px 12px;
    }
    .total-value { font-size: 14px; }
    .bank-table tr.bt-row { padding: 12px 14px; }
    .bank-table .bt-amount-cell { font-size: 20px; }
}


/* ============================================================ */
/*  PRICELIST — Прайс-лист услуг                                */
/* ============================================================ */

/* ===== Кнопки тулбара ===== */
.pl-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    box-sizing: border-box;
}
.pl-btn svg { stroke: currentColor; fill: none; flex-shrink: 0; }
.pl-btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.pl-btn-primary:hover { background: var(--primary); border-color: var(--primary); }
.pl-btn-secondary { background: var(--bg-secondary); color: var(--text-secondary); }
.pl-btn-secondary:hover { background: var(--bg-tertiary); color: var(--text-primary); border-color: var(--accent); }

.pricelist-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.pricelist-toolbar-main {
    display: flex;
    gap: 10px;
    align-items: stretch;
    flex-wrap: wrap;
}
.tt-export-group { display: inline-flex; align-items: stretch; height: 40px; }
.pl-select-wrap { position: relative; display: inline-flex; align-items: center; height: 40px; }
.pl-select {
    height: 40px;
    padding: 0 36px 0 14px;
    font-size: 13px;
    font-family: inherit;
    font-weight: 500;
    line-height: 1;
    color: var(--text-secondary);
    background-color: var(--bg-secondary);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    text-overflow: ellipsis;
    max-width: 320px;
    min-width: 200px;
    box-sizing: border-box;
}
.pl-select:hover {
    color: var(--text-primary);
    border-color: #475569;
    background-color: var(--bg-tertiary);
}
.pl-select:focus { border-color: var(--accent); }
.pl-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}
.pl-btn-tz {
    border-radius: 0 var(--radius) var(--radius) 0;
    border-left: 1px solid var(--border);
}

/* ===== Подсказки ===== */
.pricelist-hint {
    background: rgba(124,58,237,0.06);
    border-left: 3px solid var(--accent);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.pricelist-hint-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.55;
}
.pricelist-hint-item svg {
    flex-shrink: 0;
    color: var(--accent);
    margin-top: 2px;
    stroke: currentColor;
}
.pricelist-hint-item strong { color: var(--text-primary); font-weight: 600; }

/* ===== Поиск ===== */
.pricelist-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.pricelist-search-icon { color: var(--text-tertiary); flex-shrink: 0; }
#pricelist-search-input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    padding: 0;
}
#pricelist-search-input::placeholder { color: var(--text-muted); }
.pricelist-search-clear {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}
.pricelist-search-clear:hover { background: var(--danger); color: white; }

.pricelist-no-results {
    text-align: center;
    padding: 30px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
    font-style: italic;
    margin: 0;
}

/* ===== Группы ===== */
.groups-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin-bottom: 24px;
}
.service-group { background: transparent; }
.group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.group-drag-handle {
    color: var(--text-tertiary);
    cursor: grab;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    transition: color 0.15s;
}
.group-drag-handle:hover { color: var(--accent); }
.group-drag-handle svg { stroke: currentColor; fill: none; }
.group-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    outline: none;
    min-width: 100px;
    transition: background 0.15s;
}
.group-title:hover,
.group-title:focus { background: rgba(124,58,237,0.1); }
.group-title-static {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--text-tertiary);
    padding: 4px 8px;
}
.group-delete-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    border-radius: 4px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.group-delete-btn svg { stroke: currentColor; fill: none; }
.group-delete-btn:hover { background: var(--danger); color: white; }

/* ===== Таблица прайса ===== */
.pricelist-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    overflow: hidden;
}
.pricelist-table th,
.pricelist-table td {
    padding: 10px 12px;
    vertical-align: middle;
    box-sizing: border-box;
    line-height: 1.4;
    border-bottom: 1px solid var(--border);
}
.pricelist-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 12px;
    white-space: nowrap;
}
.pricelist-table td { color: var(--text-secondary); font-size: 14px; }
.pricelist-table tbody tr {
    transition: opacity 0.15s, background 0.15s;
    background: var(--bg-secondary);
}
.pricelist-table tbody tr:hover { background: var(--bg-tertiary); }
.pricelist-table tbody tr.row-disabled { opacity: 0.5; }
.pricelist-table tbody tr.row-disabled:hover { background: var(--bg-secondary); }

.drag-cell { text-align: center; padding: 4px !important; width: 32px; }
.drag-handle {
    color: var(--text-tertiary);
    cursor: grab;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle:hover { color: var(--accent); }
.drag-handle svg { stroke: currentColor; fill: none; }

.drag-ghost { opacity: 0.4; background: var(--accent) !important; }
.drag-chosen { background: var(--bg-tertiary) !important; }

.empty-hint {
    text-align: center;
    color: var(--text-tertiary);
    font-style: italic;
    padding: 20px !important;
    font-size: 13px;
}

.checkbox-cell,
.group-toggle-all,
.service-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    vertical-align: middle;
}
.checkbox-cell { text-align: center; }

.editable-cell {
    cursor: pointer;
    position: relative;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.editable-cell:hover { background: rgba(124,58,237,0.1); }
.editable-cell:hover::after {
    content: '';
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 16px;
    background: var(--accent);
    border-radius: 2px;
    opacity: 0.7;
}
.inline-editor {
    width: 100%;
    padding: 6px 8px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 2px solid var(--accent);
    border-radius: var(--radius-sm);
    outline: none;
}
.name-extra { display: none; }

.qty-cell { text-align: center; }
.qty-input {
    padding: 6px 10px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    width: 72px;
    text-align: center;
    transition: border-color 0.15s;
}
.qty-input:hover { border-color: #475569; }
.qty-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}

.sum-cell { font-weight: 600; white-space: nowrap; text-align: right; }

.pricelist-table .actions-cell {
    display: table-cell;
    text-align: center;
    vertical-align: middle;
    white-space: nowrap;
    width: 110px;
    padding: 10px 8px;
}
.actions-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: nowrap;
    vertical-align: middle;
}

/* Кнопки внутри прайса */
.pricelist-table .action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    flex-shrink: 0;
    padding: 0;
    line-height: 0;
}
.pricelist-table .action-btn svg {
    width: 16px;
    height: 16px;
    display: block;
    flex-shrink: 0;
    stroke: #cbd5e1;
    fill: none;
    pointer-events: none;
}
.pricelist-table .action-btn:hover { transform: scale(1.1); }
.pricelist-table .action-btn:hover svg { stroke: #ffffff; }
.pricelist-table .action-btn.edit-service:hover { background: var(--info); }
.pricelist-table .action-btn.delete-service:hover { background: var(--danger); }
.pricelist-table .action-btn.more-service:hover { background: var(--accent); }
.pricelist-table .action-btn.more-service { display: none; }

/* ===== Добавить группу ===== */
.add-group-bar {
    display: flex;
    gap: 10px;
    padding: 14px 18px;
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    align-items: center;
    margin-bottom: 20px;
}
.add-group-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s;
    box-sizing: border-box;
}
.add-group-input::placeholder { color: var(--text-muted); }
.add-group-input:focus { border-color: var(--accent); }

/* ===== Панель итогов (fixed внизу) ===== */
.pricelist-totals-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    background: var(--bg-secondary);
    border-top: 2px solid var(--accent);
    box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
    padding: 14px 24px calc(14px + env(safe-area-inset-bottom, 0px));
}
.ptb-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 32px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
}
.ptb-item { display: flex; align-items: baseline; gap: 8px; font-size: 14px; }
.ptb-label { color: var(--text-tertiary); font-size: 13px; }
.ptb-value {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 15px;
    font-variant-numeric: tabular-nums;
}
.ptb-time { color: var(--info); }
.ptb-sum {
    margin-left: auto;
    padding-left: 24px;
    border-left: 1px solid var(--border);
}
.ptb-sum .ptb-label { font-size: 14px; font-weight: 600; color: var(--text-secondary); }
.ptb-sum-value {
    color: var(--success);
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.3px;
}

/* ===== Отступ внизу только для страницы прайса ===== */
body:has(.pricelist-totals-bar) .doki-contents {
    padding-bottom: 130px !important;
}

/* ===== Popover действий (мобильный) ===== */
.card-action-popover {
    position: absolute;
    z-index: 10000;
    min-width: 180px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    padding: 4px;
    display: none;
    flex-direction: column;
    gap: 2px;
}
.card-action-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-align: left;
    transition: background 0.12s, color 0.12s;
}
.card-action-item svg { stroke: currentColor; fill: none; flex-shrink: 0; }
.card-action-item:hover { background: var(--bg-tertiary); color: var(--text-primary); }
.card-action-danger { color: #f87171; }
.card-action-danger svg { stroke: #f87171; }
.card-action-danger:hover { background: rgba(239,68,68,0.12); color: #fca5a5; }

/* ===== Модалка добавления/редактирования услуги ===== */
.service-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}
.service-modal-overlay[style*="flex"] { display: flex !important; }
.service-modal-window {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 90%;
    max-width: 680px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.service-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.service-modal-header h3 { margin: 0; font-size: 17px; color: var(--text-primary); }
.service-modal-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    padding: 0;
}
.service-modal-close svg { stroke: currentColor; fill: none; pointer-events: none; }
.service-modal-close:hover { background: var(--danger); color: white; }

.service-modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.sm-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}
.sm-field:last-child { margin-bottom: 0; }
.sm-field label { font-weight: 500; font-size: 13px; color: var(--text-secondary); }
.sm-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sm-input,
.sm-select,
.sm-textarea {
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 400;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    width: 100%;
    box-sizing: border-box;
}
.sm-input::placeholder,
.sm-textarea::placeholder { color: var(--text-muted); }
.sm-input:focus,
.sm-select:focus,
.sm-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}
.sm-input-wrap { position: relative; }
.sm-input-wrap > .sm-input { padding-right: 40px; }
.sm-num-btn {
    position: absolute;
    right: 1px;
    width: 32px;
    height: 50%;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    outline: none;
    transition: color 0.15s, background 0.15s;
}
.sm-num-btn.sm-num-up { top: 1px; border-top-right-radius: var(--radius-sm); }
.sm-num-btn.sm-num-down { bottom: 1px; border-bottom-right-radius: var(--radius-sm); }
.sm-num-btn::before {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    background-color: currentColor;
    -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
}
.sm-num-btn.sm-num-up::before { transform: scaleY(-1); }
.sm-num-btn:hover { color: var(--accent); background: rgba(124,58,237,0.08); }
.sm-select-wrap { position: relative; display: block; }
.sm-select {
    padding-right: 36px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}
.sm-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}
.sm-textarea { resize: vertical; min-height: 140px; line-height: 1.55; }
.service-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}
.sm-btn {
    padding: 10px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    font-family: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    border: none;
}
.sm-btn-primary { background: var(--accent); color: white; }
.sm-btn-primary:hover:not(:disabled) { background: var(--primary); }
.sm-btn-primary:disabled { opacity: 0.6; cursor: wait; }
.sm-btn-secondary { background: var(--bg-tertiary); color: var(--text-secondary); }
.sm-btn-secondary:hover { background: var(--bg-primary); }

/* ===== Мобильная адаптация прайса ===== */
@media (max-width: 900px) {
    .pricelist-toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 14px;
    }
    .pricelist-toolbar-main {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    .pricelist-toolbar-main .pl-btn-primary { grid-column: 1 / -1; }
    .pricelist-toolbar-main .pl-btn {
        padding: 0 14px;
        font-size: 12px;
        height: 38px;
    }
    .tt-export-group {
        grid-column: 1 / -1;
        height: auto;
        flex-direction: column;
        gap: 8px;
    }
    .pl-select-wrap { width: 100%; height: 40px; }
    .pl-select {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        border-right: 1px solid var(--border);
        border-radius: var(--radius);
        height: 40px;
        font-size: 16px;
    }
    .pl-btn-tz { border-radius: var(--radius); width: 100%; height: 38px; }

    .pricelist-hint { display: none; }
    #pricelist-search-input { font-size: 16px; }

    .group-header { gap: 6px; }
    .group-title,
    .group-title-static { font-size: 15px; }
    .group-drag-handle { display: none; }

    .pricelist-table th { background: transparent !important; }
    .pricelist-table {
        display: block;
        width: 100%;
        background: transparent;
        border: none;
        border-radius: 0;
        overflow: visible;
    }
    .pricelist-table thead {
        display: block;
        padding: 10px 14px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        margin-bottom: 8px;
    }
    .pricelist-table thead tr {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .pricelist-table thead th {
        display: none;
        padding: 0;
        border: none;
    }
    .pricelist-table thead th:nth-child(2) {
        display: flex;
        align-items: center;
        gap: 10px;
        width: auto;
        font-size: 13px;
        text-transform: none;
        letter-spacing: 0;
        font-weight: 500;
        color: var(--text-secondary);
    }
    .pricelist-table thead th:nth-child(2)::after {
        content: 'Выделить все в группе';
        font-size: 13px;
        font-weight: 500;
        color: var(--text-secondary);
        text-transform: none;
        letter-spacing: 0;
    }
    .pricelist-table thead th:nth-child(2) .group-toggle-all {
        width: 22px;
        height: 22px;
        touch-action: manipulation;
    }

    .pricelist-table tbody { display: block; width: 100%; }

    /* Карточка — жёсткая сетка, элементы по верхнему краю */
    .pricelist-table tr.service-row {
        display: grid;
        grid-template-columns: 22px minmax(0, 1fr) auto auto auto;
        gap: 6px;
        padding: 10px 12px;
        margin-bottom: 8px;
        align-items: start;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        min-height: 0;
        transition: border-color 0.15s, opacity 0.15s;
    }
    .pricelist-table tr.service-row:hover { background: var(--bg-secondary); }
    .pricelist-table tr.service-row.row-disabled { opacity: 0.5; }
    .pricelist-table tr.service-row:last-of-type { margin-bottom: 0; }

    .pricelist-table tr.service-row td {
        display: block;
        padding: 0;
        border: none;
        background: transparent;
        text-align: left;
        font-size: 14px;
        color: var(--text-secondary);
        min-width: 0;
        align-self: start;
    }

    .pricelist-table .drag-cell { display: none !important; }
    .pricelist-table .editable-time { display: none !important; }
    .pricelist-table .editable-price { display: none !important; }
    .pricelist-table .edit-service,
    .pricelist-table .delete-service { display: none !important; }

    .pricelist-table .checkbox-cell {
        grid-column: 1;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        padding-top: 4px;
    }
    .pricelist-table .service-checkbox {
        width: 22px;
        height: 22px;
        margin: 0;
        touch-action: manipulation;
    }

    .pricelist-table .editable-name {
        grid-column: 2;
        font-size: 14px;
        font-weight: 600;
        color: var(--text-primary);
        line-height: 1.35;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        cursor: pointer;
        padding: 4px 0;
        min-width: 0;
    }
    .pricelist-table .editable-name:hover { background: transparent; }
    .pricelist-table .editable-name:hover::after { display: none; }
    .pricelist-table .editable-name .cell-value { display: block; }

    .pricelist-table tr.service-row.name-expanded .editable-name {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        word-break: break-word;
    }
    .pricelist-table tr.service-row.name-expanded .editable-name .name-extra {
        display: block;
        margin-top: 6px;
        font-size: 12px;
        color: var(--text-tertiary);
        font-weight: 500;
    }
    .pricelist-table tr.service-row.name-expanded .editable-name .name-extra-time {
        display: inline-block;
    }

    .pricelist-table .qty-cell {
        grid-column: 3;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        padding-top: 3px;
    }
    .pricelist-table .sum-cell {
        grid-column: 4;
        justify-self: end;
        align-self: start;
        font-size: 14px;
        font-weight: 700;
        color: var(--text-primary);
        white-space: nowrap;
        padding-top: 6px;
        text-align: right;
        line-height: 1.2;
    }
    .pricelist-table .actions-cell {
        grid-column: 5;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        width: auto;
        padding: 0;
        border: none;
    }
    .pricelist-table .actions-wrap { display: flex; gap: 0; }
    .pricelist-table .action-btn.more-service {
        display: inline-flex !important;
        width: 32px;
        height: 32px;
        background: transparent;
        color: var(--text-tertiary);
        touch-action: manipulation;
    }
    .pricelist-table .action-btn.more-service svg { width: 18px; height: 18px; }
    .pricelist-table .action-btn.more-service:hover {
        background: rgba(124,58,237,0.1);
        transform: none;
    }

    .pricelist-table .editable-price::before,
    .pricelist-table .qty-cell::before,
    .pricelist-table .sum-cell::before { content: none !important; }

    /* Empty placeholder */
    .pricelist-table tr.empty-placeholder { display: block; }
    .pricelist-table tr.empty-placeholder td {
        display: block;
        padding: 16px;
        text-align: center;
        color: var(--text-tertiary);
        font-size: 13px;
        font-style: italic;
        background: var(--bg-secondary);
        border: 1px dashed var(--border);
        border-radius: var(--radius);
    }

    /* Мини-степпер */
    .inline-stepper {
        display: inline-flex;
        align-items: center;
        background: var(--bg-primary);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
        overflow: hidden;
        height: 32px;
        flex-shrink: 0;
    }
    .inline-step {
        width: 30px;
        height: 30px;
        padding: 0;
        background: transparent;
        border: none;
        color: var(--text-secondary);
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s, color 0.15s;
        font-family: inherit;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
        line-height: 1;
    }
    .inline-step:hover { background: rgba(124,58,237,0.1); color: var(--accent); }
    .inline-step:active { background: rgba(124,58,237,0.2); }
    .inline-stepper .qty-input {
        width: 32px;
        height: 30px;
        padding: 0;
        border: none;
        border-left: 1px solid var(--border);
        border-right: 1px solid var(--border);
        border-radius: 0;
        background: transparent;
        text-align: center;
        font-size: 14px;
        font-weight: 600;
        color: var(--text-primary);
        -moz-appearance: textfield;
        appearance: textfield;
        min-width: 0;
    }
    .inline-stepper .qty-input::-webkit-outer-spin-button,
    .inline-stepper .qty-input::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

    /* Popover */
    .card-action-popover { min-width: 160px; padding: 4px; }
    .card-action-item { padding: 12px 14px; font-size: 15px; }

    /* Добавить группу */
    .add-group-bar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 14px;
        margin-bottom: 20px;
    }
    .add-group-input { font-size: 16px; min-width: 0; }
    .add-group-bar .pl-btn { width: 100%; }

    /* Панель итогов */
    .pricelist-totals-bar {
        bottom: calc(58px + env(safe-area-inset-bottom, 0px));
        padding: 10px 14px;
        border-top-width: 1px;
    }
    .ptb-inner {
        display: flex;
        flex-wrap: nowrap;
        gap: 8px 12px;
        justify-content: space-between;
        align-items: center;
    }
    .ptb-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 1px;
        flex-shrink: 0;
    }
    .ptb-label {
        font-size: 9px;
        text-transform: uppercase;
        letter-spacing: 0.3px;
        line-height: 1;
    }
    .ptb-value { font-size: 12px; line-height: 1.2; }
    .ptb-sum {
        margin-left: auto;
        padding-left: 0;
        border-left: none;
        flex-direction: column;
        align-items: flex-end;
        flex-shrink: 0;
    }
    .ptb-sum .ptb-label { font-size: 10px; }
    .ptb-sum-value { font-size: 16px; }

    body:has(.pricelist-totals-bar) .doki-contents {
        padding-bottom: calc(58px + 70px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Модалка */
    .service-modal-window {
        width: 100%;
        max-width: 100%;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        padding-top: var(--doki-safe-top, env(safe-area-inset-top, 0px));
        padding-bottom: var(--doki-safe-bottom, env(safe-area-inset-bottom, 0px));
    }
    .service-modal-header { padding: 12px 16px; min-height: 56px; }
    .service-modal-header h3 { font-size: 16px; }
    .service-modal-close { width: 40px; height: 40px; }
    .service-modal-close svg { width: 20px; height: 20px; }
    .service-modal-body { padding: 16px; }
    .sm-row { grid-template-columns: 1fr; gap: 12px; }
    .sm-input,
    .sm-select,
    .sm-textarea { font-size: 16px; }
    .sm-textarea { min-height: 120px; }
    .service-modal-footer { padding: 12px 16px; gap: 8px; }
    .sm-btn { flex: 1; padding: 12px 16px; font-size: 15px; }
}

@media (max-width: 420px) {
    .pricelist-toolbar-main { grid-template-columns: 1fr; }
    .pricelist-toolbar-main .pl-btn { height: 40px; }

    .pricelist-table tr.service-row {
        grid-template-columns: 20px minmax(0, 1fr) auto auto auto;
        gap: 5px;
        padding: 8px 10px;
    }
    .pricelist-table .editable-name { font-size: 13px; }
    .pricelist-table .sum-cell { font-size: 13px; }
    .pricelist-table .action-btn.more-service { width: 28px; height: 28px; }
    .pricelist-table .action-btn.more-service svg { width: 16px; height: 16px; }

    .inline-step { width: 26px; height: 28px; font-size: 14px; }
    .inline-stepper .qty-input { width: 28px; height: 28px; font-size: 13px; }
    .inline-stepper { height: 30px; }

    .ptb-label { font-size: 8px; }
    .ptb-value { font-size: 11px; }
    .ptb-sum-value { font-size: 14px; }
}


/* ============================================================ */
/*  REPORTS — Отчёты                                            */
/* ============================================================ */

/* ===== Шапка ===== */
.reports-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    padding: 16px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.reports-header-info {
    display: flex;
    gap: 28px;
    flex-wrap: wrap;
    align-items: center;
    flex: 1;
    min-width: 0;
}
.reports-header-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.reports-header-label {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}
.reports-header-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}
.reports-header-reason {
    color: var(--warning);
    font-style: italic;
    font-weight: 500;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}
.reports-header-total-item {
    padding-left: 20px;
    border-left: 1px solid var(--border);
}
.reports-header-total {
    color: var(--accent);
    font-size: 18px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.reports-header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-shrink: 0;
}
.reports-year-select { display: flex; align-items: center; gap: 6px; }
.reports-year-select label {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}
.reports-year-select select {
    padding: 6px 26px 6px 10px;
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px;
    outline: none;
    font-family: inherit;
}
.reports-year-select select:focus { border-color: var(--accent); }
.reports-header-edit {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
}
.reports-header-edit:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-color: var(--accent);
}
.reports-header-edit svg { stroke: currentColor; flex-shrink: 0; }

/* ===== Вкладки ===== */
.reports-tabs {
    display: flex;
    gap: 6px;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.rep-tablink {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-tertiary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.rep-tablink svg { stroke: currentColor; flex-shrink: 0; }
.rep-tablink:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.rep-tablink.active { color: white; background: var(--accent); border-color: var(--accent); }

.rep-content { display: none; }
.rep-content.active { display: block; animation: repFadeIn 0.2s ease; }
@keyframes repFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== Календарь ===== */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.calendar-header-text { flex: 1; min-width: 0; }
.calendar-header h2 { margin: 0 0 4px 0; font-size: 20px; }
.calendar-subtitle {
    color: var(--text-tertiary);
    font-size: 14px;
    margin: 0;
    line-height: 1.5;
}
.calendar-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    flex-shrink: 0;
}
.calendar-toggle svg { stroke: currentColor; flex-shrink: 0; }
.calendar-toggle:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border-color: var(--accent);
}
.calendar-toggle.is-active {
    color: var(--accent);
    background: rgba(124,58,237,0.1);
    border-color: rgba(124,58,237,0.4);
}

.calendar-events { display: flex; flex-direction: column; gap: 24px; }
.calendar-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
}
.calendar-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-right-color: var(--accent);
    border-radius: 50%;
    animation: calendarSpin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes calendarSpin { to { transform: rotate(360deg); } }

.calendar-empty-filtered {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
    font-size: 14px;
    font-style: italic;
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.calendar-empty-filtered p { margin: 0; }

.calendar-month-name {
    font-size: 14px;
    font-weight: 700;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.calendar-event {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 14px;
    margin-bottom: 6px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--border);
    transition: var(--transition);
}
.calendar-event:hover { background: var(--bg-tertiary); }
.calendar-event.event-done { opacity: 0.55; }
.calendar-event.event-done .event-title {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

.event-checkbox { display: flex; align-items: center; cursor: pointer; }
.event-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--accent);
    cursor: pointer;
}
.event-day {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    min-width: 32px;
    text-align: center;
    line-height: 1.1;
}
.event-body { flex: 1; min-width: 0; }
.event-title { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.event-desc { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

.event-vat { border-left-color: #ef4444; }
.event-usn_advance { border-left-color: #f59e0b; }
.event-usn_decl { border-left-color: #10b981; }
.event-profit { border-left-color: #3b82f6; }
.event-ndfl { border-left-color: #8b5cf6; }
.event-ndfl_pay { border-left-color: #a78bfa; }
.event-ip_contrib { border-left-color: #06b6d4; }
.event-ip_contrib_1pct { border-left-color: #22d3ee; }
.event-rsv { border-left-color: #ec4899; }
.event-ndfl6 { border-left-color: #f97316; }
.event-sFR_monthly { border-left-color: #14b8a6; }
.event-efs1 { border-left-color: #84cc16; }
.event-tax_notice { border-left-color: #8b5cf6; background: rgba(139,92,246,0.06); }

/* ===== Налоги ===== */
.tax-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.tax-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.tax-card-contrib,
.tax-card-contrib-emp,
.tax-card-summary {
    grid-column: 1 / -1;
    margin-bottom: 16px;
}
.tax-card-contrib { border-left: 3px solid #06b6d4; }
.tax-card-contrib-emp { border-left: 3px solid #ec4899; }

.tax-card-header {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.tax-card-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.tax-card-badge {
    display: inline-block;
    padding: 3px 10px;
    font-size: 11px;
    font-weight: 700;
    color: #c4b5fd;
    background: rgba(124,58,237,0.15);
    border: 1px solid rgba(124,58,237,0.3);
    border-radius: 100px;
    white-space: nowrap;
}
.tax-card-body { padding: 16px 20px; }

.tax-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--border);
}
.tax-row:last-child { border-bottom: none; }
.tax-row-label { font-size: 13px; color: var(--text-secondary); }
.tax-row-value {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.tax-row-total {
    border-top: 2px solid var(--border);
    border-bottom: none;
    padding-top: 12px;
    margin-top: 8px;
}
.tax-row-total .tax-row-label { font-size: 14px; color: var(--text-primary); }
.tax-row-total .tax-row-value { font-size: 18px; }
.tax-income { color: var(--success); }
.tax-expense { color: var(--danger); }
.tax-accent { color: var(--accent); }
.tax-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 12px 0 0 0;
    font-style: italic;
    line-height: 1.5;
}

.tax-card-summary {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(124,58,237,0.06) 100%);
    border-color: rgba(124,58,237,0.3);
}
.tax-card-summary .tax-card-body { padding: 20px 24px; }

.tax-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}
.tax-total-label-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}
.tax-total-label {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}
.tax-total-sublabel { font-size: 12px; color: var(--text-tertiary); }
.tax-total-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    white-space: nowrap;
}
.tax-notes {
    margin: 16px 0 0 0;
    padding: 12px 0 0 0;
    border-top: 1px dashed var(--border);
    font-size: 12px;
    color: var(--text-tertiary);
    list-style: none;
    line-height: 1.6;
}
.tax-notes li { margin-bottom: 4px; }
.tax-notes li:last-child { margin-bottom: 0; }

/* ===== Взносы — карточки ===== */
.contrib-breakdown {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 14px;
}
.contrib-item {
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.contrib-item-label {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
    min-height: 2.5em;
}
.contrib-item-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.contrib-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 16px;
}
.contrib-summary-single {
    grid-template-columns: 1fr;
    margin-bottom: 14px;
}
.contrib-summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-primary);
    min-width: 0;
}
.contrib-summary-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
    white-space: nowrap;
}
.contrib-summary-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contrib-summary-paid { color: var(--success); }
.contrib-summary-topay { color: var(--warning); }

.contrib-quarters {
    margin: 16px 0;
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.contrib-quarters-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 12px;
}
.contrib-quarters-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}
.contrib-q-card {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.contrib-q-label {
    font-size: 10px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
    margin-bottom: 4px;
}
.contrib-q-amount {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    margin-bottom: 8px;
}
.contrib-q-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}
.contrib-q-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #06b6d4, #22d3ee);
    border-radius: 2px;
    transition: width 0.4s ease;
}
.contrib-q-bar-fill-emp { background: linear-gradient(90deg, #ec4899, #f472b6); }

.contrib-details {
    margin-top: 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
.contrib-details-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--bg-primary);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    list-style: none;
    user-select: none;
    transition: background 0.15s;
}
.contrib-details-summary::-webkit-details-marker { display: none; }
.contrib-details-summary:hover { background: var(--bg-tertiary); }
.contrib-details-chevron {
    stroke: currentColor;
    transition: transform 0.2s ease;
}
.contrib-details[open] .contrib-details-chevron { transform: rotate(180deg); }

.contrib-payments-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.contrib-payments-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.contrib-payments-table th,
.contrib-payments-table td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}
.contrib-payments-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-tertiary);
    font-weight: 700;
    background: rgba(124,58,237,0.04);
    white-space: nowrap;
}
.contrib-payments-table td { color: var(--text-secondary); }
.contrib-payments-table .contrib-num {
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text-primary);
}

.src-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.src-bank { background: rgba(59,130,246,0.15); color: #60a5fa; }
.src-manual { background: rgba(245,158,11,0.15); color: #fbbf24; }

.contrib-empty {
    padding: 14px 16px;
    background: rgba(124,58,237,0.05);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.6;
    font-style: italic;
    margin-top: 12px;
}
.contrib-empty a { color: var(--accent); text-decoration: none; }
.contrib-empty a:hover { text-decoration: underline; }

/* ===== Отчётность ===== */
.docs-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
    overflow: hidden;
}
.docs-section-muted { background: var(--bg-primary); border-style: dashed; }
.docs-section-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}
.docs-section-header h3 {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.docs-section-hint {
    margin: 0;
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
}
.docs-section-body { padding: 16px 20px; }

.docs-stats {
    display: flex;
    gap: 32px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}
.docs-stat { display: flex; flex-direction: column; gap: 4px; }
.docs-stat-label {
    font-size: 11px;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-weight: 600;
}
.docs-stat-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.docs-stat-income { color: var(--success); }
.docs-stat-expense { color: var(--danger); }

.docs-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.docs-btn svg { stroke: currentColor; flex-shrink: 0; }
.docs-btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.docs-btn-primary:hover { background: var(--primary); border-color: var(--primary); }
.docs-btn-secondary { background: var(--bg-primary); color: var(--text-secondary); }
.docs-btn-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent);
}

.docs-btn-mini {
    padding: 5px 10px;
    font-size: 11px;
    font-weight: 700;
    font-family: inherit;
    letter-spacing: 0.3px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.docs-btn-mini:hover:not(:disabled) {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}
.docs-btn-mini:disabled { opacity: 0.4; cursor: not-allowed; }

.docs-notices {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}
.docs-notice {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s;
}
.docs-notice:hover { border-color: rgba(124,58,237,0.3); }
.docs-notice-info { flex: 1; min-width: 0; }
.docs-notice-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.docs-notice-deadline { font-size: 12px; color: var(--text-tertiary); }
.docs-notice-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}
.docs-notice-amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    min-width: 90px;
    text-align: right;
}
.docs-notice-actions { display: flex; gap: 4px; }

.docs-note {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0;
    padding: 12px 14px;
    background: rgba(124,58,237,0.04);
    border-left: 2px solid rgba(124,58,237,0.3);
    border-radius: var(--radius-sm);
}

.docs-list { display: flex; flex-direction: column; gap: 8px; }
.docs-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s;
    flex-wrap: wrap;
}
.docs-item:hover { border-color: rgba(124,58,237,0.3); }
.docs-item-info { flex: 1; min-width: 200px; }
.docs-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.docs-item-meta { font-size: 12px; color: var(--text-tertiary); }

.docs-empty {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    color: var(--text-tertiary);
    font-size: 13px;
    line-height: 1.5;
}
.docs-empty svg { stroke: currentColor; flex-shrink: 0; opacity: 0.6; }
.docs-empty p { margin: 0; }
.docs-empty a { color: var(--accent); text-decoration: none; font-weight: 500; }
.docs-empty a:hover { text-decoration: underline; }

/* ===== Мобильная адаптация отчётов ===== */
@media (max-width: 900px) {
    .reports-header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        padding: 14px 16px;
    }
    .reports-header-info { gap: 14px; }
    .reports-header-item { flex: 1 1 auto; min-width: 120px; }
    .reports-header-reason { max-width: 100%; font-size: 12px; }
    .reports-header-total-item {
        padding-left: 0;
        border-left: none;
        flex-basis: 100%;
        margin-top: 4px;
        padding-top: 12px;
        border-top: 1px dashed var(--border);
    }
    .reports-header-total { font-size: 20px; }
    .reports-header-actions { width: 100%; justify-content: space-between; }
    .reports-year-select select { height: 38px; font-size: 16px; }
    .reports-header-edit { padding: 8px 12px; }

    .reports-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 4px;
        gap: 4px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .reports-tabs::-webkit-scrollbar { display: none; }
    .rep-tablink { flex-shrink: 0; padding: 9px 14px; font-size: 12px; }

    .calendar-header { flex-direction: column; align-items: stretch; gap: 12px; }
    .calendar-header h2 { font-size: 17px; }
    .calendar-subtitle { font-size: 12px; }
    .calendar-toggle {
        width: 100%;
        justify-content: center;
        padding: 10px 16px;
        font-size: 13px;
    }
    .calendar-event { padding: 10px 12px; gap: 10px; }
    .event-day { font-size: 18px; min-width: 28px; }
    .event-title { font-size: 13px; }
    .event-desc { font-size: 11px; }
    .calendar-empty-filtered { padding: 30px 16px; font-size: 13px; }
    .calendar-loading { padding: 30px 16px; font-size: 13px; }

    .tax-grid { grid-template-columns: 1fr; gap: 12px; }
    .tax-card-header { padding: 12px 16px; }
    .tax-card-body { padding: 14px 16px; }
    .tax-card-summary .tax-card-body { padding: 16px 18px; }
    .tax-total { gap: 12px; }
    .tax-total-value { font-size: 24px; }

    .contrib-breakdown {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .contrib-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        padding: 10px 14px;
    }
    .contrib-item-label {
        margin-bottom: 0;
        font-size: 13px;
        flex: 1;
        min-width: 0;
        min-height: 0;
    }
    .contrib-item-value {
        font-size: 15px;
        flex-shrink: 0;
    }

    .contrib-summary { grid-template-columns: 1fr; }
    .contrib-summary-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: baseline;
        gap: 10px;
        padding: 10px 14px;
    }
    .contrib-summary-label { font-size: 12px; }
    .contrib-summary-value { font-size: 15px; }

    .contrib-quarters-grid { grid-template-columns: repeat(2, 1fr); }
    .contrib-q-amount { font-size: 14px; }

    .contrib-payments-table th,
    .contrib-payments-table td { padding: 8px 10px; font-size: 12px; }
    .src-badge { font-size: 10px; padding: 2px 7px; }

    .docs-section-header { padding: 14px 16px; }
    .docs-section-body { padding: 14px 16px; }
    .docs-stats { gap: 18px; margin-bottom: 14px; }
    .docs-stat-value { font-size: 18px; }
    .docs-btn { width: 100%; justify-content: center; }

    .docs-notice { flex-direction: column; align-items: stretch; gap: 10px; }
    .docs-notice-right { justify-content: space-between; width: 100%; }
    .docs-notice-amount { text-align: left; min-width: 0; font-size: 18px; }

    .docs-item { flex-wrap: wrap; }
    .docs-item .docs-btn { width: auto; padding: 8px 16px; }
}

@media (max-width: 480px) {
    .reports-header-info { flex-direction: column; align-items: stretch; gap: 10px; }
    .reports-header-item {
        flex-direction: row;
        justify-content: space-between;
        align-items: baseline;
        gap: 8px;
    }
    .reports-header-item.reports-header-total-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .reports-header-label { font-size: 10px; }
    .reports-header-value { font-size: 13px; text-align: right; }

    .reports-header-actions { flex-wrap: wrap; gap: 8px; }
    .reports-year-select { flex: 1; }
    .reports-year-select select { width: 100%; }
    .reports-header-edit { flex: 0 0 auto; }

    .tax-total-value { font-size: 22px; }
    .contrib-summary-value { font-size: 14px; }
    .contrib-q-amount { font-size: 13px; }

    .docs-stat-value { font-size: 16px; }
    .docs-stat-label { font-size: 10px; }
    .docs-item { flex-direction: column; align-items: stretch; }
    .docs-item .docs-btn { width: 100%; justify-content: center; }
}


/* ============================================================ */
/*  SETTINGS — Настройки                                        */
/* ============================================================ */

/* ---- Toast (уведомление о сохранении) ---- */
.settings-toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}
.settings-toast svg { flex-shrink: 0; stroke: currentColor; fill: none; }
.settings-toast-success {
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.4);
    border-left: 4px solid var(--success);
    color: var(--success);
}
.settings-toast-error {
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.4);
    border-left: 4px solid var(--danger);
    color: #fca5a5;
}

/* ---- Онбординг (выбор типа организации) ---- */
.settings-onboarding {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 40px 20px;
}
.settings-onboarding-card {
    max-width: 640px;
    width: 100%;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
}
.settings-onboarding-card h2 {
    margin: 0 0 12px 0;
    font-size: 22px;
    color: var(--text-primary);
}
.settings-onboarding-desc {
    color: var(--text-tertiary);
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 28px;
}
.settings-onboarding-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.settings-onboarding-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 28px 20px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.2s;
    text-align: center;
}
.settings-onboarding-btn:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(124,58,237,0.2);
}
.settings-onboarding-btn svg { stroke: var(--accent); margin-bottom: 4px; }
.settings-onboarding-btn-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
}
.settings-onboarding-btn-sub {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* ---- Вкладки (переопределяют базовые .tablink из style.css) ---- */
.settings-tabs {
    display: flex;
    gap: 6px;
    padding: 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.settings-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: var(--text-tertiary);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}
.settings-tab svg { stroke: currentColor; flex-shrink: 0; }
.settings-tab:hover { color: var(--text-primary); background: var(--bg-tertiary); }
.settings-tab.active {
    color: white;
    background: var(--accent);
    border-color: var(--accent);
}

.settings-content { display: none; }
.settings-content.active { display: block; animation: settingsFadeIn 0.2s ease; }
@keyframes settingsFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Карточки ---- */
.settings-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}
.settings-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.settings-card-header h2 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}
.settings-card-header p {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
}
.settings-card-body { padding: 20px; }

/* ---- Форма ---- */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.settings-grid-full { grid-column: 1 / -1; }
.settings-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.settings-field label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.settings-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}
.settings-input::placeholder { color: var(--text-muted); }
.settings-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124,58,237,0.15);
}
.settings-input:disabled,
.settings-input-disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-tertiary);
}
.settings-textarea {
    resize: vertical;
    min-height: 60px;
    line-height: 1.5;
}
.settings-help {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.settings-help-block {
    margin-top: 14px;
    padding: 10px 14px;
    background: rgba(124,58,237,0.05);
    border-left: 2px solid rgba(124,58,237,0.3);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}
.settings-help-block a { color: var(--accent); text-decoration: none; }
.settings-help-block a:hover { text-decoration: underline; }
.settings-muted { color: var(--text-muted); font-style: italic; }

/* ---- Кнопки ---- */
.settings-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    box-sizing: border-box;
    text-decoration: none;
}
.settings-btn svg { stroke: currentColor; fill: none; flex-shrink: 0; }
.settings-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}
.settings-btn-primary:hover { background: var(--primary); border-color: var(--primary); }
.settings-btn-secondary {
    background: var(--bg-primary);
    color: var(--text-secondary);
}
.settings-btn-secondary:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-color: var(--accent);
}
.settings-btn-danger {
    background: transparent;
    border-color: rgba(239,68,68,0.3);
    color: #f87171;
    padding: 0 12px;
}
.settings-btn-danger:hover {
    background: rgba(239,68,68,0.1);
    border-color: rgba(239,68,68,0.5);
}

.settings-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 0;
    position: sticky;
    bottom: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

/* ---- Банковские счета — как в форме контрагента ---- */
.settings-banks {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
}
.settings-bank-row {
    display: grid;
    grid-template-columns:
        32px
        minmax(140px, 1.5fr)
        minmax(90px, 1fr)
        minmax(160px, 2fr)
        minmax(140px, 1.5fr)
        36px;
    gap: 8px;
    align-items: center;
    padding: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s;
}
.settings-bank-row.has-error {
    border-color: rgba(239,68,68,0.5);
    background: rgba(239,68,68,0.03);
}
.settings-bank-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-align: center;
}

/* Обёртка «исчезает» — её дети участвуют в grid родителя напрямую */
.settings-bank-fields {
    display: contents;
}

/* Отменяем прежние span-правила: теперь всё в одну строку */
.settings-bank-account,
.settings-bank-name {
    grid-column: auto;
}

.settings-bank-remove {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}
.settings-bank-remove:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}
.settings-bank-remove svg { stroke: currentColor; fill: none; }

.settings-bank-validation {
    grid-column: 2 / -1;
    font-size: 11px;
    color: #f87171;
    line-height: 1.5;
    margin-top: 4px;
}
.settings-bank-validation:empty { display: none; }

/* ---- Шаблоны ---- */
.settings-templates {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}
/* Три шаблона в одну строку (Общие шаблоны) */
.settings-templates--row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.settings-template-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s;
    min-width: 0;
    overflow: hidden;
}
.settings-template-item:hover { border-color: rgba(124,58,237,0.3); }
.settings-template-info {
    flex: 1 1 200px;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
    margin-bottom: 0;
}
.settings-template-name {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.settings-template-file {
    display: block;
    font-size: 12px;
    color: var(--text-tertiary);
    word-break: normal;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.settings-template-file a {
    display: inline;
    color: var(--accent);
    text-decoration: none;
}
.settings-template-file a:hover { text-decoration: underline; }
.settings-template-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 6px;
    flex-wrap: nowrap;
    margin-left: auto;
}

.settings-template-item .settings-attachments-panel {
    flex-basis: 100%;
    width: 100%;
}

.settings-attachments-panel {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
}
.settings-attachments-hint {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
    margin-bottom: 10px;
}
.settings-attachments-hint code {
    background: rgba(124,58,237,0.15);
    color: #c4b5fd;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
}
.settings-attachments-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}
.settings-attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}
.settings-att-icon { flex-shrink: 0; stroke: var(--text-tertiary); fill: none; }
.settings-attachment-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.settings-attachment-delete {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.settings-attachment-delete:hover { background: var(--danger); border-color: var(--danger); color: white; }
.settings-attachment-delete svg { stroke: currentColor; fill: none; }
.settings-attachments-empty {
    padding: 12px;
    text-align: center;
    font-size: 12px;
    font-style: italic;
    color: var(--text-muted);
    background: var(--bg-primary);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}
.settings-add-type {
    display: flex;
    gap: 8px;
}
.settings-add-type .settings-input { flex: 1; }

/* ---- Маски нумерации ---- */
.settings-masks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}
.settings-mask-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.settings-mask-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.settings-mask-label label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}
.settings-mask-hint {
    font-size: 11px;
    color: var(--text-muted);
}
.settings-mask-hint code {
    background: var(--bg-primary);
    color: var(--accent);
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
}
.settings-mask-vars {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.settings-var-btn {
    padding: 4px 10px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 600;
    color: var(--accent);
    background: rgba(124,58,237,0.1);
    border: 1px solid rgba(124,58,237,0.3);
    border-radius: 100px;
    cursor: pointer;
    transition: var(--transition);
}
.settings-var-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ---- Раскрывающийся блок переменных ---- */
.settings-details {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}
.settings-details summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    list-style: none;
    user-select: none;
    transition: background 0.15s;
}
.settings-details summary::-webkit-details-marker { display: none; }
.settings-details summary::after {
    content: '';
    margin-left: auto;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid var(--text-tertiary);
    transition: transform 0.2s;
}
.settings-details[open] summary::after { transform: rotate(180deg); }
.settings-details summary:hover { background: var(--bg-tertiary); }
.settings-details summary svg { stroke: var(--accent); fill: none; flex-shrink: 0; }
.settings-details-hint {
    margin-left: auto;
    margin-right: 10px;
    font-size: 11px;
    font-weight: 400;
    color: var(--text-tertiary);
    font-style: italic;
}
.settings-vars-block {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.settings-vars-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.settings-vars-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-tertiary);
}
.settings-vars-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.copy-variable {
    padding: 5px 10px;
    font-size: 12px;
    background: var(--bg-primary);
    color: var(--accent);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'SF Mono', Consolas, monospace;
    font-weight: 500;
}
.copy-variable:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* ---- Чекбокс-карточка ---- */
.settings-checkbox-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color 0.15s;
}
.settings-checkbox-card:hover { border-color: var(--accent); }
.settings-checkbox-card input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 2px 0 0;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.settings-checkbox-card-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.settings-checkbox-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}
.settings-checkbox-card-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
}

/* ---- Ручные страховые взносы ---- */
.settings-manual-sv {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}
.settings-manual-sv-row {
    display: grid;
    grid-template-columns: 100px 1fr 1fr 36px;
    gap: 8px;
    align-items: center;
    padding: 10px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.settings-manual-sv-year { text-align: center; }
.settings-manual-sv-date { text-align: center; }
.settings-manual-sv-amount { text-align: right; }
.settings-manual-sv-remove {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.settings-manual-sv-remove:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}
.settings-manual-sv-remove svg { stroke: currentColor; fill: none; }
.settings-manual-sv-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 24px;
    font-size: 13px;
    font-style: italic;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
}
.settings-manual-sv-empty svg { stroke: var(--text-muted); fill: none; }
.settings-manual-sv-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 12px 16px;
    margin-top: 12px;
    background: rgba(16,185,129,0.05);
    border-left: 3px solid var(--success);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
}
.settings-manual-sv-total strong {
    font-size: 16px;
    color: var(--success);
    font-variant-numeric: tabular-nums;
}

/* ---- Инструменты ---- */
.settings-tool-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 10px;
    transition: border-color 0.15s;
    text-decoration: none;
}
.settings-tool-row:hover { border-color: var(--accent); }
.settings-tool-row-link:hover { transform: translateY(-1px); }
.settings-tool-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(124,58,237,0.1);
    border-radius: var(--radius-sm);
}
.settings-tool-icon svg { stroke: var(--accent); fill: none; }
.settings-tool-info { flex: 1; min-width: 0; }
.settings-tool-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}
.settings-tool-desc {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.4;
}
.settings-tool-arrow { flex-shrink: 0; stroke: var(--text-tertiary); fill: none; }
.settings-tool-result {
    font-size: 13px;
    padding: 0 16px;
    margin-bottom: 10px;
    min-height: 0;
}
.settings-tool-result:not(:empty) {
    padding: 10px 16px;
    background: rgba(124,58,237,0.05);
    border-radius: var(--radius-sm);
}

/* ---- Мобильная адаптация ---- */
@media (max-width: 900px) {
    .settings-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        padding: 4px;
        gap: 4px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .settings-tabs::-webkit-scrollbar { display: none; }
    .settings-tab {
        flex-shrink: 0;
        padding: 9px 14px;
        font-size: 12px;
    }

    .settings-onboarding { padding: 20px 16px; }
    .settings-onboarding-card { padding: 24px 20px; }
    .settings-onboarding-card h2 { font-size: 18px; }
    .settings-onboarding-desc { font-size: 13px; margin-bottom: 20px; }
    .settings-onboarding-buttons { grid-template-columns: 1fr; gap: 10px; }
    .settings-onboarding-btn { padding: 20px 16px; }
    .settings-onboarding-btn-title { font-size: 20px; }

    .settings-card-header { padding: 14px 16px; }
    .settings-card-header h2 { font-size: 14px; }
    .settings-card-body { padding: 16px; }

    .settings-grid { grid-template-columns: 1fr; gap: 14px; }
    .settings-field { gap: 4px; }

    .settings-input { font-size: 16px; }

    .settings-actions {
        padding: 12px 0;
        position: sticky;
        bottom: 60px;
        background: var(--bg-primary);
        z-index: 10;
    }
    .settings-actions .settings-btn {
        width: 100%;
        height: 44px;
    }

        /* Банковские счета — как в форме контрагента */
    .settings-bank-row {
        grid-template-columns: 1fr 40px;
        grid-template-areas:
            "account    remove"
            "bic        remove"
            "name       remove"
            "corr       remove"
            "validation validation";
        gap: 6px 8px;
        padding: 10px;
        align-items: stretch;
    }
    .settings-bank-num { display: none; }
    .settings-bank-account { grid-area: account; }
    .settings-bank-bic     { grid-area: bic; }
    .settings-bank-name    { grid-area: name; }
    .settings-bank-corr    { grid-area: corr; }
    .settings-bank-remove {
        grid-area: remove;
        width: 40px;
        height: 100%;
        min-height: 40px;
        align-self: stretch;
        justify-self: stretch;
        background: rgba(239,68,68,0.1);
        border-color: rgba(239,68,68,0.3);
        color: #f87171;
        border-radius: var(--radius-sm);
    }
    .settings-bank-remove::after { display: none; }
    .settings-bank-validation {
        grid-area: validation;
        margin-top: 0;
    }
    .settings-bank-row .settings-input {
        font-size: 16px;
        min-height: 42px;
    }

    /* Шаблоны */
    .settings-template-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }
    .settings-template-actions .delete-type-btn {
        grid-column: 1 / -1;
        width: 100%;
    }
    .settings-template-actions .delete-type-btn::after {
        content: 'Удалить тип';
        margin-left: 6px;
        font-family: inherit;
        font-weight: 500;
    }

    /* Маски */
    .settings-mask-vars { gap: 4px; }
    .settings-var-btn { font-size: 11px; padding: 5px 10px; }

    /* Переменные */
    .settings-vars-grid { gap: 4px; }
    .copy-variable { font-size: 11px; padding: 5px 8px; }
    .settings-details summary { padding: 14px 16px; font-size: 13px; }
    .settings-details-hint { display: none; }
    .settings-vars-block { padding: 14px 16px; }

    /* Ручные СВ */
    .settings-manual-sv-row {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
        padding: 10px;
    }
    .settings-manual-sv-year { grid-column: 1 / 2; }
    .settings-manual-sv-date { grid-column: 2 / 3; }
    .settings-manual-sv-amount { grid-column: 1 / -1; text-align: left; }
    .settings-manual-sv-remove {
        grid-column: 1 / -1;
        width: 100%;
        height: 36px;
        background: rgba(239,68,68,0.1);
        border-color: rgba(239,68,68,0.3);
        color: #f87171;
    }
    .settings-manual-sv-remove::after {
        content: 'Удалить платёж';
        margin-left: 8px;
        font-family: inherit;
        font-weight: 500;
        font-size: 13px;
    }
    .settings-manual-sv-total {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    /* Инструменты */
    .settings-tool-row { flex-wrap: wrap; gap: 10px; }
    .settings-tool-row .settings-btn { width: 100%; height: 40px; }
    .settings-tool-info { flex-basis: 100%; order: 3; }
    .settings-tool-icon { order: 1; }
    .settings-tool-arrow { order: 2; margin-left: auto; }
    .settings-tool-row .settings-btn { order: 4; }
}

@media (max-width: 420px) {
    .settings-tab {
        padding: 8px 12px;
        font-size: 11px;
        gap: 6px;
    }
    .settings-tab svg { width: 14px; height: 14px; }
    .settings-onboarding-btn { padding: 16px 14px; }
    .settings-onboarding-btn svg { width: 28px; height: 28px; }
    .settings-onboarding-btn-title { font-size: 18px; }
    .settings-onboarding-btn-sub { font-size: 11px; }
    .settings-card-body { padding: 14px; }
    .settings-actions { bottom: 56px; }
}


/* ============================================================ */
/*  ARCHIVE — Архив (страница .archive-page)                    */
/* ============================================================ */

.archive-years {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.archive-years .year-tab {
    padding: 10px 22px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}
.archive-years .year-tab:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.archive-years .year-tab.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Вкладки "Договоры / Счета / Акты" —
   переопределяем .doc-tabs/.doc-tab из style.css,
   сохраняя оригинальные цвета (border #475569, bg #2a2a2a). */
.archive-page .doc-tabs {
    display: flex;
    gap: 8px;
    margin: 20px 0;
    border-bottom: 1px solid #475569;
    padding-bottom: 8px;
}
.archive-page .doc-tab {
    padding: 8px 20px;
    background: #2a2a2a;
    color: #94a3b8;
    border: 1px solid #475569;
    border-radius: 6px 6px 0 0;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
}
.archive-page .doc-tab.active {
    background: #7C3AED;
    color: white;
    border-color: #7C3AED;
}
.archive-page .doc-tab:hover:not(.active) {
    background: #3a3a4a;
    color: #f8fafc;
}

/* status-in_progress (с underscore) — отсутствует в style.css,
   но используется в archive. Дублируем. */
.archive-page .status-in_progress {
    background: #f59e0b;
}

/* SVG иконки в кнопках DOCX/PDF принудительно приглушены —
   сохранение оригинального поведения. */
.archive-page .action-btn.pdf svg,
.archive-page .action-btn.docx svg {
    stroke: #94a3b8 !important;
}

/* Строка "По запросу ничего не найдено" */
.archive-page .no-results {
    text-align: center;
    padding: 30px;
    color: var(--text-tertiary);
}

/* Мобильная адаптация archive */
@media (max-width: 900px) {
    .archive-years {
        gap: 6px;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 4px;
    }
    .archive-years::-webkit-scrollbar { display: none; }
    .archive-years .year-tab {
        flex-shrink: 0;
        padding: 8px 16px;
        font-size: 13px;
    }
    .archive-page .doc-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .archive-page .doc-tabs::-webkit-scrollbar { display: none; }
    .archive-page .doc-tab {
        flex-shrink: 0;
        padding: 7px 16px;
        font-size: 13px;
    }
}


/* ============================================================ */
/*  DOCUMENT-FORM — форма счёта                                 */
/*  Всё содержимое страницы обёрнуто в .document-form-page       */
/* ============================================================ */

.document-form-page .form-container {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.document-form-page fieldset {
    padding: 20px;
    margin-bottom: 20px;
}

.document-form-page .form-field input,
.document-form-page .form-field select,
.document-form-page .form-field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
}
.document-form-page .form-field input:focus,
.document-form-page .form-field select:focus,
.document-form-page .form-field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.2);
}

/* Чекбокс-карточка "+ Акт" */
.document-form-page .checkbox-inline {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s;
}
.document-form-page .checkbox-inline:hover { border-color: var(--accent); }
.document-form-page .checkbox-inline input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 1px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.document-form-page .checkbox-inline span {
    display: block;
    line-height: 1.5;
    min-width: 0;
}
.document-form-page .checkbox-inline strong {
    color: var(--text-primary);
    font-size: 14px;
    display: block;
    margin-bottom: 2px;
}
.document-form-page .checkbox-inline small {
    color: var(--text-tertiary);
    font-size: 12px;
    display: block;
}

/* Позиции — grid-строка */
.document-form-page .item-row {
    position: relative;
    margin-bottom: 10px;
}
.document-form-page .form-row {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 40px;
    gap: 10px;
    align-items: end;
}
.document-form-page .form-row > .form-field { min-width: 0; }
.document-form-page .form-row .remove-item {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    align-self: end;
    flex-shrink: 0;
}
.document-form-page .form-row .remove-item svg {
    stroke: currentColor;
    fill: none;
    pointer-events: none;
}
.document-form-page .form-row .remove-item:hover {
    background: var(--danger);
    color: white;
}

/* Панель переменных */
.document-form-page .variables-details {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
    overflow: hidden;
}
.document-form-page .variables-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background 0.15s;
}
.document-form-page .variables-summary::-webkit-details-marker { display: none; }
.document-form-page .variables-summary:hover { background: rgba(124,58,237,0.06); }
.document-form-page .variables-summary-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 0;
}
.document-form-page .variables-summary-label svg {
    stroke: var(--accent);
    fill: none;
    flex-shrink: 0;
}
.document-form-page .variables-chevron {
    stroke: currentColor;
    fill: none;
    color: var(--text-tertiary);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.document-form-page .variables-details[open] .variables-chevron { transform: rotate(180deg); }
.document-form-page .variables-panel-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}
.document-form-page .variables-panel-buttons .var-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}
.document-form-page .variables-panel-buttons .var-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Итого по позициям */
.document-form-page .items-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.document-form-page .button-add-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    background: transparent;
    border: 1px dashed var(--accent);
    color: var(--accent);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.document-form-page .button-add-row svg { stroke: currentColor; fill: none; }
.document-form-page .button-add-row:hover {
    background: rgba(124,58,237,0.1);
    border-style: solid;
}
.document-form-page .items-total {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.document-form-page .items-total-label {
    font-size: 13px;
    color: var(--text-tertiary);
}
.document-form-page .items-total-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--success);
    font-variant-numeric: tabular-nums;
}

/* Панель акта */
.document-form-page .act-panel {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-left: 3px solid #ec4899;
    border-radius: var(--radius);
}
.document-form-page .act-panel-hint {
    padding: 10px 12px;
    background: rgba(236,72,153,0.08);
    border-left: 2px solid #ec4899;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
    margin-bottom: 14px;
}

/* Автодополнение */
.document-form-page .autocomplete-suggestions,
.document-form-page .unit-autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    margin-top: 2px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.document-form-page .autocomplete-suggestions > div,
.document-form-page .unit-autocomplete-suggestions > div {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.document-form-page .autocomplete-suggestions > div:last-child,
.document-form-page .unit-autocomplete-suggestions > div:last-child { border-bottom: none; }
.document-form-page .autocomplete-suggestions > div:hover,
.document-form-page .unit-autocomplete-suggestions > div:hover {
    background: var(--bg-tertiary);
}

/* Фикс-бар (скрыт на десктопе) */
.document-form-page .form-fixed-bar { display: none; }

/* Мобильная адаптация */
@media (max-width: 900px) {
    .document-form-page .form-container {
        padding: 14px;
        border-radius: var(--radius);
    }
    .document-form-page fieldset {
        padding: 14px;
        margin-bottom: 14px;
    }
    .document-form-page legend {
        font-size: 14px;
        padding: 4px 10px;
    }
    .document-form-page .form-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    .document-form-page .form-field input,
    .document-form-page .form-field select {
        padding: 12px 14px;
        font-size: 16px;
        min-height: 44px;
    }
    .document-form-page .form-field small { font-size: 11px; }

    .document-form-page .checkbox-inline { padding: 12px; }
    .document-form-page .checkbox-inline input[type="checkbox"] {
        width: 22px;
        height: 22px;
    }

    .document-form-page .variables-summary-label { font-size: 12px; }
    .document-form-page .variables-panel-buttons { padding: 10px; gap: 5px; }
    .document-form-page .variables-panel-buttons .var-btn {
        font-size: 11px;
        padding: 6px 10px;
    }

    /* Позиции — карточки */
    .document-form-page .item-row {
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 12px;
        margin-bottom: 12px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    }
    .document-form-page .item-row:last-child { margin-bottom: 0; }
    .document-form-page .form-row {
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-areas:
            "purpose purpose purpose"
            "qty     unit    price";
        gap: 10px 8px;
        align-items: start;
    }
    .document-form-page .form-row > .form-field:nth-child(1) { grid-area: purpose; }
    .document-form-page .form-row > .form-field:nth-child(2) { grid-area: qty; }
    .document-form-page .form-row > .form-field:nth-child(3) { grid-area: unit; }
    .document-form-page .form-row > .form-field:nth-child(4) { grid-area: price; }
    .document-form-page .form-row .remove-item {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 28px;
        height: 28px;
        background: rgba(239,68,68,0.1);
        border-color: rgba(239,68,68,0.3);
        color: #f87171;
        align-self: auto;
    }
    .document-form-page .form-row .remove-item svg { width: 14px; height: 14px; }
    .document-form-page .form-row .remove-item:hover { background: var(--danger); color: white; }
    .document-form-page .form-field-purpose label { padding-right: 32px; }

    .document-form-page .form-field .purpose-input,
    .document-form-page .form-field .unit-input,
    .document-form-page .form-field .price-input,
    .document-form-page .form-field .quantity-input {
        padding: 10px 12px;
        font-size: 16px;
        min-height: 42px;
        box-sizing: border-box;
    }
    .document-form-page .form-field .quantity-input { text-align: center; }
    .document-form-page .form-field .price-input { text-align: right; }
    .document-form-page .form-field label {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        color: var(--text-tertiary);
        font-weight: 600;
    }

    .document-form-page .items-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-top: 12px;
        padding-top: 12px;
    }
    .document-form-page .button-add-row {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    .document-form-page .items-total {
        justify-content: space-between;
        padding: 10px 14px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
    }
    .document-form-page .items-total-label {
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
    }
    .document-form-page .items-total-value { font-size: 18px; }
    .document-form-page .act-panel { padding: 12px; }
    .document-form-page .act-panel-hint { font-size: 11px; }

    /* Скрываем статичные кнопки — они в фикс-баре */
    .document-form-page .form-actions { display: none; }

    /* Фикс-бар */
    .document-form-page .form-fixed-bar {
        display: flex;
        position: fixed;
        left: 0; right: 0;
        bottom: calc(58px + env(safe-area-inset-bottom, 0px));
        z-index: 2000;
        background: var(--bg-secondary);
        border-top: 2px solid var(--accent);
        box-shadow: 0 -6px 20px rgba(0, 0, 0, 0.35);
        padding: 10px 14px;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
    }
    .document-form-page .form-fixed-total {
        display: flex;
        flex-direction: column;
        gap: 1px;
        min-width: 0;
    }
    .document-form-page .form-fixed-total-label {
        font-size: 10px;
        color: var(--text-tertiary);
        text-transform: uppercase;
        letter-spacing: 0.3px;
        line-height: 1;
    }
    .document-form-page .form-fixed-total-value {
        font-size: 16px;
        font-weight: 700;
        color: var(--success);
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
        line-height: 1.2;
    }
    .document-form-page .form-fixed-actions {
        display: flex;
        gap: 6px;
        flex-shrink: 0;
    }
    .document-form-page .form-fixed-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        height: 40px;
        padding: 0 14px;
        border-radius: var(--radius);
        font-size: 13px;
        font-weight: 600;
        font-family: inherit;
        text-decoration: none;
        cursor: pointer;
        border: 1px solid var(--border);
        transition: background 0.15s, color 0.15s;
        white-space: nowrap;
    }
    .document-form-page .form-fixed-btn svg {
        stroke: currentColor;
        fill: none;
        flex-shrink: 0;
    }
    .document-form-page .form-fixed-btn-cancel {
        background: transparent;
        color: var(--text-secondary);
    }
    .document-form-page .form-fixed-btn-cancel:hover {
        background: var(--bg-tertiary);
        color: var(--text-primary);
    }
    .document-form-page .form-fixed-btn-save {
        background: var(--accent);
        border-color: var(--accent);
        color: white;
    }
    .document-form-page .form-fixed-btn-save:hover {
        background: var(--primary);
        border-color: var(--primary);
    }

    /* Автодополнение — крупнее */
    .document-form-page .autocomplete-suggestions > div,
    .document-form-page .unit-autocomplete-suggestions > div {
        padding: 12px 14px;
        font-size: 14px;
    }
}

/* Место внизу под фикс-бар (только на document-form) */
@media (max-width: 900px) {
    body:has(.document-form-page) .doki-contents {
        padding-bottom: calc(58px + 58px + 70px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

@media (max-width: 420px) {
    .document-form-page .form-row { gap: 8px 6px; }
    .document-form-page .form-field .purpose-input,
    .document-form-page .form-field .unit-input,
    .document-form-page .form-field .price-input,
    .document-form-page .form-field .quantity-input {
        padding: 10px;
        font-size: 15px;
    }
    .document-form-page .form-fixed-btn { padding: 0 12px; font-size: 12px; }
    .document-form-page .form-fixed-btn span { display: none; }
    .document-form-page .form-fixed-btn svg { width: 18px; height: 18px; }
    .document-form-page .form-fixed-btn-save span { display: inline; }
    .document-form-page .form-fixed-total-value { font-size: 15px; }
}


/* ============================================================ */
/*  CONTRACT-FORM — форма договора                              */
/*  Всё содержимое страницы обёрнуто в .contract-form-page       */
/* ============================================================ */

.contract-form-page .form-container {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.contract-form-page fieldset {
    padding: 20px;
    margin-bottom: 20px;
}
.contract-form-page .form-container fieldset {
    padding: 20px;
    margin-bottom: 20px;
}

.contract-form-page .form-field input[type="text"],
.contract-form-page .form-field input[type="number"],
.contract-form-page .form-field input[type="email"],
.contract-form-page .form-field input[type="password"],
.contract-form-page .form-field input[type="date"],
.contract-form-page .form-field input[type="tel"],
.contract-form-page .form-field input[type="url"],
.contract-form-page .form-field select,
.contract-form-page .form-field textarea {
    width: 100%;
    box-sizing: border-box;
}

/* Actions — override базового margin-top/gap */
.contract-form-page .form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

/* Периодический договор */
.contract-form-page .periodic-toggle {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 16px;
}
.contract-form-page .periodic-toggle input[type="checkbox"] {
    width: 18px !important;
    height: 18px !important;
    padding: 0 !important;
    margin: 2px 0 0 0 !important;
    min-width: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
    box-sizing: border-box;
}
.contract-form-page .periodic-toggle-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}
.contract-form-page .periodic-toggle-label strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}
.contract-form-page .periodic-toggle-label small {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
}
.contract-form-page .periodic-settings {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    padding-top: 8px;
}
.contract-form-page .periodic-status {
    margin-top: 18px;
    padding: 14px 16px;
    background: rgba(124,58,237,0.06);
    border: 1px solid rgba(124,58,237,0.2);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.contract-form-page .periodic-status-row {
    display: flex;
    gap: 8px;
    align-items: baseline;
    font-size: 13px;
}
.contract-form-page .periodic-status-label {
    color: var(--text-tertiary);
    min-width: 170px;
}
.contract-form-page .periodic-status-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* Приложения к типу */
.contract-form-page .type-attachment-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: var(--transition);
}
.contract-form-page .type-attachment-row:hover {
    border-color: rgba(124,58,237,0.4);
    background: rgba(124,58,237,0.04);
}
.contract-form-page .type-attachment-icon { font-size: 18px; flex-shrink: 0; }
.contract-form-page .type-attachment-name {
    flex: 1;
    min-width: 0;
    color: var(--text-secondary);
    font-size: 13px;
    word-break: break-all;
}
.contract-form-page .type-attachment-download {
    flex-shrink: 0;
    padding: 6px 14px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}
.contract-form-page .type-attachment-download:hover { background: var(--primary); }

/* Создание документов */
.contract-form-page .add-doc-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.contract-form-page .add-doc-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-size: 14px;
}
.contract-form-page .add-doc-btn:hover { background: var(--primary); }

.contract-form-page .doc-block {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    border-radius: var(--radius);
}
.contract-form-page .doc-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.contract-form-page .doc-block-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 600;
}
.contract-form-page .remove-doc-btn {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
}
.contract-form-page .remove-doc-btn:hover {
    background: var(--danger);
    color: white;
}

/* ============================================================ */
/*  ПОЗИЦИИ И ПРИВЯЗАННЫЙ АКТ ВНУТРИ ФОРМЫ ДОГОВОРА             */
/*  Идентично форме счёта (page-document-form.php)               */
/* ============================================================ */

.contract-form-page .doc-block .items-section { margin-top: 18px; }
.contract-form-page .doc-block .items-section-title {
    display: block;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

/* Панель переменных */
.contract-form-page .doc-block .variables-details {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
    overflow: hidden;
}
.contract-form-page .doc-block .variables-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background 0.15s;
}
.contract-form-page .doc-block .variables-summary::-webkit-details-marker { display: none; }
.contract-form-page .doc-block .variables-summary:hover { background: rgba(124,58,237,0.06); }
.contract-form-page .doc-block .variables-summary-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 0;
}
.contract-form-page .doc-block .variables-summary-label svg {
    stroke: var(--accent);
    fill: none;
    flex-shrink: 0;
}
.contract-form-page .doc-block .variables-chevron {
    stroke: currentColor;
    fill: none;
    color: var(--text-tertiary);
    flex-shrink: 0;
    transition: transform 0.2s ease;
}
.contract-form-page .doc-block .variables-details[open] .variables-chevron { transform: rotate(180deg); }
.contract-form-page .doc-block .variables-panel-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    background: var(--bg-primary);
}
.contract-form-page .doc-block .variables-panel-buttons .var-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    white-space: nowrap;
}
.contract-form-page .doc-block .variables-panel-buttons .var-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Позиции (grid-строка) */
.contract-form-page .doc-block .item-row {
    position: relative;
    margin-bottom: 10px;
}
.contract-form-page .doc-block .form-row {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) 40px;
    gap: 10px;
    align-items: end;
}
.contract-form-page .doc-block .form-row > .form-field { min-width: 0; }
.contract-form-page .doc-block .form-row .remove-item {
    width: 40px;
    height: 40px;
    padding: 0;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: var(--radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    align-self: end;
    flex-shrink: 0;
}
.contract-form-page .doc-block .form-row .remove-item svg {
    stroke: currentColor;
    fill: none;
    pointer-events: none;
}
.contract-form-page .doc-block .form-row .remove-item:hover {
    background: var(--danger);
    color: white;
}
.contract-form-page .doc-block .item-row .form-field label {
    font-weight: 500;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.3;
}

/* Автодополнение */
.contract-form-page .doc-block .autocomplete-suggestions,
.contract-form-page .doc-block .unit-autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    margin-top: 2px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.contract-form-page .doc-block .autocomplete-suggestions > div,
.contract-form-page .doc-block .unit-autocomplete-suggestions > div {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}
.contract-form-page .doc-block .autocomplete-suggestions > div:last-child,
.contract-form-page .doc-block .unit-autocomplete-suggestions > div:last-child { border-bottom: none; }
.contract-form-page .doc-block .autocomplete-suggestions > div:hover,
.contract-form-page .doc-block .unit-autocomplete-suggestions > div:hover {
    background: var(--bg-tertiary);
}

/* Футер позиций */
.contract-form-page .doc-block .items-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.contract-form-page .doc-block .button-add-row {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    background: transparent;
    border: 1px dashed var(--accent);
    color: var(--accent);
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
}
.contract-form-page .doc-block .button-add-row svg { stroke: currentColor; fill: none; }
.contract-form-page .doc-block .button-add-row:hover {
    background: rgba(124,58,237,0.1);
    border-style: solid;
}
.contract-form-page .doc-block .items-total {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.contract-form-page .doc-block .items-total-label {
    font-size: 13px;
    color: var(--text-tertiary);
}
.contract-form-page .doc-block .items-total-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--success);
    font-variant-numeric: tabular-nums;
}

/* Чекбокс "Создать привязанный акт" */
.contract-form-page .doc-block .act-fieldset {
    margin-top: 18px;
    padding: 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.contract-form-page .doc-block .act-fieldset legend {
    font-weight: 600;
    font-size: 14px;
    padding: 4px 12px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
}
.contract-form-page .doc-block .checkbox-inline {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s;
}
.contract-form-page .doc-block .checkbox-inline:hover { border-color: var(--accent); }
.contract-form-page .doc-block .checkbox-inline input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-top: 1px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}
.contract-form-page .doc-block .checkbox-inline span {
    display: block;
    line-height: 1.5;
    min-width: 0;
}
.contract-form-page .doc-block .checkbox-inline strong {
    color: var(--text-primary);
    font-size: 14px;
    display: block;
    margin-bottom: 2px;
}
.contract-form-page .doc-block .checkbox-inline small {
    color: var(--text-tertiary);
    font-size: 12px;
    display: block;
}

/* Панель акта */
.contract-form-page .doc-block .act-panel {
    margin-top: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-left: 3px solid #ec4899;
    border-radius: var(--radius);
}
.contract-form-page .doc-block .act-panel-hint {
    padding: 10px 12px;
    background: rgba(236,72,153,0.08);
    border-left: 2px solid #ec4899;
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.5;
    margin-bottom: 14px;
}

/* ===== Мобильная адаптация ===== */
@media (max-width: 900px) {
    .contract-form-page .doc-block .variables-summary-label { font-size: 12px; }
    .contract-form-page .doc-block .variables-panel-buttons { padding: 10px; gap: 5px; }
    .contract-form-page .doc-block .variables-panel-buttons .var-btn { font-size: 11px; padding: 6px 10px; }

    .contract-form-page .doc-block .item-row {
        background: var(--bg-tertiary);
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 12px;
        margin-bottom: 12px;
        box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    }
    .contract-form-page .doc-block .item-row:last-child { margin-bottom: 0; }
    .contract-form-page .doc-block .form-row {
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-areas:
            "purpose purpose purpose"
            "qty     unit    price";
        gap: 10px 8px;
        align-items: start;
    }
    .contract-form-page .doc-block .form-row > .form-field:nth-child(1) { grid-area: purpose; }
    .contract-form-page .doc-block .form-row > .form-field:nth-child(2) { grid-area: qty; }
    .contract-form-page .doc-block .form-row > .form-field:nth-child(3) { grid-area: unit; }
    .contract-form-page .doc-block .form-row > .form-field:nth-child(4) { grid-area: price; }
    .contract-form-page .doc-block .form-row .remove-item {
        position: absolute;
        top: 8px;
        right: 8px;
        width: 28px;
        height: 28px;
        background: rgba(239,68,68,0.1);
        border-color: rgba(239,68,68,0.3);
        color: #f87171;
        align-self: auto;
    }
    .contract-form-page .doc-block .form-row .remove-item svg { width: 14px; height: 14px; }
    .contract-form-page .doc-block .form-row .remove-item:hover { background: var(--danger); color: white; }
    .contract-form-page .doc-block .form-field-purpose label { padding-right: 32px; }

    .contract-form-page .doc-block .form-row > .form-field input {
        padding: 10px 12px;
        font-size: 16px;
        min-height: 42px;
        box-sizing: border-box;
        width: 100%;
    }
    .contract-form-page .doc-block .form-row > .form-field .quantity-input { text-align: center; }
    .contract-form-page .doc-block .form-row > .form-field .price-input { text-align: right; }
    .contract-form-page .doc-block .item-row .form-field label {
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
        color: var(--text-tertiary);
        font-weight: 600;
    }

    .contract-form-page .doc-block .items-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-top: 12px;
        padding-top: 12px;
    }
    .contract-form-page .doc-block .button-add-row {
        width: 100%;
        justify-content: center;
        padding: 12px 16px;
        font-size: 14px;
        min-height: 44px;
    }
    .contract-form-page .doc-block .items-total {
        justify-content: space-between;
        padding: 10px 14px;
        background: var(--bg-secondary);
        border: 1px solid var(--border);
        border-radius: var(--radius-sm);
    }
    .contract-form-page .doc-block .items-total-label {
        font-size: 13px;
        text-transform: uppercase;
        letter-spacing: 0.4px;
    }
    .contract-form-page .doc-block .items-total-value { font-size: 18px; }
    .contract-form-page .doc-block .act-panel { padding: 12px; }
    .contract-form-page .doc-block .act-panel-hint { font-size: 11px; }
}

/* ====== Привязанные документы ====== */
.contract-form-page .linked-docs-group { margin-bottom: 20px; }
.contract-form-page .linked-docs-group:last-child { margin-bottom: 0; }
.contract-form-page .linked-docs-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px dashed var(--border);
}
.contract-form-page .doc-group-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 6px;
    flex-shrink: 0;
}
.contract-form-page .doc-group-badge svg {
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
}
.contract-form-page .doc-group-badge.badge-invoice {
    background: rgba(124,58,237,0.15);
    border: 1px solid rgba(124,58,237,0.3);
    color: #c4b5fd;
}
.contract-form-page .doc-group-badge.badge-act {
    background: rgba(16,185,129,0.15);
    border: 1px solid rgba(16,185,129,0.3);
    color: #6ee7b7;
}
.contract-form-page .linked-docs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.contract-form-page .linked-doc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s, background 0.15s;
    min-width: 0;
}
.contract-form-page .linked-doc-item:hover {
    border-color: rgba(124,58,237,0.4);
    background: rgba(124,58,237,0.04);
}
.contract-form-page .linked-doc-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}
.contract-form-page .linked-doc-icon.icon-invoice {
    background: rgba(124,58,237,0.15);
    border: 1px solid rgba(124,58,237,0.3);
    color: #c4b5fd;
}
.contract-form-page .linked-doc-icon.icon-act {
    background: rgba(16,185,129,0.15);
    border: 1px solid rgba(16,185,129,0.3);
    color: #6ee7b7;
}
.contract-form-page .linked-doc-icon svg {
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
}
.contract-form-page .linked-doc-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.contract-form-page .linked-doc-link {
    font-weight: 600;
    color: var(--accent);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.35;
}
.contract-form-page .linked-doc-link:hover {
    color: #c4b5fd;
    text-decoration: underline;
}
.contract-form-page .linked-doc-meta {
    font-size: 12px;
    color: var(--text-tertiary);
    line-height: 1.3;
}
.contract-form-page .linked-doc-meta strong {
    color: var(--text-secondary);
    font-weight: 600;
}
.contract-form-page .linked-doc-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 700;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}
.contract-form-page .linked-doc-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.contract-form-page .linked-doc-badge.payment-paid {
    background: rgba(16,185,129,0.15);
    color: #34d399;
}
.contract-form-page .linked-doc-badge.payment-partial {
    background: rgba(245,158,11,0.15);
    color: #fbbf24;
}
.contract-form-page .linked-doc-badge.payment-unpaid {
    background: rgba(239,68,68,0.15);
    color: #f87171;
}
.contract-form-page .linked-doc-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.contract-form-page .mini-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    padding: 0;
    font-family: inherit;
    line-height: 0;
}
.contract-form-page .mini-btn svg {
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
    pointer-events: none;
}
.contract-form-page .mini-btn:hover {
    background: var(--accent);
    color: #ffffff;
}
.contract-form-page .mini-btn.mini-edit:hover { background: var(--info); color: #ffffff; }
.contract-form-page .mini-btn.mini-download:hover { background: #2b579a; color: #ffffff; }
.contract-form-page .mini-btn.mini-delete:hover { background: var(--danger); color: #ffffff; }
.contract-form-page .mini-btn:disabled { opacity: 0.5; cursor: wait; }

@media (max-width: 640px) {
    .contract-form-page .linked-doc-item {
        flex-wrap: wrap;
        gap: 8px 10px;
        padding: 10px 12px;
    }
    .contract-form-page .linked-doc-icon {
        width: 36px;
        height: 36px;
        flex-shrink: 0;
    }
    .contract-form-page .linked-doc-info {
        flex: 1 1 calc(100% - 46px);
        min-width: 0;
    }
    .contract-form-page .linked-doc-badge {
        margin-left: 46px;
        flex-shrink: 0;
        font-size: 10px;
        padding: 3px 8px;
    }
    .contract-form-page .linked-doc-actions {
        margin-left: auto;
        flex-shrink: 0;
    }
}

/* ============================================================ */
/*  LANDING — продающая страница                                */
/*  Все селекторы изолированы: .landing — корневой контейнер,    */
/*  внутренние классы уникальны (.l-*, .hero-*, .link-*,         */
/*  .tax-cal-*, .bank-row и т.д.). Конфликтов с другими          */
/*  страницами нет.                                              */
/* ============================================================ */

.landing {
    min-height: 100vh;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
}

/* === ОБЩИЕ КОНТЕЙНЕРЫ === */
.landing .l-container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.landing .l-section { padding: 90px 0; position: relative; }
.landing .l-section-tight { padding: 60px 0; }

.landing .l-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: rgba(124,58,237,0.12);
    border: 1px solid rgba(124,58,237,0.3);
    border-radius: 100px;
    font-size: 13px;
    font-weight: 600;
    color: #a78bfa;
    margin-bottom: 20px;
}
.landing .l-badge-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #a78bfa;
    box-shadow: 0 0 12px #a78bfa;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}

.landing .l-h1 {
    font-size: 56px;
    line-height: 1.08;
    font-weight: 800;
    letter-spacing: -1.5px;
    margin: 0 0 24px;
    color: var(--text-primary);
}
.landing .l-h2 {
    font-size: 40px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -1px;
    margin: 0 0 16px;
    color: var(--text-primary);
}
.landing .l-h3 {
    font-size: 22px;
    line-height: 1.3;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--text-primary);
}
.landing .l-lead {
    font-size: 19px;
    line-height: 1.6;
    color: var(--text-tertiary);
    max-width: 680px;
    margin: 0 0 32px;
}
.landing .l-highlight {
    background: linear-gradient(135deg, #a78bfa 0%, #7C3AED 60%, #c084fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.landing .l-center { text-align: center; }
.landing .l-center .l-lead { margin-left: auto; margin-right: auto; }

/* === КНОПКИ === */
.landing .l-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
    cursor: pointer;
    border: none;
    white-space: nowrap;
}
.landing .l-btn-primary {
    background: linear-gradient(135deg, #7C3AED 0%, #a855f7 100%);
    color: white;
    box-shadow: 0 8px 24px rgba(124,58,237,0.4);
}
.landing .l-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(124,58,237,0.55);
    color: white;
}
.landing .l-btn-secondary {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
    border: 1px solid rgba(255,255,255,0.12);
}
.landing .l-btn-secondary:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.24);
    color: var(--text-primary);
}
.landing .l-btn-lg { padding: 20px 40px; font-size: 17px; }

.landing .l-cta-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.landing .l-cta-row.l-center { justify-content: center; }

.landing .l-cta-hint {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
}

/* === HERO === */
.landing .l-hero {
    position: relative;
    padding: 80px 0 100px;
    overflow: hidden;
}
.landing .l-hero::before {
    content: '';
    position: absolute;
    top: -200px;
    left: 50%;
    width: 900px;
    height: 900px;
    transform: translateX(-50%);
    background: radial-gradient(circle, rgba(124,58,237,0.22) 0%, rgba(124,58,237,0) 65%);
    pointer-events: none;
}
.landing .l-hero-grid {
    display: grid;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 60px;
    align-items: center;
    position: relative;
    z-index: 1;
}
.landing .l-hero h1 { font-size: 58px; }

.landing .l-hero-visual {
    width: 100%;
    max-width: 460px;
    margin-left: auto;
}

.landing .hero-card {
    position: relative;
    background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(124,58,237,0.35);
    border-radius: 20px;
    padding: 28px 26px 24px;
    box-shadow: 0 24px 60px rgba(124,58,237,0.18), 0 8px 20px rgba(0,0,0,0.45);
    overflow: hidden;
}
.landing .hero-card::before {
    content: '';
    position: absolute;
    top: -60%;
    right: -60%;
    width: 120%;
    height: 120%;
    background: radial-gradient(circle, rgba(124,58,237,0.22), transparent 60%);
    pointer-events: none;
    z-index: 0;
}
.landing .hero-card > * { position: relative; z-index: 1; }

.landing .hero-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding-bottom: 18px;
    margin-bottom: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.landing .hero-card-title {
    font-size: 20px;
    font-weight: 800;
    color: #f8fafc;
    letter-spacing: -0.3px;
    line-height: 1.2;
}
.landing .hero-card-date {
    font-family: ui-monospace, monospace;
    font-size: 13px;
    color: #a78bfa;
    background: rgba(124,58,237,0.15);
    padding: 5px 11px;
    border-radius: 6px;
    white-space: nowrap;
    font-weight: 600;
}

.landing .hero-card-rows {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 22px;
}
.landing .hero-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    line-height: 1.4;
}
.landing .hero-card-row span { color: var(--text-muted); }
.landing .hero-card-row strong {
    color: var(--text-secondary);
    font-weight: 600;
    text-align: right;
}

.landing .hero-card-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 18px 0;
    margin-bottom: 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.landing .hero-card-total span {
    color: var(--text-muted);
    font-size: 14px;
}
.landing .hero-card-total strong {
    font-size: 32px;
    font-weight: 800;
    color: #10b981;
    letter-spacing: -0.6px;
    line-height: 1;
}

.landing .hero-card-tags {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}
.landing .hero-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    background: rgba(124,58,237,0.12);
    border: 1px solid rgba(124,58,237,0.3);
    border-radius: 100px;
    font-size: 12px;
    font-weight: 600;
    color: #c4b5fd;
    white-space: nowrap;
}
.landing .hero-tag svg { stroke: currentColor; flex-shrink: 0; }
.landing .hero-tag.green {
    background: rgba(16,185,129,0.12);
    border-color: rgba(16,185,129,0.3);
    color: #6ee7b7;
}

.landing .hero-card-caption {
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-muted);
    text-align: center;
    padding-top: 4px;
    font-style: italic;
}

/* === МЕТРИКИ === */
.landing .l-metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    margin-top: 60px;
    position: relative;
    z-index: 1;
}
.landing .l-metric { text-align: center; }
.landing .l-metric-value {
    font-size: 34px;
    font-weight: 800;
    background: linear-gradient(135deg, #a78bfa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}
.landing .l-metric-label {
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.4;
}

/* === БОЛИ === */
.landing .l-pains {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-top: 48px;
}
.landing .l-pain {
    padding: 26px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
}
.landing .l-pain::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 3px;
    height: 100%;
    background: linear-gradient(180deg, #ef4444, #f59e0b);
}
.landing .l-pain-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(239,68,68,0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.landing .l-pain-icon svg { stroke: #f87171; }
.landing .l-pain h4 {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 8px;
    color: var(--text-primary);
}
.landing .l-pain p {
    font-size: 14px;
    line-height: 1.55;
    color: var(--text-tertiary);
    margin: 0;
}

/* === ФИЧИ === */
.landing .l-features {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 22px;
    margin-top: 56px;
}
.landing .l-feature {
    padding: 30px 26px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 18px;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}
.landing .l-feature::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at top right, rgba(124,58,237,0.12), transparent 60%);
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}
.landing .l-feature:hover {
    border-color: rgba(124,58,237,0.5);
    transform: translateY(-4px);
    box-shadow: 0 16px 40px rgba(124,58,237,0.15);
}
.landing .l-feature:hover::after { opacity: 1; }
.landing .l-feature-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(168,85,247,0.08));
    border: 1px solid rgba(124,58,237,0.3);
}
.landing .l-feature-icon svg { stroke: #a78bfa; }
.landing .l-feature h3 {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--text-primary);
}
.landing .l-feature p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-tertiary);
    margin: 0;
}

/* === ШАГИ === */
.landing .l-steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 30px;
    margin-top: 56px;
    position: relative;
}
.landing .l-step {
    text-align: center;
    padding: 32px 20px;
    position: relative;
}
.landing .l-step-num {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7C3AED, #a855f7);
    color: white;
    font-size: 26px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 22px;
    box-shadow: 0 12px 32px rgba(124,58,237,0.4);
    position: relative;
    z-index: 2;
}
.landing .l-step h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--text-primary);
}
.landing .l-step p {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-tertiary);
    margin: 0;
}
.landing .l-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 60px;
    left: calc(50% + 50px);
    width: calc(100% - 60px);
    height: 2px;
    background: linear-gradient(90deg, rgba(124,58,237,0.5), rgba(124,58,237,0.05));
    z-index: 1;
}

/* === SPLIT === */
.landing .l-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 70px;
    align-items: center;
}
.landing .l-split.reverse { direction: rtl; }
.landing .l-split.reverse > * { direction: ltr; }

.landing .l-split-visual {
    position: relative;
    border-radius: 20px;
    padding: 30px;
    background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid var(--border);
    min-height: 380px;
    overflow: hidden;
}
.landing .l-split-visual::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 80% 20%, rgba(124,58,237,0.2), transparent 55%);
    pointer-events: none;
}

.landing .l-check-list {
    list-style: none;
    padding: 0;
    margin: 24px 0 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.landing .l-check-list li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text-secondary);
}
.landing .l-check-mark {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(16,185,129,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}
.landing .l-check-mark svg { stroke: #10b981; }

/* === СВЯЗКА СЧЁТ ↔ АКТ === */
.landing .link-visual {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    z-index: 1;
}
.landing .link-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: #0f172a;
    border: 1px solid rgba(124,58,237,0.3);
    border-radius: 12px;
}
.landing .link-card.act { border-color: rgba(16,185,129,0.35); }
.landing .link-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background: rgba(124,58,237,0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.landing .link-card.act .link-card-icon { background: rgba(16,185,129,0.15); }
.landing .link-card-icon svg { stroke: #a78bfa; }
.landing .link-card.act .link-card-icon svg { stroke: #10b981; }
.landing .link-card-info { flex: 1; min-width: 0; }
.landing .link-card-title { font-size: 14px; font-weight: 700; color: #f8fafc; }
.landing .link-card-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.landing .link-connector {
    align-self: center;
    width: 2px;
    height: 28px;
    background: linear-gradient(180deg, #7C3AED, #10b981);
    border-radius: 2px;
    position: relative;
}
.landing .link-connector::after {
    content: '🔗';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #0f172a;
    padding: 2px 4px;
    font-size: 12px;
}

/* === КАЛЕНДАРЬ НАЛОГОВ === */
.landing .tax-cal-visual { position: relative; z-index: 1; }
.landing .tax-cal-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: #0f172a;
    border-left: 3px solid #7C3AED;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}
.landing .tax-cal-row.orange { border-left-color: #f59e0b; }
.landing .tax-cal-row.green  { border-left-color: #10b981; }
.landing .tax-cal-row.blue   { border-left-color: #3b82f6; }
.landing .tax-cal-date {
    font-weight: 800;
    color: #f8fafc;
    min-width: 42px;
    font-variant-numeric: tabular-nums;
}
.landing .tax-cal-text { flex: 1; color: var(--text-secondary); }
.landing .tax-cal-tag {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 100px;
    background: rgba(124,58,237,0.15);
    color: #a78bfa;
    white-space: nowrap;
}
.landing .tax-cal-tag.orange { background: rgba(245,158,11,0.15); color: #fbbf24; }
.landing .tax-cal-tag.green  { background: rgba(16,185,129,0.15); color: #34d399; }
.landing .tax-cal-tag.blue   { background: rgba(59,130,246,0.15); color: #60a5fa; }

/* === БАНКОВСКАЯ ВЫПИСКА (визуал) === */
.landing .bank-visual { position: relative; z-index: 1; }
.landing .bank-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #0f172a;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    gap: 12px;
}
.landing .bank-row-left { flex: 1; min-width: 0; }
.landing .bank-row-purpose {
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}
.landing .bank-row-meta { font-size: 11px; color: var(--text-muted); margin-top: 3px; }
.landing .bank-row-amount { font-weight: 700; white-space: nowrap; }
.landing .bank-row-amount.income  { color: #34d399; }
.landing .bank-row-amount.expense { color: #f87171; }
.landing .bank-row-badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(16,185,129,0.15);
    color: #34d399;
    font-weight: 700;
    white-space: nowrap;
}
.landing .bank-row-badge.warn { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* === СРАВНИТЕЛЬНАЯ ТАБЛИЦА === */
.landing .l-compare {
    margin-top: 56px;
    overflow-x: auto;
    border-radius: 18px;
    border: 1px solid var(--border);
}
.landing .l-compare table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
    background: var(--bg-secondary);
}
.landing .l-compare th,
.landing .l-compare td {
    padding: 18px 20px;
    text-align: left;
    font-size: 14px;
    border-bottom: 1px solid var(--border);
}
.landing .l-compare th {
    background: var(--bg-tertiary);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-secondary);
}
.landing .l-compare th.col-doki {
    background: linear-gradient(135deg, rgba(124,58,237,0.25), rgba(168,85,247,0.1));
    color: #c4b5fd;
}
.landing .l-compare td:first-child {
    color: var(--text-secondary);
    font-weight: 500;
}
.landing .l-compare td.col-doki {
    background: rgba(124,58,237,0.06);
    color: #f8fafc;
    font-weight: 600;
}
.landing .l-compare tr:last-child td { border-bottom: none; }
.landing .l-compare .mark-yes { color: #34d399; font-weight: 800; }
.landing .l-compare .mark-no  { color: #64748b; }
.landing .l-compare .mark-part { color: #fbbf24; font-weight: 600; }

/* === FAQ === */
.landing .l-faq {
    max-width: 820px;
    margin: 48px auto 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.landing .l-faq-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    transition: border-color 0.2s;
}
.landing .l-faq-item[open] { border-color: rgba(124,58,237,0.4); }
.landing .l-faq-item summary {
    padding: 20px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.landing .l-faq-item summary::-webkit-details-marker { display: none; }
.landing .l-faq-item summary::after {
    content: '+';
    font-size: 24px;
    font-weight: 300;
    color: #a78bfa;
    transition: transform 0.2s;
    line-height: 1;
}
.landing .l-faq-item[open] summary::after { content: '−'; }
.landing .l-faq-answer {
    padding: 0 24px 22px;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-tertiary);
}

/* === ФИНАЛЬНЫЙ CTA === */
.landing .l-final-cta {
    padding: 80px 40px;
    text-align: center;
    background: linear-gradient(160deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid rgba(124,58,237,0.3);
    border-radius: 28px;
    position: relative;
    overflow: hidden;
    margin: 80px 0 40px;
}
.landing .l-final-cta::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 50% 0%, rgba(124,58,237,0.3), transparent 60%);
    pointer-events: none;
}
.landing .l-final-cta > * { position: relative; z-index: 1; }
.landing .l-final-cta h2 { font-size: 42px; margin-bottom: 16px; }

/* === АДАПТИВ === */
@media (max-width: 1024px) {
    .landing .l-h1 { font-size: 44px; }
    .landing .l-hero h1 { font-size: 46px; }
    .landing .l-h2 { font-size: 32px; }
    .landing .l-hero-grid { grid-template-columns: 1fr; gap: 50px; }
    .landing .l-hero-visual { max-width: 460px; margin: 0 auto; }
    .landing .l-features { grid-template-columns: repeat(2, 1fr); }
    .landing .l-pains { grid-template-columns: 1fr; }
    .landing .l-metrics { grid-template-columns: repeat(2, 1fr); padding: 24px; }
    .landing .l-split { grid-template-columns: 1fr; gap: 40px; }
    .landing .l-split.reverse { direction: ltr; }
    .landing .l-split-visual { min-height: 320px; }
}
@media (max-width: 640px) {
    .landing .l-section { padding: 60px 0; }
    .landing .l-h1 { font-size: 34px; letter-spacing: -1px; }
    .landing .l-hero h1 { font-size: 36px; }
    .landing .l-h2 { font-size: 26px; }
    .landing .l-lead { font-size: 16px; }
    .landing .l-container { padding: 0 18px; }
    .landing .l-features { grid-template-columns: 1fr; }
    .landing .l-metrics { grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px; }
    .landing .l-metric-value { font-size: 26px; }
    .landing .l-steps { grid-template-columns: 1fr; }
    .landing .l-step:not(:last-child)::after { display: none; }
    .landing .l-btn { width: 100%; padding: 15px 24px; }
    .landing .l-cta-row { flex-direction: column; align-items: stretch; }
    .landing .l-final-cta { padding: 50px 24px; }
    .landing .l-final-cta h2 { font-size: 28px; }
    .landing .l-compare th, .landing .l-compare td { padding: 12px 14px; font-size: 13px; }
}

/* ============================================================ */
/*  ЕДИНЫЕ СТИЛИ ПОЛЕЙ ФОРМ                                     */
/*  (Договор / Счёт / Контрагент)                               */
/*  Селекты — по образцу страницы «Платежи»                     */
/* ============================================================ */

/* ----- Базовые поля: input / select / textarea ----- */
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field select,
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    font-weight: 400;
    line-height: 1.4;
    color: var(--text-primary);
    background-color: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

/* Placeholder */
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field input::placeholder,
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field textarea::placeholder {
    color: var(--text-muted);
}

/* Hover */
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field input:hover:not(:disabled):not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field select:hover:not(:disabled),
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field textarea:hover:not(:disabled) {
    border-color: #475569;
}

/* Focus */
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field input:focus,
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field select:focus,
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15);
}

/* Textarea */
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field textarea {
    resize: vertical;
    min-height: 60px;
    line-height: 1.5;
}

/* ----- SELECT — кастомный вид как на «Платежах» ----- */
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field select {
    padding: 10px 32px 10px 14px;
    font-weight: 500;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 11px 11px;
    text-overflow: ellipsis;
}

:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field select:focus {
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>");
}

/* Отключённые поля */
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field input:disabled,
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field select:disabled,
:is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--bg-tertiary);
}

/* ----- Мобильная адаптация (iOS не зумит при фокусе) ----- */
@media (max-width: 900px) {
    :is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    :is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field select,
    :is(.contract-form-page, .document-form-page, .counterparty-form-page) .form-field textarea {
        font-size: 16px;
        min-height: 44px;
    }
}

/* ============================================================ */
/*  FLATPICKR — глобальная стилизация под тёмную тему           */
/*  Применяется ко всем календарям на сайте                     */
/* ============================================================ */

.flatpickr-calendar {
    background: var(--bg-secondary, #1e293b) !important;
    border: 1px solid var(--border, #334155) !important;
    border-radius: 12px !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55) !important;
    font-family: inherit !important;
    color: var(--text-primary, #f8fafc) !important;
    z-index: 100000 !important;
    padding: 8px !important;
    width: 320px !important;
}

.flatpickr-calendar:before,
.flatpickr-calendar:after,
.flatpickr-calendar.arrowTop:before,
.flatpickr-calendar.arrowTop:after,
.flatpickr-calendar.arrowBottom:before,
.flatpickr-calendar.arrowBottom:after { display: none !important; }

/* Шапка */
.flatpickr-months {
    background: transparent !important;
    height: 40px !important;
    margin-bottom: 6px;
}
.flatpickr-months .flatpickr-month {
    background: transparent !important;
    color: var(--text-primary, #f8fafc) !important;
    fill: currentColor !important;
    height: 40px !important;
}
.flatpickr-current-month {
    font-size: 15px !important;
    font-weight: 600 !important;
    color: var(--text-primary, #f8fafc) !important;
    padding-top: 10px !important;
    line-height: 1.2 !important;
}

/* Селект месяца — как везде в проекте */
.flatpickr-current-month .flatpickr-monthDropdown-months {
    background-color: var(--bg-primary, #0f172a) !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 11px 11px !important;
    color: var(--text-primary, #f8fafc) !important;
    border: 1px solid var(--border, #334155) !important;
    border-radius: var(--radius-sm, 4px) !important;
    padding: 5px 28px 5px 12px !important;
    font-weight: 500 !important;
    font-size: 14px !important;
    font-family: inherit !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    cursor: pointer !important;
    outline: none !important;
    text-overflow: ellipsis !important;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months:hover {
    border-color: #475569 !important;
    color: var(--text-primary, #f8fafc) !important;
    background-color: var(--bg-secondary, #1e293b) !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months:focus {
    border-color: var(--accent, #7C3AED) !important;
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15) !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>") !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months option,
.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month {
    background-color: var(--bg-secondary, #1e293b) !important;
    color: var(--text-primary, #f8fafc) !important;
    padding: 8px 12px !important;
    font-family: inherit !important;
    font-size: 14px !important;
    font-weight: 500 !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months option:checked,
.flatpickr-current-month .flatpickr-monthDropdown-months .flatpickr-monthDropdown-month.selected {
    background-color: rgba(124, 58, 237, 0.2) !important;
    color: #ffffff !important;
}
.flatpickr-current-month .flatpickr-monthDropdown-months option:hover {
    background-color: rgba(124, 58, 237, 0.15) !important;
}

/* Год и стрелки-спиннеры */
.flatpickr-current-month .numInputWrapper {
    width: 70px !important;
    display: inline-block;
}
.flatpickr-current-month .numInputWrapper span.arrowUp,
.flatpickr-current-month .numInputWrapper span.arrowDown {
    border-bottom-color: var(--text-tertiary, #94a3b8) !important;
    border-top-color: var(--text-tertiary, #94a3b8) !important;
}
.flatpickr-current-month .numInputWrapper span.arrowUp:hover,
.flatpickr-current-month .numInputWrapper span.arrowDown:hover {
    border-bottom-color: var(--accent, #7C3AED) !important;
    border-top-color: var(--accent, #7C3AED) !important;
}
.flatpickr-current-month .numInputWrapper:hover {
    background: rgba(124, 58, 237, 0.08) !important;
    border-radius: 6px;
}
.flatpickr-current-month input.cur-year {
    background: transparent !important;
    color: var(--text-primary, #f8fafc) !important;
    font-weight: 600 !important;
    font-size: 15px !important;
    padding: 0 0 0 4px !important;
    border: none !important;
    height: auto !important;
}
.flatpickr-current-month input.cur-year:focus {
    outline: none !important;
}

/* Стрелки влево/вправо */
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    color: var(--text-secondary, #cbd5e1) !important;
    fill: currentColor !important;
    padding: 8px !important;
    height: 40px !important;
    width: 40px !important;
    border-radius: 8px;
    transition: background 0.15s, color 0.15s;
    top: 0 !important;
    line-height: 40px !important;
}
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    background: rgba(124, 58, 237, 0.15) !important;
    color: var(--accent, #7C3AED) !important;
    fill: currentColor !important;
}
.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
    width: 14px !important;
    height: 14px !important;
    color: inherit !important;
    fill: currentColor !important;
}
.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: currentColor !important;
}

/* Дни недели */
.flatpickr-weekdays {
    background: transparent !important;
    height: 32px !important;
    padding: 4px 0 !important;
}
span.flatpickr-weekday {
    background: transparent !important;
    color: var(--text-tertiary, #94a3b8) !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.4px;
    line-height: 24px !important;
}

/* Сетка дней */
.flatpickr-days {
    width: 100% !important;
    border-left: 0 !important;
    border-right: 0 !important;
}
.dayContainer {
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    padding: 4px 0 0 !important;
}
.flatpickr-day {
    color: var(--text-secondary, #cbd5e1) !important;
    background: transparent !important;
    border: 1px solid transparent !important;
    border-radius: 8px !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    height: 38px !important;
    line-height: 36px !important;
    max-width: 38px !important;
    flex-basis: 13.6% !important;
    margin: 1px !important;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.flatpickr-day:hover,
.flatpickr-day:focus {
    background: rgba(124, 58, 237, 0.15) !important;
    border-color: rgba(124, 58, 237, 0.4) !important;
    color: var(--text-primary, #f8fafc) !important;
    outline: none !important;
}

.flatpickr-day.today {
    border-color: var(--accent, #7C3AED) !important;
    color: var(--accent, #7C3AED) !important;
    background: transparent !important;
    font-weight: 700 !important;
}
.flatpickr-day.today:hover,
.flatpickr-day.today:focus {
    background: rgba(124, 58, 237, 0.15) !important;
    color: var(--accent, #7C3AED) !important;
    border-color: var(--accent, #7C3AED) !important;
}

.flatpickr-day.selected,
.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected.inRange,
.flatpickr-day.selected:focus,
.flatpickr-day.selected:hover,
.flatpickr-day.selected.prevMonthDay,
.flatpickr-day.selected.nextMonthDay {
    background: var(--accent, #7C3AED) !important;
    border-color: var(--accent, #7C3AED) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
}

.flatpickr-day.inRange,
.flatpickr-day.prevMonthDay.inRange,
.flatpickr-day.nextMonthDay.inRange,
.flatpickr-day.today.inRange,
.flatpickr-day.prevMonthDay.today.inRange,
.flatpickr-day.nextMonthDay.today.inRange {
    background: rgba(124, 58, 237, 0.18) !important;
    border-color: rgba(124, 58, 237, 0.18) !important;
    color: var(--text-primary, #f8fafc) !important;
    box-shadow: none !important;
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: var(--text-muted, #64748b) !important;
}
.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover {
    color: var(--text-primary, #f8fafc) !important;
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
    color: var(--text-muted, #64748b) !important;
    background: transparent !important;
    border-color: transparent !important;
    cursor: not-allowed !important;
    opacity: 0.4;
}

/* Блок времени (на будущее) */
.flatpickr-time {
    border-top: 1px solid var(--border, #334155) !important;
    background: transparent !important;
    height: 44px !important;
}
.flatpickr-time input {
    background: transparent !important;
    color: var(--text-primary, #f8fafc) !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    height: 40px !important;
}
.flatpickr-time input:hover,
.flatpickr-time input:focus {
    background: rgba(124, 58, 237, 0.12) !important;
    border-radius: 6px;
    outline: none !important;
}
.flatpickr-time .flatpickr-am-pm {
    color: var(--text-secondary, #cbd5e1) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    height: 40px !important;
    line-height: 40px !important;
}
.flatpickr-time .flatpickr-am-pm:hover,
.flatpickr-time .flatpickr-am-pm:focus {
    background: rgba(124, 58, 237, 0.12) !important;
    color: var(--text-primary, #f8fafc) !important;
    border-radius: 6px;
}
.flatpickr-time .numInputWrapper span.arrowUp,
.flatpickr-time .numInputWrapper span.arrowDown {
    border-bottom-color: var(--text-tertiary, #94a3b8) !important;
    border-top-color: var(--text-tertiary, #94a3b8) !important;
}
.flatpickr-time .numInputWrapper span.arrowUp:hover,
.flatpickr-time .numInputWrapper span.arrowDown:hover {
    border-bottom-color: var(--accent, #7C3AED) !important;
    border-top-color: var(--accent, #7C3AED) !important;
}

/* Мобильная адаптация */
@media (max-width: 480px) {
    .flatpickr-calendar {
        width: calc(100vw - 24px) !important;
        max-width: 360px !important;
        padding: 10px !important;
    }
    .flatpickr-day {
        height: 42px !important;
        line-height: 40px !important;
        max-width: 42px !important;
        font-size: 14px !important;
    }
    .flatpickr-current-month {
        font-size: 16px !important;
    }
    .flatpickr-current-month input.cur-year {
        font-size: 16px !important;
    }
}

/* ============================================================ */
/*  FLATPICKR — выпадающий ГОД (select вместо счётчика)          */
/* ============================================================ */

.flatpickr-current-month .doki-year-select {
    background-color: var(--bg-primary, #0f172a) !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px center !important;
    background-size: 11px 11px !important;
    color: var(--text-primary, #f8fafc) !important;
    border: 1px solid var(--border, #334155) !important;
    border-radius: var(--radius-sm, 4px) !important;
    padding: 5px 28px 5px 12px !important;
    font-weight: 500 !important;
    font-size: 14px !important;
    font-family: inherit !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    cursor: pointer !important;
    outline: none !important;
    margin-left: 6px !important;
    transition: border-color 0.15s, background-color 0.15s, color 0.15s !important;
}
.flatpickr-current-month .doki-year-select:hover {
    border-color: #475569 !important;
    background-color: var(--bg-secondary, #1e293b) !important;
}
.flatpickr-current-month .doki-year-select:focus {
    border-color: var(--accent, #7C3AED) !important;
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15) !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>") !important;
}
.flatpickr-current-month .doki-year-select option {
    background-color: var(--bg-secondary, #1e293b) !important;
    color: var(--text-primary, #f8fafc) !important;
    padding: 8px 12px !important;
    font-family: inherit !important;
    font-size: 14px !important;
    font-weight: 500 !important;
}
.flatpickr-current-month .doki-year-select option:checked {
    background-color: rgba(124, 58, 237, 0.2) !important;
    color: #ffffff !important;
}

@media (max-width: 480px) {
    .flatpickr-current-month .doki-year-select {
        padding: 4px 24px 4px 8px !important;
        font-size: 13px !important;
        margin-left: 4px !important;
    }
}


/* ============================================================ */
/*  Settings → Документы: адаптив для трёх-в-ряд                */
/* ============================================================ */
@media (max-width: 900px) {
    .settings-templates--row {
        grid-template-columns: 1fr;
    }
    .settings-masks {
        grid-template-columns: 1fr;
    }
    .settings-template-item {
        gap: 8px;
        padding: 12px;
    }
    .settings-template-actions {
        flex: 1 1 100%;
        justify-content: flex-end;
        margin-left: 0;
    }
	.settings-template-name,
    .settings-template-file {
        white-space: normal;
        overflow: hidden;
        text-overflow: clip;
        word-break: break-word;
        overflow-wrap: anywhere;
    }
}


/* ============================================================ */
/*  Settings — селекты как везде (со стрелкой)                  */
/* ============================================================ */
.settings-field select,
select.settings-input {
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    padding: 10px 32px 10px 14px !important;
    font-weight: 500 !important;
    font-family: inherit !important;
    cursor: pointer !important;
    text-overflow: ellipsis !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>") !important;
    background-repeat: no-repeat !important;
    background-position: right 10px center !important;
    background-size: 11px 11px !important;
}
.settings-field select:hover,
select.settings-input:hover {
    border-color: #475569 !important;
}
.settings-field select:focus,
select.settings-input:focus {
    border-color: var(--accent, #7C3AED) !important;
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.15) !important;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6,9 12,15 18,9'/></svg>") !important;
}


/* ============================================================ */
/*  LEGAL — юридические страницы (оферта, политика, согласие)    */
/* ============================================================ */

.legal-page {
    max-width: 820px;
    margin: 0 auto;
    padding: 0 0 40px;
    line-height: 1.7;
    color: var(--text-secondary);
    font-size: 15px;
}
.legal-page h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.2;
}
.legal-page .legal-meta {
    font-size: 13px;
    color: var(--text-tertiary);
    margin: 0 0 28px;
}
.legal-page h2 {
    font-size: 18px;
    color: var(--text-primary);
    margin: 32px 0 12px;
    line-height: 1.3;
}
.legal-page h3 {
    font-size: 15px;
    color: var(--text-primary);
    margin: 20px 0 8px;
    line-height: 1.4;
}
.legal-page p,
.legal-page ul,
.legal-page ol {
    margin: 0 0 14px;
}
.legal-page ul,
.legal-page ol {
    padding-left: 22px;
}
.legal-page li {
    margin-bottom: 6px;
}
.legal-page a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed rgba(124,58,237,0.4);
}
.legal-page a:hover {
    border-bottom-style: solid;
}
.legal-page strong {
    color: var(--text-primary);
    font-weight: 600;
}
.legal-page .legal-note {
    background: rgba(124,58,237,0.06);
    border-left: 3px solid var(--accent);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin: 20px 0;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

@media (max-width: 900px) {
    .legal-page {
        font-size: 14px;
        line-height: 1.65;
    }
    .legal-page h1 { font-size: 22px; }
    .legal-page h2 { font-size: 16px; margin-top: 24px; }
    .legal-page h3 { font-size: 14px; }
    .legal-page .legal-note {
        padding: 12px 14px;
        font-size: 13px;
    }
}


/* ============================================================ */
/*  FOOTER — подвал с юридическими ссылками и реквизитами         */
/* ============================================================ */

.doki-footer {
    margin-top: 60px;
    background: linear-gradient(180deg, var(--bg-primary, #0f172a) 0%, #0a0f1f 100%);
    border-top: 1px solid var(--border, #334155);
    padding: 48px 24px calc(48px + env(safe-area-inset-bottom, 0px));
}
.doki-footer-inner {
    max-width: 1200px;
    margin: 0 auto;
}
.doki-footer-top {
    display: grid;
    grid-template-columns: minmax(220px, 1.2fr) 2fr;
    gap: 60px;
    align-items: flex-start;
    padding-bottom: 32px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}
.doki-footer-brand {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.doki-footer-logo {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    width: fit-content;
}
.doki-footer-logo img {
    height: 26px;
    width: auto;
    display: block;
    flex-shrink: 0;
}
.doki-footer-logo span {
    font-family: 'Comfortaa', system-ui, -apple-system, sans-serif;
    font-weight: 100;
    font-size: 22px;
    letter-spacing: 2px;
    color: var(--text-primary, #f8fafc);
    line-height: 1;
}
.doki-footer-tagline {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-tertiary, #94a3b8);
    margin: 0;
    max-width: 280px;
}
.doki-footer-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
}
.doki-footer-col {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}
.doki-footer-col-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-tertiary, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 4px;
}
.doki-footer-col a {
    font-size: 13px;
    color: var(--text-secondary, #cbd5e1);
    text-decoration: none;
    width: fit-content;
    max-width: 100%;
    transition: color 0.15s;
    line-height: 1.4;
    word-break: break-word;
}
.doki-footer-col a:hover {
    color: var(--accent, #7C3AED);
}
.doki-footer-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding-top: 24px;
    flex-wrap: wrap;
}
.doki-footer-copy {
    font-size: 12px;
    color: var(--text-tertiary, #94a3b8);
}
.doki-footer-legal {
    font-size: 11.5px;
    color: var(--text-muted, #64748b);
    text-align: right;
    line-height: 1.5;
}

@media (max-width: 900px) {
    .doki-footer {
        margin-top: 40px;
        padding: 32px 16px calc(100px + env(safe-area-inset-bottom, 0px));
    }
    .doki-footer-top {
        grid-template-columns: 1fr;
        gap: 32px;
        padding-bottom: 24px;
    }
    .doki-footer-brand {
        align-items: center;
        text-align: center;
        gap: 12px;
    }
    .doki-footer-tagline {
        max-width: 100%;
        text-align: center;
    }
    .doki-footer-cols {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .doki-footer-col {
        align-items: center;
        text-align: center;
    }
    .doki-footer-col a {
        width: auto;
    }
    .doki-footer-bottom {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding-top: 20px;
    }
    .doki-footer-legal {
        text-align: center;
    }
}

/* ============================================================ */
/*  COUNTERPARTY-FORM — контактная информация и контактные лица   */
/* ============================================================ */

.counterparty-form-page .contact-persons-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 14px;
}
.counterparty-form-page .contact-person-row {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px;
    position: relative;
}
.counterparty-form-page .contact-person-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--border);
}
.counterparty-form-page .contact-person-num {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.counterparty-form-page .contact-person-remove {
    width: 28px;
    height: 28px;
    padding: 0;
    background: rgba(239,68,68,0.1);
    border: 1px solid rgba(239,68,68,0.3);
    border-radius: var(--radius-sm);
    color: #f87171;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    transition: var(--transition);
    flex-shrink: 0;
}
.counterparty-form-page .contact-person-remove:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}
.counterparty-form-page .contact-person-row .form-grid {
    margin-bottom: 10px;
}
.counterparty-form-page .contact-person-row .checkbox-inline {
    margin-top: 8px;
}
.counterparty-form-page .contact-persons-empty {
    padding: 16px;
    text-align: center;
    font-size: 13px;
    font-style: italic;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 14px;
}

@media (max-width: 900px) {
    .counterparty-form-page .contact-person-row {
        padding: 12px;
    }
    .counterparty-form-page .contact-person-row .form-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .counterparty-form-page .contact-person-row .form-grid > .form-field,
    .counterparty-form-page .contact-person-row .form-grid > .form-grid-full {
        grid-column: 1 / -1;
    }
}

/* ============================================================ */
/*  Уведомления об авансах — статус и нулевые суммы             */
/* ============================================================ */

.docs-notice-amount.is-zero {
    color: var(--text-muted);
}

.docs-notice-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-tertiary);
}
.docs-notice-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

/* ============================================================ */
/*  ВСЕ СТИЛИ ПЕРЕНЕСЕНЫ.                                       */
/*  Этот файл — единственное место для page-specific CSS.        */
/*  Базовые стили (переменные, кнопки, формы) — в style.css.     */
/*  Логотип и фиксы шапки — в style-additional.css.              */
/* ============================================================ */