/* ==========================================================================
   Widi Holding - Modern Financial Management System
   Mobile-First & Executive Infographic Styling (Vanilla CSS)
   ========================================================================== */

:root {
    --primary: #0284c7;
    --primary-dark: #0369a1;
    --primary-light: #e0f2fe;
    --primary-gradient: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
    
    --success: #10b981;
    --success-dark: #059669;
    --success-light: #ecfdf5;
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);

    --danger: #ef4444;
    --danger-dark: #dc2626;
    --danger-light: #fef2f2;
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);

    --warning: #f59e0b;
    --warning-dark: #d97706;
    --warning-light: #fffbeb;

    --info: #3b82f6;
    --info-light: #eff6ff;

    --purple: #8b5cf6;
    --purple-light: #f5f3ff;

    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-sidebar: #0f172a;
    --bg-header: #ffffff;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    --border: #e2e8f0;
    --border-light: #f1f5f9;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.03);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --bottom-nav-height: 64px;
    --top-header-height: 64px;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
    overflow-x: hidden;
    padding-bottom: calc(var(--bottom-nav-height) + 20px);
}

/* ==========================================================================
   Typography & Utilities
   ========================================================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
}

.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning-dark); }
.text-primary { color: var(--primary); }

.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.fw-medium { font-weight: 500; }

.text-center { text-align: center; }
.text-right { text-align: right; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }

/* ==========================================================================
   Header & Top Bar
   ========================================================================== */
.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
@media (max-width: 768px) {
    .app-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 14px;
        gap: 12px;
    }

    .header-brand {
        display: flex;
        align-items: center;
        gap: 10px;
        min-width: 0;
        flex: 1;
    }

    .brand-logo-badge {
        width: 36px !important;
        height: 36px !important;
        min-width: 36px !important;
        max-width: 36px !important;
        flex-shrink: 0 !important;
        display: flex !important;
    }

    .brand-info {
        min-width: 0;
        overflow: hidden;
    }

    .brand-info h1 {
        font-size: 15px;
        line-height: 1.2;
        margin: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .brand-info p {
        font-size: 11px;
        line-height: 1.2;
        margin: 0;
        color: var(--text-secondary);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

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

    #currentBusinessBtn {
        display: none !important;
    }

    .user-menu-wrapper {
        flex-shrink: 0;
    }

    .user-menu-dropdown {
        right: 0;
        top: calc(100% + 6px);
    }
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
}

.brand-logo-badge {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}

.brand-info h1 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.3px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.brand-info p {
    font-size: 11px;
    color: var(--text-secondary);
}

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

.business-select-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    max-width: 170px;
}
.business-select-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.business-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ==========================================================================
   Mobile Business Selector Bar (Moved out of header for clean layout)
   ========================================================================== */
.mobile-business-bar {
    background: #ffffff;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
}

.mobile-business-select-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.mobile-business-select-btn:active {
    background: #f1f5f9;
    border-color: var(--primary);
    transform: scale(0.99);
}

.mobile-business-select-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.mobile-business-text-wrap {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.mobile-business-tag {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    line-height: 1.1;
}

.mobile-business-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.mobile-business-action {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--primary);
    background: var(--primary-light);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

/* ==========================================================================
   Filter Bar (Periods & Quick Switch)
   ========================================================================== */
.filter-bar {
    background: white;
    padding: 6px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: none;
}
@media (max-width: 768px) {
    .filter-bar {
        padding: 6px 12px;
    }
}
.filter-bar::-webkit-scrollbar { display: none; }

.period-pills {
    display: flex;
    gap: 6px;
    align-items: center;
}

.pill-btn {
    padding: 5px 12px;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 600;
    border: 1px solid var(--border);
    background: var(--bg-page);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}
.pill-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}
.pill-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);
}

.custom-date-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
}

/* ==========================================================================
   Container & Layout
   ========================================================================== */
.app-container {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 12px 20px;
}
@media (max-width: 768px) {
    .app-container {
        padding: 10px 12px;
    }
}

