/* ============================================================
   FinHub – Main CSS Design System
   Grupo KTS Sistema Financeiro
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ────────────────────────────────────────────────────────────
   CSS CUSTOM PROPERTIES
   ──────────────────────────────────────────────────────────── */
:root {
    /* Background – Dark Theme */
    --bg-primary:    #0f172a;
    --bg-secondary:  #1e293b;
    --bg-tertiary:   #334155;

    /* Cards – Dark */
    --card-bg:     #1e293b;
    --card-border: #334155;

    /* Text – Light on Dark */
    --text-primary: #f8fafc;
    --text-muted:   #94a3b8;
    --text-subtle:  #64748b;

    /* Accent – Green (income / positive) */
    --accent-green:       #34d399;
    --accent-green-hover: #10b981;
    --accent-green-light: rgba(52, 211, 153, 0.1);

    /* Accent – Red (expense / negative) */
    --accent-red:       #f87171;
    --accent-red-hover: #ef4444;
    --accent-red-light: rgba(248, 113, 113, 0.1);

    /* Accent – Navy (primary action) */
    --accent-blue:       #60a5fa;
    --accent-blue-hover: #3b82f6;
    --accent-blue-light: rgba(96, 165, 250, 0.1);

    /* Accent – Yellow (warning) */
    --accent-yellow:       #fbbf24;
    --accent-yellow-hover: #f59e0b;
    --accent-yellow-light: rgba(251, 191, 36, 0.1);

    /* Accent – Gold (main brand) */
    --accent-purple:       #c8a951;
    --accent-purple-hover: #a08630;
    --accent-purple-light: rgba(200, 169, 81, 0.1);

    /* Accent – Cyan */
    --accent-cyan: #22d3ee;
    --accent-cyan-light: rgba(34, 211, 238, 0.1);

    /* Accent – Pink */
    --accent-pink: #f472b6;
    --accent-pink-light: rgba(244, 114, 182, 0.1);

    /* Sidebar – Dark Navy */
    --sidebar-bg:     #0f1f33;
    --sidebar-border: rgba(200, 169, 81, 0.15);
    --sidebar-active: rgba(200, 169, 81, 0.15);
    --sidebar-hover:  rgba(255, 255, 255, 0.06);
    --sidebar-width:  260px;

    /* Inputs – Dark */
    --input-bg:     #1e293b;
    --input-border: #475569;
    --input-focus:  #60a5fa;

    /* Glass – Dark */
    --glass-bg: rgba(30, 41, 59, 0.9);
    --glass-border: #334155;
    --glass-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);

    /* Gradient presets – Navy + Gold */
    --gradient-primary: linear-gradient(135deg, #1e3a5f 0%, #2a5298 100%);
    --gradient-blue-purple: linear-gradient(135deg, #1e3a5f, #2a5298);
    --gradient-green-cyan: linear-gradient(135deg, #34d399, #22d3ee);
    --gradient-red-pink: linear-gradient(135deg, #f87171, #f472b6);
    --gradient-yellow-orange: linear-gradient(135deg, #fbbf24, #fb923c);
    --gradient-purple-pink: linear-gradient(135deg, #c8a951, #e8d48b);

    /* Shadows – dark theme */
    --glow-blue: 0 4px 14px rgba(96, 165, 250, 0.2);
    --glow-purple: 0 4px 14px rgba(200, 169, 81, 0.25);
    --glow-green: 0 4px 14px rgba(52, 211, 153, 0.2);
    --glow-red: 0 4px 14px rgba(248, 113, 113, 0.2);
    --glow-pink: 0 4px 14px rgba(244, 114, 182, 0.2);

    /* Misc */
    --header-height: 60px;
    --radius-sm:   6px;
    --radius-md:   8px;
    --radius-lg:  12px;
    --radius-xl:  16px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4);
    --transition: 0.2s ease;
}

/* ────────────────────────────────────────────────────────────
   RESET & BASE
   ──────────────────────────────────────────────────────────── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent-blue);
    text-decoration: none;
    transition: color var(--transition);
}

a:hover { color: var(--accent-blue-hover); }

img { max-width: 100%; display: block; }

ul, ol { list-style: none; }

button { cursor: pointer; font-family: inherit; }

input, textarea, select { font-family: inherit; }

/* ────────────────────────────────────────────────────────────
   APP LAYOUT
   ──────────────────────────────────────────────────────────── */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ────────────────────────────────────────────────────────────
   SIDEBAR
   ──────────────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f1f33 0%, #1e3a5f 50%, #152d4a 100%);
    border-right: 1px solid rgba(200, 169, 81, 0.2);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition), transform var(--transition);
    overflow: hidden;
    box-shadow: 4px 0 24px rgba(30, 58, 95, 0.15);
}

.sidebar.collapsed {
    width: 60px;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 18px 0;
}

.sidebar.collapsed .sidebar-logo span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

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

.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-group-title,
.sidebar.collapsed .user-details {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
    pointer-events: none;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.collapsed .nav-item .nav-icon {
    margin: 0;
}

.sidebar.collapsed .user-info {
    justify-content: center;
}

.sidebar.collapsed .sidebar-footer {
    padding: 12px 0;
    justify-content: center;
}

.sidebar.collapsed .user-avatar {
    margin: 0 auto;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px;
    border-bottom: 1px solid var(--sidebar-border);
    min-height: 60px;
    flex-shrink: 0;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.sidebar-logo .logo-icon {
    width: 32px;
    height: 32px;
    background: linear-gradient(135deg, #c8a951, #e8d48b);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-logo .logo-icon svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

.sidebar-logo span {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.2s ease;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.sidebar-toggle svg { width: 16px; height: 16px; }

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px 0 12px;
    scrollbar-width: thin;
    scrollbar-color: var(--sidebar-border) transparent;
}

.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--sidebar-border); border-radius: 4px; }

/* Nav Groups */
.nav-group {
    margin-bottom: 4px;
}

.nav-group-title {
    padding: 14px 16px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-subtle);
    white-space: nowrap;
    transition: opacity 0.2s ease, width 0.2s ease;
    overflow: hidden;
}

/* Nav Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 16px;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 450;
    border-radius: 0;
    transition: background var(--transition), color var(--transition);
    position: relative;
    white-space: nowrap;
    text-decoration: none;
    margin: 1px 8px;
    border-radius: var(--radius-md);
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #c8a951;
    font-weight: 500;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: #c8a951;
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    stroke-width: 1.75;
}

.nav-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s ease, width 0.2s ease;
}

.nav-badge {
    background: var(--accent-red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    flex-shrink: 0;
}

/* Sidebar Footer */
.sidebar-footer {
    border-top: 1px solid var(--sidebar-border);
    padding: 12px 16px;
    flex-shrink: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px;
    border-radius: var(--radius-md);
    cursor: default;
}

.user-avatar {
    width: 34px;
    height: 34px;
    background: linear-gradient(135deg, #1e3a5f, #c8a951);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.user-details {
    overflow: hidden;
}

.user-name {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-subtle);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ────────────────────────────────────────────────────────────
   TOP HEADER
   ──────────────────────────────────────────────────────────── */
.top-header {
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    height: var(--header-height);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid #334155;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 90;
    transition: left var(--transition);
}

.sidebar.collapsed ~ .top-header {
    left: 60px;
}

/* Show hamburger in header when sidebar is hidden */
.sidebar.collapsed ~ .top-header .header-menu-toggle {
    display: flex;
    cursor: pointer;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: background var(--transition);
}

.header-menu-toggle:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.header-menu-toggle svg { width: 20px; height: 20px; }

/* Show the sidebar-expand button in header when sidebar is collapsed */
.header-sidebar-expand {
    display: none;
    background: none;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
    flex-shrink: 0;
}

.header-sidebar-expand:hover {
    background: rgba(30, 58, 95, 0.06);
    color: var(--accent-blue);
    border-color: rgba(30, 58, 95, 0.2);
}

.header-sidebar-expand svg { width: 16px; height: 16px; }

.sidebar.collapsed ~ .top-header .header-sidebar-expand {
    display: flex;
}

.page-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

/* Notifications */
.header-notifications {
    position: relative;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: background var(--transition), color var(--transition);
    position: relative;
}

.btn-icon:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.btn-icon svg { width: 18px; height: 18px; }

.notif-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--accent-red);
    color: #fff;
    font-size: 0.6rem;
    font-weight: 700;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--bg-secondary);
}

/* Notification Dropdown */
.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 340px;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 200;
    overflow: hidden;
}

