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

:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --success: #16a34a;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-secondary: #64748b;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #ffffff;
}

body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

.hidden { display: none !important; }

/* Login */
#login-view { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: var(--card); padding: 2.5rem; border-radius: 12px; box-shadow: 0 4px 24px rgba(0,0,0,0.08); width: 380px; }
.login-card h1 { font-size: 1.75rem; margin-bottom: 0.25rem; color: var(--primary); }
.login-card .subtitle { color: var(--text-secondary); margin-bottom: 1.5rem; }

.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.875rem; font-weight: 500; margin-bottom: 0.375rem; color: var(--text-secondary); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%; padding: 0.625rem 0.75rem; border: 1px solid var(--border); border-radius: 6px;
    font-size: 0.9375rem; transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.error-msg { color: var(--danger); font-size: 0.875rem; min-height: 1.25rem; margin-bottom: 0.5rem; }

/* Buttons */
.btn { display: inline-flex; align-items: center; padding: 0.5rem 1rem; border: none; border-radius: 6px; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: background 0.15s; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-sm { padding: 0.25rem 0.625rem; font-size: 0.8125rem; }
.btn-block { width: 100%; justify-content: center; padding: 0.75rem; font-size: 1rem; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }

/* Layout */
#main-view { display: flex; min-height: 100vh; }

.sidebar { width: 220px; background: var(--sidebar-bg); color: var(--sidebar-text); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 1.25rem 1rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.sidebar-header h2 { font-size: 1.25rem; color: white; }
.nav-list { list-style: none; padding: 0.5rem 0; flex: 1; }
.nav-link { display: block; padding: 0.625rem 1rem; color: var(--sidebar-text); text-decoration: none; font-size: 0.9375rem; border-radius: 6px; margin: 0.125rem 0.5rem; }
.nav-link:hover { background: rgba(255,255,255,0.08); color: white; }
.nav-link.active { background: rgba(255,255,255,0.12); color: var(--sidebar-active); font-weight: 500; }
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,0.08); font-size: 0.8125rem; display: flex; justify-content: space-between; align-items: center; }
.sidebar-footer a { color: var(--sidebar-text); text-decoration: none; }
.sidebar-footer a:hover { color: white; }

.content { flex: 1; padding: 1.5rem 2rem; overflow-y: auto; }
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; }
.page-header h2 { font-size: 1.375rem; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.stat-card { background: var(--card); padding: 1.5rem; border-radius: 10px; border: 1px solid var(--border); }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.25rem; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.data-table th { background: var(--bg); padding: 0.75rem 1rem; text-align: left; font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.025em; }
.data-table td { padding: 0.75rem 1rem; border-top: 1px solid var(--border); font-size: 0.875rem; }
.data-table tr:hover td { background: #f8fafc; }
.data-table .actions { display: flex; gap: 0.375rem; flex-wrap: wrap; }

.badge { display: inline-block; padding: 0.125rem 0.5rem; border-radius: 9999px; font-size: 0.75rem; font-weight: 500; }
.badge-admin { background: #dbeafe; color: #1d4ed8; }
.badge-superadmin { background: #fef3c7; color: #92400e; }
.badge-user { background: #f1f5f9; color: #475569; }
.badge-active { background: #dcfce7; color: #15803d; }
.badge-disabled { background: #fee2e2; color: #b91c1c; }
.badge-system { background: #e0e7ff; color: #3730a3; }
.badge-custom { background: #f0fdf4; color: #166534; }

.pagination { display: flex; justify-content: center; gap: 0.25rem; margin-top: 1rem; }
.pagination button { padding: 0.375rem 0.75rem; border: 1px solid var(--border); background: var(--card); border-radius: 4px; cursor: pointer; font-size: 0.8125rem; }
.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.5; cursor: default; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal { background: var(--card); border-radius: 12px; width: 440px; max-width: 90vw; max-height: 85vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,0.15); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 1.125rem; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-secondary); padding: 0 0.25rem; }
.modal-body { padding: 1.25rem; }
.modal-body .form-group:last-of-type { margin-bottom: 1.25rem; }
.modal-body .btn { margin-right: 0.5rem; }
