@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600&family=JetBrains+Mono:wght@400;500&display=swap');

/* ============================================================
   CSS Reset - Modern approach based on Josh Comeau's reset
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

body {
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img, picture, video, canvas, svg {
    display: block;
    max-width: 100%;
}

input, button, textarea, select {
    font: inherit;
}

p, h1, h2, h3, h4, h5, h6 {
    overflow-wrap: break-word;
}

#root, #__next, #app {
    isolation: isolate;
}

/* ============================================================
   Design Tokens & CSS Custom Properties
   ============================================================ */
:root {
    /* ── Typography ── */
    --text-xs:   0.6875rem;
    --text-sm:   0.8125rem;
    --text-base: 0.875rem;
    --text-lg:   1rem;
    --text-xl:   1.0625rem;
    --text-2xl:  1.25rem;
    --text-3xl:  1.5rem;
    --text-4xl:  1.875rem;

    --font-light:    300;
    --font-normal:   400;
    --font-medium:   500;
    --font-semibold: 600;
    --font-bold:     700;

    /* ── Z-Index ── */
    --z-dropdown:       100;
    --z-sticky:         200;
    --z-modal-backdrop: 300;
    --z-modal:          350;
    --z-popover:        400;
    --z-toast:          500;
    --z-tooltip:        600;
    --z-loading-screen: 9999;

    /* ── Spacing ── */
    --space-1:  0.25rem;
    --space-2:  0.375rem;
    --space-3:  0.5rem;
    --space-4:  0.75rem;
    --space-5:  1rem;
    --space-6:  1.25rem;
    --space-8:  1.5rem;
    --space-10: 2rem;
    --space-12: 2.5rem;
    --space-16: 3rem;

    /* ── Border Radius ── */
    --radius-sm:   4px;
    --radius-md:   6px;
    --radius-lg:   8px;
    --radius-xl:   10px;
    --radius-full: 9999px;

    /* ── Transitions ── */
    --transition-fast: 0.12s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    /* ── Surfaces ── */
    --bg-base:         #F7F8FA;
    --bg-card:         #FFFFFF;
    --bg-glass:        #FFFFFF;
    --bg-glass-hover:  #F7F8FA;

    /* ── Borders ── */
    --border-glass:    #EBEBEB;
    --border-strong:   #E0E0E0;
    --glass-highlight: rgba(255, 255, 255, 0.9);

    /* ── Text ── */
    --text-primary:   #111111;
    --text-secondary: #555555;
    --text-muted:     #888888;

    /* ── Accent — single orange, use sparingly ── */
    --accent:       #E8723A;
    --accent-hover: #D45F27;
    --accent-soft:  rgba(232, 114, 58, 0.08);
    --primary:      #E8723A;

    /* ── Semantic ── */
    --success:    #1A7A4A;
    --success-bg: rgba(26, 122, 74, 0.08);
    --danger:     #CC3333;
    --danger-bg:  rgba(204, 51, 51, 0.08);
    --warning:    #E8723A;
    --warning-bg: rgba(232, 114, 58, 0.08);
    --info:       #1A5FAA;
    --info-bg:    rgba(26, 95, 170, 0.08);

    /* ── Shadows — very subtle ── */
    --shadow-soft: 0 2px 12px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 1px 4px rgba(0, 0, 0, 0.04);

    /* ── Forms ── */
    --input-bg:         #FFFFFF;
    --input-border:     #E0E0E0;
    --input-focus-bg:   #FFFFFF;
    --option-bg:        #FFFFFF;
    --option-text:      #111111;

    /* ── Misc ── */
    --scrollbar-track: #F7F8FA;
    --scrollbar-thumb: rgba(0, 0, 0, 0.12);
    --scrollbar-hover: #888888;
    --table-hover:     rgba(0, 0, 0, 0.02);
    --modal-overlay:   rgba(0, 0, 0, 0.4);
    --loading-overlay: rgba(247, 248, 250, 0.92);
    --nav-hover:       rgba(0, 0, 0, 0.04);
    --date-icon-filter: none;

    /* ── Focus ── */
    --focus-ring-color:  rgba(232, 114, 58, 0.4);
    --focus-ring-width:  2px;
    --focus-ring-offset: 2px;
}

/* ============================================================
   Base Styles
   ============================================================ */
html {
    scroll-behavior: smooth;
}

body {
    background-color: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: var(--text-base);
    line-height: 1.5;
}

/* Focus Visible - Accessibility */
:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring-color);
    outline-offset: var(--focus-ring-offset);
}

:focus:not(:focus-visible) {
    outline: none;
}

button:focus:not(:focus-visible),
a:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) {
    outline: none;
}

/* ============================================================
   Accessibility Utilities
   ============================================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sr-only-focusable:focus-visible {
    position: static;
    width: auto;
    height: auto;
    padding: var(--space-2);
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: normal;
    background: var(--accent);
    color: white;
    border-radius: var(--radius-md);
    z-index: var(--z-tooltip);
}

.skip-link {
    position: absolute;
    top: -100%;
    left: var(--space-4);
    background: var(--accent);
    color: white;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    z-index: var(--z-tooltip);
    text-decoration: none;
    font-weight: var(--font-medium);
    transition: top var(--transition-fast);
}

.skip-link:focus-visible {
    top: var(--space-4);
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ============================================================
   Layout Components
   ============================================================ */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #F7F8FA;
}

