@font-face {
    font-family: 'TTFirs';
    src: url('../fonts/TTFirs-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}
@font-face {
    font-family: 'TTFirs';
    src: url('../fonts/TTFirs-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
}
@font-face {
    font-family: 'TTFirs';
    src: url('../fonts/TTFirs-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}
@font-face {
    font-family: 'Rhythmic';
    src: url('../fonts/Rhythmic_RUS.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

:root {
    --brown-dark:   #331d12;
    --brown-mid:    #5f3f30;
    --brown:        #896447;
    --brown-light:  #c8ad8f;
    --cream:        #f6e2c1;
    --cream-light:  #fcecd3;
    --blue:         #548b9e;
    --blue-light:   #8ab4c3;
    --blue-pale:    #cde3ec;
    --olive-dark:   #525c3a;
    --olive:        #66783b;
    --olive-light:  #94a865;
    --olive-pale:   #dce8c8;
    --gold:         #dea345;
    --gold-light:   #f0c98b;
    --gold-pale:    #fdf0d4;
    --terra:        #c76b3e;
    --terra-light:  #d68e6e;
    --terra-pale:   #f5ddd4;
    --text:         #2a1a0e;
    --text-muted:   #6b4e33;
    --text-faint:   #896447;
    --border:       #c8ad8f;
    --border-light: #e0cebc;
    --bg:           #f8f0e4;
    --surface:      #fff;
    --surface-alt:  #fdf6ec;
}

* { box-sizing: border-box; }

/* Page loading spinner */
.page-spinner {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255,255,255,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.page-spinner-ring {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-light, #e5d5c0);
    border-top-color: var(--brown-mid, #5f3f30);
    border-radius: 50%;
    animation: spinner-rotate .7s linear infinite;
}
@keyframes spinner-rotate { to { transform: rotate(360deg); } }

body {
    margin: 0;
    font-family: 'TTFirs', Arial, sans-serif;
    font-weight: 400;
    color: var(--text);
    background: var(--bg);
}

/* На странице 60 счёта основной текст читается плотнее, без потери фирменной лёгкости. */
body:has(.account60-dashboard) { font-weight: 500; }
body:has(.account60-dashboard) .account60-heading strong,
body:has(.account60-dashboard) .chart-title,
body:has(.account60-dashboard) .account60-manager-table th,
body:has(.account60-dashboard) .supplier-name { font-weight: 700; }
body:has(.account60-dashboard) .account60-heading .muted,
body:has(.account60-dashboard) .metric-card span,
body:has(.account60-dashboard) .metric-card small { font-weight: 500; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 12px 24px;
    background: var(--brown-dark);
    color: var(--cream);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Rhythmic', 'TTFirs', Arial, sans-serif;
    color: var(--cream);
    font-weight: 400;
    font-size: 18px;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.03em;
    min-width: 0;
    flex-shrink: 1;
}
.brand-text { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.brand-logo {
    height: 34px;
    width: 34px;
    object-fit: contain;
    border-radius: 6px;
    flex-shrink: 0;
    filter: invert(90%) sepia(25%) saturate(400%) hue-rotate(340deg) brightness(108%);
}

nav {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
}
nav a {
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    border-radius: 6px;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(200,173,143,.2);
    color: var(--brown-light);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, color .15s, border-color .15s;
    white-space: nowrap;
}
nav a:hover {
    background: rgba(255,255,255,.14);
    border-color: rgba(200,173,143,.45);
    color: var(--cream);
}
.nav-dropdown { position: relative; }
.nav-dropdown-trigger {
    display: inline-flex; align-items: center; padding: 5px 10px; border-radius: 6px;
    background: rgba(255,255,255,.07); border: 1px solid rgba(200,173,143,.2);
    color: var(--brown-light); font: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer; white-space: nowrap;
}
.nav-dropdown-trigger:hover,
.nav-dropdown.is-open .nav-dropdown-trigger { background: rgba(255,255,255,.14); border-color: rgba(200,173,143,.45); color: var(--cream); }
.nav-dropdown-trigger span { margin-left: 5px; font-size: 12px; opacity: .8; }
.nav-submenu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    min-width: 220px;
    padding: 6px;
    background: var(--brown-dark);
    border: 1px solid var(--brown-mid);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
    z-index: 120;
}
.nav-dropdown:hover .nav-submenu,
.nav-dropdown:focus-within .nav-submenu,
.nav-dropdown.is-open .nav-submenu { display: block; }
.nav-submenu a { display: flex; width: 100%; box-sizing: border-box; background: transparent; border: 0; }
.nav-submenu a:hover { background: var(--brown-mid); }

/* Переключатель разделов БДР / ДДС */
.section-switch {
    display: inline-flex;
    gap: 4px;
    padding: 3px;
    border-radius: 8px;
    background: rgba(0,0,0,.22);
    flex-shrink: 0;
}
.section-tab {
    display: inline-flex;
    align-items: center;
    padding: 5px 16px;
    border-radius: 6px;
    color: var(--brown-light);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .02em;
    transition: background .15s, color .15s;
    white-space: nowrap;
}
.section-tab:hover { color: var(--cream); }
.section-tab.active {
    background: var(--gold);
    color: var(--brown-dark);
}
@media (max-width: 720px) {
    .section-tab { padding: 4px 12px; font-size: 13px; }
}

.fact-src-toggle {
    display: flex;
    align-items: center;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    margin: 0 4px;
}
.fact-src-btn {
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-faint);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    letter-spacing: 0.02em;
}
.fact-src-btn:hover { color: var(--text); }
.fact-src-btn.active {
    background: var(--gold);
    color: var(--brown-dark);
}

.burger-wrap {
    position: relative;
}
.burger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 0;
    opacity: 0.65;
    transition: opacity .15s;
}
.burger-btn:hover { opacity: 1; }
.burger-btn span {
    display: block;
    height: 2px;
    background: var(--cream);
    border-radius: 2px;
    transition: transform .2s, opacity .2s;
}
.burger-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.burger-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.burger-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.burger-menu {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    background: var(--brown-dark);
    border: 1px solid var(--brown-mid);
    border-radius: 10px;
    min-width: 190px;
    padding: 6px 0;
    z-index: 100;
    box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.burger-menu.open { display: block; }
.burger-menu a {
    display: block;
    padding: 9px 18px;
    color: var(--brown-light);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background .12s, color .12s;
}
.burger-menu a:hover {
    background: var(--brown-mid);
    color: var(--cream);
}

/* Уведомления — колокольчик и dropdown */
.notif-wrap { position: relative; }
.notif-bell {
    background: none; border: none; cursor: pointer; color: var(--cream);
    position: relative; padding: 4px; opacity: .75; transition: opacity .15s;
}
.notif-bell:hover { opacity: 1; }
.notif-badge {
    position: absolute; top: -2px; right: -4px;
    background: #dc2626; color: #fff; font-size: 10px; font-weight: 600;
    min-width: 16px; height: 16px; line-height: 16px;
    border-radius: 999px; text-align: center; padding: 0 4px;
}
.notif-dropdown {
    display: none; position: absolute; top: calc(100% + 10px); right: 0;
    background: var(--brown-dark); border: 1px solid var(--brown-mid);
    border-radius: 10px; min-width: 340px; max-width: 460px;
    z-index: 110; box-shadow: 0 8px 24px rgba(0,0,0,.35);
}
.notif-dropdown.open { display: block; }
.notif-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px 14px; border-bottom: 1px solid var(--brown-mid);
    color: var(--cream); font-size: 14px;
}
.notif-read-all {
    background: none; border: none; color: var(--gold); font-size: 12px;
    cursor: pointer; text-decoration: underline; padding: 0;
}
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
    display: block; padding: 10px 14px; text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,.06);
    transition: background .12s; color: var(--cream); font-size: 13px; line-height: 1.4;
    word-wrap: break-word; overflow-wrap: break-word; white-space: normal;
}
.notif-item:hover { background: var(--brown-mid); }
.notif-item.unread { font-weight: 500; }
.notif-item.unread::before {
    content: ''; display: inline-block; width: 6px; height: 6px;
    background: var(--gold); border-radius: 50%; margin-right: 8px; vertical-align: middle;
}
.notif-time { display: block; font-size: 11px; color: var(--brown-light); margin-top: 2px; }
.notif-empty { padding: 20px 14px; text-align: center; color: var(--brown-light); font-size: 13px; }

.page {
    max-width: 1480px;
    margin: 0 auto;
    padding: 24px;
}

h1 {
    margin: 0 0 18px;
    font-size: 26px;
    font-weight: 700;
    color: var(--brown-dark);
    letter-spacing: -0.01em;
}

.data-freshness {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: -4px 0 14px;
    color: #6b7280;
    font-size: 12px;
}
.data-freshness__label {
    font-weight: 600;
}
.data-freshness__item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 22px;
    padding: 2px 7px 2px 5px;
    border: 1px solid rgba(200, 173, 143, .35);
    border-radius: 999px;
    background: rgba(255, 255, 255, .48);
    color: #6b7280;
    cursor: default;
    white-space: nowrap;
}
.data-freshness__item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 50%;
    top: calc(100% + 8px);
    z-index: 40;
    min-width: 150px;
    padding: 8px 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--surface);
    box-shadow: 0 8px 18px rgba(51, 29, 18, .16);
    color: var(--text-muted);
    font-size: 12px;
    line-height: 1.35;
    text-align: left;
    white-space: pre-line;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, -3px);
    transition: opacity .08s ease, transform .08s ease;
}
.data-freshness__item:hover::after {
    opacity: 1;
    transform: translate(-50%, 0);
}
.data-freshness__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex: 0 0 auto;
}

