/* ================================================================
   PREMIUM DARK THEME — Donasi Komunitas Dashboard
   Features: Glassmorphism, Gradient Accents, Glow, Micro-animations
   ================================================================ */

/* ----- Bootstrap 5.3 Dark Theme Overrides ----- */
[data-bs-theme="dark"] {
    --bs-body-bg: #080c14;
    --bs-body-color: #e2e8f0;
    --bs-secondary-bg: #111827;
    --bs-tertiary-bg: #0d1117;
    --bs-border-color: rgba(255, 255, 255, 0.06);
    --bs-border-color-translucent: rgba(255, 255, 255, 0.04);

    --bs-primary: #10b981;
    --bs-primary-rgb: 16, 185, 129;

    /* Custom palette */
    --primary: #10b981;
    --primary-glow: rgba(16, 185, 129, 0.4);
    --primary-hover: #059669;
    --surface-0: #080c14;  /* Page bg */
    --surface-1: #111827;  /* Cards */
    --surface-2: #1a2332;  /* Elevated / hover */
    --surface-3: #243049;  /* Inputs */
    --border: rgba(255, 255, 255, 0.06);
    --border-subtle: rgba(255, 255, 255, 0.03);
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --font: 'Inter', system-ui, -apple-system, sans-serif;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 20px var(--primary-glow);
}

/* ----- Global Reset & Typography ----- */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--surface-0);
    color: var(--text-primary);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.6;
}

body, button, input, select, textarea,
.form-control, .form-select, .btn, .table,
.nav-link, .badge, .card {
    font-family: var(--font) !important;
    letter-spacing: -0.011em;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font);
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
    line-height: 1.2;
}

a { text-decoration: none; }