.glass-panel {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    position: relative;
    transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.glass-panel:hover {
    border-color: var(--border-strong);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* ============================================================
   App Shell — Monarch-style white sidebar
   ============================================================ */

/* ── Sidebar ── */
.sidebar {
    width: 200px;
    flex-shrink: 0;
    background: #FFFFFF;
    border-right: 1px solid #EBEBEB;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Brand / Logo row */
.brand {
    height: 56px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border-bottom: 1px solid #EBEBEB;
    flex-shrink: 0;
}

.brand h2 {
    font-size: 14px;
    font-weight: 600;
    color: #111;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.logo-icon {
    width: 28px;
    height: 28px;
    background: var(--accent);
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.brand-logo-img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

/* Nav list */
.nav-links {
    list-style: none;
    flex: 1;
    padding: 8px 8px 0;
    overflow-y: auto;
}

.nav-links li {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 8px 10px;
    margin-bottom: 1px;
    border-radius: 7px;
    cursor: pointer;
    color: #333;
    font-size: 13px;
    font-weight: 400;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}

.nav-links li i {
    font-size: 13px;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.nav-links li:hover {
    background: #F7F8FA;
    color: #444;
}

.nav-links li.active {
    background: rgba(232, 114, 58, 0.08);
    color: var(--accent);
    font-weight: 500;
}

/* Sidebar footer group */
.sidebar-footer-group {
    border-top: 1px solid #EBEBEB;
    flex-shrink: 0;
}

/* Trial bar */
.trial-bar {
    padding: 10px 14px;
    border-bottom: 1px solid #EBEBEB;
}

.trial-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #888;
    margin-bottom: 5px;
}

.trial-days {
    font-weight: 500;
    color: #555;
}

.trial-progress {
    height: 3px;
    background: #EBEBEB;
    border-radius: 2px;
    overflow: hidden;
}

.trial-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 2px;
}

/* Footer links */
.sidebar-footer-links {
    padding: 4px 8px;
    border-bottom: 1px solid #EBEBEB;
}

.sidebar-footer-link {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 10px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 12.5px;
    color: #333;
    transition: background 0.12s, color 0.12s;
}

.sidebar-footer-link:hover {
    background: #F7F8FA;
    color: #444;
}

.sidebar-footer-link i {
    font-size: 12px;
    width: 16px;
    text-align: center;
}

/* User profile row at very bottom */
.user-profile {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
}

.avatar-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    user-select: none;
}

.user-details h4 {
    font-size: 12.5px;
    font-weight: 600;
    color: #111;
    margin-bottom: 0;
}

.user-details p {
    font-size: 10.5px;
    color: #BBB;
    margin-top: 0;
}

.logout-btn {
    margin-left: auto;
    width: 26px;
    height: 26px;
    border-radius: 5px;
    border: 1px solid #EBEBEB;
    background: transparent;
    color: #BBB;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: all 0.12s;
    flex-shrink: 0;
}

.logout-btn:hover {
    background: #FEF2F2;
    border-color: #FECACA;
    color: #CC3333;
}

/* ============================================================
   Main Content Area + Topbar
   ============================================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

#pageContent {
    flex: 1;
    min-height: 0;
}

/* Hamburger button — hidden on desktop, shown via mobile media query */
.hamburger-btn { display: none; }

/* Sidebar overlay — hidden by default; mobile media query shows it when .visible */
.sidebar-overlay { display: none; }

/* Inner topnav container — takes remaining space after hamburger button */
#pageTopNav {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    min-width: 0;
}

/* ── Topbar / Top Nav ── */
.top-nav {
    height: 56px;
    background: #FFFFFF;
    border-bottom: 1px solid #EBEBEB;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    gap: 16px;
}

.topnav-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.topnav-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.topnav-title {
    font-size: 15px;
    font-weight: 600;
    color: #111;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.topnav-subtitle {
    font-size: 11px;
    color: #BBB;
    margin-top: 1px;
    white-space: nowrap;
}

/* Topbar tab bar */
.topnav-tabs {
    display: flex;
    gap: 2px;
    background: #F7F8FA;
    border: 1px solid #EBEBEB;
    border-radius: 7px;
    padding: 2px;
    margin-left: 4px;
}

.topnav-tab {
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    color: #888;
    border-radius: 5px;
    cursor: pointer;
    border: none;
    background: transparent;
    font-family: inherit;
    white-space: nowrap;
    transition: all 0.12s;
}

.topnav-tab.active {
    background: #FFFFFF;
    color: #111;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.topnav-tab:hover:not(.active) {
    color: #444;
}

/* Topbar buttons */
.topnav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid #E0E0E0;
    background: #FFFFFF;
    color: #555;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: all 0.12s;
}

.topnav-btn:hover {
    background: #F7F8FA;
    color: #111;
}

