/* ============================================
   SIRAMEN - Design System & Global Styles
   Mobile-first, dark modern theme
   ============================================ */

/* --- Post-login Loading Video Overlay --- */
.loading-video-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    z-index: 99999;
    margin: 0;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.4s ease;
}

.loading-video-overlay.hide {
    opacity: 0;
    pointer-events: none;
}

.loading-video-player {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.loading-video-skip {
    position: absolute;
    bottom: 24px;
    right: 24px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 24px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
}

.loading-video-skip:hover {
    background: rgba(255, 255, 255, 0.2);
}

@media (max-width: 480px) {
    .loading-video-skip {
        bottom: 16px;
        right: 16px;
        padding: 8px 14px;
        font-size: 0.82rem;
    }
}

/* --- CSS Variables --- */
:root {
    --primary: #6C63FF;
    --primary-light: #8B85FF;
    --primary-dark: #4F46E5;
    --secondary: #00D4AA;
    --secondary-light: #34E0BF;
    --accent: #FF6B6B;
    --warning: #FFB84D;
    --success: #22C55E;
    --danger: #EF4444;
    --info: #3B82F6;

    /* Light Theme Defaults */
    --bg-dark: #F5F7FA;
    --bg-card: #FFFFFF;
    --bg-card-hover: #F8FAFC;
    --bg-input: #FFFFFF;
    --bg-sidebar: #FFFFFF;
    --bg-glass: rgba(255, 255, 255, 0.85);

    --text-primary: #1E293B;
    --text-secondary: #475569;
    --text-muted: #94A3B8;

    --border: #E2E8F0;
    --border-light: rgba(0, 0, 0, 0.05);

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

    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --shadow-glow: 0 0 15px rgba(108, 99, 255, 0.2);

    --sidebar-width: 260px;
    --navbar-height: 81px;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-dark: #0F0F1A;
    --bg-card: #1A1A2E;
    --bg-card-hover: #222240;
    --bg-input: #16162B;
    --bg-sidebar: #12122A;
    --bg-glass: rgba(26, 26, 46, 0.85);

    --text-primary: #F0F0FF;
    --text-secondary: #A0A0C0;
    --text-muted: #6B6B8A;

    --border: rgba(108, 99, 255, 0.15);
    --border-light: rgba(255, 255, 255, 0.08);
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(108, 99, 255, 0.3);
}

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: var(--font-family);
    background: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary);
}

/* --- Layout --- */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .logo {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 18px;
    color: white;
}

.brand-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    line-height: 1.2;
}

.sidebar-brand h2 {
    font-size: 1.2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.brand-tagline {
    font-size: 0.58rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-menu {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.menu-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 12px 12px 6px;
    font-weight: 600;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
    cursor: pointer;
}

.menu-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
}

.menu-item.active {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.2), rgba(0, 212, 170, 0.1));
    color: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.menu-item i {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar {
    height: var(--navbar-height);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 500;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.4rem;
    cursor: pointer;
    padding: 8px;
}

.page-title {
    font-size: 1.15rem;
    font-weight: 600;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.user-menu:hover {
    background: var(--bg-card);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

.user-avatar-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    border: 2px solid var(--border);
}

.user-info {
    text-align: right;
    min-width: 0;
    max-width: 180px;
}

.user-info .name,
.user-info .role {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-info .name {
    font-size: 0.85rem;
    font-weight: 600;
}

.user-info .role {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

.content-area {
    flex: 1;
    min-width: 0;
    padding: 24px;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: var(--transition);
}

.card:hover {
    border-color: rgba(108, 99, 255, 0.3);
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Centered single-column form pages (e.g. setoran/penarikan) */
.form-narrow {
    width: 100%;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

@media (max-width: 480px) {
    .form-narrow {
        padding: 18px 16px;
    }
    .form-narrow .btn-lg {
        padding: 12px 20px;
        font-size: 0.95rem;
    }
}

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    min-width: 0;
    overflow: hidden;
    container-type: inline-size;
}

.stat-info {
    min-width: 0;
    flex: 1;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
}

.stat-icon.purple {
    background: rgba(108, 99, 255, 0.15);
    color: var(--primary-light);
}

.stat-icon.green {
    background: rgba(0, 212, 170, 0.15);
    color: var(--secondary);
}

.stat-icon.orange {
    background: rgba(255, 184, 77, 0.15);
    color: var(--warning);
}

.stat-icon.red {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.stat-icon.blue {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

/* Colored stat-card variants (e.g. student dashboard) */
.stat-card.c-purple {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.16), rgba(108, 99, 255, 0.04));
    border-color: rgba(108, 99, 255, 0.30);
}
.stat-card.c-green {
    background: linear-gradient(135deg, rgba(0, 212, 170, 0.16), rgba(0, 212, 170, 0.04));
    border-color: rgba(0, 212, 170, 0.30);
}
.stat-card.c-red {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.16), rgba(239, 68, 68, 0.04));
    border-color: rgba(239, 68, 68, 0.30);
}
.stat-card.c-orange {
    background: linear-gradient(135deg, rgba(255, 184, 77, 0.18), rgba(255, 184, 77, 0.05));
    border-color: rgba(255, 184, 77, 0.35);
}
.stat-card.c-purple .stat-info h3 { color: var(--primary-light); }
.stat-card.c-green .stat-info h3 { color: var(--secondary); }
.stat-card.c-red .stat-info h3 { color: var(--danger); }
.stat-card.c-orange .stat-info h3 { color: var(--warning); }

.stat-info h3 {
    font-size: clamp(1.05rem, 1.6vw, 1.5rem);
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Nominal panjang (Rp 12.345.678,00) mengecil mengikuti lebar kartunya,
   bukan lebar layar, jadi tidak pernah keluar dari kartu. */
@supports (container-type: inline-size) {
    .stat-info h3 {
        font-size: clamp(0.8rem, 8.5cqi, 1.5rem);
    }
}

.stat-info p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 2px;
    overflow-wrap: anywhere;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 16px;
}

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

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}

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

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B6B8A' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
}

/* --- Password show/hide toggle --- */
.password-field {
    position: relative;
}

.password-field .form-control {
    padding-right: 42px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
}

.password-toggle:hover {
    color: var(--text-primary);
}

/* Hide native browser reveal/clear icons so they don't flicker or duplicate */
input[type="password"]::-ms-reveal,
input[type="password"]::-ms-clear {
    display: none;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
}

.btn-primary:hover {
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
    color: white;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #16A34A);
    color: white;
}

.btn-success:hover {
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #DC2626);
    color: white;
}

.btn-danger:hover {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.3);
    color: white;
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #F59E0B);
    color: #1A1A2E;
}

