* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Roboto", "Segoe UI", sans-serif;
    background: #f4f7fb;
    color: #1b1f2a;
}

.header {
    height: 60px;
    background: linear-gradient(90deg, #1b3b6f 0%, #1f4c8f 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 1100;
    /* Выше всего, включая мобильное меню */
    box-shadow: 0 10px 24px rgba(13, 33, 64, 0.18);
}

.header__left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header__logo {
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    margin-left: 8px;
}

.header__toggle {
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 10px;
}

.header__toggle:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.6);
}

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

.layout {
    display: flex;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #1b3b6f 0%, #122a52 100%);
    color: #d7e3f7;
    padding: 18px 14px;
    transition: width 0.2s ease, padding 0.2s ease;
    position: sticky;
    top: 60px;
    align-self: flex-start;
    height: calc(100vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 8px 0 24px rgba(11, 27, 52, 0.18);
}

.sidebar--collapsed,
html.sidebar-collapsed .sidebar {
    width: 72px;
    padding: 20px 10px;
}

.sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar__item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 10px 12px;
    color: inherit;
    text-decoration: none;
    border-radius: 12px;
    position: relative;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.sidebar__item i {
    width: 24px;
    height: 24px;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.sidebar__item:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    transform: translateX(2px);
}

.sidebar__text {
    white-space: nowrap;
    transition: opacity 0.15s ease, width 0.15s ease;
}

.sidebar--collapsed .sidebar__item,
html.sidebar-collapsed .sidebar__item {
    justify-content: center;
    gap: 0;
    padding: 12px;
}

.sidebar--collapsed .sidebar__item i {
    margin: 0 auto;
}

.sidebar--collapsed .sidebar__text,
html.sidebar-collapsed .sidebar__text {
    display: none;
}

.sidebar--collapsed .sidebar__item::after,
html.sidebar-collapsed .sidebar__item::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 12px);
    top: 50%;
    transform: translateY(-50%);
    background: #102a4f;
    color: #fff;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(15, 39, 71, 0.25);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.sidebar--collapsed .sidebar__item:hover::after,
html.sidebar-collapsed .sidebar__item:hover::after {
    opacity: 1;
    transform: translate(4px, -50%);
}

.sidebar__divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 0;
}

.content {
    flex: 1;
    padding: 24px;
}

.hero {
    background: #fff;
    border-radius: 16px;
    padding: 28px;
    box-shadow: 0 8px 24px rgba(15, 39, 71, 0.08);
}

.hero h1 {
    margin-top: 0;
}

.hero__actions {
    margin-top: 16px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.hero--center {
    text-align: center;
}

.hero--center p {
    margin-left: auto;
    margin-right: auto;
    max-width: 640px;
}

.dashboard {
    margin-top: 24px;
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.dashboard--center {
    grid-template-columns: 1fr;
    justify-items: center;
}

.dashboard__card {
    background: #fff;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 6px 18px rgba(15, 39, 71, 0.06);
}

.form-card {
    width: 100%;
    max-width: 460px;
}

.form-divider {
    border-top: 1px solid #e1e6ef;
    margin: 12px 0 18px;
}

.form-actions {
    margin-top: 28px;
}

.login-page {
    background: radial-gradient(circle at top, #e3ecff 0%, #f5f7fb 45%, #edf2fa 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-shell {
    width: 100%;
    max-width: 520px;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 18px 40px rgba(15, 39, 71, 0.12);
}

.login-brand {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 24px;
}

.login-brand h1 {
    margin: 0;
    font-size: 28px;
}

.login-brand p {
    margin: 2px 0 0;
    color: #5a6a85;
}

.login-brand__icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, #1b3b6f 0%, #2c5aa0 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.login-hint {
    color: #6b7a93;
    font-size: 13px;
}

.operation-type-toggle .btn-operation-income.btn-primary {
    background: #19b36b;
    border-color: #19b36b;
}

.operation-type-toggle .btn-operation-expense.btn-primary {
    background: #e24c4c;
    border-color: #e24c4c;
}

.operation-type-toggle .btn-operation-transfer.btn-primary {
    background: #7a8797;
    border-color: #7a8797;
}

.operation-type-toggle .btn-outline-primary {
    color: #1b1f2a;
    border-color: #1b1f2a;
}

.operation-type-toggle {
    display: flex;
    justify-content: center;
    width: 100%;
}

.dds-page,
.responsive-page {
    overflow-x: hidden;
    width: 100%;
}

.dds-dashboard {
    grid-template-columns: 1fr;
}

.dds-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    align-items: end;
}

.dds-filters .input-group {
    flex-wrap: nowrap;
    align-items: stretch;
}

.dds-filters .input-group .lookup {
    flex: 1 1 auto;
}

.dds-filters .input-group .btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    border-radius: 6px;
}

