/* --- 1. MODERN COLOR PALETTE & TYPOGRAPHY (INSPIRED BY TAILWIND/SHADCN) --- */
:root {
    --background: #f3f6fb;
    --surface: #ffffff;
    --surface-muted: #edf1fb;
    --foreground: #0f172a;
    --muted-foreground: #475569;
    --muted: #e2e8f0;
    --primary: #6366f1;
    --primary-soft: #818cf8;
    --primary-foreground: #eef2ff;
    --border: rgba(15, 23, 42, 0.12);
    --card: #ffffff;
    --card-muted: #f8fafc;
    --card-border: rgba(15, 23, 42, 0.08);
    --success: #22c55e;
    --danger: #f87171;
    --shadow-lg: 0 25px 60px rgba(15, 23, 42, 0.18);
    --shadow-soft: 0 10px 30px rgba(15, 23, 42, 0.1);
    --shadow-card: 0 25px 45px rgba(15, 23, 42, 0.12), 0 12px 30px rgba(15, 23, 42, 0.08);
    --radius-xl: 1.5rem;
    --radius-lg: 1.25rem;
    --radius-md: 0.75rem;
}

body {
    background: radial-gradient(circle at top, rgba(99, 102, 241, 0.13), transparent 45%), var(--background);
    color: var(--foreground);
    font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

/* --- 2. COMPONENT REDESIGN --- */

/* Topbar */
.topbar {
    width: 100%;
    padding: 0.6rem 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85), rgba(229, 231, 235, 0.9));
    backdrop-filter: blur(18px);
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.12);
}
.topbar.navbar {
    padding: 0.45rem 0;
}
.topbar__collapse {
    flex-basis: auto;
    align-items: center;
    width: 100%;
}
.topbar__container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    flex-wrap: wrap;
}
.topbar__brand-group {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}
.topbar__logo {
    width: 48px;
    height: 48px;
    padding: 0.35rem;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(147, 159, 255, 0.25));
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.topbar__nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 1;
    justify-content: center;
    flex-wrap: wrap;
    padding-left: 0.2rem;
}
.topbar__nav-link {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--foreground);
    border-radius: 999px;
    padding: 0.35rem 1rem;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none;
}
.topbar__nav-link--active {
    background: rgba(99, 102, 241, 0.12);
    color: var(--primary);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.35);
}
.topbar__nav-link:hover,
.topbar__nav-link:focus-visible {
    transform: translateY(-1px);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.5);
}
.topbar__profile {
    position: relative;
    display: flex;
    align-items: center;
}
.topbar__profile-btn {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: none;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(99, 102, 241, 0.05));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.15);
}
.topbar__profile-panel {
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    width: 220px;
    padding: 1rem;
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 25px 60px rgba(15, 23, 42, 0.15);
    border: 1px solid rgba(15, 23, 42, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 50;
}
.topbar__profile-panel.topbar__profile-panel--visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.topbar__profile:hover .topbar__profile-panel,
.topbar__profile:focus-within .topbar__profile-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.topbar__profile-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
    margin-bottom: 0.75rem;
}
.topbar__profile-email {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin: 0;
}
.topbar__profile-avatar {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
}
.topbar__profile-actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.topbar__profile-item {
    text-decoration: none;
    color: var(--foreground);
    font-weight: 500;
    border: none;
    background: transparent;
    text-align: left;
    padding: 0;
    cursor: pointer;
}
.topbar__profile-item:hover {
    color: var(--primary);
}
.topbar__title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}
.topbar__subtitle {
    margin: 0;
    font-size: 0.8rem;
    color: var(--muted-foreground);
}
.topbar__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.topbar__user {
    display: flex;
    flex-direction: column;
    font-size: 0.75rem;
    color: var(--muted-foreground);
    text-align: right;
}
.topbar__user-label {
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.topbar__user-email {
    font-weight: 600;
    color: var(--foreground);
}
.topbar__link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    color: var(--foreground);
    font-weight: 500;
    transition: border-color 0.2s ease, color 0.2s ease;
    text-decoration: none;
}
.topbar__link:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.topbar__logout {
    border-radius: 14px;
    padding: 0.45rem 1.25rem;
    border: none;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: var(--primary-foreground);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    box-shadow: 0 15px 35px rgba(99, 102, 241, 0.3);
}
.topbar__logout i {
    font-size: 0.9rem;
}