.notice, .success, .error {
    margin: 16px 24px 0;
    padding: 12px 14px;
    border-radius: 6px;
    font-weight: 500;
}
.notice  { background: var(--gold-pale);   color: var(--brown-dark); border: 1px solid var(--gold-light); }
.success { background: var(--olive-pale);  color: var(--olive-dark); border: 1px solid var(--olive-light); }
.error   { background: var(--terra-pale);  color: var(--terra);      border: 1px solid var(--terra-light); }

.filters, .panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.supplier-groups { margin-bottom: 16px; }
.supplier-group { display: block; padding: 0; overflow: hidden; border-left:4px solid var(--border); }
.supplier-group:hover { border-left-color: var(--blue-light); }
.supplier-group[open] { border-left-color: var(--olive); }
.supplier-group summary { cursor: pointer; padding: 10px 14px; min-height:44px; list-style-position: inside; display:flex; align-items:center; gap:10px; background:var(--surface); }
.supplier-group summary:focus { outline:none; }
.supplier-group summary:focus-visible { outline:1px solid var(--border); outline-offset:-1px; }
.supplier-name { flex:1; min-width:0; }
.supplier-summary-meta { margin-left:auto; display:flex; align-items:center; gap:14px; white-space:nowrap; }
.supplier-count { color:var(--text); font-size:15px; font-weight:700; }
.supplier-total { min-width:140px; text-align:right; font-size:18px; color:var(--text); }
.supplier-group[open] summary { border-bottom: 1px solid var(--border); }
.supplier-group .table-wrap { margin: 0; border: 0; }
.account60-status-tag { display:inline-flex; align-items:center; flex:0 1 auto; max-width:260px; overflow:hidden; text-overflow:ellipsis; padding:4px 10px; border-radius:999px; background:var(--gold-pale); border:1px solid var(--gold-light); color:var(--brown-mid); font-size:12px; font-weight:700; line-height:1.2; white-space:nowrap; }
.account60-status-tag[data-status="waiting_document"] { background:var(--blue-pale); border-color:var(--blue-light); color:var(--blue); }
.account60-status-tag[data-status="documents_pyrus"] { background:var(--olive-pale); border-color:var(--olive-light); color:var(--olive-dark); }
.account60-status-tag[data-status="overpayment_confirmed"] { background:var(--olive-pale); border-color:var(--olive-light); color:var(--olive-dark); }
.account60-status-tag[data-status="waiting_refund"] { background:var(--terra-pale); border-color:var(--terra-light); color:var(--terra); }
.account60-status-panel { display:flex; justify-content:flex-end; padding:10px 14px; background:var(--surface-alt); border-bottom:1px solid var(--border-light); }
.account60-status-form { display:flex; align-items:center; gap:10px; flex-wrap:wrap; padding:10px 12px; background:var(--surface); border:1px solid var(--border); border-radius:8px; box-shadow:0 6px 16px rgba(42,26,14,.10); }
.account60-status-form label { display:inline-flex; align-items:center; gap:8px; color:var(--text-muted); font-size:13px; font-weight:600; }
.account60-status-form select { min-height:32px; padding:4px 8px; font-size:13px; }
.account60-fixed-note { color:var(--text-muted); font-size:12px; }
.account60-status-result { color:var(--olive-dark); font-size:12px; font-weight:600; }
.account60-heading { display:flex; align-items:center; justify-content:space-between; gap:16px; margin-bottom:16px; padding:14px 16px; background:var(--surface); border:1px solid var(--border); border-radius:8px; }
.account60-heading-tools { display:flex; align-items:center; gap:12px; flex-wrap:wrap; justify-content:flex-end; }
.account60-asof { display:inline-flex; align-items:center; gap:8px; color:var(--brown-mid); font-size:13px; font-weight:600; white-space:nowrap; }
.account60-asof input { min-height:34px; padding:5px 8px; font-size:13px; }
.account60-top { display:flex; flex-direction:column; }
#account60-filters { scroll-margin-top:16px; }
.account60-top > .account60-dashboard { order:1; }
.account60-top > .panel { order:2; }
.account60-manager-table { border:1px solid var(--border); border-radius:8px; background:var(--surface); overflow:auto; }
.account60-manager-table table { min-width:760px; }
.account60-manager-table th { background:var(--gold-pale); color:var(--text); padding:12px 14px; font-size:15px; font-weight:700; }
.sortable-header { color:inherit; text-decoration:none; display:inline-flex; align-items:center; gap:5px; }
.sortable-header:hover { color:var(--blue); text-decoration:underline; }
.account60-manager-table td { padding:12px 14px; color:var(--text-muted); font-size:15px; line-height:1.35; }
.account60-manager-table tbody tr:hover td { background:var(--surface-alt); }
.account60-manager-table tbody tr { cursor:pointer; }
.account60-manager-table th:nth-child(4),
.account60-manager-table td:nth-child(4) { text-align:center; }
.manager-progress { display:grid; grid-template-columns:auto 72px; align-items:center; justify-content:center; gap:3px; min-width:0; }
.manager-progress strong { color:var(--brown-mid); font-size:13px; font-weight:700; white-space:nowrap; }
.manager-progress > span { display:block; height:6px; overflow:hidden; background:var(--surface-alt); border:1px solid var(--border-light); border-radius:999px; }
.manager-progress i { display:block; height:100%; min-width:0; background:var(--olive-light); border-radius:inherit; }
body:has(.account60-dashboard) .account60-manager-table td a,
body:has(.account60-dashboard) .account60-manager-table td a:visited { color:var(--brown-mid) !important; text-decoration:none !important; font-weight:600; }
body:has(.account60-dashboard) .account60-manager-table td a:hover { color:var(--olive-dark) !important; text-decoration:none !important; background:transparent !important; padding:0; margin:0; }
.account60-manager-table td.num { color:var(--text); font-weight:600; }
.data-chip { display:inline-flex; align-items:center; gap:6px; white-space:nowrap; padding:6px 10px; border:1px solid var(--border); border-radius:999px; color:var(--text-muted); font-size:13px; background:var(--surface-alt); }
.data-chip i { width:8px; height:8px; border-radius:50%; background:var(--olive); display:inline-block; }
.account60-content { display:flex; flex-direction:column; gap:16px; }
.account60-content main { min-width:0; order:2; }
.account60-sidebar { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:12px; order:1; }
.account60-breadcrumb { display:flex; align-items:center; gap:14px; margin:0 0 12px; padding:10px 14px; background:var(--surface); border:1px solid var(--border); border-left:4px solid var(--blue); border-radius:8px; font-size:14px; }
.account60-breadcrumb a { color:var(--blue); text-decoration:none; font-weight:700; padding:6px 10px; background:var(--blue-pale); border:1px solid var(--blue-light); border-radius:6px; }
.account60-breadcrumb a:hover { text-decoration:underline; }
.account60-breadcrumb span { color:var(--text); font-weight:600; }
.account60-reset,
.compact-filters > .account60-reset { display:inline-flex; align-items:center; justify-content:center; width:44px !important; height:50px !important; min-height:50px !important; max-height:50px !important; box-sizing:border-box !important; align-self:end !important; padding:0 !important; margin:0 2px 0 0 !important; overflow:hidden; color:var(--terra); border:1px solid var(--terra-light); border-radius:8px; text-decoration:none; font-size:21px; line-height:1 !important; font-weight:500; background:var(--terra-pale); transition:background .15s, color .15s; }
.compact-filters input,
.compact-filters select,
.compact-filters .button { box-sizing:border-box; height:50px; }
.account60-reset:hover { color:#fff; background:var(--terra); }
.compact-filters #account60-export { min-height:34px; white-space:nowrap; }
.metric-card { padding:16px; background:var(--surface); border:1px solid var(--border); border-radius:8px; }
.metric-card span, .metric-card small { display:block; color:var(--text-muted); font-size:13px; }
.metric-card strong { display:block; margin:8px 0 4px; font-size:24px; color:var(--text); }
.dashboard-link { display:block; color:inherit; text-decoration:none; transition:transform .15s ease, box-shadow .15s ease; }
.dashboard-link:hover { color:inherit; text-decoration:none; transform:translateY(-2px); box-shadow:0 4px 14px rgba(42,26,14,.12); }
.account60-dashboard { display:grid; grid-template-columns:1fr; gap:12px; margin:0 0 16px; }
.account60-kpis { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:10px; align-items:stretch; }
.account60-kpis .metric-card { min-height:128px; box-sizing:border-box; display:flex; flex-direction:column; justify-content:space-between; }
.account60-kpis .metric-card { border-top:4px solid var(--blue); }
.account60-kpis .metric-card:nth-child(2) { border-top-color:var(--olive); }
.account60-kpis .metric-card:nth-child(3n) { border-top-color:var(--gold); }
.account60-kpis .metric-good { border-top-color:var(--olive) !important; }
.account60-kpis .metric-bad { border-top-color:var(--terra) !important; }
.account60-daily-change { border-top-color:var(--terra) !important; min-height:128px !important; height:auto; box-sizing:border-box !important; padding:14px 16px !important; }
.account60-daily-chips { display:grid; gap:4px; margin-top:7px; }
.account60-daily-row { display:grid; grid-template-columns:58px minmax(0,1fr) 22px; align-items:center; column-gap:5px; min-height:25px; }
.account60-daily-row > span { color:var(--text-muted); font-size:12px; line-height:1; }
.account60-daily-row strong { display:block; margin:0; color:var(--text); font-size:16px; line-height:1; white-space:nowrap; }
.account60-daily-row i { justify-self:end; font-size:20px; font-style:normal; font-weight:800; line-height:1; }
.account60-daily-row--added i { color:var(--terra); }
.account60-daily-row--removed i { color:var(--olive-dark); }
.account60-visuals { display:grid; grid-template-columns:1.2fr .8fr; gap:12px; align-items:stretch; }
.account60-chart { height:auto; box-sizing:border-box; padding:14px; background:var(--surface); border:1px solid var(--border); border-radius:8px; }
.chart-title { margin-bottom:12px; color:var(--text); font-size:18px; font-weight:700; line-height:1.25; }
.chart-row { display:grid; grid-template-columns:minmax(230px, 280px) minmax(70px,1fr) 100px; align-items:center; gap:8px; margin:7px 0; }
.chart-label { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--brown-dark); font-size:15px; font-weight:600; }
.chart-link { text-decoration:none; }
.chart-label.chart-link:hover, .chart-value.chart-link:hover { color:var(--text); text-decoration:none; }
.chart-track { height:12px; background:var(--surface-alt); border:1px solid var(--border-light); border-radius:999px; overflow:hidden; }
.chart-track i { display:block; height:100%; background:linear-gradient(90deg,#91aaa7,#9ca97c); border-radius:999px; }
.chart-value { text-align:right; font-size:15px; font-weight:700; color:var(--brown-dark); white-space:nowrap; }
.age-row { display:grid; grid-template-columns:1fr auto auto; gap:12px; align-items:center; padding:9px 0; border-bottom:1px solid var(--border-light); color:var(--text); font-size:15px; font-weight:500; }
.age-row:last-child { border-bottom:0; }
.age-row strong { color:var(--text); white-space:nowrap; font-weight:700; }
.age-row small { min-width:55px; text-align:right; color:var(--text-faint); }
.age-row a { color:var(--text-muted); text-decoration:none; }
.age-row a:hover { color:var(--blue); text-decoration:underline; }
.age-columns { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:12px; align-items:end; min-height:158px; padding:2px 0 0; border-bottom:1px solid var(--border-light); }
.age-column { min-width:0; height:152px; display:grid; grid-template-rows:24px 1fr 25px 18px; justify-items:center; align-items:end; gap:5px; }
.age-column-value { color:var(--brown-dark); font-size:14px; font-weight:700; white-space:nowrap; }
.age-column-value a { color:var(--brown-dark) !important; text-decoration:none !important; }
.age-column-bar { align-self:end; width:min(48px,72%); min-height:10px; background:linear-gradient(180deg,#a8bcb7,#b8c19b); border:1px solid #b0bb9a; border-radius:7px 7px 2px 2px; box-shadow:0 2px 5px rgba(42,26,14,.06); transition:filter .15s ease, transform .15s ease; }
.age-column-bar:hover { filter:brightness(1.08); transform:translateY(-2px); }
.age-column-label { max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; color:var(--brown-dark); font-size:14px; font-weight:600; text-decoration:none; }
.age-column-label:hover { color:var(--blue); text-decoration:underline; }
.age-column-documents { color:var(--brown-mid); font-size:13px; font-weight:600; white-space:nowrap; }
@media (max-width: 1200px) { .compact-filters { grid-template-columns:repeat(4,minmax(130px,1fr)); } }
@media (max-width: 900px) { .compact-filters { grid-template-columns:repeat(2,minmax(0,1fr)); } #dds-period-form { grid-template-columns:repeat(2,minmax(0,1fr)); } .account60-kpis { grid-template-columns:repeat(2,minmax(0,1fr)); } .account60-visuals { grid-template-columns:1fr; } .supplier-summary-meta { gap:8px; } .supplier-total { min-width:110px; font-size:17px; } }
@media (max-width: 600px) { .account60-kpis { grid-template-columns:1fr; } .chart-row { grid-template-columns:110px minmax(80px,1fr) 90px; } }

label {
    display: grid;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
}

input, select, textarea {
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font: inherit;
    background: var(--surface);
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--blue);
    outline-offset: -1px;
    border-color: var(--blue);
}

textarea {
    min-width: 240px;
    min-height: 42px;
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 16px;
    border: 0;
    border-radius: 6px;
    background: var(--blue);
    color: #fff;
    font-family: inherit;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: filter 0.15s;
}
.button.secondary { background: var(--brown); color: #fff; }
.button.danger { background: #b42318; color: #fff; }
.button:hover { filter: brightness(0.92); }

.table-wrap {
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    min-width: 980px;
    border-collapse: collapse;
}

th, td {
    padding: 6px 8px;
    border-bottom: 1px solid #d4bc9e;
    text-align: left;
    vertical-align: top;
}

th {
    position: sticky;
    top: 0;
    background: var(--cream);
    z-index: 1;
    font-size: 14px;
    font-weight: 700;
    color: #3a2210;
    border-bottom: 1px solid var(--border);
}

td {
    color: #1e1108;
    font-size: 14px;
}

.num { text-align: right; white-space: nowrap; }

.total {
    background: var(--surface-alt);
    font-weight: 700;
}
.calculated-row {
    background: #e7f3ee;
    box-shadow: inset 3px 0 0 #3f8f72;
}
.calculated-row > td:first-child {
    background: #e7f3ee;
}
.calculated-row input,
.calculated-row textarea,
.calculated-row select {
    background: #f4faf7;
    border-color: #9fcdbb;
    color: #466a5d;
}

.tree-row.is-hidden { display: none; }

.tree-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 260px;
    max-width: 320px;
    white-space: normal;
}

.depth-1 .tree-label { padding-left: 24px; }
.depth-2 .tree-label { padding-left: 48px; }
.depth-3 .tree-label { padding-left: 72px; }
.depth-4 .tree-label { padding-left: 96px; }

.tree-toggle,
.tree-spacer {
    width: 22px;
    height: 22px;
    flex: 0 0 22px;
}
.tree-toggle {
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--surface);
    color: var(--brown);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
}
.tree-row.is-collapsed > td .tree-toggle {
    transform: rotate(-90deg);
}
.has-children > td:first-child {
    font-weight: 700;
}

.bad     { color: var(--terra);      font-weight: 700; }
.good    { color: var(--olive-dark); font-weight: 700; }
.neutral { color: var(--text-faint); font-weight: 700; }
.bad-bg  { background: color-mix(in srgb, var(--terra) 8%, transparent); }

.kpis {
    display: grid;
    grid-template-columns: repeat(4, minmax(170px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.kpi {
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    border-top: 3px solid var(--blue);
}
.kpi span { color: var(--text-faint); font-size: 13px; font-weight: 500; }
.kpi strong {
    display: block;
    margin-top: 8px;
    font-size: 22px;
    font-weight: 700;
    color: var(--brown-dark);
}

.login-card {
    display: grid;
    gap: 14px;
    max-width: 360px;
    padding: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.user-form { align-items: end; }
.user-form input,
.user-form select { min-width: 180px; }

.multi-select { min-height: 150px; }

.hint {
    max-width: 260px;
    color: var(--text-faint);
    font-size: 12px;
    line-height: 1.25;
}

.compact-filters { 
    padding: 12px;
    gap: 10px;
    align-items: flex-end;
    display: grid;
    grid-template-columns: 1.45fr repeat(4, minmax(120px, 1fr)) auto auto;
}
.panel > .compact-filters { width:100%; flex:1 1 100%; box-sizing:border-box; }
.compact-filters input,
.compact-filters select,
.compact-filters .button {
    min-height: 34px;
}
.compact-filters label { min-width: 0; }
.compact-filters .button { white-space: nowrap; }
.compact-filters input::placeholder { color: var(--text-faint); opacity: .8; }
.period-group { display:flex; gap:4px; }
.period-group select { flex:1; min-width:0; }
.period-group .year-input { width:72px; flex:0 0 72px; text-align:center; }
#dds-period-form { grid-template-columns:auto repeat(2, minmax(140px,1fr)) 1fr auto auto; }
#dds-period-form[data-mode="date"] { grid-template-columns:auto repeat(2, minmax(120px,auto)) 1fr auto auto; }
.period-field.period-date { display:none; }
#dds-period-form[data-mode="date"] .period-field.period-month { display:none; }
#dds-period-form[data-mode="date"] .period-field.period-date { display:block; }
.period-field.period-date input[type="date"] { width:100%; }
.filter-combo { position:relative; display:block; }
.filter-combo > input { width:100%; }
.filter-options { display:none; position:absolute; z-index:20; top:calc(100% + 4px); left:0; right:0; max-height:260px; overflow:auto; padding:6px; background:var(--surface); border:1px solid var(--border); border-radius:7px; box-shadow:0 8px 20px rgba(42,26,14,.16); }
.filter-options.is-open { display:block; }
.filter-options.is-empty::after { content:'Ничего не найдено'; display:block; padding:8px 10px; color:var(--text-faint); font-size:13px; }
.filter-options button { display:block; width:100%; padding:8px 10px; border:0; border-radius:5px; background:transparent; color:var(--text); text-align:left; font:inherit; cursor:pointer; }
.filter-options button[hidden] { display:none; }
.filter-options button:hover { background:var(--blue-pale); color:var(--text); }

.compact-kpis {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
.compact-kpis .kpi { padding: 10px 12px; }
.compact-kpis .kpi strong { font-size: 17px; }
.kpi-submetric { display:block; margin-top:3px; color:var(--text-muted); font-size:11px; }

.compact-table-wrap {
    max-height: calc(100vh - 240px);
}
.budget-table-wrap {
    max-height: calc(100vh - 210px);
}

.compact-table {
    min-width: 700px;
    font-size: 14px;
    color: #1e1108;
    table-layout: auto;
}
.budget-table { min-width: 1060px; }

.compact-table th,
.compact-table td {
    padding: 4px 10px;
    line-height: 1.35;
    vertical-align: middle;
    white-space: nowrap;
}
.compact-table td:first-child,
.compact-table th:first-child {
    white-space: normal;
    width: 400px;
    min-width: 400px;
    max-width: 400px;
}

.compact-table th:first-child,
.compact-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--surface);
}
.total .compact-table td:first-child,
tr.total > td:first-child { background: var(--surface-alt); }
.calculated-row > td:first-child { background: #e7f3ee; }
.compact-table th:first-child {
    z-index: 3;
    background: var(--cream);
}

.compact-table .tree-label { min-width: 0; max-width: 100%; }
.compact-table .tree-toggle,
.compact-table .tree-spacer {
    width: 18px;
    height: 18px;
    flex-basis: 18px;
}
.compact-table .tree-toggle { font-size: 11px; }

.compact-table .depth-1 .tree-label { padding-left: 18px; }
.compact-table .depth-2 .tree-label { padding-left: 36px; }
.compact-table .depth-3 .tree-label { padding-left: 54px; }
.compact-table .depth-4 .tree-label { padding-left: 72px; }

.budget-table .tree-label { min-width: 240px; max-width: 300px; }

/* Компактные строки таблицы статей: меньше вертикальной прокрутки */
.budget-table { font-size: 13px; }
.budget-table th,
.budget-table td {
    padding: 1px 8px;
    line-height: 1.2;
}
.budget-table .compact-input {
    width: 120px;
    min-height: 24px;
    padding: 2px 7px;
}
.budget-table .compact-select {
    min-height: 24px;
    padding: 1px 6px;
    font-size: 11px;
}
.budget-table .compact-textarea {
    min-height: 24px;
    height: 24px;
    padding: 2px 7px;
}
.budget-table .tree-label { line-height: 1.2; }
.budget-table .tree-toggle,
.budget-table .tree-spacer {
    width: 16px;
    height: 16px;
    flex-basis: 16px;
}

/* Более узкие колонки таблицы статей: меньше горизонтальной прокрутки */
.budget-table th:first-child,
.budget-table td:first-child {
    width: 300px;
    min-width: 300px;
    max-width: 300px;
}
.budget-table .tree-label { min-width: 190px; max-width: 250px; }
.budget-table .compact-input { width: 104px; }
.budget-table .percent-input { width: 76px !important; }
.budget-table .compact-textarea { min-width: 150px; }

/* Колонки «% от базы» и «План»: заголовок и значение по центру */
.budget-table .col-pct-base,
.budget-table .col-plan { text-align: center; }
.budget-table .col-pct-base .compact-input,
.budget-table .col-plan .compact-input { text-align: center; }

/* Компактный переключатель режима расчёта в блоке названия статьи */
.calc-mode-chip {
    margin-left: auto;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    background: var(--surface-alt);
    color: var(--brown);
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.calc-mode-chip:hover { border-color: var(--gold); }
.calc-mode-chip.is-percent {
    background: var(--olive-pale);
    border-color: var(--olive-light);
    color: var(--olive-dark);
}
.calc-mode-chip:disabled { opacity: .4; cursor: default; }

.compact-textarea {
    min-width: 170px;
    width: 100%;
    min-height: 28px;
    height: 28px;
    padding: 4px 7px;
    resize: vertical;
    font-size: 12px;
    line-height: 1.25;
}

.compact-select {
    min-height: 28px;
    padding: 4px 7px;
    font-size: 12px;
}

.fact-readonly {
    color: var(--text-muted);
    font-style: italic;
}

/* Fact column toggle */
.fact-col { display: none; }
.show-fact .fact-col { display: table-cell; }
.prev-year-col { display: none; }
.show-prev-year .prev-year-col { display: table-cell; }

.action-panel {
    display: flex !important;
    align-items: center !important;
}

.income-panel-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.budget-approval-panel {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) auto;
    align-items: center;
    gap: 16px;
    min-height: 0;
    margin-bottom: 10px;
    padding: 12px 18px;
    flex-wrap: nowrap;
}
.approval-summary {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 280px;
}
.approval-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: nowrap;
    min-width: 0;
}
.approval-actions form,
.approval-action-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    margin: 0;
}
.approval-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 24px;
    flex-wrap: wrap;
}
.approval-note {
    color: var(--text-faint);
    font-size: 12px;
}
.budget-approval-panel .button {
    min-height: 34px;
    padding: 6px 12px;
    font-size: 13px;
}
.status-lock,
.status-edit {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
}
.status-lock {
    border: 1px solid var(--gold-light);
    background: var(--gold-pale);
    color: var(--brown);
}
.status-edit {
    border: 1px solid var(--olive-light);
    background: var(--olive-pale);
    color: var(--olive-dark);
}
.year-lock-badge {
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
}
.year-lock-badge.is-locked {
    border-color: #e2b3a3;
    background: #fbe6de;
    color: #a4442a;
}
.year-lock-badge.is-open {
    border-color: var(--olive-light);
    background: var(--olive-pale);
    color: var(--olive-dark);
}
.inline-notice {
    margin: 0 0 8px;
    padding: 8px 10px;
    font-size: 12px;
}
.muted {
    color: var(--text-faint);
    font-size: 12px;
}
.yandex-settings-form label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}
.yandex-settings-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding-left: 10px;
    border-left: 1px solid var(--border-light);
    white-space: nowrap;
}
.yandex-settings-form .compact-input {
    width: 78px;
    min-height: 34px;
    padding: 5px 8px;
}

.budget-income-panel {
    display: block;
    margin-bottom: 10px;
}
.income-panel-head {
    justify-content: space-between;
    margin-bottom: 8px;
}
.income-panel-head h2 {
    margin: 0;
    font-size: 17px;
    color: var(--brown-dark);
}
.income-table-wrap {
    max-height: none;
}
.income-table {
    min-width: 860px;
    width: 100%;
}
.income-table td:first-child,
.income-table th:first-child {
    min-width: 250px;
    width: 250px;
    max-width: 250px;
}
.income-table .compact-input {
    width: 125px;
    text-align: right;
}
/* Сгруппированная двухуровневая шапка доходной таблицы */
.income-table thead .group-head {
    text-align: center;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    letter-spacing: .01em;
}
.income-table thead .sub-head {
    font-weight: 500;
    font-size: 12px;
    color: var(--text-muted);
}
/* Вертикальный разделитель между блоками «Кофейня» и «Доставка» */
.income-table .group-split {
    border-left: 1px solid var(--border-light);
}
/* Итоговая строка «Всего ТО» */
.income-table .grand-total td { background: var(--surface-alt); }
.income-table .grand-total strong[data-income-turnover] { font-size: 15px; }
.income-table .cell-cap {
    display: block;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: var(--text-faint);
    line-height: 1.2;
}
.calc-mode-select {
    width: 116px;
}
.percent-input {
    width: 92px !important;
}

.toggle-label {
    display: flex !important;
    align-items: center !important;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: default;
    user-select: none;
}
.toggle-btn {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    min-width: 36px;
    border: none;
    border-radius: 10px;
    background: var(--border);
    cursor: pointer;
    padding: 0;
    transition: background .2s;
    flex-shrink: 0;
    vertical-align: middle;
}
.toggle-btn[aria-pressed="true"] { background: var(--blue); }
.toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    transition: transform .2s;
    pointer-events: none;
}
.toggle-btn[aria-pressed="true"] .toggle-thumb { transform: translateX(16px); }

.autosave-status {
    padding: 3px 8px;
    border-radius: 4px;
    background: transparent;
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 500;
    border: none;
}
.autosave-status.saving {
    color: var(--brown);
}
.autosave-status.saved {
    color: var(--olive);
}
.autosave-status.error {
    color: var(--terra);
}

.autosave-float {
    position: absolute;
    top: 8px;
    right: 16px;
    pointer-events: none;
}
.page { position: relative; }

.icon-btn {
    width: 34px;
    min-width: 34px;
    padding: 0;
    font-size: 16px;
    line-height: 1;
}

.row-actions { display: flex; gap: 8px; }

.compact-input { width: 148px; }
.money-input {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.wide { width: 100%; }

.col-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: var(--brown-light);
    color: var(--brown-dark);
    font-size: 10px;
    font-weight: 700;
    cursor: help;
    vertical-align: middle;
    margin-left: 4px;
    line-height: 1;
}

/* Branch link */
.branch-link {
    color: var(--blue);
    text-decoration: none;
    font-weight: 500;
}
.branch-link:hover { text-decoration: underline; }

/* Note icon */
.note-icon {
    font-size: 11px;
    opacity: 0.75;
    cursor: default;
    flex-shrink: 0;
}

/* Month navigation */
.month-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}
.month-nav select { flex: 1; }
.month-nav-btn {
    width: 28px;
    min-width: 28px;
    height: 34px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--brown);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background .15s;
    flex-shrink: 0;
}
.month-nav-btn:hover { background: var(--cream); }

