:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --warning: #d97706;
    --success: #16a34a;
    --bg: #f1f5f9;
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }

/* Layout Shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 250px; background: #0f172a; color: #f8fafc; display: flex; flex-direction: column; flex-shrink: 0; transition: transform .2s; }
.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-logo { width: 40px; height: 40px; object-fit: contain; border-radius: 8px; background: #fff; padding: 2px; }
.brand-badge { width: 40px; height: 40px; border-radius: 8px; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 800; color: #fff; }
.brand-title { font-weight: 700; font-size: 14px; line-height: 1.2; }
.brand-sub { font-size: 12px; color: #94a3b8; }

.nav-menu { padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.nav-menu a { color: #cbd5e1; padding: 10px 14px; border-radius: 8px; font-size: 14px; font-weight: 500; }
.nav-menu a:hover, .nav-menu a.active { background: rgba(37,99,235,.25); color: #fff; }
.nav-menu a.nav-logout { margin-top: 20px; color: #fca5a5; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--card); border-bottom: 1px solid var(--border); padding: 14px 24px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.menu-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 18px; cursor: pointer; }
.topbar-title { font-weight: 700; font-size: 17px; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* Cards & Grids */
.card { background: var(--card); border-radius: 12px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.05); border: 1px solid var(--border); margin-bottom: 20px; }
.card h3 { margin: 0 0 14px; font-size: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-header h3 { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card); border-radius: 12px; padding: 18px; border: 1px solid var(--border); }
.stat-label { font-size: 13px; color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 800; margin-top: 4px; }

.grid-2-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* Forms & Buttons */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #334155; }
input[type="text"], input[type="password"], input[type="url"], input[type="number"], input[type="datetime-local"], input[type="file"], select, .form-control {
    width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 14px; background: #fff;
}
.checkbox-row { display: flex; flex-wrap: wrap; gap: 16px; }
.checkbox-row label { display: flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
.help-text { font-size: 12px; color: var(--muted); display: block; margin-top: 4px; }

.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-bar > * { flex: 1; min-width: 160px; }
.filter-bar button, .filter-bar a { flex: 0 0 auto; }

.btn { display: inline-block; padding: 9px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; border: none; cursor: pointer; text-align: center; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline { background: #fff; color: var(--text); border: 1px solid #cbd5e1; }
.btn-sm { padding: 6px 11px; font-size: 12px; }
.btn-block { width: 100%; }

/* Tables & Badges */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { background: #f8fafc; font-weight: 600; color: #475569; white-space: nowrap; }
.action-cell { white-space: nowrap; }

.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-secondary { background: #e2e8f0; color: #475569; }
.code-pill { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-family: monospace; letter-spacing: 1px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.empty-state { text-align: center; color: var(--muted); padding: 24px; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }

/* Login Page */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 16px; background: linear-gradient(135deg, #1e3a8a, #0f172a); }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 20px 40px rgba(0,0,0,.25); }
.login-header { text-align: center; margin-bottom: 20px; }
.login-logo { height: 68px; object-fit: contain; margin-bottom: 8px; }
.login-logo-placeholder { width: 60px; height: 60px; border-radius: 14px; background: var(--primary); color: #fff; font-size: 24px; font-weight: 800; display: flex; align-items: center; justify-content: center; margin: 0 auto 10px; }
.login-header h1 { margin: 0; font-size: 20px; }
.login-header p { margin: 4px 0 0; font-size: 13px; color: var(--muted); }

/* Student Portal */
.student-portal-body { padding: 20px; }
.portal-container { max-width: 820px; margin: 0 auto; }
.portal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; background: #fff; padding: 16px 20px; border-radius: 12px; border: 1px solid var(--border); }
.brand-inline { display: flex; align-items: center; gap: 12px; }
.brand-inline h2 { margin: 0; font-size: 18px; }
.rules-list { margin: 0; padding-left: 18px; font-size: 14px; color: #334155; }
.rules-list li { margin-bottom: 6px; }
.exam-item-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.exam-start-form { display: flex; gap: 8px; align-items: center; }

/* Exam Room Terkunci */
.exam-room-body { overflow: hidden; height: 100vh; width: 100vw; display: flex; flex-direction: column; background: #000; }
.no-select { -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; }
.exam-topbar { height: 48px; background: #0f172a; color: #fff; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; font-size: 13px; flex-shrink: 0; }
.exam-topbar-left .sep { margin: 0 8px; color: #475569; }
.exam-topbar-right { display: flex; align-items: center; gap: 10px; }
.cbt-iframe { flex: 1; width: 100%; border: none; background: #fff; }

.exam-overlay { position: fixed; inset: 0; background: rgba(15,23,42,.92); display: flex; align-items: center; justify-content: center; z-index: 9999; padding: 16px; }
.exam-overlay.hidden { display: none !important; }
.lock-overlay { background: rgba(127,29,29,.97); }
.overlay-box { background: #fff; color: var(--text); max-width: 440px; width: 100%; border-radius: 14px; padding: 26px; text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.warning-box { border-top: 6px solid var(--warning); }
.lock-box { border-top: 6px solid var(--danger); }

@media (max-width: 820px) {
    .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 1000; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .menu-toggle { display: inline-block; }
    .grid-2-col, .form-grid { grid-template-columns: 1fr; }
    .content { padding: 14px; }
}
