/* ===== Аксон — Apple-style UI ===== */

:root {
    /* Бренд */
    --apple-blue:    #1E52A0;
    --apple-blue-hv: #163D80;
    --apple-blue-bg: #E8EEF7;
    /* Aliases — для исторических ссылок в шаблонах */
    --primary:       #1E52A0;
    --accent:        #1E52A0;
    --text-primary:  #1D1D1F;

    /* Семантика */
    --success: #0E9E72;
    --warning: #F59E0B;
    --danger:  #EF4444;
    --success-bg: #F0FFF6;
    --warning-bg: #FFF8EC;
    --danger-bg:  #FFF2F1;

    /* Нейтральные */
    --bg:        #E8E9ED;
    --bg-white:  #FFFFFF;
    --text:      #1D1D1F;
    --text-2:    #3A3A3C;
    --text-muted:#6E6E73;
    --border:    #D2D2D7;
    --border-light: #E5E5EA;
    --hover-bg:  rgba(0,0,0,0.04);

    /* Тени */
    --shadow-xs: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.07);
    --shadow:    0 4px 16px rgba(0,0,0,0.08);

    /* Радиусы */
    --radius-sm:   8px;
    --radius:      12px;
    --radius-lg:   18px;
    --radius-pill: 9999px;

    /* Типошкала — 6 уровней (для финансового продукта где цифры главные) */
    --text-xs:  11px;   /* labels, captions */
    --text-sm:  13px;   /* table cells, secondary text */
    --text-md:  14px;   /* base body */
    --text-lg:  16px;   /* card titles, section headings */
    --text-xl:  20px;   /* stats values */
    --text-2xl: 28px;   /* page headers, big numbers */

    /* Spacing — 4/8 шкала */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;

    /* Прочее */
    --sidebar-w: 230px;
    --tr: 0.2s ease;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 15px; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

a { color: var(--apple-blue); text-decoration: none; }
a:hover { color: var(--apple-blue-hv); }

/* ===== LAYOUT ===== */

.app-layout { display: flex; min-height: 100vh; }

/* ===== SIDEBAR ===== */

.sidebar {
    width: var(--sidebar-w);
    background: rgba(246,246,248,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-light);
    position: fixed;
    top: 0; left: 0; bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: 200;
    overflow-y: auto;
    transition: width 0.25s ease, transform var(--tr);
}


.sidebar-nav { padding: 4px 8px; flex: 1; }

.sidebar-section {
    padding: 14px 8px 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 450;
    transition: background var(--tr), color var(--tr);
    margin-bottom: 1px;
}

.sidebar-nav a svg { flex-shrink: 0; color: var(--text-muted); transition: color var(--tr); }

.sidebar-nav a:hover { background: var(--hover-bg); color: var(--text); }
.sidebar-nav a:hover svg { color: var(--text-2); }

.sidebar-nav a.active {
    background: rgba(30, 82, 160, 0.1);
    color: #1E52A0;
    font-weight: 500;
}
.sidebar-nav a.active svg { color: #1E52A0; }

.sidebar-footer {
    padding: 8px 16px 12px;
    border-top: 1px solid var(--border-light);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin: 0 -8px 2px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-footer a {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    padding: 6px 8px;
    margin: 0 -8px;
    transition: background var(--tr), color var(--tr);
}
.sidebar-footer a:hover { background: var(--hover-bg); color: var(--text-2); }

/* ===== TOPBAR (mobile) ===== */

.topbar { display: none; }

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 10px auto 4px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: background var(--tr), color var(--tr);
    align-self: flex-start;
    margin-left: 10px;
}
.sidebar-toggle:hover { background: var(--hover-bg); color: var(--text); }

.overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 190;
    backdrop-filter: blur(4px);
}

/* ===== MAIN CONTENT ===== */

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-width: 0;
    padding: 32px 36px;
    min-height: 100vh;
    transition: margin-left 0.25s ease, padding 0.25s ease;
}
/* Когда сайдбар свёрнут — даём контенту больше места по бокам */
.sidebar.collapsed ~ .main-content {
    margin-left: 56px;
    padding-left: 20px;
    padding-right: 20px;
}