.topnav-btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #FFFFFF;
    font-weight: 600;
}

.topnav-btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.topnav-icon-btn {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid #EBEBEB;
    background: transparent;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.12s;
}

.topnav-icon-btn:hover {
    background: #F7F8FA;
    color: #111;
    border-color: #E0E0E0;
}

/* ── Scrollable page area ── */
.page-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: #F7F8FA;
}

/* ============================================================
   Buttons — Clean flat style
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    font-family: inherit;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

.btn-primary {
    background: var(--accent);
    color: #FFFFFF;
    border-color: var(--accent);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    background: #FFFFFF;
    border-color: var(--border-strong);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--bg-base);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

.btn-danger:hover {
    background: #B52A2A;
    border-color: #B52A2A;
}

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-success:hover {
    background: #14603A;
}

.btn-ghost {
    background: transparent;
    border-color: var(--border-glass);
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-base);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.btn-sm {
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-3) var(--space-6);
    font-size: var(--text-base);
}

.btn-xl {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-lg);
}

.btn-full-width {
    width: 100%;
}

.icon-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
    font-size: 14px;
}

.icon-btn:hover {
    background: var(--bg-base);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.icon-btn:active {
    transform: scale(0.95);
}

.icon-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

/* Legacy Button Classes (for backward compatibility) */
.primary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    border-radius: var(--radius-md);
    border: 1px solid var(--accent);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    letter-spacing: -0.01em;
    background: var(--accent);
    color: #FFFFFF;
}

.primary-btn:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.secondary-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-strong);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    background: #FFFFFF;
    color: var(--text-secondary);
}

.secondary-btn:hover {
    background: var(--bg-base);
    color: var(--text-primary);
}

.danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    border-radius: var(--radius-md);
    border: 1px solid var(--danger);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-decoration: none;
    background: var(--danger);
    color: white;
}

.danger-btn:hover {
    background: #B52A2A;
    border-color: #B52A2A;
}

.full-width {
    width: 100%;
}

/* ============================================================
   Welcome Banner
   ============================================================ */
.welcome-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-8);
    margin-bottom: var(--space-6);
    background: #FFFFFF;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-glass);
    position: relative;
    box-shadow: var(--shadow-soft);
}

.welcome-banner h1 {
    font-size: var(--text-2xl);
    margin-bottom: var(--space-2);
    font-weight: var(--font-bold);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.welcome-banner p {
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.total-balance {
    text-align: right;
    padding: var(--space-4) var(--space-6);
    background: var(--bg-base);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-glass);
}

.total-balance .label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: var(--space-1);
    display: block;
}

.total-balance h2 {
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

/* ============================================================
   Metrics & Cards
   ============================================================ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.metric-card {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5) var(--space-6);
    background: #FFFFFF;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    cursor: default;
    overflow: hidden;
    position: relative;
    transition: box-shadow var(--transition-fast);
}

.metric-card:hover {
    box-shadow: var(--shadow-soft);
    border-color: var(--border-strong);
}

/* Icon Wrappers */
.icon-wrapper {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-base);
    flex-shrink: 0;
}

.icon-wrapper.blue  { background: var(--info-bg);    color: var(--info); }
.icon-wrapper.green { background: var(--success-bg); color: var(--success); }
.icon-wrapper.orange{ background: var(--accent-soft); color: var(--accent); }
.icon-wrapper.red   { background: var(--danger-bg);  color: var(--danger); }

