/* ─── VARIABLES ──────────────────────────────────────────────────────────── */
:root {
  --navy:    #1F3864;
  --blue:    #2E75B6;
  --lblue:   #D6E4F0;
  --teal:    #1A6B7A;
  --green:   #375623;
  --amber:   #7F6000;
  --red:     #C00000;
  --orange:  #C55A11;
  --bg:      #F0F4F8;
  --card:    #FFFFFF;
  --border:  #D8E4F0;
  --text:    #1A2B3C;
  --muted:   #5A7090;
  --nav-h:   60px;
  --side-w:  240px;
  --radius:  10px;
  --shadow:  0 2px 12px rgba(31,56,100,.10);
  --shadow-lg: 0 4px 24px rgba(31,56,100,.16);
}

/* ─── RESET ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: 'Segoe UI', Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
ul { list-style: none; }

/* ─── LOGIN ──────────────────────────────────────────────────────────────── */
#login-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1F3864 0%, #2E75B6 60%, #1A6B7A 100%);
  padding: 20px;
}
.login-card {
  background: #fff; border-radius: 16px; padding: 40px 44px; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-header { display: flex; align-items: center; gap: 16px; margin-bottom: 32px; }
.logo-ring {
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--navy); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; letter-spacing: 1px; flex-shrink: 0;
}
.login-institution { font-weight: 700; font-size: 15px; color: var(--navy); }
.login-system { font-size: 13px; color: var(--blue); font-weight: 600; }
.login-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.login-footer { text-align: center; margin-top: 24px; font-size: 12px; color: var(--muted); line-height: 1.8; }
.auth-tabs { display: flex; border-bottom: 2px solid #e0e8f0; margin-bottom: 22px; gap: 0; }
.auth-tab {
  flex: 1; padding: 10px; background: none; border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s;
}
.auth-tab:hover { color: var(--blue); }
.auth-tab.active { color: var(--navy); border-bottom-color: var(--navy); }
.login-card .form-group label { color: var(--navy); }
.login-card .form-group input,
.login-card .form-group select { background: #f7fafd; }

/* ─── TOPNAV ─────────────────────────────────────────────────────────────── */
#topnav {
  position: fixed; top: 0; left: 0; right: 0; height: var(--nav-h);
  background: var(--navy); color: #fff; display: flex; align-items: center;
  justify-content: space-between; padding: 0 20px; z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.nav-left, .nav-right { display: flex; align-items: center; gap: 12px; }
.nav-brand { display: flex; flex-direction: column; line-height: 1.2; }
.nav-brand-rec { font-size: 15px; font-weight: 800; letter-spacing: 2px; color: #fff; }
.nav-brand-sys { font-size: 11px; color: #93b4d4; letter-spacing: 1px; }
.icon-btn {
  background: none; border: none; color: #fff; cursor: pointer; font-size: 18px;
  width: 36px; height: 36px; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.icon-btn:hover { background: rgba(255,255,255,.12); }
.user-info { text-align: right; }
#nav-user-name { font-size: 13px; font-weight: 600; color: #fff; }
.role-badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 10px;
  font-weight: 700; letter-spacing: 1px; text-transform: uppercase; margin-top: 2px;
}
.role-badge.admin      { background: #FFD700; color: #1F3864; }
.role-badge.rep        { background: #2E75B6; color: #fff; }
.role-badge.researcher { background: #375623; color: #fff; }
.btn-outline-sm {
  background: none; border: 1px solid rgba(255,255,255,.4); color: #fff; padding: 6px 14px;
  border-radius: 6px; cursor: pointer; font-size: 12px; transition: all .15s;
}
.btn-outline-sm:hover { background: rgba(255,255,255,.12); }

/* ─── NOTIFICATIONS ──────────────────────────────────────────────────────── */
.notif-wrap { position: relative; }
.badge {
  position: absolute; top: 2px; right: 2px; background: #ff4444; color: #fff;
  border-radius: 10px; min-width: 16px; height: 16px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.notif-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); width: 340px; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 200;
}
.notif-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.link-btn { background: none; border: none; color: var(--blue); cursor: pointer; font-size: 12px; }
.notif-item {
  padding: 12px 16px; border-bottom: 1px solid #f0f4f8; cursor: pointer; transition: background .1s;
}
.notif-item:hover { background: var(--lblue); }
.notif-item.unread { background: #EEF4FB; }
.notif-item-title { font-weight: 600; font-size: 13px; margin-bottom: 2px; }
.notif-item-msg { font-size: 12px; color: var(--muted); line-height: 1.4; }
.notif-item-time { font-size: 11px; color: #aaa; margin-top: 4px; }
.notif-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

/* ─── LAYOUT ─────────────────────────────────────────────────────────────── */
#layout { display: flex; margin-top: var(--nav-h); min-height: calc(100vh - var(--nav-h)); }
#sidebar {
  width: var(--side-w); background: #fff; border-right: 1px solid var(--border);
  position: fixed; top: var(--nav-h); bottom: 0; left: 0; overflow-y: auto; z-index: 50;
  transition: transform .25s;
}
#sidenav { padding: 16px 0; }
.side-section { padding: 8px 20px 4px; font-size: 10px; font-weight: 700; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted); }
.side-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 20px;
  color: var(--text); cursor: pointer; border-radius: 0; transition: all .15s;
  border-left: 3px solid transparent; font-size: 14px;
}
.side-item:hover { background: var(--lblue); color: var(--blue); }
.side-item.active { background: var(--lblue); color: var(--navy); font-weight: 600; border-left-color: var(--navy); }
.side-icon { font-size: 16px; width: 20px; text-align: center; }
#content { margin-left: var(--side-w); flex: 1; padding: 28px; max-width: 1400px; }

/* ─── CARDS & PANELS ─────────────────────────────────────────────────────── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--navy); }
.card-body { padding: 20px; }

.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 800; color: var(--navy); }
.page-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ─── STAT CARDS ─────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: #fff; border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); border-top: 3px solid var(--blue); }
.stat-card.navy   { border-top-color: var(--navy); }
.stat-card.green  { border-top-color: var(--green); }
.stat-card.amber  { border-top-color: var(--amber); }
.stat-card.red    { border-top-color: var(--red); }
.stat-card.teal   { border-top-color: var(--teal); }
.stat-card.orange { border-top-color: var(--orange); }
.stat-val { font-size: 32px; font-weight: 800; color: var(--navy); line-height: 1; }
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }

/* ─── TABLES ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: #F0F4F8; color: var(--navy); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; padding: 12px 14px; text-align: left; }
td { padding: 12px 14px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
tr:hover td { background: #FAFCFF; }
.ref-no { font-family: 'Courier New', monospace; font-size: 12px; font-weight: 700; color: var(--navy); background: var(--lblue); padding: 3px 7px; border-radius: 4px; white-space: nowrap; }

/* ─── STATUS BADGES ──────────────────────────────────────────────────────── */
.status { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; white-space: nowrap; }
.status-pending       { background: #FFF3CD; color: #7F4500; }
.status-under_review  { background: #D6E4F0; color: #1F3864; }
.status-resubmitted   { background: #E0D6F0; color: #4A235A; }
.status-approved      { background: #D6E8D0; color: #375623; }
.status-rejected      { background: #FDDEDE; color: #C00000; }
.status-deferred      { background: #FFF2CC; color: #7F6000; }

/* ─── BUTTONS ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 7px; border: none; cursor: pointer; font-weight: 600; font-size: 13px; transition: all .15s; }
.btn-primary    { background: var(--navy); color: #fff; }
.btn-primary:hover { background: #152b52; }
.btn-blue       { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #255f99; }
.btn-green      { background: var(--green); color: #fff; }
.btn-green:hover { background: #2a4119; }
.btn-red        { background: var(--red); color: #fff; }
.btn-red:hover  { background: #a00000; }
.btn-amber      { background: var(--amber); color: #fff; }
.btn-amber:hover { background: #614a00; }
.btn-outline    { background: #fff; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--lblue); border-color: var(--blue); color: var(--blue); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ─── FORMS ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--navy); }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 7px;
  background: #fff; color: var(--text); outline: none; transition: border .15s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--blue); }
.form-group textarea { min-height: 100px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ─── FILE UPLOAD ZONE ───────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px;
  text-align: center; cursor: pointer; transition: all .2s; background: #FAFCFF;
}
.upload-zone:hover, .upload-zone.dragover { border-color: var(--blue); background: var(--lblue); }
.upload-zone-icon { font-size: 36px; margin-bottom: 8px; }
.upload-zone-text { font-size: 14px; color: var(--muted); }
.upload-zone-text strong { color: var(--blue); }
.file-list { margin-top: 12px; }
.file-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; background: #fff;
  border: 1px solid var(--border); border-radius: 6px; margin-top: 6px; }
.file-item-name { flex: 1; font-size: 13px; font-weight: 500; }
.file-item-size { font-size: 12px; color: var(--muted); }
.file-remove { background: none; border: none; color: var(--red); cursor: pointer; font-size: 16px; padding: 0 4px; }

/* ─── ALERTS ─────────────────────────────────────────────────────────────── */
.alert { padding: 11px 14px; border-radius: 7px; font-size: 13px; margin-bottom: 14px; }
.alert-danger  { background: #FDDEDE; color: var(--red); border: 1px solid #f5b8b8; }
.alert-success { background: #D6E8D0; color: var(--green); border: 1px solid #b3d4a8; }
.alert-info    { background: var(--lblue); color: var(--navy); border: 1px solid #b0c8e0; }
.alert-warning { background: #FFF2CC; color: var(--amber); border: 1px solid #ffe08a; }

/* ─── DETAIL VIEW ────────────────────────────────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.detail-section { background: #fff; border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.detail-section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; }
.dl dt { font-weight: 600; color: var(--navy); font-size: 13px; }
.dl dd { color: var(--text); font-size: 13px; }

/* ─── REVIEW HISTORY ─────────────────────────────────────────────────────── */
.review-card { border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.review-card.approved { background: #D6E8D0; border-left: 4px solid var(--green); }
.review-card.rejected { background: #FDDEDE; border-left: 4px solid var(--red); }
.review-card.deferred { background: #FFF2CC; border-left: 4px solid var(--amber); }
.review-decision { font-weight: 700; font-size: 13px; text-transform: uppercase; letter-spacing: .5px; }
.review-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.review-comments { margin-top: 10px; font-size: 13px; line-height: 1.6; padding: 10px 12px; background: rgba(255,255,255,.7); border-radius: 6px; }

/* ─── FILE CHIPS ─────────────────────────────────────────────────────────── */
.file-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px;
  background: var(--lblue); border-radius: 20px; font-size: 12px; color: var(--navy);
  text-decoration: none; margin: 3px; font-weight: 500; border: 1px solid #b0cce0;
  cursor: pointer; transition: background .15s;
}
.file-chip:hover { background: #c2d9ef; text-decoration: none; }

/* ─── REP MULTI-SELECT ───────────────────────────────────────────────────── */
.rep-checkbox-list { display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow-y: auto; border: 1.5px solid var(--border); border-radius: 7px; padding: 10px 12px; background: #fafcff; }
.rep-checkbox-label { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; transition: background .12s; }
.rep-checkbox-label:hover { background: var(--lblue); }
.rep-checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--navy); flex-shrink: 0; cursor: pointer; }
.rep-checkbox-info { display: flex; flex-direction: column; }
.rep-checkbox-name { font-weight: 600; font-size: 13px; color: var(--navy); }
.rep-checkbox-dept { font-size: 11px; color: var(--muted); }
.rep-tag { display: inline-block; background: var(--lblue); color: var(--navy); font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 20px; margin: 2px 2px 2px 0; }

/* ─── MODAL ──────────────────────────────────────────────────────────────── */
#modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 500;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
#modal-box { background: #fff; border-radius: 12px; width: 100%; max-width: 680px; max-height: 90vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
#modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--border); }
#modal-title { font-size: 16px; font-weight: 700; color: var(--navy); }
#modal-header .icon-btn { color: var(--muted); }
#modal-body { padding: 22px; overflow-y: auto; }

/* ─── TOAST ──────────────────────────────────────────────────────────────── */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 13px 18px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 600; min-width: 260px; animation: slideIn .25s ease; display: flex; gap: 10px; align-items: flex-start; }
.toast.success { background: var(--green); color: #fff; }
.toast.error   { background: var(--red); color: #fff; }
.toast.info    { background: var(--navy); color: #fff; }
@keyframes slideIn { from { transform: translateX(50px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ─── SEARCH / FILTER ────────────────────────────────────────────────────── */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-bar input, .filter-bar select { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 7px; background: #fff; outline: none; }
.filter-bar input:focus, .filter-bar select:focus { border-color: var(--blue); }
.filter-bar input { flex: 1; min-width: 200px; }

/* ─── EMPTY STATE ────────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-title { font-size: 16px; font-weight: 600; margin-bottom: 6px; }
.empty-state-sub { font-size: 13px; }

/* ─── SECTION DIVIDER ────────────────────────────────────────────────────── */
.section-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); margin: 20px 0 12px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

/* ─── ARCHIVE CARDS ──────────────────────────────────────────────────────── */
.archive-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden; border-left: 4px solid var(--blue); }
.archive-card.is-archived { border-left-color: #aaa; opacity: .85; }
.archive-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 20px; flex-wrap: wrap; }
.archive-year { font-size: 17px; font-weight: 800; color: var(--navy); margin-bottom: 4px; }
.archive-meta { font-size: 12px; color: var(--muted); }
.is-archived .archive-year { color: #888; }

/* ─── SETTINGS EDITOR ────────────────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 24px; }
.settings-section { background: #f7fafd; border-radius: var(--radius); padding: 18px 20px; border: 1.5px solid var(--border); }
.settings-section-title { font-size: 13px; font-weight: 700; color: var(--navy); margin-bottom: 12px; }
.settings-list { display: flex; flex-direction: column; gap: 6px; min-height: 40px; margin-bottom: 12px; max-height: 260px; overflow-y: auto; }
.settings-item { display: flex; align-items: center; justify-content: space-between; background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; font-size: 13px; }
.settings-item-text { flex: 1; }
.settings-del-btn { flex-shrink: 0; background: none; border: none; cursor: pointer; }
.settings-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 10px 0; }
.settings-add-row { display: flex; gap: 8px; }
.settings-input { flex: 1; padding: 8px 10px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13px; background: #fff; outline: none; }
.settings-input:focus { border-color: var(--blue); }

/* ─── UNIFIED REGISTRATION FIELD ROWS ───────────────────────────────────── */
.rf-item { border: 1px solid #e2eaf4; border-radius: 10px; margin-bottom: 8px; overflow: hidden; background: #fff; }
.rf-item-custom { border-color: #c5dfc5; }
.rf-row { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; background: #fff; }
.rf-item-custom .rf-row { background: #f7fbf7; }
.rf-lbl-input { flex: 1; min-width: 120px; height: 34px; font-size: 13px; padding: 6px 10px; border: 1.5px solid var(--border); border-radius: 7px; }
.rf-lbl-input:focus { border-color: var(--blue); outline: none; }
.rf-sel { height: 34px; font-size: 12px; border: 1.5px solid var(--border); border-radius: 7px; padding: 0 8px; background: #fff; cursor: pointer; }
.rf-sel:focus { border-color: var(--blue); outline: none; }
.rf-type-fixed { font-size: 12px; color: var(--muted); padding: 0 4px; white-space: nowrap; }
.rf-toggle-lbl { display: flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.rf-show-txt, .rf-req-txt { font-size: 11px; color: var(--muted); }
.rf-req-lbl { display: flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.rf-label-cell { flex: 1; min-width: 130px; }
.rf-type-cell { flex-shrink: 0; }
.rf-badge-builtin { font-size: 10px; background: #e8f0fe; color: #2E75B6; padding: 2px 8px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }
.rf-badge-custom  { font-size: 10px; background: #e0f3e0; color: #375623; padding: 2px 8px; border-radius: 10px; white-space: nowrap; flex-shrink: 0; }
.rf-opts-panel { padding: 0 14px 12px; border-top: 1px dashed #e2eaf4; background: #f8fafc; }
.rf-item-custom .rf-opts-panel,
.rf-item-custom .rf-ph-panel,
.rf-item-custom .rf-cf-opts-panel { background: #f0f7f0; border-top-color: #c5dfc5; }
.rf-ph-panel { padding: 0 14px 10px; background: #f8fafc; border-top: 1px dashed #e2eaf4; }
.rf-cf-opts-panel { padding: 0 14px 12px; background: #f0f7f0; border-top: 1px dashed #c5dfc5; }
.rf-opts-hdr { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; padding: 10px 0 6px; }
.rf-opts-list { max-height: 180px; overflow-y: auto; margin-bottom: 8px; }
.rf-opts-add { display: flex; gap: 8px; }

/* ─── ACTIVITY TIMELINE ──────────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid #eef2f7; }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 32px; height: 32px; border-radius: 50%; background: var(--lblue); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; margin-top: 2px; }
.timeline-body { flex: 1; }
.timeline-action { font-weight: 700; font-size: 13px; color: var(--navy); }
.timeline-actor { font-size: 12px; color: var(--blue); }
.timeline-details { font-size: 12px; color: var(--text); margin-top: 3px; line-height: 1.5; }
.timeline-time { font-size: 11px; color: #aaa; margin-top: 4px; }

/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE LAYOUT
   Desktop (>768px) : sidebar always pinned, toggle button hidden
   Mobile  (≤768px) : sidebar is a slide-over drawer, toggle shows it
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Desktop baseline ────────────────────────────────────────────────────── */
/* Hide the hamburger on desktop — sidebar is always visible */
#sidebar-toggle { display: none; }

/* ── Tablet (769px – 1100px) ─────────────────────────────────────────────── */
@media (max-width: 1100px) and (min-width: 769px) {
  :root { --side-w: 200px; }
  #content { padding: 20px 18px; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .perf-star-score { font-size: 20px; }
}

/* ── Mobile (≤ 768px) ────────────────────────────────────────────────────── */
@media (max-width: 768px) {

  /* 1. Hamburger toggle — show on mobile only */
  #sidebar-toggle { display: flex; }

  /* 2. Sidebar — hidden off-screen, slides in as full-height drawer */
  #sidebar {
    transform: translateX(-100%);
    z-index: 200;
    width: 260px;
    box-shadow: 4px 0 28px rgba(0,0,0,.22);
  }
  #sidebar.open { transform: translateX(0); }

  /* 3. Semi-transparent page overlay — shown via JS class on body */
  body.sidebar-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 190;
  }

  /* 4. Content — full width, no left margin */
  #content { margin-left: 0 !important; padding: 14px 12px; }

  /* 5. Top nav */
  #topnav { padding: 0 10px; gap: 8px; }
  .nav-brand-sys { display: none; }
  .user-info { display: none; }
  .btn-outline-sm { padding: 5px 10px; font-size: 11px; }

  /* 6. Notification dropdown — full width */
  .notif-dropdown { width: calc(100vw - 20px); right: -54px; max-height: 70vh; overflow-y: auto; }

  /* 7. Login */
  .login-card { padding: 24px 18px; border-radius: 12px; }
  .login-header { flex-direction: column; text-align: center; gap: 8px; }

  /* 8. Grids → single column */
  .detail-grid       { grid-template-columns: 1fr; }
  .form-row          { grid-template-columns: 1fr; }
  .settings-grid     { grid-template-columns: 1fr; }
  .stats-grid        { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .perf-rating-summary { flex-direction: column; gap: 10px; }

  /* 9. Cards */
  .card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .card-header .btn-group { width: 100%; }
  .card-body { padding: 14px; }

  /* 10. Page header */
  .page-title { font-size: 18px; }
  .page-header { margin-bottom: 16px; }

  /* 11. Tables — horizontal scroll wrapper; table itself keeps full columns */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 0 0 var(--radius) var(--radius); }
  table { min-width: 520px; font-size: 13px; }
  .perf-table { min-width: 580px; }
  th { padding: 10px 10px; font-size: 11px; }
  td { padding: 10px 10px; font-size: 12px; }

  /* 12. Buttons */
  .btn-group { flex-wrap: wrap; gap: 6px; }
  .btn { font-size: 12px; padding: 8px 13px; }
  .btn-sm { font-size: 11px; padding: 5px 10px; }
  .btn-block { width: 100%; justify-content: center; }

  /* 13. Modal — bottom sheet style */
  #modal-bg { padding: 0; align-items: flex-end; background: rgba(0,0,0,.5); }
  #modal-box {
    max-width: 100%;
    width: 100%;
    max-height: 88vh;
    border-radius: 18px 18px 0 0;
    margin: 0;
  }
  #modal-header { padding: 16px 18px; }
  #modal-body { padding: 14px 18px 24px; }

  /* 14. Stage progress bar */
  .stage-progress { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px; gap: 4px; }
  .stage-step-label { font-size: 11px; }
  .stage-step-status { font-size: 10px; }
  .stage-step-num { width: 28px; height: 28px; font-size: 12px; }

  /* 15. Filter bar */
  .filter-bar { flex-direction: column; gap: 8px; }
  .filter-bar input, .filter-bar select { width: 100%; min-width: 0; }

  /* 16. Toast — full width strip at bottom */
  #toast-container { left: 10px; right: 10px; bottom: 10px; }
  .toast { min-width: 0; width: 100%; }

  /* 17. Rep rating */
  .rep-rating-block { padding: 12px; }
  .star { font-size: 26px; }

  /* 18. Description list */
  .dl { grid-template-columns: 110px 1fr; gap: 6px 10px; }

  /* 19. Stat cards */
  .stat-val { font-size: 26px; }
  .stat-card { padding: 12px 14px; }

  /* 20. Archive cards */
  .archive-card-header { flex-direction: column; gap: 10px; }

  /* 21. Settings sections */
  .settings-add-row { flex-direction: column; }
  .settings-input { width: 100%; }

  /* 22. Breadcrumb */
  .breadcrumb { font-size: 12px; }

  /* 23. Rep perf modal sections */
  .perf-comments-list { max-height: 200px; }
  .perf-comment-header { flex-direction: column; gap: 2px; }

  /* 24. Stage sections */
  .stage-section-header { flex-direction: column; align-items: flex-start; gap: 8px; }
}

/* ── Small mobile (≤ 420px) ──────────────────────────────────────────────── */
@media (max-width: 420px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .login-card { padding: 20px 14px; }
  .dl { grid-template-columns: 1fr; }
  .dl dt { margin-top: 4px; color: var(--muted); font-size: 11px; }
  .dl dd { font-size: 13px; }
  #modal-body { padding: 12px 14px 20px; }
  .stage-progress { flex-wrap: nowrap; }
  .stat-val { font-size: 22px; }
  .stat-label { font-size: 10px; }
  .page-title { font-size: 16px; }
  .card-title { font-size: 13px; }
  th { font-size: 10px; padding: 8px 8px; }
  td { font-size: 11px; padding: 8px 8px; }
}

/* ─── APP FOOTER ─────────────────────────────────────────────────────────── */
.app-footer {
  margin-top: 40px; padding: 16px 0;
  text-align: center; font-size: 11px; color: #a0b0c4;
  border-top: 1px solid var(--border); letter-spacing: .3px;
}

/* ─── LOADING ────────────────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 20px; height: 20px; border: 3px solid rgba(255,255,255,.3); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.spinner.dark { border-color: rgba(31,56,100,.2); border-top-color: var(--navy); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-overlay { display: flex; align-items: center; justify-content: center; padding: 60px; }

/* ─── TABS ───────────────────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 2px; }
.tab { padding: 10px 18px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab:hover { color: var(--blue); }
.tab.active { color: var(--navy); border-bottom-color: var(--navy); }

/* ─── BREADCRUMB ─────────────────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 16px; flex-wrap: wrap; }
.breadcrumb .sep { color: #ccc; }
.breadcrumb a { color: var(--blue); cursor: pointer; }
.breadcrumb .current { color: var(--navy); font-weight: 600; }

/* ─── STAGE PROGRESS ─────────────────────────────────────────────────────── */
.stage-progress { display: flex; align-items: center; gap: 0; margin-bottom: 20px; padding: 16px 20px; background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); }
.stage-step { display: flex; align-items: center; gap: 10px; }
.stage-step-num { width: 32px; height: 32px; border-radius: 50%; background: var(--lblue); color: var(--navy); font-weight: 700; font-size: 14px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stage-step.done .stage-step-num { background: var(--green); color: #fff; }
.stage-step.active .stage-step-num { background: var(--blue); color: #fff; }
.stage-step.locked .stage-step-num { background: #e0e8f0; color: #aaa; }
.stage-step-label { font-size: 13px; font-weight: 600; color: var(--navy); }
.stage-step-status { font-size: 11px; font-weight: 400; color: var(--muted); }
.stage-connector { flex: 1; height: 3px; background: var(--lblue); margin: 0 12px; }
.stage-connector.done { background: var(--green); }

/* ─── STAGE SECTIONS ─────────────────────────────────────────────────────── */
.stage-section { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 20px; overflow: hidden; }
.stage-section-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 20px; border-bottom: 1px solid var(--border); flex-wrap: wrap; background: #f7fafd; }
.stage-section-title { font-size: 14px; font-weight: 700; color: var(--navy); }
.stage-section-body { padding: 20px; }
.stage-locked { text-align: center; padding: 32px 20px; color: var(--muted); }
.stage-locked-icon { font-size: 36px; margin-bottom: 10px; }
.stage-badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 10px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase; }
.stage-badge.stage1 { background: #D6E4F0; color: #1F3864; }
.stage-badge.stage2 { background: #D6E8D0; color: #375623; }

/* ─── STAR RATING WIDGET ─────────────────────────────────────────────────── */
.star-rating { display: flex; gap: 4px; margin: 8px 0 6px; }
.star {
  font-size: 28px; color: #ddd; cursor: pointer;
  transition: color .15s, transform .1s;
  line-height: 1; user-select: none;
}
.star.active { color: #f0b429; }
.star.hover  { color: #f0b429; transform: scale(1.1); }
.star:hover  { transform: scale(1.1); }

.star-display { font-size: 16px; color: #f0b429; }

/* ─── REP RATING BLOCK ───────────────────────────────────────────────────── */
.rep-rating-block { border: 1.5px solid var(--border); border-radius: 8px; padding: 14px 16px; margin-bottom: 12px; background: #fafcff; }
.rep-rating-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; flex-wrap: wrap; }
.rep-rating-name  { font-weight: 700; font-size: 14px; color: var(--navy); }
.rep-rating-stage { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; background: var(--lblue); color: var(--navy); padding: 2px 7px; border-radius: 20px; }
.rated-badge { font-size: 11px; color: var(--green); font-weight: 700; margin-left: auto; }
.rep-rating-comment { width: 100%; margin: 6px 0 8px; padding: 7px 10px; border: 1.5px solid var(--border); border-radius: 6px; font-size: 13px; resize: vertical; min-height: 52px; }
.rep-rating-comment:focus { border-color: var(--blue); outline: none; }

/* ─── PERFORMANCE TABLE ──────────────────────────────────────────────────── */
.perf-table th, .perf-table td { padding: 12px 14px; }
.perf-table td:nth-child(2),
.perf-table td:nth-child(3),
.perf-table td:nth-child(4) { text-align: center; }

/* ─── RATING BAR ─────────────────────────────────────────────────────────── */
.rating-bar {
  height: 100%; background: linear-gradient(90deg, #f0b429, #e08a00);
  border-radius: 6px; transition: width .3s;
}

/* ─── REP PERF CARD (modal) ──────────────────────────────────────────────── */
.rep-perf-card { padding: 4px 0; }

/* ─── PERF DETAIL MODAL SECTIONS ─────────────────────────────────────────── */
.perf-detail-section { margin-bottom: 18px; }
.perf-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

/* Rating summary block */
.perf-rating-summary { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.perf-rating-big { text-align: center; min-width: 80px; }
.perf-rating-number { font-size: 40px; font-weight: 800; color: var(--navy); line-height: 1; }
.perf-rating-stars { font-size: 22px; color: #f0b429; margin: 4px 0; }
.perf-rating-count { font-size: 11px; color: var(--muted); }
.perf-rating-bars { flex: 1; min-width: 150px; }

/* Student comments list */
.perf-comments-list { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; }
.perf-comment-card {
  background: #f7fafd; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; border-left: 3px solid #f0b429;
}
.perf-comment-header {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px;
}
.perf-comment-stars { font-size: 14px; color: #f0b429; flex-shrink: 0; }
.perf-comment-meta { font-size: 11px; font-weight: 600; color: var(--blue); flex: 1; min-width: 100px; }
.perf-comment-date { font-size: 10px; color: #aaa; white-space: nowrap; }
.perf-comment-text { font-size: 13px; color: var(--text); line-height: 1.6; }

/* Performance table star metric */
.perf-star-metric { display: flex; align-items: center; gap: 10px; }
.perf-star-score { font-size: 24px; font-weight: 800; line-height: 1; }
.perf-star-row { font-size: 14px; color: #f0b429; line-height: 1; }
.perf-star-count { font-size: 10px; color: var(--muted); margin-top: 2px; }
.perf-no-rating { font-size: 12px; color: #bbb; font-style: italic; }

/* ─── SECRETARIAT ROLE BADGE ─────────────────────────────────────────────── */
.role-badge.secretariat { background: #E0D6F0; color: #4A235A; }