.btn-info {
    background: linear-gradient(135deg, var(--info), #2563EB);
    color: white;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* --- Tables --- */
.table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    /* overflow-x auto removed so DataTables Responsive can compute widths natively */
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

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

table.dataTable thead th {
    background: var(--bg-card) !important;
    color: var(--text-secondary) !important;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--border) !important;
    white-space: nowrap;
}

table.dataTable tbody td {
    padding: 12px 16px !important;
    border-bottom: 1px solid var(--border-light) !important;
    font-size: 0.88rem;
    color: var(--text-primary);
    vertical-align: middle;
    white-space: nowrap;
}

table.dataTable tbody tr:hover {
    background: var(--bg-card-hover) !important;
}

/* DataTables custom styling */
.dataTables_wrapper {
    padding: 0;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text-secondary) !important;
    padding: 12px 16px !important;
    font-size: 0.85rem;
}

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background: var(--bg-input) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-primary) !important;
    padding: 6px 12px !important;
    outline: none;
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-secondary) !important;
    border-radius: var(--radius-sm) !important;
    margin: 0 2px;
    padding: 4px 12px !important;
    transition: var(--transition);
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* DataTables Responsive Extensions */
table.dataTable.dtr-inline.collapsed > tbody > tr > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr > th.dtr-control:before {
    background-color: var(--primary) !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 4px !important;
    color: white !important;
    font-weight: 800 !important;
    font-size: 14px !important;
    height: 18px !important;
    width: 18px !important;
    line-height: 18px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    left: 10px !important;
}

table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td.dtr-control:before,
table.dataTable.dtr-inline.collapsed > tbody > tr.parent > th.dtr-control:before {
    background-color: var(--danger) !important;
}

table.dataTable > tbody > tr.child ul.dtr-details {
    width: 100%;
}

table.dataTable > tbody > tr.child ul.dtr-details > li {
    border-bottom: 1px solid var(--border-light) !important;
    padding: 8px 0 !important;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 4px 12px;
}

table.dataTable > tbody > tr.child ul.dtr-details > li:last-child {
    border-bottom: none !important;
}

table.dataTable > tbody > tr.child span.dtr-title {
    font-weight: 600 !important;
    color: var(--text-secondary) !important;
    flex: 0 0 auto;
    white-space: nowrap;
}

table.dataTable > tbody > tr.child span.dtr-data {
    color: var(--text-primary) !important;
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: normal;
    text-align: right;
}