.metric-info h3 {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-bottom: var(--space-1);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.metric-info p {
    font-size: var(--text-lg);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

.chart-container {
    padding: var(--space-4);
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.chart-header h3 {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
}

.dropdown-filter {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    outline: none;
    font-size: var(--text-sm);
}

.canvas-wrapper {
    position: relative;
    height: 220px;
    width: 100%;
}

/* ============================================================
   Tables
   ============================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: var(--space-3) var(--space-4);
    font-size: 10px;
    font-weight: var(--font-semibold);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-glass);
    background: var(--bg-base);
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-glass);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover td {
    background: var(--bg-base);
}

/* Monospace amounts in tables */
.data-table td.amount,
.data-table td[data-type="amount"] {
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--text-sm);
    text-align: right;
    font-weight: var(--font-medium);
}

.data-table tbody tr {
    transition: var(--transition-base);
}

.table-actions {
    display: flex;
    gap: var(--space-1);
}

.table-action-btn {
    background: transparent;
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
    font-size: var(--text-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
}

.table-action-btn:hover {
    background: var(--bg-base);
    border-color: var(--border-strong);
}

.table-action-btn.edit {
    color: var(--info);
    border-color: var(--info-bg);
}

.table-action-btn.edit:hover {
    background: var(--info-bg);
    border-color: var(--info);
}

.table-action-btn.delete {
    color: var(--danger);
    border-color: var(--danger-bg);
}

.table-action-btn.delete:hover {
    background: var(--danger-bg);
    border-color: var(--danger);
}

.table-action-btn.view {
    color: var(--success);
    border-color: var(--success-bg);
}

.table-action-btn.view:hover {
    background: var(--success-bg);
    border-color: var(--success);
}

.table-action-btn:active {
    transform: scale(0.95);
}

/* ============================================================
   Animations
   ============================================================ */
.fade-in {
    animation: fadeIn 0.8s ease-out forwards;
    opacity: 0;
    transform: translateY(20px);
}

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }

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

/* Page Navigation Transitions */
.page-scroll-area {
    animation: pageEnter 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.page-exit {
    animation: pageExit 0.25s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

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

/* ============================================================
   Modal
   ============================================================ */
.modal {
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal-backdrop);
    padding: var(--space-5);
}

.modal-content {
    background: #FFFFFF;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.12);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: var(--z-modal);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-header {
    padding: var(--space-5) var(--space-6);
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-base);
}

.modal-header h2,
.modal-header h3 {
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(40px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-content::-webkit-scrollbar {
    width: 6px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 10px;
}

/* Close Button */
.close-modal, .close-btn {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
    background: transparent;
    border: 1px solid var(--border-glass);
}

.close-modal:hover, .close-btn:hover {
    background: var(--danger-bg);
    color: var(--danger);
    border-color: var(--danger);
}

.close-modal:active, .close-btn:active {
    transform: scale(0.95);
}

.close-modal:focus-visible,
.close-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 var(--focus-ring-width) var(--focus-ring-color);
}

.modal-content > form, .modal-content > div:not(.modal-header) {
    padding: var(--space-4) var(--space-5);
}

.modal-content > h2 {
    padding: var(--space-4) var(--space-5) 0;
    font-size: var(--text-base);
    font-weight: var(--font-semibold);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.modal-content > form {
    padding-top: var(--space-3);
}

/* ============================================================
   Forms — Clean minimal
   ============================================================ */
.form-group {
    margin-bottom: var(--space-5);
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: var(--space-2);
    color: var(--text-muted);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    background: #FFFFFF;
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    font-size: var(--text-sm);
    font-family: inherit;
}

.form-group input:hover,
.form-group select:hover,
.form-group textarea:hover {
    border-color: var(--border-strong);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(232, 114, 58, 0.12);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.form-group input[readonly] {
    opacity: 0.6;
    cursor: not-allowed;
    border-style: dashed;
}

/* Select Styling */
.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-4) center;
    padding-right: var(--space-10);
}

.form-group select option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: var(--space-2);
}

/* Input with Icon */
.input-icon-wrapper {
    position: relative;
}

.input-icon-wrapper i {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.input-icon-wrapper input {
    padding-left: var(--space-10);
}

.input-icon-wrapper:focus-within i {
    color: var(--accent);
}

/* Floating Label Effect */
.form-group.floating {
    position: relative;
}

.form-group.floating label {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    transition: all var(--transition-fast);
    pointer-events: none;
    background: transparent;
    padding: 0 var(--space-1);
}

.form-group.floating input:focus ~ label,
.form-group.floating input:not(:placeholder-shown) ~ label {
    top: 0;
    font-size: var(--text-xs);
    color: var(--accent);
    background: var(--bg-base);
}

/* ============================================================
   Global Select Styles
   ============================================================ */
select, .form-group select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition-base);
    width: 100%;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right var(--space-2) center;
}

select:focus, .form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 var(--focus-ring-width) rgba(232, 114, 58, 0.15);
}

select option, .form-group select option {
    background: var(--option-bg);
    color: var(--option-text);
    padding: var(--space-1);
}

/* ============================================================
   Auth Styles
   ============================================================ */
.auth-switch {
    text-align: center;
    margin-top: var(--space-4);
    color: var(--text-secondary);
    font-size: var(--text-sm);
}

.auth-switch a {
    color: var(--accent);
    text-decoration: none;
    font-weight: var(--font-medium);
}

.auth-switch a:hover {
    text-decoration: underline;
}

.error-message {
    background: var(--danger-bg);
    color: var(--danger);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
}

.hidden {
    display: none !important;
}

.logout-btn:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring-color);
}

/* ============================================================
   Toast Notifications
   ============================================================ */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: var(--z-toast);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 16px;
    background: #111;
    color: #fff;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.2s, transform 0.2s;
    max-width: 340px;
}

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

.toast.toast-success { background: #1A7A4A; }
.toast.toast-error   { background: #CC3333; }
.toast.toast-warning { background: #C06010; }
.toast.toast-info    { background: #1A5FAA; }

/* ============================================================
   Loading States
   ============================================================ */
.btn-loading {
    display: inline-block;
}

.btn-loading.hidden {
    display: none;
}

.btn-text.hidden {
    display: none;
}

/* ============================================================
   Filters Bar
   ============================================================ */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: flex-end;
    padding: var(--space-3);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}

.filter-group label {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.filter-input {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-md);
    outline: none;
    transition: var(--transition-base);
    font-size: var(--text-sm);
}

.filter-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 var(--focus-ring-width) rgba(232, 114, 58, 0.15);
}

.filter-input::-webkit-calendar-picker-indicator {
    filter: var(--date-icon-filter);
    cursor: pointer;
}

/* ============================================================
   Text Utilities
   ============================================================ */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--text-primary); }

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-base { font-size: var(--text-base); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }

.font-light { font-weight: var(--font-light); }
.font-normal { font-weight: var(--font-normal); }
.font-medium { font-weight: var(--font-medium); }
.font-semibold { font-weight: var(--font-semibold); }
.font-bold { font-weight: var(--font-bold); }

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-1);
    margin-top: var(--space-4);
}

.pagination button {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-base);
    font-size: var(--text-sm);
}

.pagination button:hover:not(:disabled) {
    background: var(--nav-hover);
}

.pagination button:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ============================================================
   Skeleton / Loading States
   ============================================================ */
.skeleton {
    background: var(--bg-base);
    border-radius: var(--radius-md);
    animation: pulse 1.5s ease-in-out infinite;
}

.loading-pulse {
    background: var(--bg-base);
    border-radius: var(--radius-md);
    height: 20px;
    margin-bottom: var(--space-2);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

.loading-overlay {
    position: absolute;
    inset: 0;
    background: var(--loading-overlay);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-sticky);
    border-radius: var(--radius-lg);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-glass);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Scrollbar Styles
   ============================================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-hover);
}

/* ============================================================
   SweetAlert2 Overrides
   ============================================================ */
.swal2-popup.glass-panel,
.swal2-popup {
    background: var(--bg-card) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-glass) !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-soft), var(--shadow-glow) !important;
}

.swal2-popup .swal2-title {
    color: var(--text-primary) !important;
    font-size: var(--text-xl) !important;
}

.swal2-popup .swal2-html-container,
.swal2-popup .swal2-content {
    color: var(--text-secondary) !important;
    font-size: var(--text-sm) !important;
}

.swal2-popup .swal2-input,
.swal2-popup .swal2-textarea,
.swal2-popup .swal2-select {
    background: var(--input-bg) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--input-border) !important;
    border-radius: var(--radius-md) !important;
}

.swal2-popup .swal2-input:focus,
.swal2-popup .swal2-textarea:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 var(--focus-ring-width) rgba(232, 114, 58, 0.15) !important;
}

.swal2-popup .swal2-validation-message {
    background: var(--danger-bg) !important;
    color: var(--danger) !important;
}

.swal2-popup .swal2-confirm.primary-btn,
.swal2-popup .swal2-styled.swal2-confirm {
    color: #FFFFFF !important;
    background: var(--accent) !important;
    box-shadow: none !important;
    border: 1px solid var(--accent) !important;
    border-radius: var(--radius-md) !important;
    font-weight: var(--font-semibold) !important;
    padding: var(--space-2) var(--space-5) !important;
    font-size: var(--text-sm) !important;
}

.swal2-popup .swal2-cancel.secondary-btn,
.swal2-popup .swal2-styled.swal2-cancel {
    color: var(--text-primary) !important;
    border: 1px solid var(--border-strong) !important;
    background: #FFFFFF !important;
    border-radius: var(--radius-md) !important;
    font-weight: var(--font-medium) !important;
    padding: var(--space-2) var(--space-5) !important;
    font-size: var(--text-sm) !important;
}

.swal2-popup .swal2-styled.swal2-cancel:hover {
    background: var(--nav-hover) !important;
}

.swal2-popup .swal2-icon.swal2-warning {
    border-color: var(--warning) !important;
    color: var(--warning) !important;
}

.swal2-popup .swal2-icon.swal2-error {
    border-color: var(--danger) !important;
}

.swal2-popup .swal2-icon.swal2-success {
    border-color: var(--success) !important;
}

.swal2-popup .swal2-icon.swal2-info {
    border-color: var(--info) !important;
    color: var(--info) !important;
}

/* ============================================================
   Table Wrapper
   ============================================================ */
.portfolio-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.portfolio-table-wrapper .data-table {
    min-width: 600px;   /* was 780px — tablets no longer need horizontal scroll */
}

/* Sticky first column — row label stays pinned during horizontal scroll */
.portfolio-table-wrapper .data-table th:first-child,
.portfolio-table-wrapper .data-table td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-card);
}

/* ============================================================
   Responsive Breakpoints
   ============================================================ */