/* ----- Sidebar ----- */
.sidebar {
    width: 272px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: linear-gradient(180deg, rgba(17,24,39,0.97) 0%, rgba(8,12,20,0.99) 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar .brand {
    padding: 28px 24px;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    letter-spacing: -0.02em;
}

.sidebar .brand i {
    color: var(--primary);
    font-size: 1.4rem;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.sidebar .nav {
    padding: 16px 12px;
    flex-grow: 1;
}

.sidebar .nav-item {
    margin: 2px 0;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 11px 16px;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 500;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scaleY(0);
    width: 3px;
    height: 20px;
    background: var(--primary);
    border-radius: 0 4px 4px 0;
    transition: transform 0.2s ease;
}

.sidebar .nav-link:hover {
    color: var(--text-primary);
    background: rgba(255,255,255,0.04);
}

.sidebar .nav-link.active {
    background: linear-gradient(135deg, rgba(16,185,129,0.15) 0%, rgba(16,185,129,0.05) 100%);
    color: var(--primary);
    font-weight: 600;
}

.sidebar .nav-link.active::before {
    transform: translateY(-50%) scaleY(1);
}

.sidebar .nav-link.active i {
    filter: drop-shadow(0 0 6px var(--primary-glow));
}

.sidebar .nav-link i {
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
    transition: all 0.2s ease;
}

.sidebar hr {
    border-color: var(--border);
    margin: 8px 4px;
    opacity: 1;
}

/* ----- Main Content ----- */
.main-content {
    margin-left: 272px;
    padding: 28px 32px;
    min-height: 100vh;
}

/* ----- Top Navbar ----- */
.top-navbar {
    background: var(--surface-1);
    padding: 16px 28px;
    border-radius: var(--radius-lg);
    margin-bottom: 28px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.top-navbar .page-title h4 {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0;
}

.top-navbar .user-profile .rounded-circle {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover)) !important;
    box-shadow: 0 0 12px var(--primary-glow);
}

/* ----- Cards ----- */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
}

.card:hover {
    border-color: rgba(255,255,255,0.1);
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 20px 24px;
    font-weight: 600;
    font-size: 0.95rem;
}

.card-body {
    padding: 24px;
}

/* ----- Premium Stat Cards (KPI) ----- */
.premium-stat-card {
    background: var(--surface-1) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.premium-stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.premium-stat-card:hover {
    border-color: rgba(255,255,255,0.1) !important;
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.premium-stat-card:hover::before {
    opacity: 1;
}

/* Gradient top-line per color */
.premium-stat-card:nth-child(1) .premium-stat-card::before,
.premium-stat-card.stat-primary::before { background: linear-gradient(90deg, #10b981, #34d399); }
.premium-stat-card.stat-info::before { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.premium-stat-card.stat-warning::before { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.premium-stat-card.stat-danger::before { background: linear-gradient(90deg, #ef4444, #f87171); }

.stat-icon-sm {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
}

.premium-stat-card:hover .stat-icon-sm {
    transform: scale(1.1);
}

.stat-icon-sm.primary {
    background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(16,185,129,0.05));
    color: var(--primary);
}
.stat-icon-sm.info {
    background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(59,130,246,0.05));
    color: var(--info);
}
.stat-icon-sm.warning {
    background: linear-gradient(135deg, rgba(245,158,11,0.2), rgba(245,158,11,0.05));
    color: var(--warning);
}
.stat-icon-sm.danger {
    background: linear-gradient(135deg, rgba(239,68,68,0.2), rgba(239,68,68,0.05));
    color: var(--danger);
}

.stat-value {
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--text-primary);
}

.stat-currency {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.stat-unit {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-tertiary);
}

/* ----- Badges / Status ----- */
.badge-status {
    padding: 5px 12px;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    letter-spacing: 0.01em;
    text-transform: capitalize;
    border: 1px solid transparent;
}

.badge-lunas {
    background: rgba(16, 185, 129, 0.1);
    color: #34d399;
    border-color: rgba(16, 185, 129, 0.15);
}
.badge-deposit {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border-color: rgba(59, 130, 246, 0.15);
}
.badge-ditalangi {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.15);
}
.badge-tanpa-keterangan {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border-color: rgba(148, 163, 184, 0.1);
}
.badge-tanpa-kabar {
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border-color: rgba(239, 68, 68, 0.15);
}

.bg-light {
    background-color: var(--surface-2) !important;
    color: var(--text-primary) !important;
}

.badge.bg-light.text-dark.border {
    background-color: var(--surface-2) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
    font-weight: 500;
}

/* ----- Rekap Status Row ----- */
.status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    transition: background 0.2s ease;
    margin-bottom: 4px;
}

.status-row:hover {
    background: rgba(255,255,255,0.02);
}

.status-row .status-count {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Progress bars for status */
.status-progress {
    height: 4px;
    border-radius: 4px;
    background: rgba(255,255,255,0.04);
    overflow: hidden;
    margin-top: 8px;
}

.status-progress-bar {
    height: 100%;
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ----- Attention List Items ----- */
.attention-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.attention-item:hover {
    background: rgba(255,255,255,0.03);
}

.attention-item .member-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.attention-item .member-status {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.klaster-title {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* WhatsApp Button */
.btn-wa {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #25d366;
    background: rgba(37, 211, 102, 0.1);
    border: 1px solid rgba(37, 211, 102, 0.15);
    font-size: 14px;
    transition: all 0.2s ease;
}

.btn-wa:hover {
    background: #25d366;
    color: #ffffff;
    border-color: #25d366;
    box-shadow: 0 0 12px rgba(37, 211, 102, 0.3);
}

/* ----- Buttons ----- */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    color: #ffffff;
    border-radius: var(--radius-sm);
    padding: 10px 22px;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #059669, #047857);
    color: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

.btn-outline-primary {
    color: var(--primary);
    border-color: rgba(16, 185, 129, 0.3);
    background: transparent;
}
.btn-outline-primary:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 12px var(--primary-glow);
}

.btn-outline-secondary {
    color: var(--text-secondary);
    border-color: var(--border);
    background: transparent;
}
.btn-outline-secondary:hover {
    background: rgba(255,255,255,0.06);
    color: var(--text-primary);
    border-color: rgba(255,255,255,0.12);
}

.btn-outline-info {
    color: var(--info);
    border-color: rgba(59, 130, 246, 0.3);
}
.btn-outline-info:hover {
    background: var(--info);
    border-color: var(--info);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

.btn-outline-danger {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
}
.btn-outline-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

/* ----- Tables ----- */
.table {
    vertical-align: middle;
    --bs-table-bg: transparent;
}

.table thead th {
    font-weight: 600;
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-tertiary);
    border-top: none;
    border-bottom: 1px solid var(--border) !important;
    padding: 12px;
}

.table tbody td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.9rem;
}

.table-hover tbody tr {
    transition: background 0.15s ease;
}

.table-hover tbody tr:hover {
    background: rgba(255, 255, 255, 0.02) !important;
    --bs-table-hover-bg: rgba(255, 255, 255, 0.02);
}

/* Member avatar circle in tables */
.member-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* ----- Form Styles ----- */
.form-control, .form-select {
    background-color: var(--surface-3);
    border-color: var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
    background-color: var(--surface-3);
    border-color: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

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

.form-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group-text {
    background-color: var(--surface-2);
    border-color: var(--border);
    color: var(--text-secondary);
    font-weight: 600;
    border-radius: var(--radius-sm);
}

/* ----- Select2 ----- */
.select2-container--bootstrap-5 .select2-selection {
    background-color: var(--surface-3) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: var(--radius-sm) !important;
    min-height: 42px !important;
}
.select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary) !important;
    padding: 6px 14px !important;
}
.select2-container--bootstrap-5 .select2-dropdown {
    background-color: var(--surface-1) !important;
    border-color: var(--border) !important;
    border-radius: var(--radius-md) !important;
    box-shadow: var(--shadow-lg) !important;
    overflow: hidden;
}
.select2-container--bootstrap-5 .select2-search__field {
    background-color: var(--surface-3) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
    border-radius: var(--radius-sm) !important;
}
.select2-container--bootstrap-5 .select2-results__option {
    color: var(--text-primary) !important;
    background-color: transparent !important;
    padding: 8px 14px !important;
    font-size: 0.9rem;
    transition: background 0.15s ease;
}
.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
    background: linear-gradient(135deg, rgba(16,185,129,0.2), rgba(16,185,129,0.1)) !important;
    color: #34d399 !important;
}
.select2-container--bootstrap-5 .select2-results__group {
    color: var(--text-tertiary) !important;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ----- DataTables ----- */
.dataTables_wrapper {
    color: var(--text-primary) !important;
}
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-secondary) !important;
    font-size: 0.85rem;
}
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background-color: var(--surface-3) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm);
    padding: 6px 12px;
}
.dataTables_wrapper .dataTables_filter input:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
    outline: none;
}
.dataTables_wrapper .dataTables_length select {
    padding-right: 2.25rem !important;
}
.dataTables_wrapper .dataTables_filter {
    text-align: left !important;
}
.dataTables_wrapper .dataTables_length {
    text-align: right !important;
}
.page-link {
    background-color: var(--surface-1);
    border-color: var(--border);
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 6px 12px;
    transition: all 0.2s ease;
}
.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
    box-shadow: 0 0 10px var(--primary-glow);
}
.page-link:hover {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-primary);
}
.page-item.disabled .page-link {
    background-color: var(--surface-1);
    border-color: var(--border);
    color: var(--text-tertiary);
    opacity: 0.4;
}

