/* =========================================
   1. CORE VARIABLES & RESET
   ========================================= */
:root {
    /* Brand Colors - Indigo/Violet Theme */
    --primary: #4F46E5;       
    --primary-light: #EEF2FF; 
    --primary-dark: #3730A3;
    
    /* Functional Colors */
    --success: #10B981;        /* Success */
    --warning: #F59E0B;       /* Pending/Warning */
    --danger: #EF4444;        /* Error */
    
    /* Surface & Text Colors */
    --bg-body: #F8FAFC;       /* Cool Grey Background */
    --bg-surface: #FFFFFF;    /* Pure White */
    --text-main: #0F172A;     /* Deep Navy/Black */
    --text-muted: #64748B;    /* Slate Grey */
    --border: #E2E8F0;        /* Light Border */
    
    /* Spacing & Layout */
    --header-h: 60px;
    --nav-h: 65px;
    --radius: 16px;
    --radius-sm: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    
    /* Animation */
    --trans-speed: 0.3s;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    padding-top: calc(var(--header-h) + 10px);
    padding-bottom: calc(var(--nav-h) + 10px);
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

/* =========================================
   2. THE NANO-GRID (Micro Framework)
   ========================================= */
.container {
    width: 100%;
    max-width: 480px; 
    margin: 0 auto;
    padding: 0 16px;
}

.row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
    margin-bottom: 16px;
}

/* Flex Utilities */
.d-flex { display: flex; align-items: center; justify-content: space-between; }
.d-flex-col { display: flex; flex-direction: column; }
.justify-center { justify-content: center; }
.align-start { align-items: flex-start; }
.gap-2 { gap: 8px; }

/* Column Spans */
.col-12 { grid-column: span 12; }
.col-8  { grid-column: span 8; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

/* Typography Helpers */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.font-bold { font-weight: 700; }
.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }

.mb-2 {
    margin-bottom: .5rem;
}
/* =========================================
   3. APP SHELL (Header, Nav, Sidebar)
   ========================================= */

/* Header */
.app-header {
    position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center; z-index: 100;
}
.header-content {
    width: 100%; max-width: 480px; padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between;
}
.brand-title { font-weight: 700; font-size: 18px; color: var(--primary); letter-spacing: -0.5px; }

/* Icon Buttons */
.icon-btn {
    background: none; border: none; cursor: pointer; padding: 8px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; transition: background 0.2s;
}
.icon-btn:active { background: var(--bg-body); transform: scale(0.95); }
.icon-btn svg { width: 24px; height: 24px; stroke: var(--text-main); }

/* Sidebar */
.sidebar-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); z-index: 1000;
    opacity: 0; visibility: hidden; transition: opacity var(--trans-speed);
    backdrop-filter: blur(3px);
}
.sidebar {
    position: fixed; top: 0; left: 0; height: 100%; width: 280px;
    background: var(--bg-surface); z-index: 1001;
    transform: translateX(-100%); transition: transform var(--trans-speed) cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex; flex-direction: column; ;
}
.sidebar-open .sidebar-overlay { opacity: 1; visibility: visible; }
.sidebar-open .sidebar { transform: translateX(0);box-shadow: 4px 0 15px rgba(0,0,0,0.05) }

.sidebar-header { padding: 25px 20px; border-bottom: 1px solid var(--border); background: var(--primary-light); }
.sidebar-menu { list-style: none; padding: 20px; flex-grow: 1;
    overflow-y: auto;}
.sidebar-menu li { margin-bottom: 8px; }
.sidebar-menu a {
    display: flex; align-items: center; padding: 12px 15px;
    color: var(--text-main); border-radius: 10px; font-size: 14px; font-weight: 500;
}
.sidebar-menu a:active { background: var(--bg-body); color: var(--primary); }
.sidebar-menu a svg { margin-right: 12px; width: 20px; height: 20px; stroke: var(--text-muted); }




/* =========================================
   SIDEBAR SUB-MENU STYLES
   ========================================= */

/* The Parent Item Container */
.menu-item {
    position: relative;
    overflow: hidden; /* Contains the submenu animation */
}