@media (max-width: 768px) {
    /* ── Hamburger button ── */
    .hamburger-btn {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        background: none;
        border: none;
        cursor: pointer;
        padding: 4px;
        border-radius: 6px;
    }
    .hamburger-btn:hover { background: #F5F5F5; }
    .hamburger-btn span {
        display: block;
        width: 20px;
        height: 2px;
        background: #333;
        border-radius: 2px;
        transition: transform 0.22s ease, opacity 0.22s ease;
    }
    .hamburger-btn.active span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .hamburger-btn.active span:nth-child(2) { opacity: 0; transform: scaleX(0); }
    .hamburger-btn.active span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    /* ── Sidebar → slide-in drawer ── */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 240px;
        flex-direction: column;
        transform: translateX(-240px);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: var(--z-modal);
        overflow-y: auto;
        border-right: 1px solid #EBEBEB;
        box-shadow: none;
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }

    /* ── Overlay behind drawer ── */
    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
        z-index: calc(var(--z-modal) - 5);
    }
    .sidebar-overlay.visible { display: block; }

    /* Brand and footer visible inside drawer */
    .brand,
    .sidebar-footer-group { display: flex; }

    /* Nav stays vertical inside the drawer */
    .sidebar > nav {
        flex: 1;
        display: block;
        height: auto;
        min-width: 0;
    }
    .nav-links {
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        padding: 8px 12px;
        gap: 2px;
        width: 100%;
        overflow: visible;
    }
    .nav-links li {
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        gap: 12px;
        padding: 10px 12px;
        font-size: 14px;
        border-radius: 8px;
        margin-bottom: 0;
        white-space: nowrap;
        min-width: 0;
        text-align: left;
    }
    .nav-links li i {
        font-size: 15px;
        width: 18px;
        flex-shrink: 0;
    }
    .nav-links li span { display: block; }

    /* ── Main content fills the full viewport width ── */
    .main-content {
        flex: 1;
        overflow: hidden;
        min-height: 0;
        width: 100%;
    }
    .page-scroll-area { padding: 14px 16px 20px; }

    /* Top nav */
    .top-nav { padding: 0 12px; gap: 8px; }
    .topnav-title { font-size: 13px; }
    .topnav-right {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        flex-shrink: 0;
        max-width: 60vw;
    }
    .topnav-right::-webkit-scrollbar { display: none; }
    .topnav-left { min-width: 0; flex: 1; overflow: hidden; }
    .topnav-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Grid and layout stacking */
    .metrics-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filter-group, .filter-input, .search-bar { width: 100%; }
    .tx-main-layout { flex-direction: column; }
    .summary-panel { width: 100%; margin-left: 0; position: static; }
    .modal-content { width: calc(100% - 32px); }
}

/* iPhone X+ safe area: keep content above home indicator */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .page-scroll-area {
            padding-bottom: calc(20px + env(safe-area-inset-bottom));
        }
    }
}

@media (max-width: 480px) {
    .welcome-banner {
        flex-direction: column;
        gap: var(--space-4);
        text-align: center;
    }

    .total-balance {
        text-align: center;
    }

    /* Even tighter padding on very small phones */
    .top-nav {
        padding: 0 10px;
    }

    .topnav-subtitle {
        display: none;
    }

    .page-scroll-area {
        padding: 10px 12px 72px;
    }

    /* On very small screens, hide secondary tx columns to avoid overflow */
    .tx-row-cat,
    .tx-row-account {
        display: none;
    }

    .tx-row-amount {
        min-width: 72px;
    }
}

/* ============================================================
   SweetAlert2 Custom Styles
   ============================================================ */

.swal2-popup.glass-panel.swal-glass {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-soft);
    padding: var(--space-6);
}

.swal2-actions.swal-actions {
    gap: var(--space-3);
    margin-top: var(--space-6);
}

.swal2-title.swal-title {
    color: var(--text-primary);
    font-size: var(--text-xl);
    font-weight: var(--font-semibold);
    padding: 0;
    margin-bottom: var(--space-4);
}

.swal2-html-container.swal-html {
    color: var(--text-secondary);
    font-size: var(--text-base);
    line-height: 1.6;
}

.swal2-icon {
    border-width: 3px;
}

.swal2-icon.swal2-success {
    border-color: var(--success);
    color: var(--success);
}

.swal2-icon.swal2-error {
    border-color: var(--danger);
    color: var(--danger);
}

.swal2-icon.swal2-warning {
    border-color: var(--warning);
    color: var(--warning);
}

.swal2-icon.swal2-info {
    border-color: var(--info);
    color: var(--info);
}

.swal2-confirm.btn.btn-primary,
.swal2-cancel.btn.btn-secondary {
    margin: 0;
    min-width: 120px;
}

.swal2-container {
    z-index: var(--z-modal-backdrop);
}

.swal2-backdrop-show {
    background: var(--modal-overlay);
}

/* ============================================================
   Badges / Status Pills
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: var(--font-semibold);
    letter-spacing: 0.03em;
}

.badge-income   { background: var(--success-bg); color: var(--success); }
.badge-expense  { background: var(--danger-bg);  color: var(--danger); }
.badge-transfer { background: var(--info-bg);    color: var(--info); }
.badge-warning  { background: var(--warning-bg); color: var(--warning); }

/* ============================================================
   Summary Cards Blur Toggle
   ============================================================ */

.summary-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.3rem 0.7rem;
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    user-select: none;
}

.summary-toggle-btn:hover {
    color: var(--accent);
    border-color: rgba(232, 114, 58, 0.3);
    background: var(--accent-soft);
}

.summary-toggle-btn.active {
    color: var(--accent);
    border-color: rgba(232, 114, 58, 0.35);
    background: var(--accent-soft);
}

.summary-toggle-btn i {
    font-size: 0.78rem;
    transition: transform var(--transition-fast);
}

