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

:root {
    --bg-primary: #002616; /* Deep saturated forest green background */
    --bg-secondary: #001a0e; /* Even darker green sidebar */
    --bg-card: #ffffff; /* Clean solid white cards */
    --border-color: #e2e8f0; /* Soft gray border for cards/tables */
    --border-hover: rgba(5, 65, 41, 0.2);
    
    --accent-purple: #054129; /* Deep Hunter Green for primary actions/buttons */
    --accent-purple-glow: rgba(5, 65, 41, 0.1);
    --accent-blue: #facc15; /* Logo Golden Yellow */
    --accent-blue-glow: rgba(250, 204, 21, 0.2);
    --accent-green: #15803d; /* Success Green */
    --accent-green-glow: rgba(21, 128, 61, 0.1);
    --accent-red: #b91c1c; /* Danger/Expense Red */
    --accent-red-glow: rgba(185, 28, 28, 0.1);
    --accent-warning: #eab308;
    
    --text-primary: #0f172a; /* Slate-900 for dark text in cards */
    --text-secondary: #475569; /* Slate-600 for labels and details */
    --text-muted: #94a3b8; /* Slate-400 for placeholders */
    --text-sidebar: #cbd5e1; /* Light gray text for sidebar items */
    
    --font-primary: 'Outfit', sans-serif;
    --font-secondary: 'Inter', sans-serif;
    
    --sidebar-width: 280px;
    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 6px;
    
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
}

/* Reset & Base Settings */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden;
    max-width: 100%;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-primary);
    min-height: 100vh;
    display: flex;
}

