:root {
    --bg-main: #060b14;
    --bg-panel: #111827;
    --bg-card: #161e31;
    --border-color: rgba(255, 255, 255, 0.08);
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --gold: #d4af37;
    
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
}

/* TOPBAR */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1rem 5%; background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 50;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
    width: 38px; height: 38px; background: linear-gradient(135deg, var(--primary), #4f46e5);
    border-radius: 10px; display: flex; justify-content: center; align-items: center;
    font-size: 1.1rem; box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
}
.brand-text { font-size: 1.25rem; font-weight: 700; letter-spacing: 0.5px; }

.btn-logout {
    background: transparent; color: var(--text-muted); border: none;
    font-size: 1.2rem; cursor: pointer; transition: 0.3s; padding: 5px;
}
.btn-logout:hover { color: var(--danger); transform: scale(1.1); }

/* CONTAINER & HEADER */
.container { max-width: 1400px; margin: 0 auto; padding: 2rem 5%; }
.page-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 2rem; flex-wrap: wrap; gap: 15px;
}
.header-titles h1 { font-size: 1.8rem; font-weight: 600; margin-bottom: 4px; }
.header-titles p { color: var(--text-muted); font-size: 0.9rem; }

/* BUTTONS */
.btn-primary {
    background: var(--primary); color: #fff; border: none;
    padding: 12px 24px; border-radius: 10px; font-weight: 500; font-family: inherit;
    cursor: pointer; transition: 0.3s; display: flex; align-items: center; gap: 8px;
}
.btn-primary:hover { background: var(--primary-hover); }
.shadow-glow { box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3); }

.btn-secondary {
    background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color);
    padding: 12px 24px; border-radius: 10px; font-weight: 500; font-family: inherit;
    cursor: pointer; transition: 0.3s; display: flex; justify-content: center; align-items: center; gap: 8px;
}
.btn-secondary:hover { background: rgba(255,255,255,0.05); }

.btn-ghost { background: transparent; color: var(--text-muted); border: none; cursor: pointer; padding: 10px; transition: 0.3s; font-family: inherit; }
.btn-ghost:hover { color: var(--text-main); }
.flex-row-gap { display: flex; gap: 10px; width: 100%; }
.flex-1 { flex: 1; }

/* STATS SCROLLABLE (Kemas Untuk Mobile) */
.stats-scroll-container {
    width: 100%; overflow-x: auto; margin-bottom: 2rem;
    scrollbar-width: none; /* Firefox */
}
.stats-scroll-container::-webkit-scrollbar { display: none; /* Chrome */ }
.stats-wrapper { display: flex; gap: 15px; padding-bottom: 10px; min-width: max-content; }
.stat-box {
    background: var(--bg-card); border: 1px solid var(--border-color);
    padding: 20px; border-radius: 16px; min-width: 160px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
.stat-box p { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px; font-weight: 600; letter-spacing: 0.5px; }
.stat-box h2 { font-size: 2rem; font-weight: 700; }
.box-total { border-bottom: 3px solid var(--primary); }
.box-active { border-bottom: 3px solid var(--success); }
.box-closed { border-bottom: 3px solid var(--warning); }
.box-expired { border-bottom: 3px solid var(--danger); }
.box-disabled { border-bottom: 3px solid var(--text-muted); }

/* TOOLBAR MINIMALIS */
.toolbar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 2rem; flex-wrap: wrap; gap: 15px;
}
.search-box { position: relative; flex-grow: 1; max-width: 450px; }
.search-box i { position: absolute; left: 18px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.search-box input {
    width: 100%; background: var(--bg-card); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 14px 20px 14px 45px; border-radius: 12px;
    font-family: inherit; font-size: 0.95rem; outline: none; transition: 0.3s;
}
.search-box input:focus { border-color: var(--primary); background: var(--bg-panel); }

.filter-group { display: flex; gap: 12px; flex-wrap: wrap; }
.input-minimal {
    background: var(--bg-card); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 14px 20px; border-radius: 12px;
    font-family: inherit; font-size: 0.9rem; outline: none; color-scheme: dark;
    cursor: pointer; transition: 0.3s;
}
.input-minimal:focus { border-color: var(--primary); }

/* CLIENT GRID (MENGGANTIKAN TABLE) */
.client-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px;
}
.client-card {
    background: var(--bg-card); border: 1px solid var(--border-color);
    border-radius: 16px; padding: 24px; display: flex; flex-direction: column;
    transition: transform 0.2s, box-shadow 0.2s;
}
.client-card:hover { transform: translateY(-3px); box-shadow: 0 10px 25px rgba(0,0,0,0.2); border-color: rgba(255,255,255,0.15); }