/* Desktop Sidebar Grid */
@media (min-width: 992px) {
    body {
        padding-bottom: 20px;
    }
    .app-layout {
        display: grid;
        grid-template-columns: 240px 1fr;
        min-height: 100vh;
    }
    .desktop-sidebar {
        background: var(--bg-sidebar);
        color: white;
        position: sticky;
        top: 0;
        height: 100vh;
        overflow-y: auto;
        padding: 24px 16px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
    }
    .sidebar-brand {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 28px;
        padding: 0 8px;
    }
    .sidebar-brand h2 {
        color: white;
        font-size: 18px;
        font-weight: 800;
    }
    .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 6px;
    }
    .sidebar-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 14px;
        color: #94a3b8;
        text-decoration: none;
        font-size: 14px;
        font-weight: 600;
        border-radius: var(--radius-md);
        transition: all 0.2s ease;
        cursor: pointer;
    }
    .sidebar-link:hover {
        background: rgba(255, 255, 255, 0.08);
        color: white;
    }
    .sidebar-link.active {
        background: var(--primary);
        color: white;
        box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
    }
    .sidebar-link i {
        font-size: 20px;
    }
    .bottom-nav {
        display: none !important;
    }
    .mobile-only {
        display: none !important;
    }
}

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

/* ==========================================================================
   KPI Cards Grid (Executive Top Metrics)
   ========================================================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 12px;
}
@media (min-width: 768px) {
    .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }
}

.kpi-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
}
.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.kpi-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.kpi-icon-badge {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.kpi-icon-income { background: #e0f2fe; color: #0284c7; }
.kpi-icon-expense { background: #fee2e2; color: #ef4444; }
.kpi-icon-profit { background: #ecfdf5; color: #10b981; }
.kpi-icon-cust { background: #eff6ff; color: #3b82f6; }

.kpi-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

.kpi-value {
    font-size: 18px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}
@media (min-width: 768px) {
    .kpi-value {
        font-size: 22px;
    }
}

.kpi-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}
.kpi-badge.up { background: var(--success-light); color: var(--success-dark); }
.kpi-badge.down { background: var(--danger-light); color: var(--danger-dark); }
.kpi-badge.neutral { background: var(--bg-page); color: var(--text-secondary); }

/* ==========================================================================
   Alert / Leak Banners
   ========================================================================== */
.leak-banner {
    background: linear-gradient(135deg, #fff1f2 0%, #ffe4e6 100%);
    border: 1px solid #fecdd3;
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.leak-banner-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.leak-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.leak-banner-btn {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s;
}
.leak-banner-btn:hover {
    background: #dc2626;
}

/* ==========================================================================
   Section Cards & Grid
   ========================================================================== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 14px 16px;
    margin-bottom: 12px;
}

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

.card-title {
    font-size: 15px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}
@media (min-width: 768px) {
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   Tables
   ========================================================================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.custom-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.custom-table th {
    background: #f1f5f9;
    padding: 8px 10px;
    text-align: left;
    font-weight: 700;
    color: var(--text-secondary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

.custom-table td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

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

.custom-table tr.table-footer td {
    background-color: #e2e8f0;
    font-weight: 800;
    border-top: 2px solid #cbd5e1;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
}
.badge-success { background: var(--success-light); color: var(--success-dark); }
.badge-danger { background: var(--danger-light); color: var(--danger-dark); }
.badge-warning { background: var(--warning-light); color: var(--warning-dark); }
.badge-primary { background: var(--primary-light); color: var(--primary-dark); }
.badge-purple { background: var(--purple-light); color: var(--purple); }

/* ==========================================================================
   Bottom Navigation Bar (Mobile First)
   ========================================================================== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-height);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 50;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.05);
    padding: 0 4px;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    padding: 6px 4px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s ease;
    flex: 1;
    white-space: nowrap;
}
.nav-item i {
    font-size: 22px;
}
.nav-item.active {
    color: var(--primary);
}
.nav-item.active i {
    transform: translateY(-2px);
}

/* Floating Action Button */
.fab-btn {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 16px);
    right: 16px;
    background: var(--primary-gradient);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.45);
    cursor: pointer;
    z-index: 45;
    transition: transform 0.2s, box-shadow 0.2s;
}
.fab-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(2, 132, 199, 0.55);
}
@media (min-width: 992px) {
    .fab-btn {
        bottom: 24px;
        right: 24px;
        padding: 14px 24px;
        font-size: 15px;
    }
}