/* ===== SIDEBAR COLLAPSED ===== */
.sidebar.collapsed { width: 56px; }
.sidebar.collapsed .sidebar-toggle { width: 100%; padding: 10px 0; height: auto; margin: 4px 0; }
.sidebar.collapsed .sidebar-section { display: none; }
.sidebar.collapsed .sidebar-nav a { justify-content: center; padding: 10px 0; }
.sidebar.collapsed .sidebar-nav a .nav-label { display: none; }
.sidebar.collapsed .sidebar-footer { padding: 8px 6px 10px; }
.sidebar.collapsed .sidebar-footer a { justify-content: center; padding: 10px 0; margin: 0; }
.sidebar.collapsed .sidebar-footer .nav-label { display: none; }
.sidebar.collapsed .sidebar-user { display: none; }

.sidebar-edge-toggle { display: none; }

/* Month navigation — кнопка-обёртка для пикера месяца.
   Стилизована как .btn .btn-outline (обычный размер) для визуальной
   согласованности с другими кнопками действий в шапках страниц
   ('Сверить платежи', '↓ Из выписки', '↓ Excel'). */
.month-nav {
    position: relative;
    display: inline-block;
}
.month-nav-arrow {
    width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    color: var(--text-2);
    font-size: 16px;
    line-height: 1;
    transition: background var(--tr), color var(--tr);
    text-decoration: none;
}
.month-nav-arrow:hover { background: var(--bg); color: var(--text); }

.month-nav-label {
    /* Идентично .btn .btn-outline */
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--bg-white);
    color: var(--text-2);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    transition: background var(--tr), color var(--tr), border-color var(--tr);
    white-space: nowrap;
    min-width: 120px;
    justify-content: center;
}
.month-nav-label:hover { background: var(--bg); color: var(--text); }

/* Month picker dropdown */
.month-picker {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.12);
    padding: 12px;
    width: 210px;
    z-index: 300;
}
.month-picker.open { display: block; }
.month-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.month-picker-yr-label { font-size: 14px; font-weight: 600; color: var(--text); }
.month-picker-yr-btn {
    width: 28px; height: 28px;
    border-radius: 50%;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-2);
    font-size: 16px;
    display: flex; align-items: center; justify-content: center;
    transition: background var(--tr), color var(--tr);
}
.month-picker-yr-btn:hover { background: var(--bg); color: var(--text); }
.month-picker-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}
.month-picker-cell {
    text-align: center;
    padding: 8px 4px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-2);
    text-decoration: none;
    transition: background var(--tr), color var(--tr);
}
.month-picker-cell:hover { background: var(--bg); color: var(--text); }
.month-picker-cell.active { background: var(--apple-blue); color: #fff; font-weight: 600; }

/* Tooltip for collapsed sidebar (JS-rendered) */
.sidebar-tooltip {
    position: fixed;
    background: #1C1C1E;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 7px;
    white-space: nowrap;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    opacity: 0;
    transition: opacity 0.15s;
}

/* ===== PAGE HEADER ===== */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header h1 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
    line-height: 1.2;
    min-width: 0;
}

.page-header .month-nav { flex-shrink: 0; }

.page-sub {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 3px;
    font-weight: 400;
}

/* ===== FLASH MESSAGES ===== */

.flash {
    padding: 13px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 500;
}

.flash-success { background: #F0FFF6; color: #1A5E35; border: 1px solid #A8E6BF; }
.flash-error   { background: #FFF2F1; color: #8B1A1A; border: 1px solid #FFBDBB; }

/* ===== CARDS ===== */

.card {
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: 0 2px 12px rgba(0,0,0,0.07), 0 1px 3px rgba(0,0,0,0.04);
    padding: 22px 24px;
    margin-bottom: 18px;
}

.card-header {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-bottom: 14px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 14px;
}

/* ===== STAT CARDS ===== */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 20px 22px;
}

.stat-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.6px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.stat-value.text-success { color: var(--success); }
.stat-value.text-danger  { color: var(--danger); }
.stat-value.text-warning { color: var(--warning); }

.stat-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 5px;
}

.stat-card.positive { border-top: 3px solid var(--success); }
.stat-card.negative { border-top: 3px solid var(--danger); }
.stat-card.warning  { border-top: 3px solid var(--warning); }
.stat-card.accent   { border: 1.5px solid rgba(30, 82, 160, 0.35); }