body.modal-open {
    overflow: hidden;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

/* App Layout */
.app-container {
    display: flex;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Sidebar Styling */
:root {
    --sb-bg: #001a0e;
    --sb-bg-2: #00150b;
    --sb-card: rgba(255,255,255,0.045);
    --sb-accent: #facc15;
    --sb-text: #f8fafc;
    --sb-muted: #8a9c90;
    --sb-border: rgba(255,255,255,0.08);
    --sb-hover: rgba(250,204,21,0.12);
    --sb-danger: #fca5a5;
}

.sidebar {
    width: 280px;
    height: 100vh;
    max-height: 100vh;
    background: linear-gradient(180deg, var(--sb-bg-2) 0%, var(--sb-bg) 100%) !important;
    border-right: 1px solid var(--sb-border);
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 35px rgba(0,0,0,.28);
    overflow: visible;
    z-index: 9999;
    position: fixed;
    left: 0;
    top: 0;
    padding: 0 !important; /* Reset padding for new sidebar */
    transition: width 0.2s ease, transform 0.2s ease;
}

.sidebar-logo-wrapper {
    padding: 22px 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 1px solid var(--sb-border);
}

.sidebar-logo {
    max-width: 150px;
    height: auto;
    max-height: 45px;
    object-fit: contain;
}

.sidebar-brand {
    margin: 14px 14px 12px;
    padding: 14px;
    border-radius: 18px;
    background: var(--sb-card);
    border: 1px solid var(--sb-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sidebar-brand__main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-grow: 1;
}

.sidebar-user-avatar {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8bc34a, #7cb342);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #001a0e;
    font-weight: 800;
    font-size: 16px;
    box-shadow: 0 4px 12px rgba(139, 195, 74, 0.2);
}

.sidebar-brand-text {
    min-width: 0;
    flex-grow: 1;
}

.sidebar-brand-text h2 {
    margin: 0;
    font-size: 15px;
    line-height: 1.2;
    font-weight: 800;
    color: var(--sb-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-brand-text p {
    margin: 4px 0 0;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: .08em;
    color: var(--sb-accent);
    text-transform: uppercase;
}

.sidebar-close-mobile {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    border: 1px solid var(--sb-border);
    background: rgba(255,255,255,.04);
    color: var(--sb-text);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 12px 14px;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.16);
    border-radius: 999px;
}

.sidebar-link {
    width: 100%;
    min-height: 46px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    color: var(--sb-muted);
    text-decoration: none;
    border-radius: 15px;
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 5px;
    transition: .2s ease;
    border: 1px solid transparent;
}

.sidebar-link:hover {
    background: var(--sb-hover);
    color: var(--sb-text);
    border-color: rgba(250,204,21,0.18);
}

.sidebar-link.active {
    background: rgba(250, 204, 21, 0.12);
    color: #fef08a;
    border-color: rgba(250, 204, 21, 0.25);
}

.sidebar-link.active .sidebar-link-icon {
    color: #facc15;
}

.sidebar-link-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: inherit;
    transition: all 0.2s ease;
}

.sidebar-link-text {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-section {
    margin-top: 8px;
}

.sidebar-accordion-item {
    margin-bottom: 8px;
}

.sidebar-accordion-toggle {
    width: 100%;
    min-height: 46px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--sb-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 13px;
    cursor: pointer;
    border-radius: 15px;
    font-weight: 800;
    font-size: 13px;
    transition: .2s ease;
}

.sidebar-accordion-toggle:hover,
.sidebar-accordion-toggle.active {
    background: rgba(255,255,255,.045);
    color: var(--sb-text);
    border-color: var(--sb-border);
}

.sidebar-accordion-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-accordion-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 12px;
    background: rgba(255,255,255,.045);
    border: 1px solid rgba(255,255,255,.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.sidebar-accordion-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-accordion-arrow {
    font-size: 12px;
    transition: .2s ease;
}

.sidebar-accordion-toggle.active .sidebar-accordion-arrow {
    transform: rotate(180deg);
}

.sidebar-accordion-content {
    display: none;
    padding: 4px 0 4px 12px;
}

.sidebar-accordion-content.open {
    display: block;
}

.sidebar-subnav {
    padding-left: 10px;
    border-left: 1px solid var(--sb-border);
}

.sidebar-subnav .sidebar-link {
    min-height: 42px;
    font-size: 13.5px;
    padding: 9px 11px;
}

.sidebar-subnav .sidebar-link-icon {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 14px;
}

.sidebar-bottom {
    padding: 14px 12px 18px;
    border-top: 1px solid var(--sb-border);
    background: rgba(0,0,0,.12);
    margin-top: auto;
}

.btn-logout {
    width: 100%;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 14px;
    background: rgba(239,68,68,.08);
    border: 1px solid rgba(239,68,68,.22);
    color: var(--sb-danger);
    border-radius: 16px;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    font-family: var(--font-primary);
}

.btn-logout:hover {
    background: rgba(239,68,68,.15);
    color: #fecaca;
}

/* Collapsed Sidebar Styles */
.sidebar.sidebar-collapsed,
.sidebar-collapsed .sidebar {
    width: 82px;
}

.sidebar.sidebar-collapsed .sidebar-brand-text,
.sidebar.sidebar-collapsed .sidebar-link-text,
.sidebar.sidebar-collapsed .sidebar-accordion-label,
.sidebar.sidebar-collapsed .sidebar-accordion-arrow,
.sidebar.sidebar-collapsed .brand-name,
.sidebar-collapsed .sidebar .sidebar-brand-text,
.sidebar-collapsed .sidebar .sidebar-link-text,
.sidebar-collapsed .sidebar .sidebar-accordion-label,
.sidebar-collapsed .sidebar .sidebar-accordion-arrow,
.sidebar-collapsed .sidebar .brand-name {
    display: none !important;
}

.sidebar.sidebar-collapsed .brand-collapsed-logo,
.sidebar-collapsed .sidebar .brand-collapsed-logo {
    display: block !important;
}

.sidebar.sidebar-collapsed .sidebar-logo-wrapper,
.sidebar-collapsed .sidebar .sidebar-logo-wrapper {
    justify-content: center;
    padding: 22px 0;
}

.sidebar.sidebar-collapsed .sidebar-brand,
.sidebar-collapsed .sidebar .sidebar-brand {
    background: transparent !important;
    border-color: transparent !important;
    margin: 14px auto 12px !important;
    padding: 0 !important;
    justify-content: center !important;
    width: 48px !important;
    height: 48px !important;
}

.sidebar.sidebar-collapsed .sidebar-brand__main,
.sidebar-collapsed .sidebar .sidebar-brand__main {
    justify-content: center !important;
}

.sidebar.sidebar-collapsed .sidebar-user-avatar,
.sidebar-collapsed .sidebar .sidebar-user-avatar {
    margin: 0 !important;
}

.sidebar.sidebar-collapsed .sidebar-link,
.sidebar-collapsed .sidebar .sidebar-link {
    justify-content: center !important;
    padding: 0 !important;
    width: 46px !important;
    height: 46px !important;
    border-radius: 50% !important; /* Circular links in collapsed state */
    margin: 0 auto 8px !important;
    display: flex !important;
    align-items: center !important;
}

.sidebar.sidebar-collapsed .sidebar-accordion-toggle,
.sidebar-collapsed .sidebar .sidebar-accordion-toggle {
    justify-content: center !important;
    padding: 0 !important;
    width: 46px !important;
    height: 46px !important;
    border-radius: 50% !important;
    margin: 0 auto 8px !important;
    display: flex !important;
    align-items: center !important;
}

.sidebar.sidebar-collapsed .sidebar-link-icon,
.sidebar-collapsed .sidebar .sidebar-link-icon {
    margin: 0 !important;
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
}

.sidebar.sidebar-collapsed .sidebar-accordion-left,
.sidebar-collapsed .sidebar .sidebar-accordion-left {
    justify-content: center !important;
}

.sidebar.sidebar-collapsed .sidebar-subnav,
.sidebar-collapsed .sidebar .sidebar-subnav {
    padding-left: 0 !important;
    border-left: none !important;
}

.sidebar.sidebar-collapsed .sidebar-bottom,
.sidebar-collapsed .sidebar .sidebar-bottom {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;
    padding: 18px 8px 18px !important;
}

.sidebar.sidebar-collapsed .sidebar-bottom form,
.sidebar-collapsed .sidebar .sidebar-bottom form {
    width: 100% !important;
    display: flex !important;
    justify-content: center !important;
}

.sidebar.sidebar-collapsed .btn-logout,
.sidebar-collapsed .sidebar .btn-logout {
    padding: 0 !important;
    justify-content: center !important;
    width: 46px !important;
    height: 46px !important;
    min-height: 46px !important;
    margin: 0 auto !important;
    border-radius: 50% !important; /* Circular logout button */
    display: flex !important;
    align-items: center !important;
}

/* Sidebar Toggle Desktop Button */
.sidebar-toggle-desktop {
    position: absolute;
    right: -12px;
    top: 50%;
    transform: translateY(-50%);
    background-color: var(--sb-bg-2) !important;
    border: 1px solid var(--sb-border) !important;
    color: var(--sb-text) !important;
    font-size: 0.9rem !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50% !important;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
    z-index: 999;
    transition: all 0.2s ease;
    padding: 0;
}

.sidebar-toggle-desktop:hover {
    background-color: var(--sb-accent) !important;
    color: var(--sb-bg-2) !important;
    border-color: var(--sb-accent) !important;
}

.sidebar-logo-wrapper {
    padding: 22px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--sb-border);
    position: relative;
    width: 100%;
}

@media (max-width: 768px) {
    .sidebar-toggle-desktop {
        display: none !important;
    }

    .sidebar,
    .sidebar.sidebar-collapsed,
    .sidebar-collapsed .sidebar {
        width: 320px !important;
        max-width: 82vw !important;
        height: 100vh !important;
        position: fixed;
        left: 0;
        top: 0;
        border-radius: 0 24px 24px 0;
    }

    .sidebar-logo-wrapper {
        padding: 24px 18px 20px;
    }

    .sidebar-logo {
        max-width: 135px !important;
        max-height: 42px;
    }

    .sidebar-brand {
        margin: 14px;
        padding: 13px;
    }

    .sidebar-user-avatar {
        width: 48px;
        height: 48px;
        min-width: 48px;
        border-radius: 16px;
    }

    .sidebar-brand-text,
    .sidebar-link-text,
    .sidebar-accordion-label,
    .sidebar-accordion-arrow {
        display: block !important;
    }

    .sidebar-link,
    .sidebar.sidebar-collapsed .sidebar-link,
    .sidebar-collapsed .sidebar .sidebar-link {
        justify-content: flex-start !important;
        padding: 11px 13px !important;
        margin-bottom: 6px;
    }

    .sidebar-accordion-toggle,
    .sidebar.sidebar-collapsed .sidebar-accordion-toggle,
    .sidebar-collapsed .sidebar .sidebar-accordion-toggle {
        justify-content: space-between !important;
        padding: 10px 13px !important;
    }

    .sidebar-accordion-left,
    .sidebar.sidebar-collapsed .sidebar-accordion-left,
    .sidebar-collapsed .sidebar .sidebar-accordion-left {
        justify-content: flex-start !important;
    }

    .sidebar-subnav,
    .sidebar.sidebar-collapsed .sidebar-subnav,
    .sidebar-collapsed .sidebar .sidebar-subnav {
        padding-left: 10px !important;
        border-left: 1px solid var(--sb-border) !important;
    }

    .sidebar-close-mobile {
        display: flex;
    }

    .sidebar-bottom {
        padding-bottom: calc(18px + env(safe-area-inset-bottom));
    }
}

/* Mobile Header */
.mobile-header {
    display: none;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
        align-items: center;
        gap: 1rem;
        background-color: var(--bg-secondary);
        border-bottom: 1px solid var(--border-color);
        padding: 1rem;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 50;
        height: 60px;
    }
    
    .sidebar-toggle-btn {
        background: none;
        border: none;
        color: #ffffff;
        font-size: 1.5rem;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .mobile-brand-name {
        color: #ffffff;
        font-weight: 800;
        font-size: 1.2rem;
    }
    
    .main-content {
        margin-left: 0 !important;
        margin-top: 60px !important;
        padding: 1.5rem !important;
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }
    
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }

    /* Table to card conversion for mobile viewports */
    .table-responsive {
        border: none !important;
        overflow-x: visible !important;
        background: transparent !important;
    }
    
    .table-responsive table {
        display: block !important;
        width: 100% !important;
        border: none !important;
        background: transparent !important;
    }
    
    .table-responsive thead {
        display: none !important;
    }
    
    .table-responsive tbody {
        display: block !important;
        width: 100% !important;
    }
    
    .table-responsive tr {
        display: block !important;
        background: #ffffff !important;
        border: 1px solid var(--border-color) !important;
        border-radius: var(--radius-md) !important;
        margin-bottom: 1rem !important;
        padding: 0.5rem 1.25rem !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.02) !important;
    }
    
    .table-responsive tr:last-child {
        margin-bottom: 0 !important;
    }
    
    .table-responsive td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0.75rem 0 !important;
        border-bottom: 1px solid #f1f5f9 !important;
        font-size: 0.9rem !important;
        background: transparent !important;
        width: 100% !important;
        min-height: auto !important;
        text-align: right !important;
        box-sizing: border-box !important;
    }
    
    .table-responsive td:last-child {
        border-bottom: none !important;
    }
    
    .table-responsive td::before {
        content: attr(data-label) !important;
        font-weight: 700 !important;
        color: var(--text-secondary) !important;
        text-align: left !important;
        margin-right: 1.5rem !important;
        font-size: 0.8rem !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
        flex-shrink: 0 !important;
    }
    
    /* Support for inner elements (buttons, badges) alignment */
    .table-responsive td > div,
    .table-responsive td > form {
        display: flex !important;
        justify-content: flex-end !important;
        align-items: center !important;
        gap: 0.5rem !important;
        width: auto !important;
    }

    .table-responsive td > form {
        margin: 0 !important;
    }
    
    /* Empty table states */
    .table-responsive td[colspan] {
        display: block !important;
        text-align: center !important;
        padding: 2.5rem 1rem !important;
        border: none !important;
        justify-content: center !important;
    }
    
    .table-responsive td[colspan]::before {
        display: none !important;
    }
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    min-height: 100vh;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-width: 0;
    max-width: 100%;
}

/* Page Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
}

.page-title h1 {
    font-size: 1.75rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.5px;
}

.page-title p {
    color: var(--text-sidebar);
    font-size: 0.95rem;
    opacity: 0.8;
    margin-top: 0.15rem;
}

/* Card Design (Solid White) */
.card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
    min-width: 0;
    max-width: 100%;
}