/* ==========================================================================
   Modals & Bottom Sheets
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: flex-end; /* bottom sheet on mobile */
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.modal-overlay.open,
.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 24px;
    box-shadow: var(--shadow-xl);
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@media (min-width: 640px) {
    .modal-overlay {
        align-items: center;
        padding: 20px;
    }
    .modal-content {
        border-radius: var(--radius-lg);
        transform: scale(0.95);
    }
}
.modal-overlay.open .modal-content,
.modal-overlay.active .modal-content {
    transform: translateY(0);
}
@media (min-width: 640px) {
    .modal-overlay.open .modal-content,
    .modal-overlay.active .modal-content {
        transform: scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.modal-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-close-btn:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-page);
    transition: border-color 0.2s, background 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* Quick Amount Chips */
.quick-chips {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 6px;
}
.chip {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    background: #f1f5f9;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.chip:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
    border-color: var(--primary);
}

/* Category Selection Chips (Inline in Transaction Modals) */
.category-chips-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    max-height: 165px;
    overflow-y: auto;
    padding: 8px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 10px;
    scrollbar-width: thin;
}
.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    line-height: 1.25;
}
.cat-chip:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
    color: #0f172a;
    transform: translateY(-1px);
}
.cat-chip.active-income {
    background: #0284c7 !important;
    border-color: #0284c7 !important;
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);
}
.cat-chip.active-expense {
    background: #ef4444 !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
    font-weight: 700;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    text-decoration: none;
}
.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);
}
.btn-primary:hover {
    box-shadow: 0 6px 14px rgba(2, 132, 199, 0.4);
}
.btn-success {
    background: var(--success-gradient);
    color: white;
}
.btn-danger {
    background: var(--danger-gradient);
    color: white;
}
.btn-secondary {
    background: #f1f5f9;
    color: var(--text-secondary);
}
.btn-secondary:hover {
    background: #e2e8f0;
}
.btn-block {
    width: 100%;
}
.btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

/* Segmented Control (Income / Expense Switch) */
.segmented-control {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
}
.segmented-btn {
    flex: 1;
    border: none;
    background: none;
    padding: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}
.segmented-btn.active-income {
    background: var(--success);
    color: white;
    box-shadow: var(--shadow-sm);
}
.segmented-btn.active-expense {
    background: var(--danger);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 120;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.toast {
    background: var(--bg-sidebar);
    color: white;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    box-shadow: var(--shadow-xl);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s forwards;
}
@keyframes slideIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Chart Canvas container */
.chart-container {
    position: relative;
    width: 100%;
    min-height: 220px;
}

/* ==========================================================================
   Authentication Screen (Login Page)
   ========================================================================== */
#authScreen {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: radial-gradient(circle at 50% 20%, #1e293b 0%, #0f172a 60%, #020617 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 24px;
    padding: 36px 28px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 40px rgba(2, 132, 199, 0.15);
    color: white;
    animation: fadeInScale 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.94); }
    to { opacity: 1; transform: scale(1); }
}

.login-brand {
    text-align: center;
    margin-bottom: 28px;
}

.login-brand-icon {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    background: var(--primary-gradient);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    color: white;
    margin-bottom: 14px;
    box-shadow: 0 8px 24px rgba(2, 132, 199, 0.45);
}

.login-brand h2 {
    color: white;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.4px;
}

.login-brand p {
    color: #94a3b8;
    font-size: 13px;
    margin-top: 4px;
}

.login-input-group {
    position: relative;
    margin-bottom: 18px;
}