.notif-dropdown.open { display: block; animation: fadeIn 0.15s ease; }

.notif-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notif-header h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--card-border);
    transition: background var(--transition);
    cursor: pointer;
}

.notif-item:hover { background: var(--sidebar-hover); }

.notif-item:last-child { border-bottom: none; }

.notif-item.unread { background: var(--accent-blue-light); }

.notif-item-title {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary);
}

.notif-item-msg {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.notif-item-time {
    font-size: 0.7rem;
    color: var(--text-subtle);
    margin-top: 4px;
}

.notif-empty {
    padding: 32px 16px;
    text-align: center;
    color: var(--text-subtle);
    font-size: 0.825rem;
}

/* User Menu */
.user-menu { position: relative; }

.user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 6px 10px;
    border-radius: var(--radius-md);
    font-size: 0.825rem;
    font-weight: 500;
    transition: background var(--transition), border-color var(--transition);
    cursor: pointer;
}

.user-menu-trigger:hover {
    background: var(--sidebar-hover);
    border-color: var(--accent-blue);
}

.user-avatar-sm {
    width: 26px;
    height: 26px;
    background: linear-gradient(135deg, #1e3a5f, #c8a951);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.user-menu-trigger svg { width: 14px; height: 14px; color: var(--text-subtle); }

/* User Dropdown */
.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 200px;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: none;
    z-index: 200;
    padding: 6px;
    animation: fadeIn 0.15s ease;
}

.user-dropdown.open { display: block; }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
    color: var(--text-muted);
    font-size: 0.825rem;
    border-radius: var(--radius-md);
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
    text-decoration: none;
    width: 100%;
    background: none;
    border: none;
}