/* --- Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-pending {
    background: rgba(255, 184, 77, 0.15);
    color: var(--warning);
}

.badge-validated {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-rejected {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-active {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-inactive,
.badge-cancelled {
    background: rgba(107, 107, 138, 0.2);
    color: var(--text-muted);
}

.badge-deposit {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-withdraw {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.badge-warning {
    background: rgba(255, 184, 77, 0.15);
    color: var(--warning);
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.swal2-container {
    z-index: 2100;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

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

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    top: 80px;
    right: 24px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 3.7s forwards;
    box-shadow: var(--shadow-md);
    min-width: 280px;
    max-width: 420px;
}

.toast-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.toast-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.toast-warning {
    background: rgba(255, 184, 77, 0.15);
    border: 1px solid rgba(255, 184, 77, 0.3);
    color: var(--warning);
}

.toast-info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--info);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* --- Progress Bar --- */
.progress {
    height: 8px;
    background: var(--bg-input);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Leaderboard --- */
.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}

.leaderboard-item:last-child {
    border-bottom: none;
}

.leaderboard-rank {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
    background: var(--bg-input);
    color: var(--text-muted);
}

.leaderboard-rank.gold {
    background: linear-gradient(135deg, #FFD700, #FFA500);
    color: #1A1A2E;
}

.leaderboard-rank.silver {
    background: linear-gradient(135deg, #C0C0C0, #A0A0A0);
    color: #1A1A2E;
}

.leaderboard-rank.bronze {
    background: linear-gradient(135deg, #CD7F32, #8B4513);
    color: white;
}

.leaderboard-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.leaderboard-info {
    flex: 1;
    min-width: 0;
}

.leaderboard-info .name,
.leaderboard-info .detail {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-info .name {
    font-weight: 600;
    font-size: 0.88rem;
}

.leaderboard-info .detail {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.leaderboard-value {
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--secondary);
    flex-shrink: 0;
}

/* --- QR Code --- */
.qr-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px;
}

.qr-container img {
    border-radius: var(--radius-sm);
    background: white;
    padding: 12px;
}

.qr-timer {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--warning);
}

/* --- Login Page --- */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0F0F1A 0%, #1A1A3E 50%, #0F0F1A 100%);
    padding: 16px;
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-card .logo-wrapper {
    text-align: center;
    margin-bottom: 28px;
}

.login-card .logo-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    color: white;
    margin-bottom: 12px;
}

.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card .subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.captcha-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 6px;
}

.captcha-wrapper img {
    height: 44px;
    flex-grow: 1;
    width: 100%;
    object-fit: cover;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.captcha-wrapper .btn-refresh {
    padding: 8px;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.flash-message {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 0.85rem;
    font-weight: 500;
}

.flash-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
}

.flash-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: var(--success);
}

.flash-warning {
    background: rgba(255, 184, 77, 0.15);
    border: 1px solid rgba(255, 184, 77, 0.3);
    color: var(--warning);
}

/* --- Goals --- */
.goal-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.goal-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}

.goal-card .goal-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 12px;
    overflow-wrap: anywhere;
}

.goal-card .goal-detail strong {
    text-align: right;
    overflow-wrap: anywhere;
}

.goal-card .goal-detail {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.goal-card .goal-detail span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.goal-card .goal-detail strong {
    font-size: 0.9rem;
}

.goal-card .goal-highlight {
    color: var(--secondary);
}

.goal-card .goal-percent,
.goal-percent {
    font-size: 0.8rem;
    margin-top: 4px;
}

.goal-card .flash-message {
    margin: 8px 0 0;
}

.steps-list {
    margin: 0 0 16px;
    padding-left: 20px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.steps-list li {
    margin-bottom: 6px;
}

.goal-weeks {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 8px;
}

.goal-week {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.8rem;
    min-width: 0;
}

.goal-week.is-done {
    color: var(--success);
    border-color: var(--success);
}

.goal-week.is-missed {
    color: var(--danger);
}

.goal-week.is-current {
    color: var(--warning);
    border-color: var(--warning);
}

/* Single mascot walking along the bottom of the page (driven by goals.html JS) */
.page-mascot {
    position: fixed;
    left: 0;
    bottom: 0;
    z-index: 40;
    pointer-events: none;
    transform: translateY(140%);                 /* hidden below the screen */
    transition: transform 0.8s ease-in-out;
}

.page-mascot.show {
    transform: translateY(0);                    /* slide up into view */
}

.page-mascot-mover {
    /* Responsive size: scales with viewport width, clamped for phone/desktop */
    width: clamp(48px, 12vw, 88px);
    will-change: transform;                      /* horizontal position set by JS */
}

/* Flip layer: scaleX set directly by JS (reliable, not via keyframe var) */
.page-mascot-flip {
    transform-origin: center bottom;
}

.page-mascot-flip img {
    display: block;
    width: 100%;
    height: auto;
    transform-origin: bottom center;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
}

/* --- Toolbar --- */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* --- Bulk select --- */
table.dataTable thead th.select-col,
table.dataTable tbody td.select-col {
    width: 44px;
    padding: 12px 8px !important;
    text-align: center;
    vertical-align: middle;
}

.selection-info {
    display: none;
    margin-bottom: 16px;
    padding: 10px 14px;
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-weight: 600;
}

.selection-info.show {
    display: block;
}

.delete-list {
    margin: 12px 0 0;
    padding-left: 24px;
    max-height: 180px;
    overflow-y: auto;
    text-align: left;
    font-size: 0.9rem;
}

.delete-list li {
    margin-bottom: 4px;
}

.delete-list-more {
    list-style: none;
    margin-left: -24px;
    font-style: italic;
    opacity: 0.7;
}

.txn-detail {
    list-style: none;
    margin: 12px 0 0;
    padding: 0;
    text-align: left;
    font-size: 0.9rem;
}

.txn-detail li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}

.txn-detail li span {
    color: var(--text-muted);
}

.txn-detail li strong {
    text-align: right;
    word-break: break-word;
}

.txn-detail-warn {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--warning);
}

