/* Sidebar: collapse on Calendar, expand on hover when collapsed */
.layout-calendar aside {
    width: 4rem;
}
.layout-calendar main {
    margin-left: 4rem;
}
.layout-calendar aside:hover {
    width: 14rem;
}
/* Шапка фиксированной высоты — иконки навигации не прыгают при раскрытии */
.layout-calendar aside:hover > div:first-child {
    height: 3.5rem;
    min-height: 3.5rem;
    padding: 0 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.layout-calendar aside:hover > div:first-child a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.layout-calendar aside:hover > div:first-child img {
    height: 19px;
}
.layout-calendar aside:hover nav {
    padding: 0.75rem 0.75rem;
}
.layout-calendar aside:hover > div:last-child {
    padding: 0.75rem 0.75rem;
}
.layout-calendar aside > div:first-child {
    box-sizing: border-box;
    height: 3.5rem;
    min-height: 3.5rem;
    padding: 0 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}
.layout-calendar aside > div:first-child a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}
.layout-calendar aside > div:first-child img {
    height: 19px;
}
.layout-calendar aside nav {
    padding: 0.75rem 0.5rem;
}
.layout-calendar aside > div:last-child {
    padding: 0.75rem 0.5rem;
}
/* Свернутый сайдбар календаря: только аватар и иконка выхода */
.layout-calendar aside:not(:hover) .layout-sidebar-footer #profileBtn {
    justify-content: center !important;
}
.layout-calendar aside:not(:hover) .layout-sidebar-footer #profileBtn .profile-sidebar-text {
    display: none !important;
}
.layout-calendar aside:not(:hover) .layout-sidebar-footer .layout-sidebar-logout {
    justify-content: center !important;
    padding: 0.5rem;
}
.layout-calendar aside:not(:hover) .layout-sidebar-footer .layout-sidebar-logout .layout-sidebar-logout-label {
    display: none !important;
}
/* Развёрнутый по hover: имя, должность, «Выйти» */
.layout-calendar aside:hover .layout-sidebar-footer #profileBtn {
    justify-content: flex-start !important;
}
.layout-calendar aside:hover .layout-sidebar-footer #profileBtn .profile-sidebar-text {
    display: flex !important;
    flex-direction: column;
}
.layout-calendar aside:hover .layout-sidebar-footer .layout-sidebar-logout {
    justify-content: flex-start !important;
    padding: 0.5rem 0.75rem;
}
.layout-calendar aside:hover .layout-sidebar-footer .layout-sidebar-logout .layout-sidebar-logout-label {
    display: inline !important;
}
.layout-calendar aside:hover nav a {
    justify-content: flex-start;
    padding: 0.625rem 0.75rem;
}
.layout-calendar aside:hover nav a span:last-child {
    display: inline !important;
}
.layout-calendar aside:hover > div:last-child > div {
    flex-direction: row;
    justify-content: flex-start;
    gap: 0.75rem;
}
@media (max-width: 1150px) {
    aside:hover {
        width: 14rem !important;
    }
    aside:hover > div:first-child {
        height: 3.5rem !important;
        min-height: 3.5rem !important;
        padding: 0 1rem !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    aside:hover > div:first-child a {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        width: 100% !important;
    }
    aside:hover > div:first-child img {
        height: 19px !important;
    }
    aside:hover nav {
        padding: 0.75rem 0.75rem !important;
    }
    aside:hover > div:last-child {
        padding: 0.75rem 0.75rem !important;
    }
    aside:hover nav a {
        justify-content: flex-start;
        padding: 0.625rem 0.75rem;
    }
    aside:hover nav a span:last-child {
        display: inline !important;
    }
    .layout-calendar aside:hover .layout-sidebar-footer #profileBtn {
        justify-content: flex-start !important;
    }
    .layout-calendar aside:hover .layout-sidebar-footer #profileBtn .profile-sidebar-text {
        display: flex !important;
        flex-direction: column;
    }
    .layout-calendar aside:hover .layout-sidebar-footer .layout-sidebar-logout {
        justify-content: flex-start !important;
        padding: 0.5rem 0.75rem;
    }
    .layout-calendar aside:hover .layout-sidebar-footer .layout-sidebar-logout .layout-sidebar-logout-label {
        display: inline !important;
    }
}