.dropdown-item:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
    text-decoration: none;
}

.dropdown-item.text-danger { color: var(--accent-red); }
.dropdown-item.text-danger:hover { background: var(--accent-red-light); }
.dropdown-item svg { width: 15px; height: 15px; }

.dropdown-divider {
    border: none;
    border-top: 1px solid var(--card-border);
    margin: 4px 0;
}

/* ────────────────────────────────────────────────────────────
   MAIN CONTENT
   ──────────────────────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    padding-top: var(--header-height);
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    flex: 1;
    transition: margin-left var(--transition), width var(--transition);
}

.sidebar.collapsed ~ .top-header + .main-content,
.sidebar.collapsed ~ .main-content {
    margin-left: 60px;
    width: calc(100% - 60px);
}

.content-inner {
    padding: 24px;
    max-width: 100%;
}

/* Page Header within content */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-header-title h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header-title p {
    font-size: 0.825rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ────────────────────────────────────────────────────────────
   CARDS
   ──────────────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: border-color 0.3s ease, box-shadow 0.3s ease, transform 0.3s ease;
    position: relative;
}

.card:hover {
    border-color: rgba(96, 165, 250, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

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

.card-header h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-footer {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

/* ────────────────────────────────────────────────────────────
   KPI CARDS
   ──────────────────────────────────────────────────────────── */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-grid {
    display: grid;
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.kpi-header .kpi-icon {
    flex-shrink: 0;
}

.kpi-header .kpi-label {
    margin-top: 0;
}

.kpi-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    cursor: default;
    overflow: hidden;
    position: relative;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--gradient-blue-purple);
    transition: height 0.3s ease;
}

.kpi-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-xl);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.kpi-card:hover {
    transform: translateY(-4px);
    border-color: rgba(30, 58, 95, 0.2);
}

.kpi-card:hover::before {
    height: 5px;
}

.kpi-card:hover::after {
    opacity: 1;
}

/* ── KPI Card Color Variants – Dark theme with subtle colored accents ── */
.kpi-card.kpi-blue {
    background: linear-gradient(135deg, rgba(96, 165, 250, 0.08) 0%, var(--card-bg) 50%);
    border-color: rgba(96, 165, 250, 0.15);
}
.kpi-card.kpi-blue::before  { background: linear-gradient(90deg, #1e3a5f, #2a5298); }
.kpi-card.kpi-blue::after   { background: radial-gradient(ellipse at top left, rgba(96,165,250,0.06) 0%, transparent 60%); }
.kpi-card.kpi-blue:hover    { box-shadow: 0 8px 24px rgba(96, 165, 250, 0.15); }

.kpi-card.kpi-green {
    background: linear-gradient(135deg, rgba(52, 211, 153, 0.08) 0%, var(--card-bg) 50%);
    border-color: rgba(52, 211, 153, 0.15);
}
.kpi-card.kpi-green::before { background: linear-gradient(90deg, #34d399, #22d3ee); }
.kpi-card.kpi-green::after  { background: radial-gradient(ellipse at top left, rgba(52,211,153,0.06) 0%, transparent 60%); }
.kpi-card.kpi-green:hover   { box-shadow: 0 8px 24px rgba(52, 211, 153, 0.15); }

.kpi-card.kpi-red {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.08) 0%, var(--card-bg) 50%);
    border-color: rgba(248, 113, 113, 0.15);
}
.kpi-card.kpi-red::before   { background: linear-gradient(90deg, #f87171, #f472b6); }
.kpi-card.kpi-red::after    { background: radial-gradient(ellipse at top left, rgba(248,113,113,0.06) 0%, transparent 60%); }
.kpi-card.kpi-red:hover     { box-shadow: 0 8px 24px rgba(248, 113, 113, 0.15); }

.kpi-card.kpi-purple {
    background: linear-gradient(135deg, rgba(200, 169, 81, 0.08) 0%, var(--card-bg) 50%);
    border-color: rgba(200, 169, 81, 0.15);
}
.kpi-card.kpi-purple::before { background: linear-gradient(90deg, #c8a951, #e8d48b); }
.kpi-card.kpi-purple::after  { background: radial-gradient(ellipse at top left, rgba(200,169,81,0.06) 0%, transparent 60%); }
.kpi-card.kpi-purple:hover   { box-shadow: 0 8px 24px rgba(200, 169, 81, 0.15); }

.kpi-card.kpi-yellow {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.08) 0%, var(--card-bg) 50%);
    border-color: rgba(251, 191, 36, 0.15);
}
.kpi-card.kpi-yellow::before { background: linear-gradient(90deg, #fbbf24, #fb923c); }
.kpi-card.kpi-yellow::after  { background: radial-gradient(ellipse at top left, rgba(251,191,36,0.06) 0%, transparent 60%); }
.kpi-card.kpi-yellow:hover   { box-shadow: 0 8px 24px rgba(251, 191, 36, 0.15); }

/* ── KPI Icon Styles ── */
.kpi-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon svg { width: 22px; height: 22px; }

.kpi-card.kpi-blue   .kpi-icon { background: rgba(30, 58, 95, 0.1);  color: #1e3a5f;   box-shadow: 0 4px 12px rgba(30, 58, 95, 0.12); }
.kpi-card.kpi-green  .kpi-icon { background: rgba(40, 167, 69, 0.1);  color: #28a745;  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.12); }
.kpi-card.kpi-red    .kpi-icon { background: rgba(220, 53, 69, 0.1); color: #dc3545;    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.12); }
.kpi-card.kpi-purple .kpi-icon { background: rgba(200, 169, 81, 0.12); color: #c8a951; box-shadow: 0 4px 12px rgba(200, 169, 81, 0.15); }
.kpi-card.kpi-yellow .kpi-icon { background: rgba(255, 193, 7, 0.12);  color: #e0a800; box-shadow: 0 4px 12px rgba(255, 193, 7, 0.15); }

.kpi-content { flex: 1; min-width: 0; }

.kpi-value {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.kpi-footer {
    margin-top: 2px;
}

.kpi-badge {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.kpi-badge svg { width: 12px; height: 12px; }

.kpi-badge-up   { color: var(--accent-green); }
.kpi-badge-down { color: var(--accent-red); }

.kpi-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
    font-weight: 500;
}

.kpi-trend {
    font-size: 0.7rem;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 3px;
}

.kpi-trend.up   { color: var(--accent-green); }
.kpi-trend.down { color: var(--accent-red);   }
.kpi-trend svg  { width: 12px; height: 12px; }

/* ────────────────────────────────────────────────────────────
   BUTTONS
   ──────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 16px;
    font-family: 'Inter', sans-serif;
    font-size: 0.825rem;
    font-weight: 500;
    line-height: 1;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
}

.btn:active { transform: translateY(1px); }

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn:disabled, .btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Primary */
.btn-primary {
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #6d28d9, #db2777);
    border-color: transparent;
    box-shadow: 0 6px 20px rgba(124, 58, 237, 0.5);
    transform: translateY(-1px);
    text-decoration: none;
    color: #fff;
}

/* Success */
.btn-success {
    background: var(--accent-green);
    color: #fff;
    border-color: var(--accent-green);
}
.btn-success:hover {
    background: var(--accent-green-hover);
    border-color: var(--accent-green-hover);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
    color: #fff;
}

/* Danger */
.btn-danger {
    background: var(--accent-red);
    color: #fff;
    border-color: var(--accent-red);
}
.btn-danger:hover {
    background: var(--accent-red-hover);
    border-color: var(--accent-red-hover);
    box-shadow: 0 4px 12px rgba(244, 63, 94, 0.35);
    color: #fff;
}

/* Warning */
.btn-warning {
    background: var(--accent-yellow);
    color: #0f172a;
    border-color: var(--accent-yellow);
}
.btn-warning:hover {
    background: var(--accent-yellow-hover);
    border-color: var(--accent-yellow-hover);
    color: #0f172a;
}

/* Purple */
.btn-purple {
    background: var(--accent-purple);
    color: #fff;
    border-color: var(--accent-purple);
}
.btn-purple:hover {
    background: var(--accent-purple-hover);
    border-color: var(--accent-purple-hover);
    color: #fff;
}

/* Ghost / Outline */
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--card-border);
}
.btn-ghost:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
    border-color: var(--text-subtle);
}

/* Outline variants */
.btn-outline-blue {
    background: transparent;
    color: var(--accent-blue);
    border-color: var(--accent-blue);
}
.btn-outline-blue:hover {
    background: var(--accent-blue-light);
    color: var(--accent-blue);
}

.btn-outline-green {
    background: transparent;
    color: var(--accent-green);
    border-color: var(--accent-green);
}
.btn-outline-green:hover {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

/* Sizes */
.btn-xs  { padding: 5px 10px; font-size: 0.72rem; }
.btn-sm  { padding: 7px 12px; font-size: 0.775rem; }
.btn-lg  { padding: 12px 22px; font-size: 0.95rem; }
.btn-xl  { padding: 14px 28px; font-size: 1rem; }
.btn-full { width: 100%; }

/* Icon-only */
.btn-icon-only {
    padding: 8px;
    width: 34px;
    height: 34px;
}

/* Loading state */
.btn.loading {
    pointer-events: none;
    opacity: 0.75;
}

.btn.loading::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 6px;
}

/* ────────────────────────────────────────────────────────────
   FORMS
   ──────────────────────────────────────────────────────────── */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 0;
}

.form-row > .form-group {
    margin-bottom: 0;
}

.form-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 6px;
}

.form-label .required { color: var(--accent-red); margin-left: 2px; }

.form-control {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    appearance: none;
}

.form-control::placeholder { color: var(--text-subtle); }

.form-control:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-control:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.form-control.is-invalid { border-color: var(--accent-red); }
.form-control.is-valid   { border-color: var(--accent-green); }

textarea.form-control {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 10px 36px 10px 14px;
    font-size: 0.875rem;
    font-family: 'Inter', sans-serif;
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.form-select:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.form-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.form-hint {
    font-size: 0.72rem;
    color: var(--text-subtle);
    margin-top: 4px;
}

.form-error {
    font-size: 0.72rem;
    color: var(--accent-red);
    margin-top: 4px;
}

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

.input-prefix {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
    font-size: 0.825rem;
    pointer-events: none;
}

.input-prefix + .form-control { padding-left: 32px; }

.input-suffix {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
}

.input-suffix button {
    background: none;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}

.input-suffix button:hover { color: var(--text-primary); }
.input-suffix button svg { width: 16px; height: 16px; }

/* Form Check (checkbox/radio) */
.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

.form-check label {
    font-size: 0.875rem;
    color: var(--text-muted);
    cursor: pointer;
}

/* ────────────────────────────────────────────────────────────
   TABLES
   ──────────────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-lg);
}

.data-table,
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 1rem;
}

.data-table thead,
.table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

.data-table th,
.table th {
    padding: 12px 16px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-subtle);
    background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(139, 92, 246, 0.08));
    border-bottom: 1px solid var(--glass-border);
    text-align: left;
    white-space: nowrap;
}

.data-table th:first-child, .table th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.data-table th:last-child, .table th:last-child  { border-radius: 0 var(--radius-lg) 0 0; }

.data-table td,
.table td {
    padding: 13px 16px;
    font-size: 1rem;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    vertical-align: middle;
}

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

.data-table tbody tr:hover td,
.table tbody tr:hover td {
    background: rgba(139, 92, 246, 0.08);
}

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

/* Alternating rows */
.data-table.striped tbody tr:nth-child(even) td,
.table.striped tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

/* Table actions column */
.table-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.table-actions .btn-icon {
    width: 30px;
    height: 30px;
    border: 1px solid var(--card-border);
}

.table-actions .btn-icon svg { width: 14px; height: 14px; }

/* ────────────────────────────────────────────────────────────
   BADGES
   ──────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge-success   { background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(6,182,212,0.15));  color: var(--accent-green);  border: 1px solid rgba(16,185,129,0.2); }
.badge-danger    { background: linear-gradient(135deg, rgba(244,63,94,0.2), rgba(236,72,153,0.15));  color: var(--accent-red);    border: 1px solid rgba(244,63,94,0.2); }
.badge-warning   { background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(249,115,22,0.15)); color: var(--accent-yellow); border: 1px solid rgba(245,158,11,0.2); }
.badge-info      { background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(99,102,241,0.15)); color: var(--accent-blue);   border: 1px solid rgba(59,130,246,0.2); }
.badge-secondary { background: rgba(100,116,139,0.12);     color: #64748b;              border: 1px solid rgba(100,116,139,0.15); }
.badge-purple    { background: linear-gradient(135deg, rgba(139,92,246,0.2), rgba(236,72,153,0.15)); color: var(--accent-purple); border: 1px solid rgba(139,92,246,0.2); }

/* ────────────────────────────────────────────────────────────
   MODAL
   ──────────────────────────────────────────────────────────── */

/* ── Global overlay backdrop (used by FinHub.showModal for confirmModal etc.) ── */
.modal-overlay#modalOverlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 990;
    display: none;
}

.modal-overlay#modalOverlay.open {
    display: block;
    animation: fadeIn 0.15s ease;
}

/* ── Modal base: hidden by default ── */
.modal {
    display: none;
}

/* ── Pattern A: Global modals (confirmModal etc.) shown via FinHub.showModal ──
   These use .open class. The modal IS the dialog (no .modal-content child).
   They are siblings of #modalOverlay. ──────────────────────────────── */
.modal.open {
    display: block;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: slideInUp 0.2s ease;
}

/* ── Pattern B: Page modals (contas_pagar, usuarios etc.) shown via .active ──
   Structure: .modal > .modal-overlay + .modal-content
   The .modal wrapper acts as full-screen centering container. ──────── */
.modal.active {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 995;
    align-items: center;
    justify-content: center;
}

/* Backdrop inside page modals */
.modal.active > .modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: block;
    z-index: 0;
    cursor: pointer;
}

/* Dialog box inside page modals */
.modal > .modal-content {
    position: relative;
    z-index: 1;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    animation: slideInUp 0.2s ease;
}

/* ── Size modifiers (work for both patterns) ── */
.modal-lg.open, .modal > .modal-content.modal-lg { max-width: 760px; }
.modal-xl.open, .modal > .modal-content.modal-xl { max-width: 960px; }
.modal-sm.open, .modal > .modal-content.modal-sm { max-width: 420px; }

/* ── Shared modal internals ── */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-subtle);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    font-size: 1.4rem;
    line-height: 1;
}

.modal-close:hover {
    background: var(--sidebar-hover);
    color: var(--text-primary);
}

.modal-close svg { width: 18px; height: 18px; }

.modal-body {
    padding: 0 24px;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 20px 24px;
    margin-top: 20px;
    border-top: 1px solid var(--card-border);
}

/* ────────────────────────────────────────────────────────────
   TOAST NOTIFICATIONS
   ──────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    pointer-events: all;
    min-width: 300px;
    max-width: 400px;
    animation: slideInRight 0.3s ease;
}

.toast.fade-out {
    animation: slideOutRight 0.3s ease forwards;
}

.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 1px;
}

.toast-body { flex: 1; }

.toast-title {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 0.775rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-subtle);
    cursor: pointer;
    padding: 2px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}

.toast-close:hover { color: var(--text-primary); }
.toast-close svg { width: 14px; height: 14px; }

/* Toast variants */
.toast-success { border-left: 3px solid var(--accent-green);  }
.toast-error   { border-left: 3px solid var(--accent-red);    }
.toast-warning { border-left: 3px solid var(--accent-yellow); }
.toast-info    { border-left: 3px solid var(--accent-blue);   }

.toast-success .toast-icon { color: var(--accent-green);  }
.toast-error   .toast-icon { color: var(--accent-red);    }
.toast-warning .toast-icon { color: var(--accent-yellow); }
.toast-info    .toast-icon { color: var(--accent-blue);   }

/* ────────────────────────────────────────────────────────────
   PAGINATION
   ──────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination-info {
    font-size: 0.775rem;
    color: var(--text-subtle);
    margin-right: 12px;
}

.page-btn {
    min-width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 8px;
    background: none;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    text-decoration: none;
}

.page-btn:hover:not(:disabled) {
    background: var(--sidebar-hover);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.page-btn.active {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: #fff;
    font-weight: 600;
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ────────────────────────────────────────────────────────────
   LOADING
   ──────────────────────────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(2px);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}

.loading-overlay p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--card-border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-sm {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-inline {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--card-border) 25%, var(--bg-tertiary) 50%, var(--card-border) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text  { height: 14px; margin-bottom: 8px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-box   { height: 80px; }

/* ────────────────────────────────────────────────────────────
   FILTERS BAR
   ──────────────────────────────────────────────────────────── */
.filters-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
}

.filters-bar .form-control,
.filters-bar .form-select {
    max-width: 200px;
    padding: 8px 12px;
    font-size: 0.8rem;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 220px;
}

.search-wrapper .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-subtle);
    pointer-events: none;
}

.search-wrapper .search-icon svg { width: 15px; height: 15px; }

.search-input {
    width: 100%;
    padding-left: 34px !important;
}

/* ────────────────────────────────────────────────────────────
   ALERTS
   ──────────────────────────────────────────────────────────── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    font-size: 0.825rem;
    border: 1px solid transparent;
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }

.alert-success {
    background: var(--accent-green-light);
    border-color: rgba(16,185,129,0.3);
    color: var(--accent-green);
}

.alert-danger {
    background: var(--accent-red-light);
    border-color: rgba(244,63,94,0.3);
    color: var(--accent-red);
}

.alert-warning {
    background: var(--accent-yellow-light);
    border-color: rgba(245,158,11,0.3);
    color: var(--accent-yellow);
}

.alert-info {
    background: var(--accent-blue-light);
    border-color: rgba(59,130,246,0.3);
    color: var(--accent-blue);
}

/* ────────────────────────────────────────────────────────────
   EMPTY STATE
   ──────────────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    text-align: center;
    color: var(--text-subtle);
}

.empty-state svg {
    width: 48px;
    height: 48px;
    color: var(--card-border);
    margin-bottom: 16px;
}

.empty-state h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.empty-state p {
    font-size: 0.825rem;
    max-width: 300px;
    line-height: 1.6;
}

/* ────────────────────────────────────────────────────────────
   BREADCRUMBS
   ──────────────────────────────────────────────────────────── */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.775rem;
    color: var(--text-subtle);
    margin-bottom: 16px;
}