.row-check,
.check-all {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
    vertical-align: middle;
}

@media (max-width: 768px) {

    .row-check,
    .check-all {
        width: 22px;
        height: 22px;
        margin: 11px;
    }
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.9rem;
}

/* --- Profile --- */
.profile-photo-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    margin: 0 auto 20px;
}

.profile-photo-wrapper img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
}

.profile-photo-wrapper .photo-overlay {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
    cursor: pointer;
}

.profile-photo-wrapper:hover .photo-overlay {
    opacity: 1;
}

.profile-photo-wrapper .photo-overlay i {
    color: white;
    font-size: 1.5rem;
}

/* --- Dropdown --- */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    min-width: 180px;
    box-shadow: var(--shadow-md);
    display: none;
    z-index: 100;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    transition: var(--transition);
    cursor: pointer;
}

.dropdown-item:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
    }

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

    .main-content {
        margin-left: 0;
    }

    .btn-sidebar-toggle {
        display: block;
    }

    .content-area {
        padding: 16px;
    }

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

    .stat-card {
        padding: 14px;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }

    .stat-info h3 {
        font-size: clamp(0.8rem, 8.5cqi, 1.2rem);
    }

    .toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .toolbar-left,
    .toolbar-right {
        justify-content: flex-start;
    }

    .modal {
        max-width: 100%;
        margin: 0 8px;
    }

    .login-card {
        padding: 28px 20px;
    }

    .user-info {
        display: none;
    }

    .navbar {
        padding: 0 16px;
    }
    
    /* Toolbar Button Optimization for Mobile */
    .toolbar-right .btn {
        padding: 8px 12px;
    }
    .toolbar-right .btn span.btn-text,
    .toolbar-right .btn font-text,
    .toolbar-right .btn text {
       display: none;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .stat-card {
        padding: 12px 8px;
        flex-direction: column;
        text-align: center;
        align-items: center;
        justify-content: center;
    }

    .stat-icon {
        margin-bottom: 8px;
    }
    
    .stat-info p {
        font-size: 0.75rem;
        margin-top: 4px;
        line-height: 1.2;
    }

    /* Force full width on charts wrapper */
    .stats-grid[style*="minmax(360px"] {
        grid-template-columns: 1fr !important;
    }

    .stats-row, .stats-3-col {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px;
    }
    .stats-row .stat-card, .stats-3-col .stat-card {
        padding: 10px 4px;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .stats-row .stat-info, .stats-3-col .stat-info {
        margin-left: 0;
        margin-top: 6px;
    }
    .stats-row .stat-icon, .stats-3-col .stat-icon {
        margin-bottom: 0px;
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    .stats-row .stat-info .stat-label, .stats-3-col .stat-info p {
        font-size: 0.65rem;
        margin-bottom: 2px;
        line-height: 1.1;
    }
    .stats-row .stat-info .stat-value, .stats-3-col .stat-info h3 {
        font-size: clamp(0.7rem, 10cqi, 0.95rem);
    }

    html {
        font-size: 14px;
    }
}

/* --- Utilities --- */
.text-center {
    text-align: center;
}

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

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

.cell-note {
    display: block;
    margin-top: 4px;
    font-size: 0.75rem;
    line-height: 1.4;
    color: var(--text-muted);
}

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

.text-danger {
    color: var(--danger);
}

.text-warning {
    color: var(--warning);
}

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

.mt-1 {
    margin-top: 8px;
}

.mt-2 {
    margin-top: 16px;
}

.mt-3 {
    margin-top: 24px;
}

.mt-4 {
    margin-top: 32px;
}

.mb-1 {
    margin-bottom: 8px;
}

.mb-2 {
    margin-bottom: 16px;
}

.mb-3 {
    margin-bottom: 24px;
}

.mb-4 {
    margin-bottom: 32px;
}

.gap-2 {
    gap: 16px;
}

.d-flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.align-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.w-full {
    width: 100%;
}

.hidden {
    display: none !important;
}
/* Select2 Customization to match theme */
.select2-container .select2-selection--single {
    height: 40px;
    background-color: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--text-primary);
    line-height: normal;
    padding-left: 1rem;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 38px;
    right: 8px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b {
    border-color: var(--text-muted) transparent transparent transparent;
}
.select2-dropdown {
    background-color: var(--bg-card);
    border-color: var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
}
.select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.select2-container--default .select2-results__option {
    color: var(--text-primary);
}
.select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background-color: var(--primary);
    color: white;
}
.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: var(--bg-card-hover);
    color: var(--text-primary);
}