/* Custom styles */
@layer utilities {
    .scrollbar-hide::-webkit-scrollbar {
        display: none;
    }
    .scrollbar-hide {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Loading spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3b82f6;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/*
 * Две колонки как в календаре (Calendar.js: flex flex-col lg:flex-row gap-6, слева flex-1 min-w-0, справа w-full lg:w-64 flex-shrink-0).
 * Классы из innerHTML SPA в Tailwind CDN не попадают — дублируем здесь целиком.
 */
.calendar-page-two-col {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    align-items: stretch;
}
@media (min-width: 1024px) {
    .calendar-page-two-col {
        flex-direction: row;
        align-items: flex-start;
    }
}
.calendar-page-two-col-main {
    flex: 1 1 0%;
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.calendar-page-two-col-aside {
    box-sizing: border-box;
    width: 100%;
    flex-shrink: 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow: visible;
    min-width: 0;
}
@media (min-width: 1024px) {
    .calendar-page-two-col-aside {
        width: 16rem;
        max-width: 16rem;
        min-width: 16rem;
        align-self: flex-start;
    }
}

.statements-page {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0 1rem;
}
@media (min-width: 640px) {
    .statements-page {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}
@media (min-width: 1024px) {
    .statements-page {
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/*
 * Выписки: как календарь — строка 1 только KPI на всю ширину; строка 2: таблица | правая колонка
 * (раньше правая колонка тянулась с 1-й строки grid и «висела» над таблицей).
 */
.statements-body-grid {
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.statements-kpi-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    min-width: 0;
}
@media (min-width: 768px) {
    .statements-kpi-row {
        grid-template-columns: 1fr 1fr;
    }
    .statements-kpi-expense {
        grid-column: 1 / -1;
    }
}
@media (min-width: 1024px) {
    .statements-kpi-row {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .statements-kpi-expense {
        grid-column: auto;
    }
}
.statements-kpi-cell {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.statements-kpi-cell .statements-kpi-card-inner {
    flex: 1 1 auto;
    width: 100%;
    min-height: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.statements-right-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
    width: 100%;
}
@media (min-width: 1024px) {
    .statements-body-grid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 16rem;
        grid-template-rows: auto auto;
        gap: 1rem 1.5rem;
        align-items: start;
    }
    .statements-kpi-row {
        grid-column: 1 / -1;
        grid-row: 1;
    }
    .statements-table-panel {
        grid-column: 1;
        grid-row: 2;
        min-width: 0;
    }
    .statements-right-column {
        grid-column: 2;
        grid-row: 2;
        width: 16rem;
        max-width: 16rem;
        align-self: start;
    }
}
.statements-table-panel {
    min-width: 0;
    max-width: 100%;
}
.statements-table-scroll {
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* Список/диаграмма внутри белой панели (как таблица) */
.statements-expense-panel {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}
.statements-expense-plain {
    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: visible;
    padding: 0;
    border: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}
.statements-expense-plain-lead {
    margin: 0;
}
.statements-expense-title {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    color: #111827;
}
.dark .statements-expense-title {
    color: #fff;
}
.statements-expense-subtitle {
    margin: 0.125rem 0 0;
    font-size: 0.75rem;
    line-height: 1.125rem;
    color: #6b7280;
}
.dark .statements-expense-subtitle {
    color: #9ca3af;
}
.statements-cat-rows {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.statements-cat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    min-width: 0;
}
.statements-cat-row-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}
.statements-cat-swatch {
    width: 0.625rem;
    height: 0.625rem;
    border-radius: 0.125rem;
    flex-shrink: 0;
}
.statements-cat-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1f2937;
}
.dark .statements-cat-name {
    color: #e5e7eb;
}
.statements-cat-sum {
    flex-shrink: 0;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    color: #dc2626;
}
.dark .statements-cat-sum {
    color: #f87171;
}
.statements-expense-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-top: 0.25rem;
    border-top: 1px solid #e5e7eb;
    font-size: 0.875rem;
    line-height: 1.25rem;
}
.dark .statements-expense-total {
    border-top-color: #374151;
}
.statements-expense-total-label {
    color: #4b5563;
}
.dark .statements-expense-total-label {
    color: #d1d5db;
}
.statements-expense-total-sum {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: #dc2626;
}
.dark .statements-expense-total-sum {
    color: #f87171;
}

/* Кольцевая диаграмма: фиксированная геометрия без Tailwind aspect-square */
.statements-donut-wrap {
    position: relative;
    width: 100%;
    max-width: 220px;
    aspect-ratio: 1 / 1;
    margin-left: auto;
    margin-right: auto;
}
.statements-donut-fill {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    box-shadow: inset 0 2px 4px 0 rgb(0 0 0 / 0.08);
}
.statements-donut-hole {
    position: absolute;
    border-radius: 50%;
    inset: 22%;
    /* как фон страницы (body bg-gray-50 / dark:bg-gray-900) */
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    box-sizing: border-box;
    z-index: 1;
}
.dark .statements-donut-hole {
    background: #111827;
    border-color: #374151;
}
.statements-expense-panel .statements-donut-hole {
    background: #fff;
}
.dark .statements-expense-panel .statements-donut-hole {
    background: #1f2937;
}

/* Пустое состояние кольца */
.statements-donut-empty-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 200px;
    margin: 0 auto 1rem;
}
.statements-donut-empty-outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 14px solid #e5e7eb;
    box-sizing: border-box;
}
.dark .statements-donut-empty-outer {
    border-color: #4b5563;
}
.statements-donut-empty-hole {
    position: absolute;
    border-radius: 50%;
    inset: 18%;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}
.dark .statements-donut-empty-hole {
    background: #111827;
    border-color: #374151;
}
.statements-expense-panel .statements-donut-empty-hole {
    background: #fff;
}
.dark .statements-expense-panel .statements-donut-empty-hole {
    background: #1f2937;
}
.statements-donut-empty-hint {
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    color: #9ca3af;
    padding: 0 0.25rem;
}
.dark .statements-donut-empty-hint {
    color: #6b7280;
}

/* Горизонтальная stacked-полоса */
.statements-stacked-bar {
    display: flex;
    height: 0.75rem;
    width: 100%;
    border-radius: 9999px;
    overflow: hidden;
    background: #f3f4f6;
}
.dark .statements-stacked-bar {
    background: #374151;
}
.statements-stacked-seg {
    min-width: 0;
    height: 100%;
}