/* Sticky footer */
.sticky-footer tr td {
    position: sticky;
    bottom: 0;
    background: var(--cream);
    border-top: 2px solid var(--border);
    font-size: 12px;
    padding: 3px 8px;
    z-index: 2;
}
.sticky-footer tr:not(:last-child) td {
    border-top: 1px solid var(--border-light);
}
.sticky-footer td:first-child {
    position: sticky;
    left: 0;
    z-index: 3;
    background: var(--cream);
}

.data-hint-tooltip {
    position: fixed;
    z-index: 9999;
    min-width: 200px;
    max-width: 320px;
    padding: 10px 14px;
    background: var(--brown-dark);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.6;
    border-radius: 8px;
    pointer-events: none;
    box-shadow: 0 8px 24px rgba(0,0,0,.45);
    white-space: pre-line;
    word-break: normal;
    overflow-wrap: break-word;
}

.upload-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-light);
    padding-bottom: 0;
}
.upload-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: 8px 8px 0 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid transparent;
    border-bottom: none;
    margin-bottom: -2px;
    transition: background .15s, color .15s;
}
.upload-tab:hover {
    background: var(--cream);
    color: var(--text);
}
.upload-tab.active {
    background: var(--surface);
    color: var(--brown-dark);
    border-color: var(--border-light);
    font-weight: 600;
}
.upload-tab-icon { font-size: 16px; }
.upload-desc {
    background: var(--surface-alt);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-muted);
}
.upload-desc strong { color: var(--text); display: block; margin-bottom: 4px; font-size: 15px; }