.dds-filters .input-group .btn:first-child {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.dds-filters .input-group .btn:last-child {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.dds-filters .input-group .lookup .form-control {
    border-radius: 0;
}

.dds-filters .input-group .btn {
    border-color: #ced4da;
    color: #1b1f2a;
}

.dds-filters .input-group .btn:hover,
.dds-filters .input-group .btn:focus {
    border-color: #ced4da;
    color: #1b1f2a;
}

.dds-filters__actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.dds-table {
    font-size: 12px;
    min-width: 960px;
    width: max-content;
}

.dds-table th,
.dds-table td {
    text-align: center;
    white-space: nowrap;
}

.dds-table {
    border-color: #2a2f3a;
}

.dds-table th,
.dds-table td {
    border-color: #212a3b;
}

.dds-table thead th {
    background: #1f6fd6;
    color: #fff;
    text-align: center !important;
    vertical-align: middle;
    padding-left: 8px;
    padding-right: 8px;
}

/* Spacious padding for reference tables (not for complex ones) */
.table-spacious th,
.table-spacious td {
    padding: 5px 8px !important;
}

.table-sort {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.table-sort:hover {
    text-decoration: none;
}

.table-sort__icon {
    font-size: 11px;
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}

.pagination-bar__label {
    font-size: 13px;
    color: #6b7a93;
}

.pagination-bar__pages {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination-bar .btn.active {
    background: #1f6fd6;
    border-color: #1f6fd6;
    color: #fff;
}

.dds-table thead th.dds-sticky-col {
    padding-top: 10px;
    padding-bottom: 10px;
}

.dds-table-card {
    width: 100%;
    overflow: hidden;
}

.table-responsive,
.dds-table-scroll {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.table-responsive::-webkit-scrollbar,
.dds-table-scroll::-webkit-scrollbar {
    display: none;
}

.dds-table-scroll {
    width: 100%;
    overflow-x: auto;
}

.dds-page .dashboard__card,
.dds-page .table-responsive {
    max-width: 100%;
}

.dds-sticky-col {
    text-align: left !important;
    min-width: 180px;
}

.dds-table thead .dds-sticky-col {
    text-align: center !important;
}

.dds-level-0 {
    padding-left: 12px;
}

.dds-level-1 {
    padding-left: 28px;
}

.dds-level-2 {
    padding-left: 44px;
}

.dds-total-col {
    min-width: 90px;
    font-weight: 600;
}

.dds-table tbody tr.dds-row-saldo td {
    background: #ffe39b !important;
}

.dds-table tbody tr.dds-row-income td {
    background: #6fdc8c !important;
}

.dds-table tbody tr.dds-row-expense td {
    background: #f3a1a1 !important;
}

.dds-table tbody tr.dds-row-diff td {
    background: #63cde3 !important;
}

.dds-table tbody tr.dds-row-transfer td {
    background: #cfd4da !important;
}

.dds-table tbody tr.dds-row-income-category td {
    background: #c9f2d8 !important;
}

.dds-table tbody tr.dds-row-expense-category td {
    background: #f9d0d0 !important;
}

.dds-table tbody tr.dds-row-saldo td,
.dds-table tbody tr.dds-row-income td,
.dds-table tbody tr.dds-row-expense td,
.dds-table tbody tr.dds-row-diff td,
.dds-table tbody tr.dds-row-transfer td,
.dds-table tbody tr.dds-row-income-category td,
.dds-table tbody tr.dds-row-expense-category td {
    font-weight: 700;
    font-size: 13px;
}

.dds-table tbody tr.dds-row-income-sub td,
.dds-table tbody tr.dds-row-expense-sub td {
    background: #ffffff !important;
    font-size: 13px;
}

.ref-grid .col-12 {
    display: flex;
}

.ref-card {
    background: #fff;
    border-radius: 18px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(15, 39, 71, 0.08);
    border: 1px solid rgba(15, 39, 71, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.ref-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(15, 39, 71, 0.12);
}

.ref-card__icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 22px;
    box-shadow: 0 12px 24px rgba(27, 59, 111, 0.25);
}

.ref-card__icon--blue {
    background: linear-gradient(135deg, #1b6cff, #66a3ff);
}

.ref-card__icon--teal {
    background: linear-gradient(135deg, #1aa6b7, #4ed0d9);
}

.ref-card__icon--purple {
    background: linear-gradient(135deg, #6f3cff, #a07bff);
}

.ref-card__icon--pink {
    background: linear-gradient(135deg, #ff5ea8, #ff91c1);
}

.ref-card__icon--orange {
    background: linear-gradient(135deg, #ff8a3d, #ffc06b);
}

.ref-card__icon--indigo {
    background: linear-gradient(135deg, #3f56ff, #7b8cff);
}

.ref-card__icon--green {
    background: linear-gradient(135deg, #16b76b, #4ddf9a);
}

.ref-card__icon--cyan {
    background: linear-gradient(135deg, #00bcd4, #4dd0e1);
}

.ref-card__title {
    margin: 0 0 6px;
    font-weight: 600;
    color: #1b1f2a;
}

.ref-card__text {
    margin: 0;
    color: #6b778c;
}

.confirm-dialog {
    border: none;
    border-radius: 14px;
    padding: 20px;
    width: min(92vw, 420px);
    box-shadow: 0 18px 45px rgba(15, 39, 71, 0.25);
}

.confirm-dialog::backdrop {
    background: rgba(15, 39, 71, 0.45);
}

.confirm-dialog__form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.confirm-dialog__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.click-row td,
.click-row th {
    cursor: pointer;
}

.click-row .cell-text {
    cursor: text;
}

.click-row td,
.click-row th {
    cursor: pointer;
}

.click-row .cell-text {
    cursor: text;
}

.table:not(.dds-table) th,
.table:not(.dds-table) td {
    white-space: nowrap;
}

.table:not(.dds-table) thead th {
    background: #1b3b6f;
    color: #fff;
    border-color: #16345f;
    padding-top: 10px;
    padding-bottom: 10px;
}

.table:not(.dds-table) {
    border-collapse: collapse;
}

.table:not(.dds-table) th,
.table:not(.dds-table) td {
    padding-top: 2px;
    padding-bottom: 2px;
    line-height: 1;
    border: 1px solid black !important;
}

/* Цвета строк в таблице операций */
.row-expense {
    --bs-table-bg: #f7b2b2;
    /* Расход - светло-красный */
    background-color: #ffe6e6;
}

.row-income {
    --bs-table-bg: #8ff78f;
    /* Доход - светло-зеленый */
    background-color: #e6ffe6;
}

.row-transfer {
    --bs-table-bg: #cacaca;
    /* Перевод - светло-серый */
    background-color: #f2f2f2;
}

.delete-btn {
    padding: 2px 6px;
    font-size: 12px;
    line-height: 1.2;
    border-radius: 6px;
}

.table:not(.dds-table) th:last-child,
.table:not(.dds-table) td:last-child {
    text-align: center;
}

.sticky-scrollbar {
    position: fixed;
    bottom: 0;
    height: 14px;
    overflow-x: auto;
    overflow-y: hidden;
    background: #f4f7fb;
    border-top: 1px solid #cfd7e3;
    z-index: 9;
}

.sticky-scrollbar__content {
    height: 1px;
}

.has-sticky-scrollbar .content {
    padding-bottom: 48px;
}

.flash-message {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.flash-message--hide {
    opacity: 0;
    transform: translateY(-4px);
}

.lookup {
    position: relative;
}

.lookup__menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 100%;
    max-height: 220px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    background: #fff;
    border: 1px solid rgba(15, 39, 71, 0.12);
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(15, 39, 71, 0.12);
}

.lookup__menu--up {
    top: auto !important;
    bottom: calc(100% + 6px) !important;
    box-shadow: 0 -12px 28px rgba(15, 39, 71, 0.12) !important;
}

.lookup__empty {
    background: #fff5f5;
    cursor: pointer;
    border-color: #fee2e2;
    transition: background 0.2s ease;
}

.lookup__empty:hover {
    background: #fee2e2 !important;
}

.lookup input::placeholder,
.hero input::placeholder {
    color: rgba(27, 31, 42, 0.35);
}

.hero input.form-control[readonly] {
    background-color: #fff;
    opacity: 1;
}

.lookup__actions {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    position: sticky;
    top: 0;
    background: #fff;
    border-bottom: 1px solid rgba(15, 39, 71, 0.08);
    z-index: 1;
}

/* Comments List Styles */
.comment-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.03);
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid rgba(0, 0, 0, 0.04);
}

.comment-text {
    font-size: 0.95rem;
    color: #2c3e50;
    line-height: 1.5;
    margin-bottom: 8px;
}

.comment-meta {
    font-size: 0.75rem;
    color: #95a5a6;
    display: flex;
    justify-content: space-between;
    font-weight: 400;
}

.lookup__actions .btn {
    flex: 1;
    background: #e9ecef;
    border-color: #cfd7e3;
    color: #4a5568;
}

.lookup__actions .btn:hover {
    background: #dee2e6;
    border-color: #c1c9d6;
    color: #2f3a4a;
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 60px;
        left: 0;
        bottom: 0;
        height: calc(100% - 60px);
        z-index: 1050;
        /* Ниже шапки (1100), выше контента */
        box-shadow: 10px 0 30px rgba(0, 0, 0, 0.4);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.2s ease;
        overflow-y: auto;
    }

    .sidebar--collapsed,
    html.sidebar-collapsed .sidebar {
        transform: translateX(-100%);
        width: 240px;
        padding: 20px 16px;
        box-shadow: none;
    }

    /* Оверлей для мобилок */
    .sidebar-overlay {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1040;
        /* Ниже меню (1050) */
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease;
    }

    html:not(.sidebar-collapsed) .sidebar-overlay {
        opacity: 1;
        pointer-events: auto;
    }

    .content {
        padding: 20px;
    }

    .header__user span {
        display: none;
    }
}

/* Фикс для модальных окон, чтобы были выше шапки и не перекрывались ею */
.modal {
    z-index: 1200 !important;
}

.modal-backdrop {
    z-index: 1150 !important;
}

.modal-dialog {
    margin-top: 80px;
    /* Отступ от шапки (60px) + 20px зазор */
}

/* Custom Status Dropdown */
.status-dropdown {
    position: relative;
    width: 100%;
}

.status-dropdown__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.status-dropdown__toggle:hover {
    background-color: rgba(255, 255, 255, 0.35);
}

.status-dropdown__toggle i {
    font-size: 0.7rem;
    margin-left: 8px;
    opacity: 0.6;
}

.status-dropdown__menu {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 180px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 15px 35px rgba(15, 39, 71, 0.25);
    border: 1px solid rgba(15, 39, 71, 0.1);
    z-index: 1000;
    display: none;
    margin-top: 6px;
    overflow: hidden;
    padding: 6px 0;
}

.status-dropdown.is-open .status-dropdown__menu {
    display: block;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.status-dropdown__item {
    padding: 8px 16px;
    cursor: pointer;
    color: #2d3748;
    transition: background-color 0.2s;
    text-align: left;
    white-space: nowrap;
}

.status-dropdown__item:hover {
    background-color: #f7fafc;
    color: #1a202c;
}


.status-dropdown__item.is-active {
    background-color: #f0f7ff;
    color: #2b6cb0;
    font-weight: 600;
}

/* Icons zoom effect */
.hover-zoom {
    display: inline-block;
    transition: transform 0.2s ease-in-out !important;
}

.hover-zoom:hover {
    transform: scale(1.25) !important;
}

/* 
 * ==========================================
 * OPU / DDS Navigation Tabs Styling
 * ==========================================
 */

.dds-page .nav-pills {
    display: inline-flex;
    padding: 6px;
    background: #f1f5f9;
    border-radius: 16px;
    gap: 4px;
    border: 1px solid #e2e8f0;
}

.dds-page .nav-pills .nav-item {
    margin: 0;
}

.dds-page .nav-pills .nav-link {
    border-radius: 12px;
    padding: 10px 24px;
    font-weight: 600;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
    letter-spacing: 0.3px;
    color: #64748b;
    background: transparent;
}

.dds-page .nav-pills .nav-link:hover:not(.active) {
    color: #334155;
    background: rgba(255, 255, 255, 0.6);
}

.dds-page .nav-pills .nav-link.active {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: scale(1.02);
}

/* Remove bg classes from html if overriding via CSS, but CSS specificity should win if structured correctly */
.dds-page .nav-pills .nav-link.bg-light.text-dark {
    background-color: transparent !important;
    /* Reset bootstrap utility */
    color: #64748b !important;
}

.dds-page .nav-pills .nav-link.bg-light.text-dark:hover {
    color: #334155 !important;
    background: rgba(255, 255, 255, 0.6) !important;
}