:root {
    --primary-color: <?php echo $settings['tema_warna']; ?>;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --dark-color: #343a40;
    --light-color: #f8f9fa;
    --sidebar-width: 250px;
    --header-height: 60px;
    --bg-color: #1a1a1a;
    --card-bg: #2d2d2d;
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --border-color: #404040;
}

/* Calendar Grid System */
.calendar-container {
    width: 100%;
    overflow: hidden;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border: 1px solid #eee;
    border-radius: 12px;
    overflow: hidden;
}

.calendar-day-head {
    padding: 1rem;
    text-align: center;
    background: #f8f9fa;
    font-weight: 700;
    border-bottom: 1px solid #eee;
    color: #666;
    font-size: 0.85rem;
}

.calendar-day, .calendar-day-empty {
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
    border-right: 1px solid #eee;
    min-height: 120px;
    background: white;
}

.calendar-day.today {
    background: #fff8fb;
}

.calendar-day-empty {
    background: #fafafa;
    min-height: 100px;
}

.day-number {
    text-align: right;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: #999;
}

.event-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.event-item {
    display: block;
    text-decoration: none;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.event-item.lunas {
    background: #d4edda;
    color: #155724;
    border-left: 3px solid #28a745;
}

.event-item.dp {
    background: #fff3e0;
    color: #ef6c00;
    border-left: 3px solid #ff9800;
}

.event-item.belum {
    background: #f8d7da;
    color: #721c24;
    border-left: 3px solid #dc3545;
}

@media (max-width: 768px) {
    .calendar-grid {
        grid-template-columns: repeat(7, 1fr) !important;
        width: 100% !important;
        border-radius: 8px;
    }

    .calendar-day-head {
        padding: 5px 2px !important;
        font-size: 0.55rem !important;
    }

    .calendar-day, .calendar-day-empty {
        padding: 2px !important;
        min-height: 50px !important;
        border-right: 0.5px solid #eee !important;
        border-bottom: 0.5px solid #eee !important;
    }

    .day-number {
        font-size: 0.65rem !important;
        margin-bottom: 2px !important;
    }

    .event-item {
        font-size: 0.5rem !important;
        padding: 1px 2px !important;
        border-left-width: 2px !important;
        border-radius: 2px !important;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    overflow-x: hidden;
}

.filter-card {
    background: var(--card-bg);
    padding: 0.5rem 0.75rem; /* Lebih kecil lagi */
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* Min-width lebih kecil */
    gap: 0.5rem;
    align-items: flex-end;
}

.filter-grid label {
    font-size: 0.65rem !important; /* Font label mikro */
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 1px !important;
    text-transform: uppercase;
}

.filter-grid .form-control {
    padding: 0.3rem 0.5rem; /* Input sangat ramping */
    font-size: 0.8rem !important;
    height: 30px; /* Tinggi sangat pendek */
    border-radius: 6px;
}

.filter-grid .btn-search {
    height: 30px !important;
    padding: 0 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

/* Base Styles */

@media (max-width: 768px) {
    .filter-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.4rem;
    }
    .filter-grid .btn-search {
        grid-column: span 2;
    }
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: #1e1e2d; /* Warna lebih deep & premium */
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1001;
    transition: all 0.3s;
    box-shadow: 4px 0 15px rgba(0,0,0,0.1);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid #eee;
}

.sidebar-header h3 {
    color: var(--primary-color);
    font-size: 1.25rem;
    font-weight: 700;
}

.sidebar-menu {
    padding: 1rem 0;
    list-style: none;
}

.sidebar-menu li {
    margin: 0.2rem 0.8rem;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    border-radius: 10px;
    margin: 4px 12px;
    transition: all 0.2s;
    font-weight: 500;
}

.sidebar-menu li a:hover, .sidebar-menu li a.active {
    background: rgba(255, 77, 141, 0.15);
    color: var(--primary-color);
}

.sidebar-menu li a i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

/* Main Content Styles */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 100px 35px 40px 35px; /* Padding lebih proporsional */
    transition: all 0.3s;
    min-height: 100vh;
    background-color: var(--bg-color); /* Background sedikit lebih soft */
}

/* Navbar Styles */
.navbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-width);
    height: 70px; /* Sedikit lebih ramping */
    background: rgba(45, 45, 45, 0.85); /* Glassmorphism dark */
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    transition: all 0.3s;
    border-bottom: 1px solid var(--border-color);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info .username {
    font-weight: 600;
    color: var(--text-primary);
}