.login-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
    font-size: 18px;
}

.login-control {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.6);
    color: white;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.login-control:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.9);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.25);
}

.login-control::placeholder {
    color: #64748b;
}

.toggle-password-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
}
.toggle-password-btn:hover {
    color: white;
}

.login-alert {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #fca5a5;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 12.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* User Profile Badge & Menu */
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 6px;
    border-radius: var(--radius-full);
    background: var(--bg-card);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}
.user-menu-btn:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.user-avatar-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
}

.user-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 16px;
    width: 200px;
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xl);
    padding: 6px;
    z-index: 60;
    display: none;
    animation: fadeInDown 0.2s forwards;
}
.user-menu-dropdown.show {
    display: block;
}

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

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
    border: none;
    width: 100%;
    background: none;
    text-align: left;
}
.dropdown-item:hover {
    background: #f1f5f9;
}
.dropdown-item.danger {
    color: #ef4444;
}
.dropdown-item.danger:hover {
    background: #fef2f2;
}

/* ==========================================================================
   Document & File Vault Styles
   ========================================================================== */
.doc-category-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 16px;
    -webkit-overflow-scrolling: touch;
}
.doc-category-bar::-webkit-scrollbar {
    height: 4px;
}
.doc-category-bar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.doc-cat-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: var(--radius-full);
    background: white;
    border: 1px solid var(--border);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.doc-cat-pill:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
}
.doc-cat-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}
.doc-cat-pill .pill-badge {
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 10.5px;
    background: #f1f5f9;
    color: var(--text-secondary);
    font-weight: 700;
}
.doc-cat-pill.active .pill-badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
}

/* Document Grid */
.doc-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}
@media (min-width: 640px) {
    .doc-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
@media (min-width: 1024px) {
    .doc-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 1400px) {
    .doc-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.doc-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
    position: relative;
}
.doc-card:hover {
    box-shadow: var(--shadow-md);
    border-color: #cbd5e1;
    transform: translateY(-2px);
}

.doc-thumb-wrap {
    height: 140px;
    background: #f8fafc;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    cursor: pointer;
}
.doc-thumb-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.doc-thumb-wrap:hover img {
    transform: scale(1.04);
}
.doc-thumb-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #64748b;
    transition: transform 0.2s ease;
}
.doc-thumb-wrap:hover .doc-thumb-icon {
    transform: scale(1.08);
}
.doc-thumb-icon i {
    font-size: 52px;
}

.doc-type-chip {
    position: absolute;
    top: 10px;
    left: 10px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    z-index: 2;
}
.doc-type-pdf { background: #ef4444; color: white; }
.doc-type-doc { background: #2563eb; color: white; }
.doc-type-xls { background: #16a34a; color: white; }
.doc-type-img { background: #8b5cf6; color: white; }

.doc-body {
    padding: 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.doc-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.doc-desc {
    font-size: 11.5px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}
.doc-meta-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #94a3b8;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
    margin-bottom: 12px;
}

.doc-actions-row {
    display: flex;
    gap: 6px;
    margin-top: auto;
}
.doc-action-btn {
    flex: 1;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid var(--border);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s;
}
.doc-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f0f9ff;
}
.doc-action-btn.btn-danger-hover:hover {
    border-color: #ef4444;
    color: #ef4444;
    background: #fef2f2;
}

/* Upload Dropzone */
.dropzone-box {
    border: 2px dashed #cbd5e1;
    border-radius: var(--radius-md);
    background: #f8fafc;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}
.dropzone-box:hover, .dropzone-box.dragover {
    border-color: var(--primary);
    background: #f0f9ff;
}
.dropzone-box i {
    font-size: 40px;
    color: var(--primary);
    margin-bottom: 8px;
}

/* Document Preview Modal */
.preview-content-box {
    width: 100%;
    min-height: 400px;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0f172a;
    border-radius: var(--radius-md);
    overflow: hidden;
}
.preview-content-box img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
}
.preview-content-box iframe {
    width: 100%;
    height: 75vh;
    border: none;
}

/* ==========================================================================
   Switch Toggle Component
   ========================================================================== */
.switch-toggle {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
    flex-shrink: 0;
}
.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.switch-toggle .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 26px;
}
.switch-toggle .slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}
.switch-toggle input:checked + .slider {
    background-color: var(--primary);
}
.switch-toggle input:checked + .slider:before {
    transform: translateX(22px);
}

/* ==========================================================================
   Hutang & Kewajiban (Debt & Liability Management) Module
   ========================================================================== */
.debt-health-banner {
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    box-shadow: var(--shadow-sm);
}
.debt-health-banner.healthy {
    background: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 100%);
    border-color: #a7f3d0;
}
.debt-health-banner.moderate {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-color: #bae6fd;
}
.debt-health-banner.warning {
    background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #fde68a;
}
.debt-health-banner.critical {
    background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
    border-color: #fca5a5;
}