/* ===== TABLES ===== */

.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    background: var(--bg-white);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-md);
}

/* Sticky thead — шапка прилипает при вертикальном скролле страницы */
thead th {
    padding: 9px 16px;
    text-align: left;
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
    background: var(--bg-white);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 4;
}

tbody td {
    padding: 9px 16px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--tr); }
tbody tr:hover { background: #F9F9FB; }

.table-compact { font-size: var(--text-sm); }
.table-compact thead th { padding: 7px 12px; }
.table-compact tbody td { padding: 6px 12px; }
.table-clickable tbody tr { cursor: pointer; }
.table-clickable tbody tr:hover { background: #EFF6FF; }

/* Sticky columns (опционально, в данный момент не применены к таблице заказов) */
.col-sticky { position: sticky; background: var(--bg-white); z-index: 2; }
.col-sticky-0 { left: 0; }
.col-sticky-1 { left: 80px; box-shadow: 2px 0 6px -2px rgba(0,0,0,0.08); }
thead .col-sticky { z-index: 5; }
.table-clickable tbody tr:hover .col-sticky { background: #EFF6FF; }

.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-nowrap { white-space: nowrap; }
.text-money  { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.text-light  { color: var(--text-2); }
.text-muted  { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }

/* ===== FORMS ===== */

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-2);
    margin-bottom: 5px;
}

.form-control {
    width: 100%;
    padding: 9px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    transition: border-color var(--tr), box-shadow var(--tr), background var(--tr);
    appearance: none;
}
.form-control:hover {
    border-color: #AEAEB2;
}

.form-control:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0,113,227,0.15);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236E6E73' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 34px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

input[type=number].no-spinner::-webkit-inner-spin-button,
input[type=number].no-spinner::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number].no-spinner { -moz-appearance: textfield; }

.search-input {
    /* Чуть крупнее обычного поля, но без яркой рамки —
       синяя обводка появится только на focus (через .form-control:focus) */
    font-size: 15px;
    padding: 10px 14px;
    background: var(--bg-white);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px;
}

.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.form-inline .form-group { margin-bottom: 0; }

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ===== BUTTONS ===== */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 18px;
    border: none;
    border-radius: var(--radius-pill);
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--tr);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: #1E52A0;
    color: #fff;
}
.btn-primary:hover { opacity: 0.9; color: #fff; box-shadow: 0 4px 14px rgba(0,0,0,0.25); }

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { background: #0A8A63; color: #fff; }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid rgba(255,59,48,0.35);
}
.btn-danger:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

.btn-outline {
    background: var(--bg-white);
    color: var(--text-2);
    border: 1px solid var(--border);
}
.btn-outline:hover { background: var(--bg); color: var(--text); }

.btn-ghost {
    background: transparent;
    color: var(--apple-blue);
    border: none;
    padding-left: 10px;
    padding-right: 10px;
}
.btn-ghost:hover { background: var(--apple-blue-bg); }

.btn-sm { padding: 5px 13px; font-size: 12.5px; }
.btn-lg { padding: 12px 26px; font-size: 16px; }

.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }

.form-actions-sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border-light);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
.form-actions-sticky .btn-primary {
    padding: 12px 32px;
    font-size: 15px;
}
.form-has-sticky-actions {
    padding-bottom: 80px;
}

/* ===== FILTER BAR ===== */