/* Stats Cards */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--bg-card);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 1rem;
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(var(--primary-rgb, 79,70,229), 0.1);
    color: var(--primary);
}
.stat-info .stat-label {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    overflow-wrap: anywhere;
}
.stat-info .stat-value {
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    font-weight: 700;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

@supports (container-type: inline-size) {
    .stat-info .stat-value {
        font-size: clamp(0.8rem, 8.5cqi, 1.25rem);
    }
}
.stat-card.success .stat-icon { background: rgba(16,185,129,0.1); color: var(--success); }
.stat-card.danger .stat-icon { background: rgba(239,68,68,0.1); color: var(--danger); }
.stat-card.info .stat-icon { background: rgba(59,130,246,0.1); color: var(--info); }

/* Split Layout for Savings Book */
.split-layout {
    display: grid;
    grid-template-columns: 350px minmax(0, 1fr);
    gap: 1.5rem;
    align-items: stretch;
}
@media (max-width: 992px) {
    .split-layout {
        grid-template-columns: minmax(0, 1fr);
    }
    .col-left,
    .col-right {
        min-height: auto;
    }
}
.col-left,
.col-right {
    min-width: 0;
}
.col-left {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    min-height: 400px;
}
.col-right {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    min-height: 400px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 350px;
    color: var(--text-muted);
    text-align: center;
}
.empty-state i {
    font-size: 4rem;
    color: #cbd5e1; /* soft gray */
    margin-bottom: 1rem;
}
.empty-state h4 {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

/* Action Button inside DataTables */
.btn-action-view {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: 4px;
}

/* DataTables rendered as a card list (one column, no header) */
.card-list-wrapper {
    border: none;
    overflow: visible;
}
table.card-list.dataTable {
    table-layout: fixed;
    max-width: 100%;
}
table.card-list.dataTable thead {
    display: none;
}
table.card-list.dataTable tbody td {
    padding: 0.3rem 0 !important;
    border-bottom: none !important;
    white-space: normal;
}
table.card-list.dataTable tbody tr:hover {
    background: transparent !important;
}

.student-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 0.875rem;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
}
.student-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}
.student-card.is-active {
    border-color: var(--primary);
    box-shadow: var(--shadow-glow);
}
.student-card-avatar {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(108, 99, 255, 0.12);
    color: var(--primary);
    font-weight: 700;
}
.student-card-info {
    flex: 1 1 0;
    min-width: 0;
}
.student-card-name {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.student-card-nis {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.student-card > .btn {
    flex: 0 0 auto;
    min-height: 44px;
}

.pending-card {
    align-items: flex-start;
}
.pending-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.4rem;
    font-size: 0.85rem;
}
.pending-actions {
    display: flex;
    flex: 0 0 auto;
    gap: 0.4rem;
    min-width: 0;
}
.pending-actions .btn {
    min-height: 44px;
}

@media (max-width: 480px) {
    .pending-actions {
        flex: 1 0 100%;
        margin-top: 0.25rem;
    }
    .pending-actions .btn {
        flex: 1;
        justify-content: center;
    }
}

.col-right .toolbar-left {
    min-width: 0;
}
.col-right .toolbar-left h3 {
    overflow-wrap: anywhere;
}

@media (max-width: 480px) {
    .student-card {
        flex-wrap: wrap;
    }
    .student-card > .btn {
        flex: 1 0 100%;
        justify-content: center;
    }
}