.debt-health-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.2px;
}
.debt-health-status-badge.healthy {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}
.debt-health-status-badge.moderate {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #7dd3fc;
}
.debt-health-status-badge.warning {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
}
.debt-health-status-badge.critical {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
}

.debt-comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin: 16px 0;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(8px);
    border-radius: var(--radius-md);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.debt-compare-item {
    display: flex;
    flex-direction: column;
}
.debt-compare-item .label {
    font-size: 11.5px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.debt-compare-item .value {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
}
.debt-compare-item .sub {
    font-size: 11.5px;
    color: #64748b;
    margin-top: 2px;
}

.debt-advice-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 14px;
}
.debt-advice-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 13px;
    line-height: 1.5;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: var(--radius-sm);
    border-left: 3px solid #0284c7;
}
.debt-advice-item.healthy {
    border-left-color: #10b981;
}
.debt-advice-item.warning {
    border-left-color: #f59e0b;
}
.debt-advice-item.critical {
    border-left-color: #ef4444;
}

.debt-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    margin-bottom: 16px;
    transition: all 0.2s ease;
    position: relative;
    box-shadow: var(--shadow-sm);
}
.debt-card:hover {
    border-color: #cbd5e1;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}
.debt-card.paid {
    background: #fafafa;
    border-left: 4px solid #10b981;
    opacity: 0.88;
}
.debt-card.active {
    border-left: 4px solid #0284c7;
}
.debt-card.overdue {
    border-left: 4px solid #ef4444;
    background: #fffcfc;
}

.debt-header-wrap {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.debt-title-group h4 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.debt-creditor {
    font-size: 13px;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 6px;
}

.debt-metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    margin: 12px 0;
}
.debt-metric-box {
    display: flex;
    flex-direction: column;
}
.debt-metric-box .metric-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 2px;
}
.debt-metric-box .metric-val {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-primary);
}

.debt-progress-wrap {
    margin: 14px 0 10px 0;
}
.debt-progress-bar-bg {
    width: 100%;
    height: 8px;
    background: #e2e8f0;
    border-radius: var(--radius-full);
    overflow: hidden;
}
.debt-progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0284c7 0%, #10b981 100%);
    border-radius: var(--radius-full);
    transition: width 0.4s ease;
}

.debt-footer-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0284c7;
    display: inline-block;
    box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.7);
    animation: pulseDotAnim 1.8s infinite cubic-bezier(0.66, 0, 0, 1);
}
@keyframes pulseDotAnim {
    0% {
        box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.7);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(2, 132, 199, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(2, 132, 199, 0);
    }
}

.pulse-dot.danger {
    background: #ef4444;
    animation: pulseDangerAnim 1.8s infinite;
}
@keyframes pulseDangerAnim {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 7px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@media (max-width: 768px) {
    .debt-health-banner {
        padding: 16px;
    }
    .debt-comparison-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
        padding: 12px;
    }
    .debt-metrics-row {
        grid-template-columns: 1fr 1fr;
    }
    .debt-footer-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .debt-footer-actions .btn-group {
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }
}