@media (max-width: 780px) {
    /* Topbar */
    .topbar { flex-direction: column; align-items: flex-start; gap: 8px; padding: 8px 12px; }
    nav { gap: 5px; flex-wrap: wrap; }
    nav a { font-size: 12px; padding: 4px 9px; }
    .brand-text { font-size: 14px; }
    .brand-logo { height: 26px; width: 26px; }

    /* Layout */
    .page { padding: 8px 10px; }
    h1 { font-size: 18px; margin-bottom: 10px; }
    h2 { font-size: 14px; margin-bottom: 8px; }

    /* KPI cards — горизонтальная полоска */
    .kpis {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        margin-bottom: 10px;
    }
    .kpi { padding: 7px 8px; border-top-width: 2px; border-radius: 6px; }
    .kpi span { font-size: 10px; line-height: 1.2; }
    .kpi strong { font-size: 14px; margin-top: 3px; }
    .compact-kpis { grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 8px; }
    .compact-kpis .kpi { padding: 6px 8px; }
    .compact-kpis .kpi strong { font-size: 13px; }

    /* Tables — максимально компактно */
    .table-wrap { border-radius: 5px; margin-bottom: 10px !important; }
    table { font-size: 11px; }
    th, td { padding: 4px 6px; vertical-align: middle; }
    th { font-size: 10px; letter-spacing: 0; }
    .num { white-space: nowrap; }

    /* Скрываем второстепенные столбцы на мобиле */
    .hide-mobile { display: none !important; }

    /* Compact table — горизонтальный скролл + план/факт видны сразу */
    .compact-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .compact-table { font-size: 11px; min-width: 280px; }
    .compact-table th, .compact-table td { padding: 4px 5px; }
    .compact-table .tree-label { min-width: 120px; max-width: 150px; }
    .compact-table td:first-child,
    .compact-table th:first-child { width: 150px; min-width: 120px; max-width: 160px; }

    /* Search panel — компактно на мобиле */
    .summary-search-panel { padding: 6px 10px !important; gap: 6px !important; }

    /* KPI — 5 карточек в 2 ряда на узких экранах */
    .compact-kpis { grid-template-columns: repeat(3, 1fr); }

    /* Budget table */
    .budget-table { min-width: 640px; font-size: 11px; }
    .budget-table th, .budget-table td { padding: 4px 5px; }

    /* Tree */
    .tree-label { min-width: 130px; max-width: 170px; font-size: 11px; gap: 4px; }
    .tree-toggle, .tree-spacer { width: 14px; font-size: 10px; }
    .depth-1 .tree-label { padding-left: 12px; }
    .depth-2 .tree-label { padding-left: 24px; }
    .depth-3 .tree-label { padding-left: 36px; }
    .depth-4 .tree-label { padding-left: 48px; }

    /* Filters & panels — горизонтально, компактно */
    .filters, .panel {
        flex-wrap: wrap;
        align-items: center;
        gap: 8px;
        padding: 8px 10px;
        margin-bottom: 10px;
    }
    .budget-approval-panel {
        display: grid;
        grid-template-columns: 1fr;
        align-items: start;
    }
    .approval-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
    .filters label, .panel label, .compact-filters label {
        font-size: 11px;
        gap: 3px;
    }
    input, select { min-height: 32px; padding: 5px 8px; font-size: 12px; }
    .compact-filters { gap: 8px; padding: 8px 10px; }
    .compact-filters input, .compact-filters select { min-height: 30px; height:30px; font-size: 12px; }
    .compact-filters .button { min-height: 30px; font-size: 12px; padding: 0 12px; }
    .compact-filters .button, .compact-filters > .account60-reset { height:30px; min-height:30px; max-height:30px; }
    .button { padding: 0 14px; min-height: 32px; font-size: 12px; }

    /* Upload */
    .upload-tabs { flex-direction: column; border-bottom: none; gap: 4px; }
    .upload-tab { border-radius: 7px; border: 1px solid var(--border-light); margin-bottom: 0; padding: 7px 12px; font-size: 13px; }
    .upload-desc { font-size: 12px; padding: 8px 10px; }

    /* Burger */
    .burger-menu { right: auto; left: 0; }
}