.filter-bar {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    padding: 16px 20px;
    margin-bottom: 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filter-bar .form-group { margin-bottom: 0; min-width: 140px; }
.filter-bar label { font-size: 11.5px; margin-bottom: 4px; }

/* ===== BADGE ===== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: var(--radius-pill);
    font-size: 12px;
    font-weight: 500;
}

.badge-cash    { background: #F0FFF6; color: #1A5E35; }
.badge-card    { background: var(--apple-blue-bg); color: var(--apple-blue); }
.badge-credit  { background: #FFF8EC; color: #7A4E00; }
.badge-mixed   { background: #F5F5F7; color: var(--text-muted); }
.badge-success { background: #F0FFF6; color: #1A5E35; }
.badge-danger  { background: #FFF2F1; color: #8B1A1A; }
.badge-warning { background: #FFF8EC; color: #7A4E00; }
.badge-neutral { background: #F5F5F7; color: var(--text-muted); }

/* ===== MONTH SELECTOR ===== */

.month-selector { display: flex; align-items: center; gap: 8px; }

.month-selector select,
.month-selector input {
    padding: 7px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    font-family: inherit;
    background: var(--bg-white);
    color: var(--text);
    appearance: none;
    cursor: pointer;
}

/* ===== BAR CHART ===== */

.bar-chart { margin-top: 12px; }

.bar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
    transition: transform 0.15s ease;
    cursor: default;
}
.bar-row:hover { transform: scale(1.015); }

.v-bar-col {
    transition: transform 0.15s ease;
    transform-origin: bottom center;
    cursor: default;
}
.v-bar-col:hover { transform: scaleY(1.08); }

.bar-label { width: 140px; font-size: 12.5px; color: var(--text-muted); text-align: right; flex-shrink: 0; }
.bar-chart-managers .bar-label { text-align: left; }
.bar-chart-managers .bar-row:hover { transform: none; cursor: default; }

.bar-track {
    flex: 1;
    height: 6px;
    background: var(--border-light);
    border-radius: 99px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--apple-blue);
    border-radius: 99px;
    min-width: 2px;
    transition: width 0.4s ease;
}

.bar-fill.accent  { background: var(--warning); }
.bar-fill.success { background: var(--success); }
.bar-fill.danger  { background: var(--danger); }

.bar-value { width: 100px; font-size: 12.5px; font-weight: 600; text-align: right; flex-shrink: 0; font-variant-numeric: tabular-nums; }

/* ===== SALARY BREAKDOWN ===== */

.salary-breakdown td { font-size: 13.5px; }
.salary-breakdown .total-row td { font-weight: 700; border-top: 1px solid var(--border); padding-top: 14px; }
.salary-breakdown .section-sep td { height: 0; padding: 0; border-bottom: 1px solid var(--border-light); }

/* ===== ITEM CARDS ===== */

.item-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 14px 16px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    border-left: 3px solid var(--apple-blue);
    transition: box-shadow var(--tr);
}

.item-card:hover { box-shadow: var(--shadow-sm); }

.item-card-info { flex: 1; min-width: 0; }

.item-card-name { font-size: 14px; font-weight: 600; color: var(--text); }

.item-card-detail { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

.item-card-cat {
    display: inline-block;
    padding: 1px 9px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    background: var(--apple-blue-bg);
    color: var(--apple-blue);
    margin-right: 6px;
}

/* ===== PAYMENT TYPE BADGES ===== */

.pay-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 4px;
    margin-left: 4px;
    vertical-align: middle;
    letter-spacing: 0.02em;
}
.pay-badge-cash { background: #F0F0F3; color: var(--text-muted); }
.pay-badge-ok   { background: #DCFCE7; color: #166534; }
.pay-badge-warn { background: #FEF9C3; color: #854D0E; }
.pay-badge-inst { background: var(--apple-blue-bg); color: var(--apple-blue); }

/* ===== FILE DROP ZONE ===== */

.file-drop-zone {
    position: relative;
    border: 2px dashed #B8CCEA;
    border-radius: var(--radius-sm);
    padding: 32px 24px 28px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: #EEF3FB;
}
.file-drop-zone:hover,
.file-drop-zone.drag-over {
    border-color: var(--apple-blue);
    background: var(--apple-blue-bg);
}
.file-drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
    z-index: 2;
}
.file-drop-icon {
    color: #7A9CC8;
    margin-bottom: 12px;
    transition: color 0.2s;
}
.file-drop-zone:hover .file-drop-icon,
.file-drop-zone.drag-over .file-drop-icon {
    color: var(--apple-blue);
}
.file-drop-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 4px;
}
.file-drop-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.file-drop-pill {
    display: inline-block;
    padding: 7px 22px;
    background: var(--apple-blue);
    color: #fff;
    border-radius: var(--radius-pill);
    font-size: 13px;
    font-weight: 500;
    pointer-events: none;
    transition: background 0.2s;
}
.file-drop-zone:hover .file-drop-pill,
.file-drop-zone.drag-over .file-drop-pill {
    background: var(--apple-blue-hv);
}
.file-drop-name {
    display: none;
    margin-top: 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--apple-blue);
    background: rgba(30,82,160,0.08);
    border-radius: 6px;
    padding: 6px 12px;
}
.file-drop-name.visible { display: inline-block; }