.topbar__collapse .topbar__nav {
    width: 100%;
}

.navbar-toggler {
    border: none;
    padding: 0.3rem 0.65rem;
    border-radius: 12px;
    background: rgba(99, 102, 241, 0.12);
    box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.35);
}
.navbar-toggler:focus-visible {
    box-shadow: 0 0 0 0.25rem rgba(99, 102, 241, 0.35);
}
.navbar-toggler-icon {
    filter: drop-shadow(0 2px 4px rgba(15, 23, 42, 0.25));
}

@media (max-width: 991px) {
    .topbar__container {
        flex-direction: column;
        align-items: flex-start;
    }
    .topbar__nav {
        justify-content: flex-start;
        gap: 0.5rem;
    }
    .topbar__profile {
        width: 100%;
        justify-content: flex-start;
    }
}
@media (max-width: 767px) {
    .topbar__container {
        flex-direction: column;
        align-items: flex-start;
    }
    .topbar__actions {
        width: 100%;
        justify-content: space-between;
        flex-wrap: wrap;
    }
    .topbar__user {
        text-align: left;
    }
    .topbar__nav {
        width: 100%;
        justify-content: space-between;
    }
    .topbar__profile-panel {
        right: 0;
    }
}

/* Navbar */
.navbar {
    background-color: var(--card) !important;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
}
.navbar-brand {
    color: var(--foreground) !important;
}

/* Cards (General) */
.card {
    background-color: var(--card);
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    font-size: 1rem;
    font-weight: 600;
    color: var(--card-foreground);
    padding: 1.25rem 1.5rem 0.9rem;
}
.card-body {
    padding: 1.5rem;
}
.card-footer {
    background-color: var(--surface-muted);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
}

/* Redesigned Summary Cards */
.summary-card .card-body {
    padding: 1rem 1.5rem;
}
.summary-card .card-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted-foreground);
    margin-bottom: 0.25rem;
}
.summary-card .card-value {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--card-foreground);
}
.summary-card .card-icon {
    font-size: 1.5rem;
}
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-info { color: var(--primary) !important; }