/* ----- Profile Page ----- */
.profile-avatar {
    width: 88px;
    height: 88px;
    border-radius: var(--radius-lg);
    font-size: 2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #ffffff;
    box-shadow: 0 4px 20px var(--primary-glow);
}

.month-cell {
    padding: 10px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-1);
    transition: all 0.2s ease;
}

.month-cell:hover {
    border-color: rgba(255,255,255,0.1);
    background: var(--surface-2);
}

.month-cell.current {
    border-color: var(--primary);
    box-shadow: 0 0 10px var(--primary-glow);
}

/* ----- Utilities ----- */
hr {
    border-color: var(--border);
    opacity: 1;
}

.text-muted {
    color: var(--text-secondary) !important;
}

.text-primary {
    color: var(--primary) !important;
}

.text-success {
    color: var(--success) !important;
}

.fw-medium {
    font-weight: 500;
}

.bg-secondary {
    background-color: var(--surface-2) !important;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.15);
}

/* Selection */
::selection {
    background: rgba(16, 185, 129, 0.3);
    color: #ffffff;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card, .premium-stat-card {
    animation: fadeInUp 0.4s cubic-bezier(0.4, 0, 0.2, 1) backwards;
}

.row > [class*="col-"]:nth-child(1) .card,
.row > [class*="col-"]:nth-child(1) .premium-stat-card { animation-delay: 0.05s; }
.row > [class*="col-"]:nth-child(2) .card,
.row > [class*="col-"]:nth-child(2) .premium-stat-card { animation-delay: 0.1s; }
.row > [class*="col-"]:nth-child(3) .card,
.row > [class*="col-"]:nth-child(3) .premium-stat-card { animation-delay: 0.15s; }
.row > [class*="col-"]:nth-child(4) .card,
.row > [class*="col-"]:nth-child(4) .premium-stat-card { animation-delay: 0.2s; }

/* ================================================================
   RESPONSIVE — Mobile-first overrides
   ================================================================ */

/* ----- Hamburger Button ----- */
.hamburger-btn {
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.hamburger-btn:hover {
    background: var(--surface-3);
    border-color: rgba(255,255,255,0.12);
}

/* ----- Sidebar Close Button ----- */
.sidebar-close {
    margin-left: auto;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255,255,255,0.06);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sidebar-close:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
}