/* The Toggle Link (Parent) */
.menu-link {
    display: flex; align-items: center; justify-content: space-between; /* Push arrow to right */
    padding: 12px 15px;
    color: var(--text-main); text-decoration: none;
    border-radius: 10px; font-size: 14px; font-weight: 500;
    transition: background 0.1s;
    cursor: pointer;
}
.menu-link:hover, .menu-link:active {
    background: var(--bg-body); color: var(--primary);
}
.menu-link svg:first-child { 
    margin-right: 12px; width: 20px; height: 20px; stroke: var(--text-muted); 
}

/* The Arrow Icon */
.menu-arrow {
    width: 16px; height: 16px; 
    color: var(--text-muted);
    transition: transform 0.3s ease;
}

/* The Submenu Container (Hidden by default) */
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0, 1, 0, 1); /* Smooth slide */
    background: transparent;
    padding-left: 12px; /* Indent logic */
}

/* Submenu Links */
.submenu a {
    display: flex; align-items: center;
    padding: 10px 10px 10px 35px; /* Deep indentation */
    font-size: 13px; color: var(--text-muted);
    text-decoration: none;
    border-radius: 8px;
    position: relative;
}
.submenu a::before {
    /* Little connecting dot */
    content: ''; position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
    width: 4px; height: 4px; background: var(--border); border-radius: 50%;
}
.submenu a:active, .submenu a:hover {
    color: var(--primary);
    background: rgba(79, 70, 229, 0.05);
}
.submenu a::before { background: var(--primary); } /* Dot color change */


/* OPEN STATE LOGIC */
.menu-item.open .submenu {
    max-height: 500px; /* Arbitrary large number to allow expansion */
    transition: max-height 0.3s ease-in-out;
}
.menu-item.open .menu-arrow {
    transform: rotate(180deg);
    color: var(--primary);
}
.menu-item.open .menu-link {
    color: var(--primary);
}
.menu-item.open .menu-link svg:first-child {
    stroke: var(--primary);
}

/* --- ACTIVE STATES --- */

/* 1. Standard Top-Level Active Link */
.menu-link.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.menu-link.active svg { stroke: var(--primary); }

/* 2. Active Submenu Child Link */
.submenu a.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
/* Change the little dot color */
.submenu a.active::before {
    background: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.2); /* Glow effect */
}

/* 3. Parent Styling when Child is Active (Optional: Keep parent highlighted too?) */
/* If you want the "Invoice" main text to stay colored when "Invoice History" is open */
.menu-item.open > .menu-link {
    color: var(--primary);
}
.menu-item.open > .menu-link svg:first-child {
    stroke: var(--primary);
}









/* Bottom Nav */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-h);
    background: var(--bg-surface); border-top: 1px solid var(--border);
    display: flex; justify-content: center; z-index: 90;
    padding-bottom: env(safe-area-inset-bottom);
}
.nav-container { width: 100%; max-width: 480px; display: flex; justify-content: space-around; align-items: center; }
.nav-item {
    display: flex; flex-direction: column; align-items: center;
    color: var(--text-muted); font-size: 10px; font-weight: 500; padding: 8px;
}
.nav-item svg { width: 24px; height: 24px; margin-bottom: 4px; stroke: currentColor; stroke-width: 2; }
.nav-item.active { color: var(--primary); }

/* =========================================
   4. COMPONENTS (Cards, Buttons, Inputs)
   ========================================= */

/* Base Card */
.card {
    background: var(--bg-surface); border-radius: var(--radius);
    padding: 16px; box-shadow: var(--shadow); border: 1px solid rgba(255,255,255,0.5);
    position: relative;
}

/* Action Grid Card */
.action-card {
    background: var(--bg-surface); border-radius: var(--radius);
    padding: 16px; display: flex; flex-direction: column; align-items: center;
    justify-content: center; text-align: center; box-shadow: var(--shadow);
    transition: transform 0.1s; cursor: pointer; height: 110px;
}
.action-card:active { transform: scale(0.96); }
.icon-box {
    width: 42px; height: 42px; border-radius: 12px;
    background: var(--primary-light); color: var(--primary);
    display: flex; align-items: center; justify-content: center; margin-bottom: 10px;
}