.user-info .role-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    background-color: var(--border-color);
    color: var(--text-secondary);
    text-transform: uppercase;
}

/* Container & Cards */
.container-fluid {
    padding: 1.5rem;
}

.card {
    background: var(--card-bg);
    border-radius: 15px; /* Lebih bulat agar modern */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2); /* Shadow lebih halus */
    margin-bottom: 25px; /* Jarak antar card lebih lega */
    border: 1px solid var(--border-color); /* Border tipis agar tegas */
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    background: transparent;
}

.card-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.card-body {
    padding: 1.25rem;
}

/* New Stats Grid Mobile Layout */
.stats-grid-mobile {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.stats-grid-row-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stats-grid-row-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.stats-grid-row-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 20px;
}

.micro-card {
    background: var(--card-bg);
    padding: 12px 5px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border: 1px solid var(--border-color);
}

.micro-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 6px;
    font-size: 0.85rem;
}

.micro-label {
    font-size: 0.6rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.2px;
}

.micro-value {
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--text-primary);
}

.stats-card-mini {
    padding: 12px 10px;
    border-radius: 12px;
    color: white;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.stats-label-mini {
    font-size: 0.75rem;
    opacity: 0.9;
    margin-bottom: 5px;
    font-weight: 500;
}

.stats-value-mini {
    font-size: 0.9rem;
    font-weight: 700;
}

@media (max-width: 480px) {
    .stats-value-mini {
        font-size: 0.8rem;
    }
    .stats-label-mini {
        font-size: 0.65rem;
    }
}

.stats-card-mini.cash { background: linear-gradient(135deg, #28a745, #218838); }
.stats-card-mini.bank { background: linear-gradient(135deg, #007bff, #0069d9); }
.stats-card-mini.luar { background: linear-gradient(135deg, #6c757d, #5a6268); }

.stats-card.total-combined { background: linear-gradient(135deg, #ff4d8d, #e03a7a); }
.stats-card.total-all { background: linear-gradient(135deg, #333, #000); }

.keuangan-tabs {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 1.5rem;
}

.tab-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 5px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    gap: 5px;
}

.tab-link i {
    font-size: 1.1rem;
}

.tab-link span {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.tab-link.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(255, 77, 141, 0.2);
}

.tab-link.active.cash { background: linear-gradient(135deg, #28a745, #218838); border-color: #28a745; }
.tab-link.active.bank { background: linear-gradient(135deg, #007bff, #0069d9); border-color: #007bff; }
.tab-link.active.luar { background: linear-gradient(135deg, #6c757d, #5a6268); border-color: #6c757d; }

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stats-card {
    padding: 1.5rem;
    border-radius: 18px;
    color: white;
    position: relative;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    border: none;
    box-shadow: 0 8px 15px rgba(0,0,0,0.08);
}

.stats-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 20px rgba(0,0,0,0.12);
}

.stats-card.cash { background: linear-gradient(135deg, #28a745, #218838); }
.stats-card.bank { background: linear-gradient(135deg, #007bff, #0069d9); }
.stats-card.luar { background: linear-gradient(135deg, #6c757d, #5a6268); }
.stats-card.total { background: linear-gradient(135deg, #ff4d8d, #e03a7a); }

.stats-icon {
    font-size: 2rem;
    opacity: 0.3;
    position: absolute;
    right: 20px;
    bottom: 20px;
}

.stats-label { font-size: 0.9rem; font-weight: 500; }
.stats-value { font-size: 1.8rem; font-weight: 700; margin-top: 0.5rem; }

/* Table Styles */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 12px 15px;
    background-color: var(--card-bg);
    color: var(--text-secondary);
    font-weight: 600;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-lunas { background-color: #d4edda; color: #155724; }
.badge-dp { background-color: #fff3e0; color: #ef6c00; }
.badge-belum { background-color: #f8d7da; color: #721c24; }

/* Form Styles */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: var(--text-secondary); }
.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.form-control:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

/* Mobile & iOS Optimizations */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }
    
    body {
        font-size: 14px; /* Perkecil font default */
    }

    .sidebar {
        left: -280px;
        width: 280px;
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 110px 15px 20px 15px; /* Tambahkan padding atas lebih banyak di mobile (dari 10px ke 110px) */
    }

    .navbar {
        left: 0;
        padding: 0 1rem;
    }

    .container-fluid {
        padding: 0.5rem; /* Padding lebih kecil untuk iPhone */
    }

    /* Stats Grid iPhone Optimization */
    .stats-grid {
        grid-template-columns: 1fr !important; /* Paksa 1 kolom di HP agar tidak sempit */
        gap: 0.75rem;
    }

    .stats-card {
        height: auto;
        padding: 1rem;
    }

    .stats-value {
        font-size: 1.5rem !important; /* Perkecil angka statistik */
    }

    .card-body {
        padding: 1rem;
    }

    /* Form iPhone Optimization */
    .row {
        display: block !important; /* Ubah grid ke block di mobile */
    }

    .form-group {
        margin-bottom: 0.75rem;
    }

    .form-control {
        padding: 0.6rem;
        font-size: 16px !important; /* Minimal 16px untuk iOS agar tidak auto-zoom saat input */
    }

    .btn {
        padding: 0.6rem 1rem;
        width: 100%; /* Tombol full width di mobile */
        justify-content: center;
    }

    /* Table iPhone Optimization */
    .table {
        width: 100% !important;
        margin-bottom: 0 !important;
    }
    
    .table th, .table td {
        padding: 6px 4px !important; /* Padding sangat minimal */
        font-size: 0.7rem !important; /* Font sangat kecil tapi tetap tajam */
        white-space: normal !important; /* Biarkan teks membungkus */
        vertical-align: middle !important;
    }

    .table th {
        font-size: 0.65rem !important;
        text-transform: uppercase;
    }

    .badge {
        padding: 2px 4px !important;
        font-size: 0.6rem !important;
    }

    /* Action Buttons in Table */
    .table .btn {
        padding: 4px 6px !important;
        width: auto !important;
        font-size: 0.7rem !important;
    }

    /* Hero Card Dashboard iPhone */
    .card h2 {
        font-size: 1.25rem !important;
    }
    
    .card p {
        font-size: 0.9rem !important;
    }

    /* Fix Calendar Cutting Off - Ultra Compact for iPhone */
    .fc {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        border: none !important;
    }

    .fc-view-harness {
        margin: 0 !important;
        width: 100% !important;
        height: 350px !important; /* Jauh lebih pendek */
    }

    .fc-scrollgrid {
        border: none !important;
        width: 100% !important;
        table-layout: fixed !important;
    }

    .fc-col-header {
        width: 100% !important;
    }

    .fc .fc-col-header-cell-cushion {
        font-size: 0.45rem !important; /* Sangat kecil */
        padding: 1px 0 !important;
    }

    .fc .fc-daygrid-day-number {
        font-size: 0.55rem !important; /* Sangat kecil */
        padding: 1px !important;
    }

    .fc .fc-daygrid-day-frame {
        min-height: 30px !important; /* Sangat pendek */
        padding: 0 !important;
        margin: 0 !important;
    }

    .fc .fc-event {
        margin: 0 !important;
        padding: 0 !important;
        font-size: 0.45rem !important;
        border-radius: 1px !important;
    }

    .fc .fc-event-title {
        padding: 0 1px !important;
        white-space: nowrap !important;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .fc .fc-toolbar {
        padding: 0 !important;
        margin-bottom: 5px !important;
        display: flex !important;
        justify-content: space-between !important;
        width: 100% !important;
    }

    .fc .fc-toolbar-title {
        font-size: 0.8rem !important;
        margin: 0 !important;
    }

    .fc .fc-button {
        padding: 1px 4px !important;
        font-size: 0.65rem !important;
        height: auto !important;
    }

    /* Menghilangkan border berlebih yang memakan pixel */
    .fc-theme-standard td, .fc-theme-standard th, .fc-theme-standard .fc-scrollgrid {
        border: 0.5px solid #eee !important;
    }
}

.btn-primary { background-color: var(--primary-color); color: white; }
.btn-danger { background-color: var(--danger-color); color: white; }
.btn-success { background-color: var(--success-color); color: white; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        left: -100%;
    }
    .sidebar.active {
        left: 0;
    }
    .main-content {
        margin-left: 0;
    }
    .navbar {
        left: 0;
    }
}