.summary-blurable {
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.summary-blurable.blurred > *:not(.summary-blur-overlay) {
    filter: blur(10px);
    opacity: 0.45;
    pointer-events: none;
    user-select: none;
    transition: filter 0.4s ease, opacity 0.4s ease;
}

.summary-blurable:not(.blurred) > * {
    filter: blur(0);
    opacity: 1;
    transition: filter 0.4s ease, opacity 0.4s ease;
}

/* ============================================================
   Utility Classes — v2 additions
   ============================================================ */

/* Amount display — monospace, right-aligned */
.amount, .font-mono {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
}

.amount-positive { color: var(--success); }
.amount-negative { color: var(--danger); }
.amount-neutral  { color: var(--text-secondary); }

/* Card header pattern */
.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-glass);
}

.card-header-row h3, .card-header-row h2 {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

/* Page header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
}

.page-header h2 {
    font-size: var(--text-2xl);
    font-weight: var(--font-semibold);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

/* Tab bar */
.tab-bar {
    display: inline-flex;
    gap: 2px;
    background: var(--bg-base);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 2px;
}

.tab-bar-item {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
    font-weight: var(--font-semibold);
    color: var(--text-muted);
    border-radius: calc(var(--radius-md) - 2px);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.tab-bar-item.active {
    background: #FFFFFF;
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

/* Category emoji row (budget / cashflow pages) */
.category-row {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--border-glass);
    transition: background var(--transition-fast);
}

.category-row:last-child { border-bottom: none; }
.category-row:hover { background: var(--bg-base); }

.category-row-name {
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-primary);
    flex: 1;
}

.category-row-bar {
    flex: 2;
    height: 5px;
    background: var(--bg-base);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.category-row-bar-fill {
    height: 100%;
    border-radius: var(--radius-full);
    transition: width 0.6s ease;
}

.category-row-amount {
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--text-xs);
    font-weight: var(--font-medium);
    color: var(--text-muted);
    text-align: right;
    min-width: 80px;
    flex-shrink: 0;
}

/* Summary sidebar panel (Transactions page) */
.summary-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #FFFFFF;
    border-left: 1px solid var(--border-glass);
    padding: var(--space-5);
    overflow-y: auto;
}

.summary-sidebar h3 {
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
    margin-bottom: var(--space-5);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--border-glass);
    font-size: var(--text-xs);
}

.summary-row:last-child { border-bottom: none; }
.summary-row-label { color: var(--text-muted); }
.summary-row-value { font-weight: var(--font-semibold); color: var(--text-primary); }
.summary-row-value.positive { color: var(--success); }


/* ============================================================
   Component Library v2 — Monarch-Inspired
   ============================================================ */

/* ── KPI / Metric cards ── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1px;
    background: #EBEBEB;
    border: 1px solid #EBEBEB;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 20px;
}

@media (max-width: 1100px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .kpi-grid { grid-template-columns: 1fr; } }

.kpi-card { background: #FFFFFF; padding: 18px 20px; }
.kpi-card.income  { border-top: 2px solid var(--success); }
.kpi-card.expense { border-top: 2px solid var(--danger); }

.kpi-label {
    font-size: 10px; font-weight: 600; letter-spacing: 0.1em;
    text-transform: uppercase; color: #888; margin-bottom: 6px;
}

.kpi-value {
    font-size: 1.35rem; font-weight: 600; color: #111;
    letter-spacing: -0.02em; line-height: 1.2; margin-bottom: 4px;
}

.kpi-change { font-size: 11px; color: #888; display: flex; align-items: center; gap: 4px; }
.kpi-change.positive { color: var(--success); }
.kpi-change.negative { color: var(--danger); }

/* ── Page cards ── */
.page-card { background: #FFFFFF; border: 1px solid #EBEBEB; border-radius: 10px; overflow: hidden; margin-bottom: 16px; }

.page-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 18px; border-bottom: 1px solid #EBEBEB; background: #FAFAFA;
}