.item-card-fields { display: flex; align-items: flex-end; gap: 8px; flex-shrink: 0; }

.item-card-fields label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 3px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.item-card-fields input { width: 100px; }

.item-totals {
    text-align: right;
    padding: 12px 16px;
    font-size: 14px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-light);
    margin-top: 6px;
}

.item-totals b { color: var(--text); font-size: 18px; font-weight: 700; }

/* ===== SEARCH DROPDOWN ===== */

.search-dropdown {
    display: none;
    position: absolute;
    z-index: 50;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--bg-white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    max-height: 280px;
    overflow-y: auto;
    box-shadow: var(--shadow);
}

.search-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: 13.5px;
    transition: background var(--tr);
}

.search-item:hover { background: var(--apple-blue-bg); }
.search-item:last-child { border-bottom: none; }

/* ===== DIVIDER ===== */

.divider { border: none; border-top: 1px solid var(--border-light); margin: 22px 0; }

/* ===== EMPTY STATE ===== */

.empty-state { text-align: center; padding: 60px 24px; color: var(--text-muted); }
.empty-state svg { margin-bottom: 14px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* ===== RESPONSIVE LAYOUT UTILITIES ===== */

/* Flex */
.r-flex          { display: flex; }
.r-flex-col      { display: flex; flex-direction: column; }
.r-flex-wrap     { display: flex; flex-wrap: wrap; }
.r-flex-between  { display: flex; justify-content: space-between; align-items: center; }
.r-flex-center   { display: flex; align-items: center; }
.r-flex-start    { display: flex; align-items: flex-start; }
.r-align-center  { align-items: center; }

/* Gaps */
.r-gap-xs  { gap: 4px; }
.r-gap-sm  { gap: 8px; }
.r-gap-md  { gap: 16px; }
.r-gap-lg  { gap: 24px; }
.r-gap-xl  { gap: 32px; }

/* Grids */
.r-grid-2   { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.r-grid-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.r-grid-4   { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.r-grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }

/* KPI banner */
.kpi-banner {
    background: linear-gradient(135deg,#1E52A0 0%,#0D3674 55%,#0058C8 100%);
    border-radius: 18px;
    padding: 28px 32px;
    margin-bottom: 24px;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    color: #fff;
    position: relative;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(30,82,160,0.22);
}
.kpi-cell {
    padding-right: 24px;
    border-right: 1px solid rgba(255,255,255,0.12);
}
.kpi-cell:first-child  { padding-left: 0; }
.kpi-cell:last-child   { padding-right: 0; border-right: none; }
.kpi-cell + .kpi-cell  { padding-left: 24px; }
.kpi-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    opacity: 0.55;
    text-transform: uppercase;
    margin-bottom: 10px;
}
.kpi-value {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
}
.kpi-sub {
    font-size: 12px;
    opacity: 0.5;
    margin-top: 8px;
}

/* Summary row (flex with wrapping stats) */
.summary-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.summary-item { min-width: 140px; }
.summary-label { font-size: 12px; color: var(--text-muted); margin-bottom: 2px; }
.summary-value { font-size: var(--text-xl); font-weight: 700; }

/* Payments (pie + legend) */
.payments-wrap  { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; }
.payments-legend { flex: 1; min-width: 180px; }

/* Period filter bar */
.period-bar { display: flex; gap: 8px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }

/* Action bar (top of list pages) */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}
.action-bar-left  { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.action-bar-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* Info row (totals line) */
.info-row { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }

/* Divider row in P&L / detail blocks */
.detail-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border-light); }
.detail-row:last-child { border-bottom: none; }
.detail-label { font-size: 13px; color: var(--text-light); }
.detail-value { font-size: 13px; font-weight: 500; }

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