.breadcrumb a {
    color: var(--text-subtle);
    text-decoration: none;
    transition: color var(--transition);
}

.breadcrumb a:hover { color: var(--accent-blue); }

.breadcrumb-sep { color: var(--card-border); }

.breadcrumb-current { color: var(--text-muted); }

/* ────────────────────────────────────────────────────────────
   CHARTS
   ──────────────────────────────────────────────────────────── */
.chart-container {
    position: relative;
    width: 100%;
}

.chart-card { display: flex; flex-direction: column; }
.chart-card .chart-container { flex: 1; min-height: 0; }

/* ────────────────────────────────────────────────────────────
   DASHBOARD LAYOUT
   ──────────────────────────────────────────────────────────── */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.tables-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ────────────────────────────────────────────────────────────
   PROGRESS BARS
   ──────────────────────────────────────────────────────────── */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--card-border);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
}

.progress-fill.blue   { background: var(--accent-blue);   }
.progress-fill.green  { background: var(--accent-green);  }
.progress-fill.red    { background: var(--accent-red);    }
.progress-fill.yellow { background: var(--accent-yellow); }

/* ────────────────────────────────────────────────────────────
   TOOLTIPS
   ──────────────────────────────────────────────────────────── */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-primary);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 300;
}

[data-tooltip]:hover::after { opacity: 1; }