/* Dashboard Shell */
.dashboard-shell {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(237, 242, 247, 0.95));
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}
.page-shell {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(239, 241, 247, 0.95));
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: 0 30px 60px rgba(15, 23, 42, 0.1);
}
.dashboard-shell__header .dash-add-btn {
    border-radius: 12px;
    padding: 0.55rem 1.5rem;
    font-weight: 600;
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.25);
}
.summary-grid .summary-card {
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(237, 242, 247, 0.8));
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-soft);
}
.summary-grid .card-body {
    padding: 1.25rem 1.5rem;
}
.summary-card .card-title {
    color: var(--muted-foreground);
}
.report-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.report-card {
    background: var(--surface);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 14px 35px rgba(15, 23, 42, 0.07);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    overflow: hidden;
}
.report-card:hover,
.report-card.active {
    transform: translateY(-6px);
    border-color: rgba(99, 102, 241, 0.7);
    box-shadow: 0 20px 45px rgba(15, 23, 42, 0.15);
}
.report-card .icon {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.12);
}
.report-card .title {
    margin: 0.8rem 0 0.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--foreground);
}
.report-card .description {
    font-size: 0.9rem;
    color: var(--muted-foreground);
    margin-bottom: 0.5rem;
}
.report-card .active-check {
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.2rem;
    color: var(--primary);
}
.report-card .active-check.d-none {
    display: none;
}
.report-card.active .active-check.d-none {
    display: block;
}
.report-shell {
    position: relative;
    padding: 2.75rem;
    border-radius: var(--radius-xl);
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(241, 243, 247, 0.85));
    overflow: hidden;
}
.report-shell::after {
    content: '';
    position: absolute;
    inset: 1rem;
    border-radius: calc(var(--radius-xl) - 6px);
    pointer-events: none;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.12), transparent 55%);
    opacity: 0.8;
}
.report-hero {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 2rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}
.report-hero__title {
    font-size: 1.85rem;
    font-weight: 700;
    margin: 0.35rem 0;
}
.report-hero__description {
    color: var(--muted-foreground);
    max-width: 420px;
}
.report-hero__tag {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    font-weight: 600;
    color: var(--primary);
    background: rgba(99, 102, 241, 0.14);
    border: 1px solid rgba(99, 102, 241, 0.4);
}
.report-hero__actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.report-hero__stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-top: 1rem;
}
.settings-card {
    border-radius: 18px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: var(--shadow-soft);
    background: var(--surface);
}
.settings-card .card-header {
    border-bottom: none;
    font-weight: 600;
}
.chart-row .chart-card {
    border-radius: var(--radius-xl);
    border: 1px solid var(--card-border);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(245, 247, 250, 0.95));
}
.chart-card .card-header {
    padding-bottom: 0.75rem;
}
.chart-card .card-body {
    min-height: 320px;
    padding: 1.5rem;
}
.transaction-card {
    border-radius: var(--radius-xl);
    border: 1px solid var(--card-border);
    overflow: hidden;
}
.transaction-card .card-body {
    padding: 0;
}
.transaction-card table {
    border: none;
}
.transaction-card thead {
    background: var(--surface);
}
.transaction-card th,
.transaction-card td {
    border-top: none;
    padding: 0.85rem 1.25rem;
}
.transaction-card tbody tr {
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
}

/* Table Redesign */
.table {
    border-collapse: collapse;
}
.table thead th {
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted-foreground);
    border-bottom: 1px solid var(--border);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}
.table tbody tr {
    transition: background-color 0.15s ease-in-out;
}
.table tbody td {
    border-top: 1px solid var(--border);
    color: var(--foreground);
    font-size: 0.875rem;
}
.table-hover tbody tr:hover {
    background-color: var(--muted);
}
.table .badge {
    font-weight: 500;
}

.table-hover tbody tr:hover {
    background-color: var(--muted);
}

.table-row-clickable tbody tr:hover {
    cursor: pointer;
}

/* Button Redesign */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--primary-foreground);
    font-weight: 500;
}
.btn-primary:hover {
    background-color: hsl(221, 83%, 48%);
    border-color: hsl(221, 83%, 48%);
}
.btn-outline-danger {
    color: var(--muted-foreground);
    border-color: var(--border);
    font-weight: 500;
}
.btn-outline-danger:hover {
    background-color: var(--danger);
    color: white;
    border-color: var(--danger);
}


/* Modal Redesign */
.modal-content {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.modal-header, .modal-footer {
    border-color: var(--border);
}

/* --- 13. TAGIFY CUSTOM STYLING --- */
.tagify {
    --tagify-dd-bg-color: var(--card);
    --tagify-dd-color-primary: var(--primary);
    border: 1px solid var(--border);
    border-radius: 0.375rem; /* Match Bootstrap's form control */
}
.tagify:hover {
    border-color: #86b7fe; /* Match Bootstrap's focus outline */
}
.tagify--focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}
.tagify__tag {
    background-color: var(--primary);
    color: var(--primary-foreground);
    font-weight: 500;
}
.tagify__tag > div::before {
    box-shadow: none;
}
.tagify__tag__removeBtn {
    color: var(--primary-foreground);
}