/* ═══════════════════════════════
   FONT
═══════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;450;500;600;700&display=swap');

/* ═══════════════════════════════
   VARIABLES
═══════════════════════════════ */
:root {
  --bg:       #f4f5f7;
  --bg2:      #ffffff;
  --bg3:      #eef0f4;
  --border:   #e7e9ee;
  --border2:  #d3d7df;
  --text:     #131720;
  --text2:    #4b5563;
  --text3:    #8b93a1;

  --blue:      #2563eb;
  --blue-bg:   #eef4ff;
  --blue-text: #1d4ed8;

  --green:      #16a34a;
  --green-bg:   #ecfdf3;
  --green-text: #15803d;

  --red:      #dc2626;
  --red-bg:   #fef2f2;
  --red-text: #b91c1c;

  --amber:      #d97706;
  --amber-bg:   #fffbeb;
  --amber-text: #b45309;

  --purple:      #7c3aed;
  --purple-bg:   #f5f3ff;
  --purple-text: #6d28d9;

  --radius-sm: 7px;
  --radius:    10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(16,24,40,0.05);
  --shadow:    0 1px 3px rgba(16,24,40,0.07), 0 1px 2px rgba(16,24,40,0.04);
  --shadow-md: 0 6px 18px rgba(16,24,40,0.08);
  --shadow-lg: 0 16px 40px rgba(16,24,40,0.14);
  --ring:      0 0 0 3px rgba(37,99,235,0.15);

  --grad-blue: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
}