/* ────────────────────────────────────────────────────────────
   ANIMATIONS
   ──────────────────────────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideInRight {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: translateX(0);    opacity: 1; }
}

@keyframes slideOutRight {
    from { transform: translateX(0);    opacity: 1; }
    to   { transform: translateX(20px); opacity: 0; }
}

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

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

@keyframes skeleton-loading {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%       { transform: translateX(-8px); }
    40%       { transform: translateX(8px); }
    60%       { transform: translateX(-6px); }
    80%       { transform: translateX(6px); }
}

.animate-shake  { animation: shake  0.4s ease; }
.animate-pulse  { animation: pulse  1.5s infinite; }
.animate-fade   { animation: fadeIn 0.3s ease; }
.animate-slide  { animation: slideInUp 0.3s ease; }

/* ────────────────────────────────────────────────────────────
   UTILITY CLASSES
   ──────────────────────────────────────────────────────────── */
.text-primary  { color: var(--text-primary) !important; }
.text-muted    { color: var(--text-muted)   !important; }
.text-subtle   { color: var(--text-subtle)  !important; }
.text-green    { color: var(--accent-green) !important; }
.text-red      { color: var(--accent-red)   !important; }
.text-blue     { color: var(--accent-blue)  !important; }
.text-yellow   { color: var(--accent-yellow)!important; }
.text-purple   { color: var(--accent-purple)!important; }