/* ── Articles page ─────────────────────────────────────────────────────────── */
.btn-sm { font-size: 11px !important; padding: 0 10px !important; min-height: 26px !important; }
.btn-xs { font-size: 11px !important; padding: 0 8px !important; min-height: 24px !important; }

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
}
.badge-total   { background: #d9f0e7; color: #1f4d3c; }
.badge-income  { background: #e8f4fd; color: #1a4a72; }
.badge-expense { background: #fdecea; color: #7d1e1e; }
.badge-warning { background: #fff3d6; color: #7a5414; }

.muted { color: var(--brown-light); }

/* Add-article collapsible panel */
.article-add-panel {
    background: var(--cream);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 10px 16px;
    margin-bottom: 10px;
}
.article-add-panel summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 13px;
    color: var(--brown-mid);
    user-select: none;
    list-style: none;
}
.article-add-panel summary::-webkit-details-marker { display: none; }
.article-add-panel[open] summary { margin-bottom: 0; }

/* Inline edit row */
.article-edit-row td {
    background: #f7f3ee;
    border-top: 2px solid var(--brown-light);
    border-bottom: 2px solid var(--brown-light);
    padding: 10px 14px;
}
.article-inline-form { width: 100%; }
.article-inline-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-end;
}
.article-inline-fields label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    color: var(--brown-mid);
}
.article-inline-name { flex: 1; min-width: 200px; }
.article-inline-actions { display: flex; gap: 6px; align-items: flex-end; padding-bottom: 1px; }

/* Edit button active state */
.article-edit-btn.active {
    background: var(--brown-light);
    color: #fff;
    border-color: var(--brown-light);
}

/* Articles table column widths */
.articles-table td:nth-child(4) { min-width: 260px; }

/* ── Toast notifications ───────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: #2d2a25;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.22);
    opacity: 0;
    transform: translateY(12px);
    transition: opacity .22s ease, transform .22s ease;
    pointer-events: none;
    white-space: nowrap;
}
.toast.toast-show {
    opacity: 1;
    transform: translateY(0);
}
.toast.toast-success { background: #2a4d35; }
.toast.toast-error   { background: #6b1f1f; }

/* ── Mobile: горизонтальный скролл таблиц ─────────────────────────────────── */
@media (max-width: 640px) {
    .table-wrap,
    .compact-table-wrap,
    .budget-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 420px) {
    .compact-kpis { grid-template-columns: repeat(2, 1fr); }
    .compact-kpis .kpi strong { font-size: 12px; }
    .filters, .compact-filters { gap: 6px; padding: 6px 8px; }
    .filters label, .compact-filters label { font-size: 11px; }
}


/* ── ДДС: расшифровка суммы (drill-down) ─────────────────────────────────── */
.dds-drill {
    cursor: pointer;
    color: var(--blue);
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}
.dds-drill:hover { background: var(--blue-pale); }
.dds-drill.active { background: var(--blue-pale); font-weight: 700; }

/* Инлайн-раскрытие расшифровки прямо под выбранной строкой */
.dds-drill-row > td { padding: 0 !important; background: var(--surface-alt); }
.dds-drill-inner {
    margin: 4px 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 3px 12px rgba(51,29,18,.10);
    overflow: hidden;
}
.dds-drill-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    background: var(--surface-alt);
    border-bottom: 1px solid var(--border-light);
    flex-wrap: wrap;
}
.dds-drill-head strong { font-size: 13px; color: var(--text); }
.dds-drill-meta { font-size: 12px; color: var(--text-faint); }
.dds-drill-head .button { margin-left: auto; }
.dds-drill-scroll { max-height: 320px; overflow: auto; }
.dds-drill-table { margin: 0; }
.dds-drill-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
}

