/* ============================================
       SFA ADMIN — SEMI-DARK "COOL SLATE" THEME (V3 FINAL)
       Palette: Lebih terang, ramah mata, dan kontras rapi
    ============================================ */
    @import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

    :root {
      --active-blue:  #3b82f6; --blue-glow: #60a5fa;
      --crimson:      #dc2626; --crimson-soft: #ef4444;
      --bg-main:      #1e293b; --bg-sidebar: #0f172a; 
      --surface-1:    #334155; --surface-2: #475569; --surface-3: #64748b; 
      --border:       rgba(148, 163, 184, 0.25); --border-bright: rgba(96, 165, 250, 0.4);
      --text-primary: #ffffff; --text-secondary: #cbd5e1; --text-muted: #94a3b8; 
      --success:      #10b981; --success-soft: rgba(16,185,129,0.15);
      --warning:      #f59e0b; --warning-soft: rgba(245,158,11,0.15);
      --danger:       #ef4444; --danger-soft: rgba(239,68,68,0.15);
      --info:         #3b82f6;
      --sidebar-color: var(--text-primary); --text-dark: var(--text-primary);
    }

    * { box-sizing: border-box; margin: 0; padding: 0; }
    body { font-family: 'Inter', 'Segoe UI', sans-serif; background: var(--bg-main); color: var(--text-primary); display: flex; height: 100vh; width: 100vw; overflow: hidden; font-size: 13px; }

    /* ========== CUSTOM SFA SPINNER ========== */
    i.fa-spinner { width: 1.2em; height: 1.2em; vertical-align: text-bottom; border: 3px solid var(--danger); border-top-color: var(--info); border-radius: 50%; animation: sfa-spin 0.8s linear infinite; }
    i.fa-spinner::before { content: "" !important; }
    @keyframes sfa-spin { to { transform: rotate(360deg); } }

    /* ========== KONTRAS ========== */
    [style*="background-color: #f8f9fa"], [style*="background-color:#f8f9fa"], [style*="background:#f8f9fa"], [style*="background:#f9f9f9"], [style*="background: #fdfefe"], [style*="background:#fdfefe"], [style*="background: white"], [style*="background:white"] { background-color: var(--surface-2) !important; border-color: var(--border) !important; }
    [style*="color:#333"], [style*="color: #333"], [style*="color:#2c3e50"], [style*="color: #2c3e50"], [style*="color:#555"], [style*="color: #555"], [style*="color: black"], [style*="color:black"], td [style*="color:#333"], td [style*="color: #333"], td [style*="color:#2c3e50"], td [style*="color: #2c3e50"], td [style*="color:#555"], td [style*="color: #555"], .board-card [style*="color: black"] { color: #ffffff !important; }
    [style*="color:#e74c3c"], [style*="color: #e74c3c"], [style*="color:var(--danger)"] { color: #ff4d4d !important; font-weight: 800 !important; text-shadow: 0 0 5px rgba(255, 77, 77, 0.3); }
    [style*="color:#7f8c8d"], [style*="color: #7f8c8d"], [style*="color:#95a5a6"], [style*="color: #95a5a6"], [style*="color:#888"], [style*="color: #888"] { color: #cbd5e1 !important; }
    td { color: #ffffff !important; font-weight: 500 !important; } td small { color: #94a3b8 !important; font-weight: 500 !important; }
    [style*="background:#ecf0f1"], [style*="background: #ecf0f1"] { background: var(--surface-3) !important; color: #ffffff !important; border: 1px solid var(--border); }

    /* ========== LOGIN PAGE ========== */
    #adminLogin { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; width: 100vw; background: radial-gradient(circle at center, var(--surface-1) 0%, var(--bg-sidebar) 100%); }
    .login-box { background: var(--surface-2); padding: 44px 40px; border-radius: 20px; border: 1px solid var(--border-bright); box-shadow: 0 25px 60px rgba(0,0,0,0.6); text-align: center; width: 380px; }
    .login-box img { width: 160px; border-radius: 12px; margin-bottom: 20px; filter: drop-shadow(0 0 10px rgba(255,255,255,0.1)); }
    .login-box h3 { color: var(--text-primary); margin-bottom: 28px; font-size: 18px; font-weight: 700; letter-spacing: 2px; }
    .login-box input { width: 100%; padding: 13px 16px; margin-bottom: 12px; background: var(--bg-main); border: 1px solid var(--border); border-radius: 10px; outline: none; font-size: 14px; color: var(--text-primary); transition: all 0.2s; }
    .login-box input::placeholder { color: var(--text-muted); }
    .login-box input:focus { border-color: var(--active-blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
    .login-box button { width: 100%; padding: 13px; background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%); color: white; border: none; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 14px; transition: all 0.2s; box-shadow: 0 4px 15px rgba(59,130,246,0.3); }
    .login-box button:hover { transform: translateY(-1px); filter: brightness(1.1); }
    #loginError { color: var(--danger-soft); font-size: 12px; margin-top: 14px; font-weight: 500; }

    /* ========== APP CONTAINER & COLLAPSIBLE SIDEBAR ========== */
    #adminApp { display: none; height: 100vh; width: 100vw; flex-direction: row; }
    
    .sidebar { width: 260px; background: var(--bg-sidebar); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; transition: width 0.3s ease; position: relative; }
    .sidebar-header { padding: 24px 20px 20px; text-align: center; border-bottom: 1px solid var(--border); position: relative; }
    .logo-admin { width: 180px; border-radius: 12px; margin-bottom: 10px; transition: 0.3s; }
    .sidebar-title { font-size: 12px; font-weight: bold; letter-spacing: 1px; color: #cbd5e1; transition: 0.3s; }
    #displayNamaUser { font-size: 11px; color: var(--blue-glow); font-weight: 600; margin-top: 6px; transition: 0.3s; }

    .sidebar-toggle { position: absolute; right: -14px; top: 35px; width: 28px; height: 28px; background: var(--active-blue); color: white; border: 2px solid var(--bg-main); border-radius: 50%; cursor: pointer; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; font-size: 12px; transition: 0.3s; }
    .sidebar-toggle:hover { background: var(--blue-glow); transform: scale(1.1); }

    /* COLLAPSED STATE MAGIC */
    .sidebar.collapsed { width: 70px; }
    .sidebar.collapsed .logo-admin { width: 0; height: 0; opacity: 0; margin: 0; overflow: hidden; }
    .sidebar.collapsed .sidebar-title, .sidebar.collapsed #displayNamaUser { display: none; }
    .sidebar.collapsed .sidebar-header { padding: 24px 0 20px 0; }
    .sidebar.collapsed .menu-group-title { font-size: 0; padding: 12px 0; justify-content: center; }
    .sidebar.collapsed .menu-group-title i:first-child { font-size: 14px; margin-right: 0 !important; color: var(--active-blue); }
    .sidebar.collapsed .menu-group-title i.fa-chevron-down, .sidebar.collapsed .menu-group-title i.fa-chevron-up { display: none; }
    .sidebar.collapsed .menu-item { font-size: 0; padding: 12px 0; justify-content: center; }
    .sidebar.collapsed .menu-item i { font-size: 15px; margin-right: 0 !important; }
    .sidebar.collapsed .badge-menu { display: none; }
    .sidebar.collapsed .submenu.open { display: none; } 

    .menu-list { flex-grow: 1; margin-top: 8px; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
    .menu-group-title { padding: 10px 18px; color: var(--text-muted); font-size: 10px; font-weight: 700; text-transform: uppercase; cursor: pointer; display: flex; justify-content: space-between; align-items: center; white-space: nowrap;}
    .menu-group-title:hover { color: var(--text-secondary); background: rgba(255,255,255,0.02); }
    .submenu { display: none; flex-direction: column; } .submenu.open { display: flex; }
    .menu-item { padding: 9px 18px 9px 32px; display: flex; align-items: center; cursor: pointer; color: var(--text-secondary); text-decoration: none; border-left: 3px solid transparent; font-size: 12.5px; transition: 0.2s; white-space: nowrap;}
    .menu-item i { width: 16px; font-size: 12px; margin-right: 12px; text-align: center;}
    .menu-item:hover { background: rgba(255,255,255,0.03); color: var(--text-primary); }
    .menu-item.active { background: rgba(59,130,246,0.15); color: var(--blue-glow); border-left-color: var(--active-blue); font-weight: 600; }
    .badge-menu { background: var(--crimson); color: white; font-size: 9px; padding: 2px 6px; border-radius: 10px; margin-left: auto; font-weight: 700; }
    .bottom-menu { flex-grow: 0; flex-shrink: 0; overflow: hidden; border-top: 1px solid var(--border); padding-top: 5px;}
    .logout-btn { color: #ff4d4d !important; font-weight: bold; margin-bottom: 15px;}
    .logout-btn:hover { background: rgba(239, 68, 68, 0.15) !important; color: #ff6b6b !important; }
    .passcode-btn { color: #f1c40f !important; }

    /* ========== MAIN CONTENT & HEADER ========== */
    .main-content { flex: 1; min-width: 0; overflow-y: auto; padding: 24px; background: var(--bg-main); transition: width 0.3s ease; }
    .page-section { display: none; } .page-section.active { display: block; }
    .top-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; background: var(--surface-1); padding: 16px 22px; border-radius: 14px; border: 1px solid var(--border); box-shadow: 0 4px 10px rgba(0,0,0,0.15); }
    .top-header h2 { font-size: 17px; font-weight: 700; color: var(--text-primary); margin-bottom: 0; }

    /* ========== FORM INPUTS ========== */
    select, input[type="date"], input[type="text"], input[type="number"], input[type="password"] { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary); font-family: 'Inter', sans-serif; font-size: 12.5px; outline: none; }
    select:focus, input:focus { border-color: var(--active-blue); box-shadow: 0 0 0 3px rgba(59,130,246,0.2); }
    select option { background: var(--surface-2); color: var(--text-primary); }
    select:disabled { opacity: 0.5; cursor: not-allowed; }

    /* ========== TAGS & BADGES ========== */
    .tag-role { background: rgba(59,130,246,0.15); color: var(--blue-glow); padding: 4px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; display: inline-block; border: 1px solid rgba(59,130,246,0.3); }
    .tag-scope { background: rgba(245,158,11,0.15); color: #fbbf24; padding: 4px 10px; border-radius: 20px; font-size: 10px; font-weight: 700; display: inline-block; border: 1px solid rgba(245,158,11,0.3); }
    .badge-status { padding: 4px 10px; border-radius: 20px; font-weight: 700; font-size: 10px; }
    .badge-pending { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
    .badge-lunas { background: var(--success-soft); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
    .badge-aging { background: var(--danger-soft); color: #ff4d4d; border: 1px solid rgba(239,68,68,0.3); padding: 4px 10px; border-radius: 12px; font-size: 10px; font-weight: 700;}

    /* ========== BUTTONS ========== */
    .btn-action { padding: 8px 16px; background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%); color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 12px; transition: 0.2s; border: 1px solid rgba(255,255,255,0.1); }
    .btn-action:hover { filter: brightness(1.1); transform: translateY(-1px); }
    .btn-success { background: linear-gradient(135deg, #059669 0%, #10b981 100%) !important; }
    .btn-warning { background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%) !important; color: white !important;}
    .btn-danger { background: linear-gradient(135deg, #b91c1c 0%, #ef4444 100%) !important; }

    /* ========== CARDS, BOARDS & KPI ========== */
    .section-label { font-size: 11px; font-weight: 700; color: var(--text-muted); margin: 22px 0 10px 4px; display: flex; align-items: center; gap: 8px; text-transform: uppercase; }
    .card-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin-bottom: 18px; }
    .kpi-card { background: var(--surface-1); padding: 20px; border-radius: 14px; border: 1px solid var(--border); text-align: center; border-top: 3px solid var(--border-bright); transition: 0.2s;}
    .kpi-card:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(0,0,0,0.2); }
    .kpi-card.blue { border-top-color: var(--active-blue); } .kpi-card.green { border-top-color: var(--success); } .kpi-card.orange { border-top-color: var(--warning); } .kpi-card.danger { border-top-color: var(--danger); }
    .kpi-value { font-size: 26px; font-weight: 800; color: var(--text-primary); }
    .kpi-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; margin-top: 6px; font-weight: 600; }
    
    .board-card { background: var(--surface-1); border-radius: 14px; padding: 20px; border: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
    .board-title { font-size: 13px; font-weight: 700; color: var(--text-primary); margin-bottom: 16px; display: flex; justify-content: space-between; border-bottom: 1px solid var(--border); padding-bottom: 12px;}
    
    /* FIX LAYOUT BERTUMPUK: Memaksa tampil sejajar (Kanan & Kiri) */
    .bottom-row { display: flex; flex-direction: row; gap: 20px; margin-top: 15px; width: 100%; align-items: stretch; }
    .bottom-row > .board-card { flex: 1; min-width: 0; margin-bottom: 0; }
    @media (max-width: 1024px) { .bottom-row { flex-direction: column; } }

    /* ========== TABLES ========== */
    table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
    th { text-align: left; color: var(--text-muted); padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 10px; font-weight: 700; text-transform: uppercase; }
    td { padding: 11px 8px; border-bottom: 1px solid rgba(255,255,255,0.05); color: var(--text-primary); }
    tr:hover td { background: rgba(255,255,255,0.03); }

    /* ========== PROGRESS BAR (PERFORMANCE SALES) ========== */
    .prog-bg { width: 100%; background-color: var(--surface-3) !important; border-radius: 10px; height: 12px !important; margin-top: 8px; overflow: hidden; border: 1px inset rgba(0,0,0,0.3); display: block; }
    .prog-fill { height: 100%; border-radius: 10px; transition: width 1s ease; display: block; }
    .kpi-title-box { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; color: var(--text-secondary); margin-top: 14px; }

    /* ========== MODALS & FORM INLINE (ANTI TULISAN HILANG) ========== */
    .modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); backdrop-filter: blur(5px); z-index: 1000; justify-content: center; align-items: center; }
    
    /* FIX MODAL TRANSPARAN: Paksa box utama jadi solid gelap */
    .modal-box { background: var(--surface-1) !important; border-radius: 16px; padding: 28px; position: relative; border: 1px solid var(--border-bright); max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,0.8) !important; }
    
    .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 16px; width: 100%; }
    .form-group { width: 100%; }
    .form-group label { display: block; font-size: 11px; color: var(--text-muted); font-weight: 700; margin-bottom: 6px; text-transform: uppercase; }
    .form-group input, .form-group select { width: 100% !important; padding: 10px 12px; box-sizing: border-box; display: block; }

    /* Hapus warna putih pada background sub-elemen, TAPI JANGAN sentuh box utama */
    [id^="modal"] [style*="background:#f8f9fa"], [id^="modal"] [style*="background:#f4f6f7"], [id^="modal"] [style*="background:#eee"] { background-color: transparent !important; }
    #detTransferBox, #lunasInfoToko { background-color: var(--surface-2) !important; border: 1px dashed var(--active-blue) !important; }
    
    /* FIX LONCENG MERAH */
    .bell-icon { color: var(--danger) !important; text-shadow: 0 0 8px rgba(239, 68, 68, 0.5); }
    
    /* Fix Form Edit Outlet yang menyusut */
    .form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 16px; width: 100%; }
    .form-group { width: 100%; }
    .form-group label { display: block; font-size: 11px; color: var(--text-muted); font-weight: 700; margin-bottom: 6px; text-transform: uppercase; }
    .form-group input, .form-group select { width: 100% !important; padding: 10px 12px; box-sizing: border-box; display: block; }

    /* Fix box Info & Teks di dalam Modal (Termasuk Transfer Bank) */
    [id^="modal"] > div { background-color: var(--surface-1) !important; border: 1px solid var(--border-bright) !important; }
    [id^="modal"] [style*="background:white"], [id^="modal"] [style*="background: white"], [id^="modal"] [style*="background:#f8f9fa"], [id^="modal"] [style*="background:#f4f6f7"], [id^="modal"] [style*="background:#eee"] { background-color: transparent !important; }
    #detTransferBox, #lunasInfoToko { background-color: var(--surface-2) !important; border: 1px dashed var(--active-blue) !important; }
    
    /* AI Chat overrides */
    #ai-chat-widget { background: var(--surface-1) !important; border: 1px solid var(--border-bright) !important; }
    #ai-chat-history { background: var(--bg-main) !important; }

    /* ========== SCROLLBAR ========== */
    * { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
    *::-webkit-scrollbar { width: 6px; height: 6px; }
    *::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }

    /* ========== PRINT ========== */
    @media screen { #printSection { display: none !important; } }
    @media print {
      body > *:not(#printSection) { display: none !important; }
      html, body { background: white !important; color: black !important; margin: 0; padding: 0; height: auto !important; overflow: visible !important; }
      @page { size: A5 portrait; margin: 5mm; }
      #printSection { display: block !important; width: 100%; max-width: 148mm; margin: 0 auto; color: black; background: white !important;}
      .print-center { text-align: center; } .print-right { text-align: right; }
      .print-table th, .print-table td { padding: 1px 2px; text-align: left; font-size: 11px; color: black !important;}
      [style*="color"] { color: black !important; } 
    }

    [style*="background: #fff"], 
    [style*="background:#fff"] {
        background-color: var(--surface-2) !important;
        border-color: var(--border) !important;
    }

    /* 2. Gelapkan Header Tabel RPR agar elegan dan teksnya terbaca */
    #sprFormContainer table thead,
    #sprFormContainer [style*="background: #f4f6f7"],
    #sprFormContainer [style*="background:#f4f6f7"] {
        background-color: var(--surface-3) !important;
        color: var(--text-primary) !important;
    }