.text-sm   { font-size: 0.775rem !important; }
.text-xs   { font-size: 0.7rem   !important; }
.text-lg   { font-size: 1rem     !important; }
.text-xl   { font-size: 1.15rem  !important; }

.font-bold   { font-weight: 700 !important; }
.font-semibold { font-weight: 600 !important; }
.font-medium { font-weight: 500 !important; }
.font-normal { font-weight: 400 !important; }

.text-right  { text-align: right  !important; }
.text-center { text-align: center !important; }
.text-left   { text-align: left   !important; }

.d-flex  { display: flex !important; }
.d-none  { display: none !important; }
.d-block { display: block !important; }
.d-grid  { display: grid !important; }

.align-center  { align-items: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-end  { justify-content: flex-end !important; }

.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.gap-4 { gap: 16px !important; }

.mt-0 { margin-top: 0    !important; }
.mt-1 { margin-top: 4px  !important; }
.mt-2 { margin-top: 8px  !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mt-5 { margin-top: 24px !important; }
.mt-6 { margin-top: 32px !important; }

.mb-0 { margin-bottom: 0    !important; }
.mb-1 { margin-bottom: 4px  !important; }
.mb-2 { margin-bottom: 8px  !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-5 { margin-bottom: 24px !important; }
.mb-6 { margin-bottom: 32px !important; }

.p-0  { padding: 0    !important; }
.p-2  { padding: 8px  !important; }
.p-3  { padding: 12px !important; }
.p-4  { padding: 16px !important; }
.p-5  { padding: 24px !important; }

.w-full { width: 100%  !important; }
.h-full { height: 100% !important; }

.rounded    { border-radius: var(--radius-md) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-full { border-radius: 50% !important; }

.overflow-hidden { overflow: hidden !important; }

.money-positive { color: var(--accent-green); font-weight: 600; }
.money-negative { color: var(--accent-red);   font-weight: 600; }
.money-neutral  { color: var(--text-primary); font-weight: 600; }

/* ────────────────────────────────────────────────────────────
   RESPONSIVE
   ──────────────────────────────────────────────────────────── */
@media (max-width: 1280px) {
    .kpi-row { grid-template-columns: repeat(2, 1fr); }
    .charts-row { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .tables-row { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --sidebar-width: 260px; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .top-header {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .header-menu-toggle {
        display: flex;
    }

    /* Hide the desktop sidebar-expand button on mobile */
    .header-sidebar-expand {
        display: none !important;
    }

    /* On mobile, collapsed sidebar should fully hide */
    .sidebar.collapsed {
        transform: translateX(-100%);
        width: var(--sidebar-width);
    }

    .sidebar.collapsed ~ .top-header {
        left: 0;
    }

    .sidebar.collapsed ~ .top-header + .main-content,
    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
        width: 100%;
    }

    .kpi-row { grid-template-columns: 1fr 1fr; gap: 12px; }

    .charts-row,
    .tables-row {
        grid-template-columns: 1fr;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filters-bar .form-control,
    .filters-bar .form-select {
        max-width: 100%;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .modal.open { width: 95%; }
    .modal > .modal-content { width: 95%; }

    .toast-container {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }

    .toast { min-width: unset; }
}

@media (max-width: 480px) {
    .kpi-row { grid-template-columns: 1fr; }
    .content-inner { padding: 16px; }
}

/* ────────────────────────────────────────────────────────────
   PRINT
   ──────────────────────────────────────────────────────────── */
@media print {
    .sidebar,
    .top-header,
    .filters-bar .btn,
    .table-actions,
    .pagination,
    .toast-container,
    .modal-overlay { display: none !important; }

    .main-content { margin: 0; padding: 0; }
    .card { border: 1px solid #ccc; box-shadow: none; }
    body { background: #fff; color: #000; }
    .data-table th { background: #f0f0f0; color: #000; }
    .badge { border: 1px solid currentColor; }
}

/* ────────────────────────────────────────────────────────────
   TOGGLE SWITCH
   ──────────────────────────────────────────────────────────── */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: #475569;
    border-radius: 20px;
    transition: background 0.25s ease, box-shadow 0.25s ease;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    bottom: 2px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.toggle-switch input:checked + .toggle-slider {
    background: #28a745;
}

.toggle-switch input:checked + .toggle-slider::before {
    transform: translateX(16px);
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}

.toggle-switch input:focus-visible + .toggle-slider {
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.15);
}