/* Primary Button */
.btn-primary {
    background: var(--primary); color: white; font-weight: 600;
    border: none; padding: 10px 20px; border-radius: 10px; font-size: 14px;
    cursor: pointer; width: 100%; text-align: center;
    box-shadow: 0 4px 6px -1px rgba(79, 70, 229, 0.3);
    height: 44px;
}
.btn-primary:active { background: var(--primary-dark); transform: scale(0.98); }

/* Danger Button */
.btn-danger {
    background: var(--danger); color: white; font-weight: 600;
    border: none; padding: 10px 20px; border-radius: 10px; font-size: 14px;
    cursor: pointer; width: 100%; text-align: center;
    box-shadow: 0 4px 6px -1px rgba(239, 68, 68, 0.3);
    height: 44px;
}
.btn-danger:active { background: #DC2626; transform: scale(0.98); }

/* Warning Button */
.btn-warning {
    background: var(--warning); color: white; font-weight: 600;
    border: none; padding: 10px 20px; border-radius: 10px; font-size: 14px;
    cursor: pointer; width: 100%; text-align: center;
    box-shadow: 0 4px 6px -1px rgba(245, 158, 11, 0.3);
    height: 44px;
}
.btn-warning:active { background: #D97706; transform: scale(0.98); }

/* Success Button */
.btn-success {
    background: var(--success); color: white; font-weight: 600;
    border: none; padding: 10px 20px; border-radius: 10px; font-size: 14px;
    cursor: pointer; width: 100%; text-align: center;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
    height: 44px;
}
.btn-success:active { background: #059669; transform: scale(0.98); }
.btn-outline {
    background: transparent; color: var(--primary); border: 1px solid var(--primary);
    padding: 8px 16px; border-radius: 8px; font-size: 12px; font-weight: 600; height: 44px;
}

/* Form Inputs */
.form-control {
    width: 100%; padding: 12px 16px; border: 1px solid var(--border);
    border-radius: 10px; font-size: 14px; background: var(--bg-surface);
    color: var(--text-main); transition: border-color 0.2s, box-shadow 0.2s;
    height: 44px;
}
.form-control:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.form-control.is-invalid {
    border-color: var(--danger);
}
.form-control.is-invalid:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}
.invalid-feedback {
    display: block; width: 100%; margin-top: 6px;
    font-size: 12px; color: var(--danger);
}

/* Form Labels */
.form-label {
    display: block; margin-bottom: 8px; font-size: 14px;
    font-weight: 600; color: var(--text-main);
}

/* Form Check (Remember Me) */
.form-check {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 16px;
}
.form-check-input {
    width: 18px; height: 18px; margin: 0;
    cursor: pointer; accent-color: var(--primary);
}
.form-check-label {
    font-size: 14px; color: var(--text-main);
    cursor: pointer; user-select: none;
}

/* Card Header */
.card-header {
    padding: 20px; border-bottom: 1px solid var(--border);
    font-size: 20px; font-weight: 700; color: var(--text-main);
    background: var(--primary-light); border-radius: var(--radius) var(--radius) 0 0;
}
.card-body {
    padding: 24px;
}

/* =========================================
   5. NEW: HORIZONTAL STATS SCROLLER
   ========================================= */
.scroller-x {
    display: flex; overflow-x: auto; gap: 12px;
    padding-bottom: 10px; scroll-snap-type: x mandatory;
    /* Hide Scrollbar */
    -ms-overflow-style: none; scrollbar-width: none;
}
.scroller-x::-webkit-scrollbar { display: none; }

.stat-tile {
    min-width: 130px; /* Width of each tile */
    scroll-snap-align: start;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px;
    display: flex; flex-direction: column;
    justify-content: space-between;
}
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-value { font-size: 18px; font-weight: 800; color: var(--text-main); margin-top: 4px; }
.stat-icon-sm { width: 24px; height: 24px; border-radius: 6px; background: var(--bg-body); color: var(--text-muted); display: flex; align-items: center; justify-content: center; margin-bottom: 8px;}

/* =========================================
   6. FUTURE PROOFING (Table & Modal)
   ========================================= */

/* Minimal Table (For Reports page) */
.table-minimal { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-minimal th { text-align: left; padding: 12px; color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 500; }
.table-minimal td { padding: 12px; border-bottom: 1px solid var(--bg-body); color: var(--text-main); }
.table-minimal tr:last-child td { border-bottom: none; }

/* Modal Styles (Hidden by default) */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 2000;
    display: none; align-items: center; justify-content: center;
    backdrop-filter: blur(2px);
}
.modal.active { display: flex; }
.modal-content {
    background: var(--bg-surface); width: 90%; max-width: 400px;
    padding: 24px; border-radius: var(--radius); box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }






/* Segmented Control (Tabs) */
        .segment-control {
            display: flex; background: var(--bg-body);
            padding: 4px; border-radius: 8px;
        }
        .segment-btn {
            flex: 1; border: none; background: transparent;
            padding: 8px; font-size: 12px; font-weight: 600;
            color: var(--text-muted); border-radius: 6px; cursor: pointer;
        }
        .segment-btn.active {
            background: var(--bg-surface); color: var(--primary);
            box-shadow: 0 1px 3px rgba(0,0,0,0.1);
        }








  /* =========================================
            COMPONENT: BOTTOM SHEET MODAL (Reusable)
            ========================================= */

    .sheet-overlay {
        position: fixed; top: 0; left: 0; width: 100%; height: 100%;
        background: rgba(0,0,0,0.6); z-index: 2000;
        opacity: 0; visibility: hidden; transition: all 0.3s;
        backdrop-filter: blur(2px);
    }
    .sheet-overlay.active { opacity: 1; visibility: visible; }

    .sheet-modal {
        position: fixed; bottom: 0; left: 0; right: 0;
        width: 100%; max-width: 480px; margin: 0 auto;
        background: var(--bg-body);
        border-top-left-radius: 24px; border-top-right-radius: 24px;
        box-shadow: 0 -10px 40px rgba(0,0,0,0);
        transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 2001;
        display: flex; flex-direction: column;
        height: 90vh; /* Takes up 90% of screen */
    }
    .sheet-modal.active { transform: translateY(0); box-shadow: 0 -10px 40px rgba(0,0,0,0.2); }

    /* Drag Handle */
    .sheet-handle-bar {
        width: 100%; padding: 12px 0 8px 0;
        display: flex; justify-content: center; flex-shrink: 0;
        background: var(--bg-surface); border-top-left-radius: 24px; border-top-right-radius: 24px;
    }
    .sheet-handle { width: 40px; height: 5px; background: var(--border); border-radius: 10px; }

    /* Sheet Content Areas */
    .sheet-header-row {
            display: flex; justify-content: space-between; align-items: flex-start;
            margin-bottom: 20px;
        }

    .sheet-header {
        padding: 0 20px 16px 20px; background: var(--bg-surface);
        border-bottom: 1px solid var(--border); flex-shrink: 0;
    }

    
    .modal-title {
        font-size: 18px; font-weight: 800; color: var(--text-main);
        line-height: 1.2;
    }
    .modal-subtitle {
        font-size: 13px; color: var(--primary); font-weight: 600;
        margin-top: 4px; display: flex; align-items: center; gap: 6px;
    }

    /* Close Button (Circle X) */
    .sheet-close-btn {
        width: 32px; height: 32px;
        background: #F3F4F6; border-radius: 50%;
        border: none; color: var(--text-muted);
        display: flex; align-items: center; justify-content: center;
        cursor: pointer; transition: all 0.2s;
    }
    .sheet-close-btn:active { background: #E5E7EB; transform: scale(0.9); }
    .sheet-body {
        flex-grow: 1; overflow-y: auto; padding: 20px;
        background: var(--bg-body);
    }
    .sheet-footer {
        padding: 16px 20px 30px 20px; background: var(--bg-surface);
        border-top: 1px solid var(--border); flex-shrink: 0;
    }