.page-card-title { font-size: 13px; font-weight: 600; color: #111; }
.page-card-title-sub { font-size: 12px; font-weight: 400; color: #BBB; margin-left: 4px; }
.page-card-action { font-size: 12px; font-weight: 500; color: var(--accent); cursor: pointer; text-decoration: none; }
.page-card-action:hover { text-decoration: underline; }
.page-card-body { padding: 18px; }

/* ── Skeleton loader ── */
.skel {
    background: #F0F0F0; border-radius: 5px; display: inline-block;
    animation: skelPulse 1.4s ease-in-out infinite;
}

@keyframes skelPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Transaction rows ── */
.tx-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid #EBEBEB; cursor: pointer; transition: background 0.1s; }
.tx-row:last-child { border-bottom: none; }
.tx-row:hover { background: #FAFAFA; }
.tx-row-income  { background: rgba(26,122,74,0.03); }
.tx-row-expense { background: rgba(204,51,51,0.02); }
.tx-row-income:hover  { background: rgba(26,122,74,0.06); }
.tx-row-expense:hover { background: rgba(204,51,51,0.04); }

.tx-row-icon { width: 30px; height: 30px; border-radius: 50%; background: #F7F8FA; border: 1px solid #EBEBEB; display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.tx-row-desc { flex: 1; min-width: 0; }
.tx-row-name { font-size: 13px; font-weight: 500; color: #111; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-row-cat  { font-size: 11.5px; color: #888; min-width: 100px; flex-shrink: 0; }
.tx-row-account { font-size: 11.5px; color: #888; min-width: 100px; flex-shrink: 0; }
.tx-row-amount { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; font-weight: 500; text-align: right; min-width: 90px; flex-shrink: 0; }
.tx-row-arrow { color: #DDD; font-size: 10px; flex-shrink: 0; }
.tx-row:hover .tx-row-arrow { color: #888; }

.tx-date-header { display: flex; justify-content: space-between; align-items: center; padding: 7px 18px; background: #F7F8FA; border-bottom: 1px solid #EBEBEB; }
.tx-date-label  { font-size: 11.5px; font-weight: 600; color: #888; }
.tx-date-total  { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: #888; }

/* ── Amount colour utilities ── */
.amt-pos { color: var(--success); }
.amt-neg { color: var(--danger); }
.amt-neu { color: #555; }

/* ── Transaction layout ── */
.tx-main-layout { display: flex; gap: 0; height: 100%; align-items: flex-start; }
.tx-list-area   { flex: 1; min-width: 0; }

/* ── Summary panel ── */
.summary-panel { width: 220px; flex-shrink: 0; background: #FFFFFF; border: 1px solid #EBEBEB; border-radius: 10px; margin-left: 16px; overflow: hidden; position: sticky; top: 0; }
.summary-panel-title { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; font-size: 13px; font-weight: 600; color: #111; border-bottom: 1px solid #EBEBEB; background: #FAFAFA; }
.summary-panel-rows { padding: 4px 0; }
.summary-stat-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 14px; border-bottom: 1px solid #F5F5F5; font-size: 12px; }
.summary-stat-row:last-child { border-bottom: none; }
.summary-stat-label { color: #888; }
.summary-stat-value { font-weight: 500; color: #111; }
.summary-stat-value.pos { color: var(--success); }
.summary-panel-footer { padding: 10px 14px; border-top: 1px solid #EBEBEB; }

/* ── Budget category rows ── */
.budget-cat-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid #EBEBEB; transition: background 0.1s; }
.budget-cat-row:last-child { border-bottom: none; }
.budget-cat-row:hover { background: #FAFAFA; }
.budget-cat-emoji { font-size: 16px; width: 22px; flex-shrink: 0; }
.budget-cat-name  { font-size: 13px; font-weight: 500; color: #111; width: 120px; flex-shrink: 0; }
.budget-cat-name.over { color: var(--danger); }
.budget-cat-track { flex: 1; height: 5px; background: #F0F0F0; border-radius: 3px; overflow: hidden; }
.budget-cat-fill  { height: 100%; border-radius: 3px; transition: width 0.6s ease; }
.budget-cat-amounts { font-family: 'JetBrains Mono', monospace; font-size: 11.5px; color: #888; text-align: right; min-width: 100px; flex-shrink: 0; }
.budget-cat-amounts.over { color: var(--danger); font-weight: 600; }

/* ── Page grid helpers ── */
.page-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.page-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 1024px) { .page-grid-2 { grid-template-columns: 1fr; } .page-grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px)  { .page-grid-3 { grid-template-columns: 1fr; } }

/* ── Empty state ── */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px 20px; color: #CCC; text-align: center; gap: 8px; }
.empty-state i { font-size: 28px; }
.empty-state p { font-size: 13px; color: #BBB; max-width: 260px; line-height: 1.5; }
.empty-state button { margin-top: 4px; font-size: 12px; font-weight: 600; padding: 7px 16px; background: var(--accent); color: #fff; border: none; border-radius: 6px; cursor: pointer; font-family: inherit; }

/* ── Reconciliation status bar ── */
.recon-status-bar { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 7px; font-size: 12.5px; font-weight: 500; margin-bottom: 16px; }
.recon-status-bar.matched   { background: rgba(26,122,74,0.07);  color: var(--success); border: 1px solid rgba(26,122,74,0.15); }
.recon-status-bar.unmatched { background: rgba(204,51,51,0.07);  color: var(--danger);  border: 1px solid rgba(204,51,51,0.15); }
.recon-status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ── Form field grid helpers (modal/form rows) ── */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }

@media (max-width: 640px) {
    .form-grid-2,
    .form-grid-3 { grid-template-columns: 1fr; }
}

/* ── Ledger summary mobile overrides (JS-generated inline style) ── */
@media (max-width: 640px) {
    .ledger-summary { grid-template-columns: 1fr 1fr !important; }
}
@media (max-width: 480px) {
    .ledger-summary { grid-template-columns: 1fr !important; }
}

/* ── Topnav More dropdown (mobile overflow actions) ── */
.topnav-more-wrap { position: relative; }
.topnav-more-btn  { flex-shrink: 0; }

.topnav-more-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 6px;
    z-index: var(--z-dropdown);
    min-width: 180px;
    white-space: nowrap;
}

.topnav-more-wrap.open .topnav-more-dropdown { display: flex; flex-direction: column; gap: 4px; }

/* Hide the More button on desktop — actions fit naturally */
@media (min-width: 769px) {
    .topnav-more-wrap { display: none; }
}