/* ── ДДС: матрица планирования по департаментам ──────────────────────────── */
.dept-matrix th.dept-col { min-width: 62px; }
.dept-matrix th.dept-group-head { border-left: 1px solid var(--border-light); }
.dept-matrix th.dept-subhead { font-size: 10px; color: var(--text-muted); padding-top: 2px; padding-bottom: 2px; }
.dept-matrix td.dept-cell { text-align: right; }
.dept-matrix input.dept-input {
    width: 88px;
    text-align: right;
    padding: 3px 6px;
    min-height: 26px;
    font-size: 12px;
}
.dept-matrix td.dept-required { background: var(--gold-pale); }
.dept-matrix input.dept-input[data-req="1"] { border-color: var(--gold); }
.dept-matrix .dept-dim { opacity: .4; }
.dept-matrix .dept-band-even { background: #eef8f5; }
.dept-matrix .dept-band-odd { background: #fbf5eb; }
.dept-matrix th.dept-band-even { border-left: 2px solid var(--border); }
.dept-matrix th.dept-band-odd { border-left: 2px solid var(--border-light); }
.dept-matrix td.dept-band-even.dept-fact-cell { background: #e3f0ec; }
.dept-matrix td.dept-band-odd.dept-fact-cell { background: #f1eade; }
.dept-matrix td.dept-required { background: var(--gold-pale); }
.dept-matrix td.dept-fact-cell { background: rgba(102,120,59,.06); color: var(--text-muted); }
.dept-matrix .dept-fact-col { display: none; }
.dept-matrix.fact-visible .dept-fact-col { display: table-cell; }
.fact-kpi { display: none; }
.view-chip {
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 5px 12px;
    background: var(--surface);
    color: var(--text-muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}
.view-chip:hover, .view-chip.active { background: var(--olive-pale); border-color: var(--olive); color: var(--olive); }
.dept-matrix td.dept-total-row { font-weight: 700; background: var(--surface-alt); }
.dept-matrix .dept-pct { color: var(--text-faint); }
.dept-matrix tr.total td.dept-cell { font-weight: 700; }
.dds-plan-drill { cursor: pointer; color: var(--olive); text-decoration: underline dotted; text-underline-offset: 2px; }
.dds-plan-drill:hover { background: var(--olive-pale); }
.dds-plan-drill.active { background: var(--olive-pale); font-weight: 700; }
/* маркер «есть автор» на ячейке департамента (детали — в тултипе при наведении) */
.dept-matrix td.dept-authored { position: relative; }
.dept-matrix td.dept-authored::after {
    content: '';
    position: absolute;
    top: 3px; right: 3px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--olive-light);
    pointer-events: none;
}

/* ── ДДС: компактная сетка ввода выручки-ориентира ──────────────────────── */
.rev-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 8px;
}
.rev-item {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-alt);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    padding: 4px 8px;
    margin: 0;
}
.rev-item > span {
    flex: 0 0 70px;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rev-item input.money-input {
    flex: 1;
    min-width: 0;
    text-align: right;
    min-height: 28px;
    padding: 3px 6px;
    background: var(--gold-pale);
}
.rev-item.rev-free { flex-direction: column; align-items: stretch; gap: 4px; }
.rev-item.rev-free input { min-height: 28px; padding: 3px 8px; }

/* ── Инлайн-выбор ответственных (галочки в выпадашке) ────────────────────── */
.resp-picker { position: relative; display: inline-block; }
.resp-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 360px;
    padding: 5px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    cursor: pointer;
}
.resp-toggle:hover { border-color: var(--blue); }
.resp-toggle.empty { color: var(--terra); }
.resp-toggle .resp-summary { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.resp-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 50;
    min-width: 220px;
    max-height: 260px;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(51,29,18,.18);
    padding: 6px;
}
.resp-menu label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: 400;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.resp-menu label:hover { background: var(--surface-alt); }
.resp-menu input[type="checkbox"] { width: 15px; height: 15px; margin: 0; }

/* значок «есть комментарий» на ячейке департамента: 💬 с всплывашкой по наведению/клику */
.dept-matrix td.dept-cell { position: relative; }
.dept-note-badge {
    position: absolute;
    top: 0; left: 2px;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    z-index: 3;
    filter: saturate(1.1);
}
.dept-note-badge:hover { transform: scale(1.2); }
.dept-note-add { opacity: 0; filter: grayscale(.25); transition: opacity .15s ease; }
.dept-matrix td.dept-cell:hover .dept-note-add { opacity: 1; }
.dept-revenue > summary { list-style: none; align-items: center; }
.dept-revenue > summary::-webkit-details-marker { display: none; }
.dept-revenue > summary::before {
    content: none;
    display: inline-block;
    margin-right: 10px;
    font-size: 14px;
    color: var(--terra);
    transition: transform .18s ease;
}
.dept-revenue[open] > summary::before { transform: rotate(90deg); }
.dept-revenue-chevron { display: inline-block; width: 18px; margin-right: 4px; color: var(--terra); transition: transform .18s ease; }
.dept-revenue[open] .dept-revenue-chevron { transform: rotate(90deg); }
.dds-approval-panel { margin: 10px 0; }
.dds-approval-panel .approval-route { color: var(--text-muted); font-size: 12px; }
.dds-period-panel { align-items: center; gap: 14px; flex-wrap: wrap; }
.dds-period-panel > form { align-items: center; }
.dds-period-panel .dds-deadline-label {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px;
    font-size: 12px;
    margin: 0;
    white-space: nowrap;
}
.dds-period-panel .dds-deadline-label input { vertical-align: middle; }
.dds-year-progress { display: block; }
.dds-progress-summary { display:flex; align-items:center; gap:18px; flex-wrap:wrap; margin-bottom:12px; }
.dds-progress-summary strong { font-size:16px; }
.dds-progress-summary span { color:var(--text-muted); font-size:12px; }
.dds-month-progress { display:grid; grid-template-columns:repeat(12,minmax(50px,1fr)); gap:8px; }
.dds-month-progress-item { display:flex; flex-direction:column; align-items:center; gap:4px; padding:8px 4px; border:1px solid var(--border-light); border-radius:8px; color:var(--text-muted); text-decoration:none; background:var(--surface-alt); }
.dds-month-progress-item strong { font-size:13px; color:var(--text); }
.dds-month-progress-item.is-current { outline:2px solid var(--terra); outline-offset:1px; }
.dds-month-progress-item.is-approved { background:#dcfce7; border-color:#86efac; }
.dds-month-progress-item.is-submitted { background:#fed7aa; border-color:#f59e0b; }
.dds-month-progress-item.is-draft { background:#fef3c7; border-color:#fcd34d; }
.dds-month-progress-item.is-empty { background:#f4f4f5; }
.dds-dashboard-summary { display:flex; align-items:center; gap:18px; flex-wrap:wrap; }
.dds-dashboard-summary span { color:var(--text-muted); font-size:12px; }
.dds-dashboard-section-title { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; }
.dds-variance-table .variance-over { background:#fff1f2; }
.dds-variance-table .variance-under { background:#f0fdf4; }
.dds-dashboard-table .dash-cell-link { display:block; color:inherit; text-decoration:none; }
.dds-history-list { width:100%; }
@media (max-width: 900px) { .dds-month-progress { grid-template-columns:repeat(6,minmax(50px,1fr)); } }
.approval-history { margin-left: auto; font-size: 12px; }
.approval-history summary { cursor: pointer; color: var(--olive); }
.history-entry { padding: 4px 0; color: var(--text-muted); }

/* ── Модальное окно (комментарии и др.) в стиле сайта ─────────────────────── */
.app-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(51,29,18,.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.app-modal-overlay[hidden] { display: none; }
.app-confirm-overlay { z-index: 1100; }
.app-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    width: 440px;
    max-width: 94vw;
    box-shadow: 0 24px 70px rgba(51,29,18,.35);
}
.app-modal-title { font-weight: 700; font-size: 17px; color: var(--brown-dark); margin-bottom: 3px; }
.app-modal-sub { font-size: 12px; color: var(--text-faint); margin-bottom: 14px; }
.app-modal-text { width: 100%; min-height: 96px; resize: vertical; }
.app-modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ── Справочник статей ДДС ↔ БДР ───────────────────────────────────────────── */
.ref-panel { align-items: flex-end; }
.ref-panel input[type=search] { width: 100%; }
.ref-count {
    margin-left: auto;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-faint);
    padding-bottom: 10px;
    white-space: nowrap;
}

.ref-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.ref-tab {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}
.ref-tab:hover { background: var(--surface-alt); }
.ref-tab.active {
    background: var(--brown-dark);
    border-color: var(--brown-dark);
    color: var(--cream);
}

.ref-hint { margin: 0 0 14px; font-size: 13px; color: var(--text-faint); }

.ref-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 3px solid var(--brown-light);
    border-radius: 8px;
    padding: 14px 16px;
    margin-bottom: 10px;
}
.ref-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 10px; }
.ref-razdel {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.ref-name { font-size: 16px; font-weight: 700; color: var(--brown-dark); }
.ref-bdr { margin: 8px 0 4px; font-size: 14px; color: var(--text-muted); }
.ref-arrow { color: var(--brown-light); margin-right: 6px; font-weight: 700; }
.ref-card code {
    background: var(--surface-alt);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: 13px;
    color: var(--brown-dark);
}
.ref-field { margin-top: 8px; font-size: 14px; line-height: 1.5; }
.ref-label {
    display: block;
    margin-bottom: 2px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.ref-partners { color: var(--text-muted); font-size: 13px; }
.ref-card mark { background: var(--gold-pale); color: var(--brown-dark); border-radius: 3px; padding: 0 2px; }
.ref-empty {
    padding: 40px;
    text-align: center;
    color: var(--text-faint);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.ref-tag-direct { background: var(--olive-pale); color: var(--olive-dark); }
.ref-tag-split  { background: var(--gold-pale);  color: #8a5a00; }
.ref-tag-cash   { background: var(--surface-alt); color: var(--text-faint); border: 1px solid var(--border-light); }
.ref-tag-uk     { background: var(--blue-pale);  color: #2d5c6d; }
.ref-tag-check  { background: var(--terra-pale); color: var(--terra); }

@media (max-width: 720px) {
    .ref-count { margin-left: 0; padding-bottom: 0; }
    .ref-panel label { flex: 1 1 100%; }
}

/* Подсказка к типу связи */
.ref-tagwrap {
    position: relative;
    display: inline-flex;
    cursor: help;
    border-radius: 10px;
    outline-offset: 2px;
}
.ref-tagwrap .badge { border-bottom: 1px dotted currentColor; }
.ref-tip {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 20;
    width: 340px;
    max-width: 78vw;
    padding: 12px 14px;
    background: var(--brown-dark);
    color: var(--cream);
    border-radius: 8px;
    box-shadow: 0 14px 40px rgba(51,29,18,.4);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.5;
    text-transform: none;
    letter-spacing: 0;
    white-space: normal;
    cursor: default;
}
.ref-tagwrap:hover .ref-tip,
.ref-tagwrap:focus .ref-tip,
.ref-tagwrap:focus-within .ref-tip { display: block; }
.ref-tip::before {
    content: "";
    position: absolute;
    bottom: 100%;
    left: 14px;
    border: 6px solid transparent;
    border-bottom-color: var(--brown-dark);
}
.ref-tip-title {
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: var(--gold-light);
    margin-bottom: 4px;
}
.ref-tip-what { display: block; }
.ref-tip-ex {
    display: block;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(200,173,143,.25);
    color: var(--brown-light);
}
.ref-tip-ex b { color: var(--cream); font-weight: 700; }

@media (max-width: 720px) {
    .ref-tip { left: auto; right: 0; }
    .ref-tip::before { left: auto; right: 14px; }
}

/* ── Годовой свод ДДС ── */
.annual-table-wrap { overflow-x: auto; margin-bottom: 16px; }
.annual-summary-table { border-collapse: collapse; font-size: 12px; min-width: 1100px; }
.annual-summary-table th,
.annual-summary-table td { padding: 4px 6px; white-space: nowrap; border-bottom: 1px solid var(--border-light); }
.annual-summary-table th { background: var(--cream-light); position: sticky; top: 0; z-index: 2; }
.annual-summary-table .col-branch { position: sticky; left: 0; background: inherit; z-index: 1; min-width: 140px; max-width: 180px; }
.annual-summary-table .col-metric { position: sticky; left: 140px; background: inherit; z-index: 1; min-width: 80px; }
.annual-summary-table th.col-branch { z-index: 3; }
.annual-summary-table th.col-metric { z-index: 3; }
.annual-summary-table .col-total { font-weight: 700; background: var(--gold-pale); }
.annual-branch-header { background: var(--cream); cursor: pointer; }
.annual-branch-header td { font-weight: 600; }
.annual-branch-header .tree-toggle { background: none; border: none; cursor: pointer; font-size: 12px; padding: 0 4px; color: var(--text-muted); }
.annual-total-header { background: var(--olive-pale); }
.annual-total-header td { font-weight: 700; }
.annual-child { background: #fff; }
.annual-net-row td { border-bottom: 2px solid var(--border); }
.annual-balance-row { background: var(--blue-pale); }
.annual-balance-row td { font-style: italic; color: var(--text-muted); }
.annual-dept-row { background: var(--cream-light); font-size: 11px; }
.annual-dept-row td { color: var(--text-muted); }
.annual-dept-group { background: var(--gold-pale); font-size: 12px; }
.annual-dept-group td { color: var(--brown-dark); border-top: 1px solid var(--border); }
.dds-dept-group-note { color: var(--text-faint); font-size: 11px; text-align: right; }
.dds-dept-empty { color: var(--text-faint); text-align: center; }
.dds-summary-guide { display:flex; align-items:center; gap:7px; flex-wrap:wrap; font-size:12px; line-height:1.5; }
.guide-pill { display:inline-block; padding:2px 6px; border-radius:5px; font-size:11px; font-weight:700; }
.guide-pill.plan { background:#fef3c7; color:#92400e; }
.guide-pill.fact { background:#dbeafe; color:#1d4ed8; }
.guide-pill.delta { background:#dcfce7; color:#166534; }
.annual-summary-table .current-month { background: rgba(102,120,59,.12); }
.annual-summary-table th.current-month { background: var(--olive-pale); font-weight: 700; }
.annual-sticky-header { position: fixed; top: 0; display: none; overflow: hidden; z-index: 90; background: var(--cream-light); border-bottom: 1px solid var(--border); box-shadow: 0 3px 8px rgba(51,29,18,.14); }
.annual-sticky-header table { margin: 0; table-layout: fixed; min-width: 1100px; }
.annual-sticky-header th { background: var(--cream-light); position: static; }
.annual-summary-table tr.hidden { display: none !important; }
.dds-income-toggle { margin-left: 10px; padding: 3px 8px; border: 1px solid var(--border-light); border-radius: 6px; background: var(--surface); color: var(--brown-mid); cursor: pointer; font-size: 11px; }
.dds-income-toggle:hover { background: var(--cream); color: var(--brown-dark); }
a.annual-drill { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--border); }
a.annual-drill:hover { color: var(--blue); border-bottom-color: var(--blue); }

/* Вкладки годового свода */
.annual-tabs { display: flex; gap: 0; margin-bottom: 12px; border-bottom: 2px solid var(--border-light); }
.annual-tab { padding: 6px 16px; font-size: 13px; font-weight: 600; color: var(--text-muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: color .15s, border-color .15s; }
.annual-tab:hover { color: var(--text); }
.annual-tab.active { color: var(--olive); border-bottom-color: var(--olive); }

/* КПЭ таблица */
.kpi-table { min-width: 900px; }
.kpi-table:not(.kpi-compare) { min-width: 820px; }
.kpi-table th { font-size: 11px; text-align: center; }
.kpi-table td.num { text-align: right; }
.kpi-table .sticky-footer { background: var(--cream); }
.kpi-table .sticky-footer td { font-weight: 700; border-top: 2px solid var(--border); }
.kpi-table .branch-link { color: var(--olive-dark); text-decoration: none; }
.kpi-table .branch-link:hover { text-decoration: underline; }

/* КПЭ: сравнение план/факт */
.kpi-compare { min-width: 1200px; }
.kpi-compare th[colspan] { text-align: center; border-bottom: 1px solid var(--border-light); }
.kpi-h-plan { background: var(--blue-pale); }
.kpi-h-fact { background: var(--olive-pale); }

/* Шаблонные статьи — подсветка (голубой) */
.budget-table tr.template-row:not(.total):not(.auto-locked-row) { background: rgba(84,139,158,.10); }
.budget-table tr.template-row:not(.total):not(.auto-locked-row) > td:first-child { background: rgba(84,139,158,.10); box-shadow: inset 4px 0 0 var(--blue); }

/* Обводка ячейки к заполнению по шаблону */
.budget-table tr.template-row[data-tpl-mode="amount"] .col-plan input:not([readonly]):not([disabled]) { outline: 2px dashed rgba(84,139,158,.55); outline-offset: -2px; }
.budget-table tr.template-row[data-tpl-mode="percent"] .percent-input:not([readonly]):not([disabled]) { outline: 2px dashed rgba(84,139,158,.55); outline-offset: -2px; }

/* Авто-расчётные (заблокированные) статьи */
.budget-table tr.auto-locked-row:not(.total) { background: rgba(253,240,212,.5); }
.budget-table tr.auto-locked-row:not(.total) > td:first-child { background: rgba(253,240,212,.5); box-shadow: inset 4px 0 0 var(--gold); }
.budget-table tr.auto-locked-row input[readonly] { background: var(--gold-pale); color: var(--text-muted); cursor: not-allowed; }
.auto-pct-label { font-size: 11px; font-weight: 600; color: var(--gold); }

/* Авто-расчётный процент — элемент с тултипом */
.auto-pct-hint {
    font-size: 11px;
    font-weight: 600;
    color: var(--gold);
    cursor: help;
    border-bottom: 1px dotted var(--gold);
}

/* Фильтр-чипы в панели действий */
.filter-chip {
    display: inline-flex !important;
    align-items: center !important;
    gap: 5px;
    padding: 3px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    margin: 0;
    white-space: nowrap;
    transition: background .15s, border-color .15s;
}
.filter-chip:hover { border-color: var(--brown-light); }
.filter-chip:has(input:checked) { background: var(--blue-pale); border-color: var(--blue-light); color: var(--text); }
.filter-chip--accent:has(input:checked) { background: var(--olive-pale); border-color: var(--olive-light); color: var(--olive-dark); }
.filter-chip input { margin: 0; width: 14px; height: 14px; }

/* Editor hint tooltip */
td.has-editor-hint { position: relative; }
td.has-editor-hint::after {
    content: '✎ ' attr(data-editor-hint);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--brown-dark, #3d2314);
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    box-shadow: 0 4px 12px rgba(51,29,18,.25);
}
td.has-editor-hint:hover::after { opacity: 1; }

/* Year progress bar */
.year-progress {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: 10px 14px;
    margin: 0 0 10px;
}
.yp-top-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.yp-ring-wrap {
    position: relative;
    width: 56px;
    height: 56px;
    flex-shrink: 0;
}
.yp-ring { width: 100%; height: 100%; }
.yp-ring circle:last-child { transition: stroke-dashoffset .5s ease; }
.yp-ring-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.yp-ring-pct {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}
.yp-top-info { flex: 1; min-width: 0; }
.year-progress-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    margin-bottom: 3px;
}
.yp-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.yp-stat {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--brown-light);
}
.yp-stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.year-progress-bar {
    display: flex;
    gap: 3px;
}
.yp-month {
    flex: 1;
    text-align: center;
    text-decoration: none;
    padding: 4px 2px 4px;
    border-radius: 8px;
    border: 2px solid transparent;
    transition: background .15s, border-color .15s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
}
.yp-month:hover { background: var(--cream); }
.yp-month.current {
    border-color: var(--brown-mid);
    background: var(--cream);
}
.yp-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
    line-height: 1;
}
.yp-mgauge {
    position: relative;
    width: 40px;
    height: 24px;
    margin: 1px auto 1px;
}
.yp-mgauge svg {
    width: 100%;
    height: 100%;
    display: block;
}
.yp-mgauge path:last-child { transition: stroke-dashoffset .4s ease; }
.yp-mgauge-pct {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    text-align: center;
    font-size: 9px;
    font-weight: 700;
    color: var(--text);
    line-height: 1;
}
.yp-chips {
    display: flex;
    justify-content: center;
    gap: 3px;
    min-height: 16px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.yp-chip {
    display: inline-block;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .3px;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
    text-transform: uppercase;
    color: #fff;
}
.yp-chip-tu-review { background: #f59e0b; }
.yp-chip-tu-done { background: #3b82f6; }
.yp-chip-fin-review { background: #f59e0b; }
.yp-chip-fin-done { background: #22c55e; }
.yp-seg-fill-leg { background: #8b5cf6; }
.yp-tu-review { background: #f59e0b; }
.yp-tu-done { background: #3b82f6; }
.yp-fin-done { background: #22c55e; }
.year-progress-legend {
    display: flex;
    gap: 14px;
    margin-top: 6px;
    justify-content: center;
}
.yp-legend-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--brown-light);
}
.yp-dot-legend {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.yp-chip-legend {
    display: inline-block;
    font-size: 8px;
    font-weight: 700;
    padding: 2px 4px;
    border-radius: 3px;
    line-height: 1;
    color: #fff;
}

/* Return banner */
.return-banner {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    border-left: 4px solid #ef4444;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 0 0 12px;
    font-size: 14px;
    line-height: 1.5;
    color: #7f1d1d;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    justify-content: space-between;
}
.return-banner-text { flex: 1; min-width: 0; }
.return-banner strong { color: #991b1b; }
.return-comment { display: inline; }
.return-banner-ack { flex-shrink: 0; }
.return-banner-ack .button.small {
    padding: 4px 14px;
    font-size: 13px;
    white-space: nowrap;
    background: #991b1b;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}
.return-banner-ack .button.small:hover { background: #7f1d1d; }

/* Last editor */
.last-editor {
    display: inline-block;
    margin-left: 12px;
    font-size: 12px;
    color: var(--brown-light);
}

/* Modal overlay */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0,0,0,.45);
    justify-content: center;
    align-items: center;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--surface);
    border-radius: 12px;
    padding: 24px;
    width: 90%;
    max-width: 480px;
    box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}
.modal-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 8px;
}
.modal-label .required { color: #ef4444; }
.modal-textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    background: var(--surface);
    color: var(--text);
}
.modal-textarea:focus { outline: none; border-color: var(--brown-light); }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}

/* History slide-in panel */
.history-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 380px;
    max-width: 90vw;
    height: 100vh;
    background: var(--surface);
    box-shadow: -4px 0 24px rgba(0,0,0,.15);
    z-index: 999;
    transition: right .3s ease;
    display: flex;
    flex-direction: column;
}
.history-panel.open { right: 0; }
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    font-size: 16px;
}
.history-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0 4px;
    line-height: 1;
}
.history-close:hover { color: var(--text); }
.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
}
.history-item {
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
}
.history-item:last-child { border-bottom: none; }
.history-action {
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}
.history-item.is-return .history-action { color: #dc2626; }
.history-meta {
    font-size: 12px;
    color: var(--brown-light);
    margin-top: 2px;
}
.history-comment {
    margin-top: 6px;
    font-size: 13px;
    color: #3d2b1f;
    background: #f5f0eb;
    border: 1px solid var(--border-light);
    padding: 8px 10px;
    border-radius: 6px;
    line-height: 1.4;
}
.history-empty {
    padding: 20px 0;
    text-align: center;
    color: var(--brown-light);
    font-size: 13px;
}

/* Filter row actions (inside compact-filters grid) */
.filter-row-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    grid-column: -1;
    align-self: center;
}
.filter-row-actions .button { font-size: 13px; padding: 0 14px; white-space: nowrap; height: 50px; line-height: 50px; box-sizing: border-box; }

/* Dashboard table */
.dashboard-table { border-collapse: collapse; }
.dashboard-table th,
.dashboard-table td { padding: 6px 8px; border: 1px solid var(--border-light); font-size: 13px; }
.dashboard-table th { background: var(--bg-warm); font-weight: 600; white-space: nowrap; }
.dashboard-table .sticky-col { position: sticky; left: 0; background: #fff; z-index: 2; white-space: nowrap; min-width: 140px; }
.dashboard-table thead .sticky-col { background: var(--bg-warm); z-index: 3; }
.dash-cell-link { text-decoration: none; color: inherit; display: block; }
.dash-cell-link:hover { text-decoration: underline; }
.dash-empty    { background: #f5f5f5; color: #999; }
.dash-draft    { background: #fef3c7; color: #92400e; }
.dash-review   { background: #fed7aa; color: #9a3412; }
.dash-tu-done  { background: #dbeafe; color: #1e40af; }
.dash-approved { background: #dcfce7; color: #166534; }
.yp-dot-legend { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 4px; }
.yp-legend-item { font-size: 13px; display: inline-flex; align-items: center; }