/* Dashboard KPIs */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.kpi-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-left: none !important; /* Remove generic borders */
    border: 1px solid #e2e8f0;
}

.kpi-details h3 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.kpi-details .value {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: var(--font-secondary);
    color: #0f172a;
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.kpi-card.earnings .kpi-icon {
    background-color: #dcfce7;
    color: #15803d;
}
.kpi-card.earnings .value {
    color: #15803d;
}

.kpi-card.expenses .kpi-icon {
    background-color: #fee2e2;
    color: #b91c1c;
}
.kpi-card.expenses .value {
    color: #b91c1c;
}

.kpi-card.profit .kpi-icon {
    background-color: #fef9c3;
    color: #a16207;
}
.kpi-card.profit .value {
    color: #1e293b;
}

.kpi-card.box .kpi-icon {
    background-color: #fef9c3;
    color: #a16207;
}
.kpi-card.box .value {
    color: #1e293b;
}

/* Charts Grid */
.charts-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.25rem;
    width: 100%;
    max-width: 100%;
}

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

.chart-card {
    min-height: 340px;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
}

.chart-body {
    flex-grow: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.chart-body canvas {
    display: block !important;
    max-width: 100% !important;
    width: 100% !important;
}

/* Forms & Controls */
.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

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

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-control {
    background-color: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    color: #0f172a;
    font-family: var(--font-primary);
    font-size: 0.95rem;
    transition: all 0.15s ease;
    width: 100%;
}

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

.form-control:focus {
    outline: none;
    border-color: var(--accent-purple);
    box-shadow: 0 0 0 3px rgba(5, 65, 41, 0.15);
}

select.form-control option {
    background-color: #ffffff;
    color: #0f172a;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    font-family: var(--font-primary);
}

.btn-primary {
    background-color: var(--accent-purple); /* Solid dark green matching reference image buttons */
    color: #ffffff;
    box-shadow: 0 2px 4px rgba(5, 65, 41, 0.15);
}

.btn-primary:hover {
    background-color: #032b1b;
    box-shadow: 0 4px 8px rgba(5, 65, 41, 0.25);
}

.btn-secondary {
    background-color: #f1f5f9;
    color: #334155;
    border: 1px solid #cbd5e1;
}

.btn-secondary:hover {
    background-color: #e2e8f0;
    border-color: #94a3b8;
}

.btn-danger {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.btn-danger:hover {
    background-color: #b91c1c;
    color: #ffffff;
}

.btn-success {
    background-color: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

.btn-success:hover {
    background-color: #15803d;
    color: #ffffff;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

/* Header bars for table containers */
.table-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--accent-purple);
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    color: #ffffff;
}

.table-header-bar h3 {
    font-size: 1rem;
    font-weight: 700;
}

/* Tables with Header Green Bands */
.table-responsive {
    overflow-x: auto;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th {
    padding: 0.85rem 1.25rem;
    background-color: #054129; /* Dark green matching header band */
    border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #ffffff;
}

td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.95rem;
    color: var(--text-primary);
    background-color: #ffffff;
    vertical-align: middle;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-flex;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-green {
    background-color: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.badge-red {
    background-color: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.badge-purple {
    background-color: #f0fdf4;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

.badge-blue {
    background-color: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

/* Organized data cards */
.data-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1rem;
}

.data-card {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.35rem;
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.data-card-top {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 0.85rem;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid #edf2f7;
    margin-bottom: 0.25rem;
}

.avatar-circle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    background: #eef2f7;
    border: 1px solid #cbd5e1;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
}

.data-card-title {
    min-width: 0;
}

.data-card-title strong,
.data-row-main .data-value {
    display: block;
    color: #0f172a;
    font-size: 1.05rem;
    font-weight: 800;
    line-height: 1.25;
}

.data-card-title span {
    display: block;
    color: #64748b;
    font-size: 0.9rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.data-row {
    display: grid;
    grid-template-columns: minmax(105px, 0.38fr) minmax(0, 1fr);
    gap: 1rem;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid #edf2f7;
}

.data-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.data-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.055em;
    text-transform: uppercase;
}

.data-value {
    color: #111827;
    font-size: 0.98rem;
    font-weight: 700;
    text-align: right;
    overflow-wrap: anywhere;
}

.data-value-success {
    color: var(--accent-green);
}

.data-actions-row {
    align-items: center;
}

.icon-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.55rem;
}

.icon-actions form {
    margin: 0;
    display: inline-flex;
}

.icon-btn {
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: var(--radius-md);
    border: 1px solid #cbd5e1;
    background: #f8fafc;
    color: #334155;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1rem;
    transition: 0.15s ease;
}

.icon-btn:hover {
    transform: translateY(-1px);
    background: #eef2f7;
}

.icon-btn-edit {
    color: #334155;
    border-color: #cbd5e1;
}

.icon-btn-secondary {
    color: #075985;
    background: #eff6ff;
    border-color: #bfdbfe;
}

.icon-btn-warning {
    color: #a16207;
    background: #fef9c3;
    border-color: #fde68a;
}

.icon-btn-danger {
    color: var(--accent-red);
    background: #fff1f2;
    border-color: #fecdd3;
}

.empty-state {
    grid-column: 1 / -1;
    background: #ffffff;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-weight: 700;
    padding: 2rem;
    text-align: center;
}

.inline-note {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.permission-pills {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 0.35rem;
}

/* Auth Page layout */
.auth-container {
    display: flex;
    min-height: 100vh;
    width: 100vw;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-primary);
    position: relative;
    overflow: hidden;
}

.auth-blur-bg {
    position: absolute;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(139, 195, 74, 0.08) 0%, transparent 75%);
    top: -200px;
    right: -200px;
    filter: blur(80px);
    z-index: 1;
    pointer-events: none;
}

.auth-blur-bg-bottom {
    position: absolute;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(250, 204, 21, 0.04) 0%, transparent 75%);
    bottom: -250px;
    left: -250px;
    filter: blur(80px);
    z-index: 1;
    pointer-events: none;
}

.auth-card {
    width: 90%;
    max-width: 420px;
    position: relative;
    z-index: 10;
    background-color: #ffffff;
    border-radius: var(--radius-lg);
    padding: 2.25rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.auth-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.35rem;
    color: #0f172a;
}

.auth-header p {
    color: #64748b;
    font-size: 0.95rem;
}

/* Alert styles */
.alert {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 1px solid transparent;
}

.alert-danger {
    background-color: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

.alert-success {
    background-color: #dcfce7;
    border-color: #86efac;
    color: #15803d;
}

/* Grid controls */
.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background-color: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 550px;
    max-height: 92vh;
    overflow-y: auto;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: scale(0.97);
    transition: transform 0.2s ease;
    color: var(--text-primary);
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.75rem;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #0f172a;
}

.modal-close {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.5rem;
    cursor: pointer;
}

.modal-close:hover {
    color: #0f172a;
}

/* Multi-select check grid */
.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.9rem;
    color: #334155;
}

.check-label:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}

.check-label input {
    accent-color: var(--accent-purple);
    width: 16px;
    height: 16px;
}

/* Mobile Responsive Overrides */
@media (max-width: 768px) {
    /* Main layout adjustments */
    .main-content {
        padding: 1rem !important;
        gap: 1rem !important;
        min-width: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Page headers */
    .page-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    .page-title h1 {
        font-size: 1.40rem !important;
    }

    .page-title p {
        font-size: 0.85rem !important;
    }

    .page-header .btn, 
    .page-header form, 
    .page-header .btn-primary, 
    .page-header .btn-secondary {
        width: 100% !important;
        display: flex !important;
        justify-content: center !important;
    }

    /* Forms */
    .form-row {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .form-control {
        font-size: 16px !important; /* Prevents auto-zoom on iOS */
        padding: 0.7rem 0.9rem !important;
    }

    .form-group {
        margin-bottom: 0.85rem !important;
    }

    /* Cards */
    .card {
        padding: 1rem !important;
        border-radius: var(--radius-md) !important;
    }

    .data-grid {
        grid-template-columns: 1fr !important;
        gap: 0.85rem !important;
    }

    .data-card {
        padding: 1rem 1.1rem !important;
        border-radius: var(--radius-md) !important;
    }

    .data-card-top {
        grid-template-columns: auto 1fr;
    }

    .data-card-top .badge {
        grid-column: 2;
        justify-self: flex-start;
    }

    .data-row {
        grid-template-columns: minmax(92px, 0.42fr) minmax(0, 1fr);
        gap: 0.85rem;
        padding: 0.72rem 0;
    }

    .data-label {
        font-size: 0.76rem;
    }

    .data-value {
        font-size: 0.95rem;
    }

    .icon-btn {
        width: 36px;
        height: 36px;
        min-width: 36px;
    }

    /* Grid Layouts */
    .kpi-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .kpi-card {
        padding: 1rem !important;
    }

    .kpi-details .value {
        font-size: 1.4rem !important;
    }

    /* Operational grids */
    .operational-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }

    .operational-card {
        padding: 0.75rem 0.85rem !important;
        gap: 0.6rem !important;
    }

    .operational-icon-box {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.1rem !important;
        border-radius: 8px !important;
    }

    .operational-details h4 {
        font-size: 0.65rem !important;
    }

    .operational-details .metric-value {
        font-size: 0.95rem !important;
    }

    /* Tables */
    table th, table td {
        padding: 0.75rem 0.85rem !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
    }

    /* Modals */
    .modal-content {
        padding: 1.25rem !important;
        width: 95% !important;
    }

    .permission-grid {
        grid-template-columns: 1fr !important;
        gap: 0.5rem !important;
    }

    /* Button stack on forms */
    .form-actions-stack,
    .form-actions {
        flex-direction: column !important;
        width: 100% !important;
        gap: 0.75rem !important;
        margin-top: 1.5rem !important;
    }

    .form-actions-stack .btn,
    .form-actions .btn {
        width: 100% !important;
    }

    /* Filter Form Stack */
    .header-filter-form {
        width: 100% !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.35rem !important;
    }
    
    .header-filter-form label {
        align-self: flex-start;
    }
    
    .filter-input,
    .header-filter-form .select-wrapper,
    .header-filter-form .period-select {
        width: 100% !important;
    }
}

/* Global Form Actions and Filter Defaults */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 2rem;
}

.header-filter-form {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-filter-form label {
    white-space: nowrap;
    color: #ffffff;
}

.filter-input {
    width: auto;
}

@media (max-width: 480px) {
    /* On very small devices, make operational grid 1 column to avoid text wrapping */
    .operational-grid {
        grid-template-columns: 1fr !important;
    }

    /* KPI Comparison Stack */
    .kpi-comparison-footer {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }
    .kpi-comparison-divider {
        display: none !important;
    }

    /* Stack occurrence selectors vertically on mobile */
    .occurrence-selector {
        grid-template-columns: 1fr !important;
    }
}