/* Dalam Kad Klien */
.c-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 20px; }
.c-title { font-size: 1.15rem; font-weight: 600; color: #fff; margin-bottom: 4px; word-break: break-all; }
.c-created { font-size: 0.75rem; color: var(--text-muted); }

.c-body { flex-grow: 1; display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.c-info-row { display: flex; align-items: center; gap: 12px; font-size: 0.85rem; color: var(--text-main); }
.c-icon { width: 30px; height: 30px; border-radius: 8px; background: rgba(255,255,255,0.05); display: flex; justify-content: center; align-items: center; color: var(--text-muted); }

.c-footer { display: flex; justify-content: space-between; align-items: center; padding-top: 15px; border-top: 1px solid var(--border-color); }
.c-actions { display: flex; gap: 10px; }
.action-btn { 
    width: 35px; height: 35px; border-radius: 8px; background: rgba(255,255,255,0.03); 
    border: 1px solid transparent; color: var(--text-muted); cursor: pointer; transition: 0.2s;
    display: flex; justify-content: center; align-items: center;
}
.action-btn.share:hover { color: var(--primary); background: rgba(37, 99, 235, 0.1); border-color: rgba(37, 99, 235, 0.2); }
.action-btn.edit:hover { color: var(--success); background: rgba(16, 185, 129, 0.1); border-color: rgba(16, 185, 129, 0.2); }
.action-btn.delete:hover { color: var(--danger); background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.2); }

/* BADGES */
.badge { padding: 5px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
.badge-active { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-closed { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.badge-expired { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-disabled { background: rgba(148, 163, 184, 0.1); color: var(--text-muted); }

.empty-state { grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: var(--text-muted); background: var(--bg-card); border-radius: 16px; border: 1px dashed var(--border-color); }

/* MODALS */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.8); backdrop-filter: blur(5px);
    display: flex; justify-content: center; align-items: center; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal-content {
    background: var(--bg-panel); border: 1px solid var(--border-color);
    width: 90%; max-width: 550px; border-radius: 16px; overflow: hidden;
    transform: scale(1); transition: transform 0.2s; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
.modal-overlay.hidden .modal-content { transform: scale(0.95); }
.modal-sm { max-width: 380px; }
.modal-header { padding: 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 1.25rem; font-weight: 600; }
.close-btn { background: rgba(255,255,255,0.05); width: 32px; height: 32px; border-radius: 50%; border: none; color: var(--text-muted); cursor: pointer; transition: 0.2s; }
.close-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.modal-body { padding: 24px; }
.form-row { display: flex; gap: 15px; margin-bottom: 16px; }
.form-group { flex: 1; margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; font-weight: 500; }
.input-field {
    width: 100%; background: var(--bg-card); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 12px 16px; border-radius: 10px;
    font-family: inherit; font-size: 0.95rem; outline: none; color-scheme: dark; transition: 0.3s;
}
.input-field:focus { border-color: var(--primary); }
.modal-footer { display: flex; justify-content: flex-end; gap: 12px; margin-top: 24px; }

/* QR SECTION */
.qr-wrapper { background: #fff; padding: 20px; border-radius: 16px; display: inline-block; margin-bottom: 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.qr-wrapper img { width: 220px; height: 220px; display: block; }

/* TOAST */
.toast-container { position: fixed; top: 90px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
    padding: 16px 24px; border-radius: 12px; font-size: 0.9rem; font-weight: 500;
    display: flex; align-items: center; gap: 12px; box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    animation: slideIn 0.3s forwards;
}
.toast.success { background: #064e3b; border: 1px solid #059669; color: #d1fae5; }
.toast.error { background: #7f1d1d; border: 1px solid #dc2626; color: #fee2e2; }
.toast.fade-out { animation: slideOut 0.3s forwards; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(100%); opacity: 0; } }

/* RESPONSIVE */
@media (max-width: 768px) {
    .form-row { flex-direction: column; gap: 0; }
    .toolbar { flex-direction: column; align-items: stretch; }
    .filter-group { flex-direction: column; }
    .search-box { max-width: 100%; }
}
