:root {
    --sidebar-width: 260px;
    --sidebar-collapsed: 80px;
    --sidebar-bg: #0f1a2b;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-text: #e6edf6;
    --sidebar-muted: rgba(230, 237, 246, 0.6);
    --accent: #2b7bff;
    --accent-soft: rgba(43, 123, 255, 0.14);
    --surface: #ffffff;
    --surface-muted: #f6f7fb;
    --text: #1a1f2b;
    --shadow: 0 10px 24px rgba(15, 26, 43, 0.08);
}

body {
    font-family: "Fira Sans", "Segoe UI", Tahoma, sans-serif;
    background: radial-gradient(circle at 20% 20%, #f8fbff, #eef1f8 40%, #e6eaf3 80%);
    color: var(--text);
}

.card {
    background-color: var(--surface);
    border: 0;
    box-shadow: var(--shadow);
}

body.theme-dark {
    --surface: #1f2533;
    --surface-muted: #222a3b;
    --text: #e6edf6;
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
    background: radial-gradient(circle at 20% 20%, #1c2230, #161b28 45%, #0f1522 80%);
}

body.theme-dark .table {
    color: var(--text);
}

body.theme-dark .content-title,
body.theme-dark .section-title,
body.theme-dark h1,
body.theme-dark h2,
body.theme-dark h3,
body.theme-dark h4,
body.theme-dark h5,
body.theme-dark h6 {
    color: var(--text);
}

body.theme-dark .text-muted {
    color: var(--sidebar-muted) !important;
}

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

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f1a2b 0%, #131f35 100%);
    color: var(--sidebar-text);
    border-right: 1px solid var(--sidebar-border);
    padding: 20px;
    transition: width 0.2s ease, transform 0.25s ease;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed);
    padding: 20px 12px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 12px;
}

.sidebar-brand {
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 0.4px;
}

.sidebar.collapsed .sidebar-brand {
    display: none;
}

.sidebar-toggle {
    border: 1px solid var(--sidebar-border);
    background: transparent;
    color: var(--sidebar-text);
    border-radius: 10px;
    padding: 6px 8px;
}

.mobile-menu-toggle {
    display: none;
}

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

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    color: var(--sidebar-text);
    background: transparent;
    border: 0;
    text-align: left;
    width: 100%;
    transition: background 0.2s ease, color 0.2s ease;
}

.sidebar-nav .nav-link:hover {
    background: rgba(255, 255, 255, 0.08);
}

.sidebar-nav .nav-link.active {
    background: var(--accent-soft);
    color: #ffffff;
}

.sidebar-nav .nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
}

.sidebar.collapsed .link-text {
    display: none;
}

.content {
    flex: 1;
    padding: 32px 32px 40px;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.table-compact th,
.table-compact td {
    padding: 0.55rem 0.6rem;
}

@media (max-width: 767px) {
    .table-compact th,
    .table-compact td {
        padding: 0.4rem 0.45rem;
        font-size: 0.85rem;
    }

    .table-compact .col-secondary,
    .table-compact .col-tertiary {
        display: none;
    }
}

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

.alert-center {
    position: relative;
}

.alert-toggle {
    position: relative;
}

.alert-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #dc3545;
    color: #ffffff;
    font-size: 0.7rem;
    line-height: 18px;
    text-align: center;
}

.alert-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 320px;
    max-width: 80vw;
    background: var(--surface);
    color: var(--text);
    border-radius: 14px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(0, 0, 0, 0.08);
    z-index: 30;
    overflow: hidden;
}

body.theme-dark .alert-panel {
    border-color: rgba(255, 255, 255, 0.08);
}