/* ═══════════════════════════════
   RESET
═══════════════════════════════ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font-family: inherit; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text3); background-clip: content-box; }

/* ═══════════════════════════════
   LAYOUT
═══════════════════════════════ */
.app    { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 232px; background: var(--bg2); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.main   { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { background: rgba(255,255,255,0.85); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--border); padding: 0 26px; height: 60px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.content { flex: 1; overflow-y: auto; padding: 26px; }

/* ═══════════════════════════════
   SIDEBAR
═══════════════════════════════ */
.sidebar-logo  { padding: 18px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 11px; }
.logo-mark     { width: 34px; height: 34px; background: var(--grad-blue); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 15px; box-shadow: 0 4px 10px rgba(37,99,235,0.3); }
.logo-text     { font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.nav-group     { padding: 10px; }
.nav-label     { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .07em; padding: 10px 8px 5px; }
.nav-item      { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: var(--radius-sm); color: var(--text2); cursor: pointer; font-size: 13px; font-weight: 500; transition: background .15s, color .15s; }
.nav-item:hover  { background: var(--bg3); color: var(--text); }
.nav-item.active { background: var(--blue-bg); color: var(--blue-text); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: -10px; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--blue); }
.nav-item i    { font-size: 18px; flex-shrink: 0; }
.sidebar-footer { margin-top: auto; padding: 12px 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; }

/* ═══════════════════════════════
   TOPBAR
═══════════════════════════════ */
.page-title  { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.avatar      { width: 34px; height: 34px; border-radius: 50%; background: var(--grad-blue); color: white; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; box-shadow: 0 2px 6px rgba(37,99,235,0.25); cursor: default; }
.notif       { width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text2); position: relative; transition: all .15s; }
.notif:hover { background: var(--bg3); color: var(--text); }
.notif-dot   { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; background: var(--red); border-radius: 50%; border: 2px solid white; }

/* ═══════════════════════════════
   STATS
═══════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat-card  { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .18s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-label { font-size: 12px; font-weight: 500; color: var(--text3); margin-bottom: 8px; }
.stat-val   { font-size: 30px; font-weight: 700; color: var(--text); letter-spacing: -0.02em; line-height: 1.1; }
.stat-sub   { font-size: 12px; font-weight: 500; color: var(--green); margin-top: 6px; }
.stat-sub.warn { color: var(--amber); }

/* ═══════════════════════════════
   CARD & TABLE
═══════════════════════════════ */
.card        { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 20px; box-shadow: var(--shadow); }
.card-header { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card-title  { font-size: 14px; font-weight: 600; }
.table       { width: 100%; border-collapse: collapse; }
.table th    { padding: 10px 14px; text-align: left; font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: .05em; background: var(--bg3); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td    { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; color: var(--text2); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover td { background: var(--bg3); }
.table td .name { color: var(--text); font-weight: 600; }

/* ═══════════════════════════════
   BADGES
═══════════════════════════════ */
.badge        { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--bg3); color: var(--text2); white-space: nowrap; }
.badge-green  { background: var(--green-bg);  color: var(--green-text); }
.badge-red    { background: var(--red-bg);    color: var(--red-text); }
.badge-amber  { background: var(--amber-bg);  color: var(--amber-text); }
.badge-blue   { background: var(--blue-bg);   color: var(--blue-text); }
.badge-purple { background: var(--purple-bg); color: var(--purple-text); }

/* ═══════════════════════════════
   BUTTONS
═══════════════════════════════ */
.btn         { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 15px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: background .15s, box-shadow .15s, transform .08s, color .15s; white-space: nowrap; }
.btn:active  { transform: translateY(1px); }
.btn-primary { background: var(--grad-blue); color: white; box-shadow: 0 2px 6px rgba(37,99,235,0.28); }
.btn-primary:hover { box-shadow: 0 4px 12px rgba(37,99,235,0.36); filter: brightness(1.04); }
.btn-outline { background: var(--bg2); color: var(--text2); border: 1px solid var(--border2); }
.btn-outline:hover { background: var(--bg3); color: var(--text); border-color: var(--border2); }
.btn-danger  { background: var(--red-bg); color: var(--red-text); border: 1px solid #fecaca; }
.btn-danger:hover { background: #fde3e3; }
.btn-sm      { padding: 5px 11px; font-size: 12px; }
.btn-icon    { width: 32px; height: 32px; padding: 0; border-radius: var(--radius-sm); display: inline-flex; align-items: center; justify-content: center; background: var(--bg2); border: 1px solid var(--border); cursor: pointer; color: var(--text2); transition: all .15s; }
.btn-icon:hover        { background: var(--bg3); color: var(--text); }
.btn-icon.danger:hover { background: var(--red-bg); color: var(--red); border-color: #fecaca; }

/* ═══════════════════════════════
   FORMS
═══════════════════════════════ */
.form-group    { margin-bottom: 16px; }
.form-label    { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
.form-input    { width: 100%; padding: 9px 12px; border: 1px solid var(--border2); border-radius: var(--radius-sm); font-size: 13px; color: var(--text); background: var(--bg2); transition: border-color .15s, box-shadow .15s; outline: none; }
.form-input::placeholder { color: var(--text3); }
.form-input:hover { border-color: var(--text3); }
.form-input:focus { border-color: var(--blue); box-shadow: var(--ring); }
.form-textarea { resize: vertical; min-height: 76px; }
.form-row      { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-hint     { font-size: 11px; color: var(--text3); margin-top: 4px; }
.required      { color: var(--red); }
select.form-input { cursor: pointer; }

/* ═══════════════════════════════
   DEPARTMENT CARDS
═══════════════════════════════ */
.dept-grid        { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px,1fr)); gap: 16px; margin-bottom: 20px; }
.dept-card        { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.dept-card[onclick]:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--border2); }
.dept-card-header { padding: 15px 16px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.dept-info        { display: flex; align-items: center; gap: 12px; }
.dept-icon        { width: 38px; height: 38px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; font-size: 18px; }
.dept-name        { font-weight: 600; font-size: 14px; }
.dept-desc        { font-size: 12px; color: var(--text3); margin-top: 1px; }
.subdept-row      { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.subdept-row:last-child { border-bottom: none; }
.subdept-name     { font-weight: 500; color: var(--text); }
.subdept-meta     { font-size: 12px; color: var(--text3); }
.link-row         { background: var(--bg3); padding: 8px 14px; display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--blue-text); font-family: monospace; border-top: 1px solid var(--border); }

/* ═══════════════════════════════
   MODAL
═══════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(17,24,39,0.45); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px; animation: overlay-in .18s ease; }
.modal         { background: var(--bg2); border-radius: var(--radius-lg); width: 100%; max-width: 540px; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: modal-in .2s cubic-bezier(.16,.84,.44,1); }
.modal-header  { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title   { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.modal-body    { padding: 22px; }
.modal-footer  { padding: 15px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
@keyframes overlay-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ═══════════════════════════════
   AUTH PAGES (login / reset / disabled)
═══════════════════════════════ */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #e7efff 0%, var(--bg) 55%); }
.auth-card { background: var(--bg2); padding: 34px 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 380px; border: 1px solid var(--border); }
.auth-logo { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 22px; }
.auth-title { font-size: 19px; font-weight: 700; text-align: center; letter-spacing: -0.01em; }
.auth-sub { font-size: 13px; color: var(--text3); text-align: center; margin-top: 4px; }

/* ═══════════════════════════════
   CANDIDATE VIEW
═══════════════════════════════ */
.candidate-wrap        { min-height: 100vh; background: radial-gradient(1200px 600px at 50% -10%, #e7efff 0%, var(--bg) 55%); display: flex; flex-direction: column; }
.candidate-nav         { background: rgba(255,255,255,0.85); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--border); padding: 0 32px; height: 60px; display: flex; align-items: center; justify-content: space-between; }
.candidate-body        { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 44px 20px; }
.candidate-card        { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 680px; box-shadow: var(--shadow-md); }
.candidate-card-header { padding: 22px 28px; border-bottom: 1px solid var(--border); }
.candidate-card-body   { padding: 28px; }

/* ── Progress ── */
.progress-wrap { margin-bottom: 22px; }
.progress-info { display: flex; justify-content: space-between; font-size: 12px; font-weight: 500; color: var(--text3); margin-bottom: 7px; }
.progress-bar  { height: 7px; background: var(--bg3); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--grad-blue); border-radius: 99px; transition: width .35s cubic-bezier(.16,.84,.44,1); }

/* ── Options ── */
.question-text { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 22px; line-height: 1.4; letter-spacing: -0.01em; }
.option        { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border: 1.5px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; cursor: pointer; transition: border-color .15s, background .15s, transform .08s; }
.option:hover  { border-color: var(--blue); background: var(--blue-bg); }
.option:active { transform: scale(.995); }
.option.selected { border-color: var(--blue); background: var(--blue-bg); box-shadow: var(--ring); }
.option-dot    { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border2); flex-shrink: 0; transition: all .15s; position: relative; }
.option.selected .option-dot { border-color: var(--blue); background: var(--blue); }
.option.selected .option-dot::after { content: ''; position: absolute; inset: 4px; background: #fff; border-radius: 50%; }
.option-text   { font-size: 14px; color: var(--text); }
.option.correct { border-color: var(--green); background: var(--green-bg); }
.option.wrong   { border-color: var(--red);   background: var(--red-bg); }
.option.correct .option-dot { border-color: var(--green); background: var(--green); }
.option.wrong   .option-dot { border-color: var(--red);   background: var(--red); }
.nav-btns { display: flex; justify-content: space-between; align-items: center; margin-top: 26px; }

/* ── Timer ── */
.timer-pill       { display: flex; align-items: center; gap: 6px; background: var(--amber-bg); color: var(--amber-text); border-radius: 99px; padding: 6px 13px; font-size: 13px; font-weight: 600; }
.timer-pill.urgent { background: var(--red-bg); color: var(--red-text); animation: pulse .8s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.55} }

/* ── Result ── */
.result-wrap  { text-align: center; padding: 44px 28px; }
.result-icon  { width: 76px; height: 76px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 34px; margin: 0 auto 20px; }
.result-icon.pass { background: var(--green-bg); color: var(--green); }
.result-icon.fail { background: var(--red-bg);   color: var(--red); }
.result-title { font-size: 23px; font-weight: 700; margin-bottom: 8px; letter-spacing: -0.01em; }
.result-sub   { font-size: 14px; color: var(--text2); margin-bottom: 28px; }
.score-circle { width: 92px; height: 92px; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; margin: 0 auto 24px; border: 3px solid; }
.score-circle.pass { border-color: var(--green); background: var(--green-bg); color: var(--green); }
.score-circle.fail { border-color: var(--red);   background: var(--red-bg);   color: var(--red); }
.score-num    { font-size: 25px; font-weight: 700; }
.score-label  { font-size: 11px; font-weight: 600; letter-spacing: .05em; }
.calendar-slots { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-top: 16px; }
.slot         { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 11px; text-align: center; cursor: pointer; transition: all .15s; font-size: 12px; }
.slot:hover, .slot.picked { border-color: var(--green); background: var(--green-bg); color: var(--green-text); }
.slot-day     { font-weight: 600; font-size: 13px; }

/* ── Question editor ── */
.question-editor        { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; background: var(--bg3); }
.question-editor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.option-editor  { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.option-radio   { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--border2); flex-shrink: 0; cursor: pointer; transition: all .15s; }
.option-radio.is-correct { border-color: var(--green); background: var(--green); box-shadow: inset 0 0 0 3px #fff; }
.option-input   { flex: 1; padding: 7px 11px; border: 1px solid var(--border2); border-radius: var(--radius-sm); font-size: 13px; outline: none; background: var(--bg2); transition: border-color .15s, box-shadow .15s; }
.option-input:focus { border-color: var(--blue); box-shadow: var(--ring); }

/* ── Misc ── */
.divider     { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.hidden      { display: none !important; }
.empty-state { text-align: center; padding: 44px; color: var(--text3); }
.empty-state i { font-size: 38px; margin-bottom: 8px; display: block; }

/* ── Pagination ── */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.pager-info { font-size: 12px; color: var(--text3); }
.pager-btns { display: flex; align-items: center; gap: 10px; }
.pager-page { font-size: 12px; font-weight: 600; color: var(--text2); min-width: 90px; text-align: center; }
.pager .btn[disabled] { opacity: .45; cursor: default; pointer-events: none; }

/* ── Toasts ── */
.toast-container {
  position: fixed; top: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  min-width: 260px; max-width: 380px;
  background: var(--bg2); color: var(--text);
  border: 1px solid var(--border); border-left: 4px solid var(--text3);
  border-radius: var(--radius); padding: 13px 15px;
  box-shadow: var(--shadow-lg);
  font-size: 13px; line-height: 1.45;
  opacity: 0; transform: translateX(20px);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: auto; cursor: pointer;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast i { font-size: 19px; flex-shrink: 0; margin-top: 1px; }
.toast-success { border-left-color: var(--green); }
.toast-success i { color: var(--green); }
.toast-error   { border-left-color: var(--red); }
.toast-error i { color: var(--red); }
.toast-info    { border-left-color: var(--blue); }
.toast-info i { color: var(--blue); }

/* ── Status pill (active / inactive toggle) ── */
.status-pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid transparent; font-family: inherit;
  transition: filter .15s ease, box-shadow .15s ease, transform .08s ease;
}
button.status-pill { cursor: pointer; }
button.status-pill:hover { filter: brightness(0.97); box-shadow: var(--shadow-sm); }
button.status-pill:active { transform: translateY(1px); }
.status-pill::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor;
}
.status-pill.is-active   { background: var(--green-bg); color: var(--green-text); border-color: #bbf7d0; }
.status-pill.is-inactive { background: var(--red-bg);   color: var(--red-text);   border-color: #fecaca; }

/* ── Confirm dialog (animated) ── */
.confirm-overlay { opacity: 0; transition: opacity .18s ease; }
.confirm-overlay.show { opacity: 1; }
.confirm-modal {
  max-width: 420px;
  transform: scale(.94) translateY(8px);
  transition: transform .18s ease;
  animation: none;
}
.confirm-overlay.show .confirm-modal { transform: scale(1) translateY(0); }
.confirm-icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.confirm-icon.danger { background: var(--red-bg); color: var(--red-text); }
.confirm-icon.primary { background: var(--blue-bg); color: var(--blue-text); }