/* ----- Sidebar Overlay (Mobile) ----- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ----- Mobile: < 992px (lg breakpoint) ----- */
@media (max-width: 991.98px) {
    /* Off-canvas Sidebar */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
    }

    /* Main content full width */
    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    /* Top Navbar */
    .top-navbar {
        padding: 12px 16px;
        border-radius: var(--radius-md);
        margin-bottom: 20px;
    }

    .top-navbar .page-title h4 {
        font-size: 1rem;
    }
}

/* ----- Mobile: < 768px (md breakpoint) ----- */
@media (max-width: 767.98px) {
    .main-content {
        padding: 12px;
    }

    .top-navbar {
        padding: 10px 14px;
        margin-bottom: 16px;
    }

    .top-navbar .page-title h4 {
        font-size: 0.95rem;
    }

    /* Cards */
    .card {
        border-radius: var(--radius-md);
    }

    .card-header {
        padding: 14px 16px;
        font-size: 0.88rem;
    }

    .card-body {
        padding: 16px;
    }

    /* Premium Stat Cards */
    .premium-stat-card .card-body {
        padding: 14px !important;
    }

    .stat-value {
        font-size: 1.25rem;
    }

    .stat-currency, .stat-unit {
        font-size: 0.72rem;
    }

    .stat-icon-sm {
        width: 36px;
        height: 36px;
        font-size: 15px;
        border-radius: var(--radius-sm);
    }

    .status-progress {
        margin-top: 6px;
    }

    /* Hide progress context text on tiny stat cards */
    .premium-stat-card .text-muted[style*="0.72rem"] {
        display: none;
    }

    /* Status Rows */
    .status-row {
        padding: 10px 12px;
    }

    .status-row .status-count {
        font-size: 0.95rem;
    }

    /* Badge Status */
    .badge-status {
        font-size: 0.68rem;
        padding: 4px 8px;
    }

    /* Attention Items */
    .attention-item {
        padding: 8px 10px;
    }

    .attention-item .member-name {
        font-size: 0.85rem;
    }

    .klaster-title {
        font-size: 0.72rem;
    }

    /* Tables */
    .table thead th {
        font-size: 0.7rem;
        padding: 10px 8px;
    }

    .table tbody td {
        font-size: 0.82rem;
        padding: 10px 8px;
    }

    .member-avatar {
        width: 32px;
        height: 32px;
        font-size: 0.75rem;
        border-radius: 8px;
    }

    /* Profile Page */
    .profile-avatar {
        width: 72px;
        height: 72px;
        font-size: 1.6rem;
    }

    .month-cell {
        padding: 8px 4px;
    }

    /* Forms */
    .form-control, .form-select {
        padding: 10px 12px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    /* Buttons */
    .btn {
        font-size: 0.85rem;
    }

    .btn-primary {
        padding: 10px 18px;
    }

    /* DataTables */
    .dataTables_wrapper .dataTables_length,
    .dataTables_wrapper .dataTables_filter {
        font-size: 0.78rem;
        margin-bottom: 12px;
    }

    .dataTables_wrapper .dataTables_info {
        font-size: 0.75rem;
    }

    .dataTables_wrapper .dataTables_filter input {
        width: 100% !important;
        max-width: 200px;
    }

    /* WhatsApp Button — larger touch target */
    .btn-wa {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
}

/* ----- Small phones: < 400px ----- */
@media (max-width: 399.98px) {
    .main-content {
        padding: 10px;
    }

    .top-navbar {
        padding: 10px 12px;
    }

    .top-navbar .page-title h4 {
        font-size: 0.88rem;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .premium-stat-card .card-body {
        padding: 12px !important;
    }

    .stat-icon-sm {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }

    .card-header h5 {
        font-size: 0.85rem !important;
    }
}

/* ----- Touch-friendly: increase tap targets ----- */
@media (pointer: coarse) {
    .sidebar .nav-link {
        padding: 14px 16px;
        min-height: 48px;
    }

    .btn-sm {
        min-height: 36px;
        min-width: 36px;
        padding: 6px 10px;
    }

    .btn-wa {
        min-height: 44px;
        min-width: 44px;
    }

    .page-link {
        padding: 8px 14px;
        min-height: 40px;
    }
}

/* ----- Safe area for devices with notch ----- */
@supports (padding: max(0px)) {
    .main-content {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    .sidebar {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

/* ----- Landscape phone adjustments ----- */
@media (max-height: 500px) and (orientation: landscape) {
    .sidebar .nav-link {
        padding: 8px 16px;
    }

    .sidebar .brand {
        padding: 16px 24px;
    }
}