.alert-panel-header {
    padding: 12px 16px;
    font-weight: 600;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

body.theme-dark .alert-panel-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

.alert-panel-body {
    max-height: 300px;
    overflow-y: auto;
    padding: 12px 16px;
    display: grid;
    gap: 12px;
}

.alert-item {
    display: grid;
    gap: 4px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.alert-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.alert-item-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.alert-item-meta {
    font-size: 0.75rem;
    color: rgba(26, 31, 43, 0.6);
}

body.theme-dark .alert-item-meta {
    color: var(--sidebar-muted);
}

.alert-panel-footer {
    padding: 10px 16px 14px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

body.theme-dark .alert-panel-footer {
    border-top-color: rgba(255, 255, 255, 0.08);
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 24px;
    display: grid;
    gap: 10px;
    z-index: 40;
}

.app-toast {
    min-width: 220px;
    max-width: 320px;
    padding: 10px 14px;
    border-radius: 10px;
    background: #1f2533;
    color: #ffffff;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    cursor: pointer;
}

.app-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.app-toast-success {
    background: #198754;
}

.app-toast-error {
    background: #dc3545;
}

.quick-toast {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-toast .quick-toast-actions {
    display: flex;
    justify-content: flex-end;
}

.quick-toast .quick-toast-undo {
    color: #ffffff;
    text-decoration: underline;
    font-size: 0.85rem;
}

.quick-entry {
    position: fixed;
    right: 24px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    z-index: 35;
}

.quick-entry-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 1.6rem;
    line-height: 1;
    padding: 0;
}

.quick-entry-panel {
    width: 320px;
    padding: 12px;
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.quick-entry-hint {
    margin-top: 6px;
    font-size: 0.75rem;
}

@media (max-width: 767px) {
    .quick-entry {
        right: 16px;
        bottom: 16px;
    }
    .quick-entry-panel {
        width: min(92vw, 320px);
    }
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.2);
    color: inherit;
    font-size: 0.75rem;
    line-height: 1;
    margin-left: 6px;
    cursor: help;
}

body.theme-dark .tooltip-icon {
    border-color: rgba(255, 255, 255, 0.3);
}

.tx-type-options {
    flex-wrap: wrap;
    gap: 6px;
}

.tx-type-option {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
}

.tx-type-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 1rem;
    line-height: 1;
    border: 1px solid currentColor;
}

.tx-type-expense {
    background: rgba(220, 53, 69, 0.12);
    color: #dc3545;
}

.tx-type-income {
    background: rgba(13, 110, 253, 0.12);
    color: #0d6efd;
}

.tx-type-transfer {
    background: rgba(25, 135, 84, 0.12);
    color: #198754;
}

.content-title {
    font-size: 1.4rem;
    margin: 0;
}

.section {
    display: none;
    animation: fadeInUp 0.25s ease;
}

.section.active {
    display: block;
}

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.report-grid {
    display: grid;
    grid-template-columns: minmax(240px, 320px) 1fr;
    gap: 24px;
    align-items: start;
}

.report-chart {
    min-height: 260px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.report-legend ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}

.report-legend li {
    display: flex;
    align-items: center;
    gap: 10px;
}

.report-legend .legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex: 0 0 12px;
}

.report-legend .legend-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

@media (max-width: 991px) {
    .report-grid {
        grid-template-columns: 1fr;
    }
    .report-chart {
        justify-content: flex-start;
    }
}

.surface {
    background: var(--surface);
    border-radius: 18px;
    padding: 24px;
    box-shadow: var(--shadow);
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

body.is-mobile .app-shell {
    flex-direction: column;
}

body.is-mobile .sidebar {
    width: min(85vw, 320px);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 1050;
    padding: 20px;
}

body.is-mobile .sidebar.mobile-open {
    transform: translateX(0) !important;
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.is-mobile .sidebar.collapsed {
    width: min(85vw, 320px);
    padding: 20px;
}

body.is-mobile .content {
    padding: 24px 16px 32px;
}

body.is-mobile .mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 991px), (hover: none) and (pointer: coarse) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: min(85vw, 320px);
        height: 100vh;
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        z-index: 1050;
        padding: 20px;
    }

    .sidebar.mobile-open {
        transform: translateX(0) !important;
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .sidebar.collapsed {
        width: min(85vw, 320px);
        padding: 20px;
    }

    .content {
        padding: 24px 16px 32px;
    }

    .mobile-menu-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}
.floating-edit-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 360px;
    max-width: 90%;
    background: #fff;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.18);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.3s ease, visibility 0.3s ease;
    z-index: 1200;
    overflow-y: auto;
    display: block;
}
.floating-edit-panel.is-visible {
    transform: translateX(0);
    visibility: visible;
}
.floating-edit-panel[hidden] {
    display: none;
}
.floating-edit-panel__inner {
    padding: 1.5rem;
    min-height: 100%;
    display: flex;
    flex-direction: column;
}
.floating-edit-panel__inner .btn-link {
    margin-top: 0.35rem;
}
@media (max-width: 768px) {
    .floating-edit-panel {
        width: 100%;
    }
}