@media (max-width: 900px) {

    /* Sidebar auto-collapses to icon-only, never fully hides */
    .sidebar:not(.open) { width: 56px; }
    .sidebar:not(.open) .sidebar-toggle { width: 100%; padding: 10px 0; height: auto; margin: 4px 0; }
    .sidebar:not(.open) .sidebar-section { display: none; }
    .sidebar:not(.open) .sidebar-nav a { justify-content: center; padding: 10px 0; }
    .sidebar:not(.open) .sidebar-nav a .nav-label { display: none; }
    .sidebar:not(.open) .sidebar-footer { padding: 8px 6px 10px; }
    .sidebar:not(.open) .sidebar-footer a { justify-content: center; padding: 10px 0; margin: 0; }
    .sidebar:not(.open) .sidebar-footer .nav-label { display: none; }
    .sidebar:not(.open) .sidebar-user { display: none; }

    /* When opened via hamburger: full width overlay */
    .sidebar.open { width: var(--sidebar-w); }
    .overlay.open { display: block; }

    .main-content { margin-left: 56px; padding: 24px 16px; }

    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .filter-bar { flex-direction: column; }
    .bar-label { width: 90px; font-size: 11px; }
    .bar-value { width: 80px; }
    .form-row { grid-template-columns: 1fr; }

    /* Responsive grids */
    .r-grid-3 { grid-template-columns: 1fr 1fr; }
    .r-grid-4 { grid-template-columns: 1fr 1fr; }

    /* KPI banner: 4 → 2 col */
    .kpi-banner { grid-template-columns: 1fr 1fr; padding: 20px 20px; gap: 0; }
    .kpi-cell { padding: 12px 16px 12px 0 !important; border-right: none !important; border-bottom: 1px solid rgba(255,255,255,0.12); }
    .kpi-cell:nth-child(3),
    .kpi-cell:nth-child(4) { border-bottom: none; }
    .kpi-value { font-size: 22px; }

    /* Payments: side-by-side → stacked */
    .payments-wrap { flex-direction: column; gap: 16px; }
    .payments-legend { min-width: 0; width: 100%; }

    /* Action bar */
    .action-bar { flex-direction: column; align-items: flex-start; }

    /* Summary items: shrink min-width */
    .summary-item { min-width: 120px; }
}

@media (max-width: 520px) {
    .stats-grid { grid-template-columns: 1fr; }
    .stat-value { font-size: 24px; }
    .main-content { padding: 20px 12px; }

    .r-grid-2 { grid-template-columns: 1fr; }
    .r-grid-3 { grid-template-columns: 1fr; }
    .r-grid-4 { grid-template-columns: 1fr 1fr; }

    .kpi-banner { padding: 16px; }
    .kpi-value { font-size: 20px; }

    .summary-item { min-width: 0; width: 100%; }
}


/* ===== UTILITIES ===== */

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 28px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 28px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center  { display: flex; align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.w-100 { width: 100%; }

/* ----- Typography utilities (используют переменные типошкалы) ----- */
.fs-xs   { font-size: var(--text-xs); }
.fs-sm   { font-size: var(--text-sm); }
.fs-md   { font-size: var(--text-md); }
.fs-lg   { font-size: var(--text-lg); }
.fs-xl   { font-size: var(--text-xl); }
.fs-2xl  { font-size: var(--text-2xl); }

.fw-normal   { font-weight: 400; }
.fw-medium   { font-weight: 500; }
.fw-semibold { font-weight: 600; }
.fw-bold     { font-weight: 700; }

/* ----- Color utilities ----- */
.c-text     { color: var(--text); }
.c-light    { color: var(--text-2); }
.c-muted    { color: var(--text-muted); }
.c-primary  { color: var(--apple-blue); }
.c-success  { color: var(--success); }
.c-warning  { color: var(--warning); }
.c-danger   { color: var(--danger); }

/* ----- Backgrounds (для бейджей и плашек) ----- */
.bg-primary-soft { background: var(--apple-blue-bg); }
.bg-success-soft { background: var(--success-bg); }
.bg-warning-soft { background: var(--warning-bg); }
.bg-danger-soft  { background: var(--danger-bg); }
.bg-muted        { background: var(--bg); }
.font-mono { font-variant-numeric: tabular-nums; }
