/* ============================================================
   KPI Thái độ – VKU Đà Nẵng  |  style.css
   ============================================================ */
:root {
  --navy: #0d2137;
  --navy2: #163356;
  --teal: #0e7490;
  --teal-light: #22d3ee;
  --gold: #d97706;
  --gold-light: #fbbf24;
  --green: #059669;
  --red: #dc2626;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --sidebar-w: 260px;
  --sidebar-collapsed: 68px;
  --header-h: 60px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 14px;
  background: var(--gray-100);
  color: var(--gray-800);
}

/* ===== LOGIN ===== */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #1a4a6e 50%, #0e7490 100%);
  position: relative;
  overflow: hidden;
}
#loginScreen::before {
  content: '';
  position: absolute;
  top: -200px; right: -200px;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
}
#loginScreen::after {
  content: '';
  position: absolute;
  bottom: -150px; left: -150px;
  width: 450px; height: 450px;
  border-radius: 50%;
  background: rgba(14,116,144,0.15);
  border: 1px solid rgba(14,116,144,0.2);
}
.login-card {
  background: white;
  border-radius: 20px;
  padding: 48px 44px;
  width: 420px;
  max-width: 95vw;
  box-shadow: 0 32px 80px rgba(0,0,0,0.4);
  position: relative; z-index: 1;
}
.login-logo { text-align: center; margin-bottom: 32px; }
.login-logo .uni-seal {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--navy), var(--teal));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(13,116,144,0.3);
}
.login-logo .uni-seal i { font-size: 32px; color: white; }
.login-logo h1 { font-family: 'Playfair Display', serif; font-size: 22px; color: var(--navy); line-height: 1.3; }
.login-logo p { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.login-divider { height: 1px; background: var(--gray-200); margin: 24px 0; }
.login-field { margin-bottom: 18px; }
.login-field label {
  display: block; font-weight: 600; font-size: 12px;
  color: var(--gray-600); margin-bottom: 7px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.login-field input {
  width: 100%; padding: 12px 16px;
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 14px; transition: border-color .2s; outline: none;
}
.login-field input:focus { border-color: var(--teal); }
.btn-login {
  width: 100%; padding: 14px;
  background: linear-gradient(135deg, var(--navy), var(--teal));
  color: white; border: none; border-radius: 10px;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 15px; font-weight: 700;
  cursor: pointer; transition: all .2s; margin-top: 8px;
}
.btn-login:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(13,116,144,0.4); }
.btn-login:disabled { opacity: .7; transform: none; cursor: not-allowed; }
.login-hint { font-size: 12px; color: var(--gray-400); text-align: center; margin-top: 20px; }
.login-hint strong { color: var(--teal); }
.login-error {
  background: #fee2e2; color: var(--red);
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; margin-bottom: 14px;
  display: flex; align-items: center; gap: 8px;
}

/* ===== APP LAYOUT ===== */
#appScreen { display: flex; height: 100vh; flex-direction: row; }

/* SIDEBAR */
#sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  display: flex; flex-direction: column;
  transition: width .3s ease;
  overflow: hidden; flex-shrink: 0;
  position: relative; z-index: 10;
}
#sidebar.collapsed { width: var(--sidebar-collapsed); }
.sb-brand {
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
  min-height: var(--header-h);
}
.sb-brand-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--teal), var(--teal-light));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-brand-icon i { color: white; font-size: 16px; }
.sb-brand-text { overflow: hidden; }
.sb-brand-text .name { font-weight: 800; font-size: 14px; color: white; white-space: nowrap; }
.sb-brand-text .sub { font-size: 10px; color: rgba(255,255,255,0.4); white-space: nowrap; }

.sb-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.sb-section-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: rgba(255,255,255,0.3);
  padding: 8px 10px 4px; white-space: nowrap; overflow: hidden;
}
.sb-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  transition: all .2s; color: rgba(255,255,255,0.6);
  font-size: 13.5px; font-weight: 500; margin-bottom: 2px;
  white-space: nowrap;
}
.sb-item:hover { background: rgba(255,255,255,0.07); color: white; }
.sb-item.active { background: rgba(14,116,144,0.35); color: white; }
.sb-item.active .sb-icon { background: var(--teal); }
.sb-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06); flex-shrink: 0;
  transition: background .2s;
}
.sb-icon i { font-size: 14px; }
.sb-item span { overflow: hidden; }
.sb-badge {
  margin-left: auto; background: var(--gold);
  color: white; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 20px; flex-shrink: 0;
}
.sb-user {
  padding: 14px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.sb-user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: white; flex-shrink: 0;
}
.sb-user-info { overflow: hidden; flex: 1; }
.sb-user-name { font-weight: 700; font-size: 13px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-user-role { font-size: 11px; color: rgba(255,255,255,0.4); white-space: nowrap; }
.btn-logout { background: none; border: none; cursor: pointer; color: rgba(255,255,255,0.4); font-size: 16px; transition: color .2s; flex-shrink: 0; }
.btn-logout:hover { color: #ef4444; }

/* MAIN */
#mainArea { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#topbar {
  height: var(--header-h); background: white;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px; flex-shrink: 0;
}
.btn-toggle-sb {
  background: none; border: none; cursor: pointer;
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-600); transition: all .2s;
}
.btn-toggle-sb:hover { background: var(--gray-100); }
.topbar-title { font-weight: 700; font-size: 16px; color: var(--navy); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-period { background: var(--teal); color: white; padding: 5px 14px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.topbar-notif { position: relative; cursor: pointer; }
.notif-dot { width: 8px; height: 8px; background: var(--gold); border-radius: 50%; position: absolute; top: 0; right: 0; border: 2px solid white; }

#content { flex: 1; overflow-y: auto; padding: 24px; }
.section-loader { text-align: center; padding: 60px; color: var(--gray-400); font-size: 16px; }

/* CARDS */
.card { background: white; border-radius: 14px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; gap: 10px; }
.card-header h3 { font-size: 15px; font-weight: 700; color: var(--navy); flex: 1; }
.card-body { padding: 20px; }

/* STATS */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-box {
  border-radius: 14px; padding: 20px;
  display: flex; align-items: flex-start; gap: 14px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  position: relative; overflow: hidden;
}
.stat-box::after {
  content: ''; position: absolute; top: -20px; right: -20px;
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(255,255,255,0.1);
}
.stat-box.navy { background: linear-gradient(135deg, var(--navy), var(--navy2)); color: white; }
.stat-box.teal { background: linear-gradient(135deg, var(--teal), #0891b2); color: white; }
.stat-box.gold { background: linear-gradient(135deg, var(--gold), var(--gold-light)); color: white; }
.stat-box.green { background: linear-gradient(135deg, var(--green), #10b981); color: white; }
.stat-box-icon { width: 44px; height: 44px; background: rgba(255,255,255,0.2); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.stat-box-info .num { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-box-info .lbl { font-size: 12px; opacity: 0.85; margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* TABLE */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  background: var(--navy); color: white; padding: 11px 14px;
  text-align: left; font-size: 12px; font-weight: 600; white-space: nowrap;
}
thead th:first-child { border-radius: 8px 0 0 0; }
thead th:last-child { border-radius: 0 8px 0 0; }
tbody tr { border-bottom: 1px solid var(--gray-100); transition: background .15s; }
tbody tr:hover { background: #f0f9ff; }
tbody tr.hidden-row { display: none; }
tbody td { padding: 10px 14px; font-size: 13px; }
tbody tr:last-child { border-bottom: none; }

/* BADGES */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.badge-aplus { background: #d1fae5; color: #065f46; }
.badge-a     { background: #dbeafe; color: #1d4ed8; }
.badge-b     { background: #ede9fe; color: #5b21b6; }
.badge-c     { background: #fef3c7; color: #92400e; }
.badge-d     { background: #fee2e2; color: #991b1b; }
.badge-admin { background: #fce7f3; color: #9d174d; }
.badge-gv    { background: #dbeafe; color: #1d4ed8; }
.badge-hc    { background: #f3e8ff; color: #6d28d9; }
.badge-sv    { background: #d1fae5; color: #065f46; }
.badge-ok     { background: #d1fae5; color: #065f46; }
.badge-pending{ background: #fef3c7; color: #92400e; }
.badge-g1    { background: #e0f2fe; color: #0369a1; }
.badge-g2    { background: #f0fdf4; color: #15803d; }
.badge-g3    { background: #fff7ed; color: #c2410c; }
.badge-reward{ background: #fef3c7; color: #92400e; }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 16px; border-radius: 8px; font-family: 'Be Vietnam Pro', sans-serif; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: all .2s; text-decoration: none; }
.btn-primary { background: var(--teal); color: white; }
.btn-primary:hover { background: #0891b2; transform: translateY(-1px); }
.btn-navy { background: var(--navy); color: white; }
.btn-navy:hover { background: var(--navy2); }
.btn-gold { background: var(--gold); color: white; }
.btn-gold:hover { background: #b45309; }
.btn-green { background: var(--green); color: white; }
.btn-green:hover { background: #047857; }
.btn-outline { background: white; color: var(--gray-600); border: 2px solid var(--gray-200); }
.btn-outline:hover { border-color: var(--teal); color: var(--teal); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }

/* FORM */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-row.col3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.col1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 700; color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.4px; }
.form-group input, .form-group select, .form-group textarea {
  padding: 10px 14px; border: 2px solid var(--gray-200);
  border-radius: 9px; font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 13px; outline: none; transition: border-color .2s; background: white;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--teal); }
.form-group textarea { resize: vertical; min-height: 80px; }

/* EVALUATION */
.eval-target-card {
  background: linear-gradient(135deg, var(--navy), var(--navy2));
  border-radius: 14px; padding: 20px; color: white;
  margin-bottom: 20px; display: flex; align-items: center; gap: 16px;
}
.eval-target-avatar {
  width: 56px; height: 56px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; flex-shrink: 0;
}
.eval-target-info h3 { font-size: 18px; font-weight: 800; }
.eval-target-info p { font-size: 13px; opacity: 0.7; margin-top: 3px; }
.eval-target-info .your-weight {
  margin-top: 8px; display: inline-block;
  background: rgba(14,116,144,0.4); padding: 4px 12px;
  border-radius: 20px; font-size: 12px; font-weight: 700;
}
.criteria-section { margin-bottom: 20px; }
.criteria-card {
  background: white; border: 2px solid var(--gray-200);
  border-radius: 14px; padding: 20px; margin-bottom: 14px;
  transition: border-color .2s;
}
.criteria-card.rated { border-color: var(--teal); }
.criteria-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.criteria-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; }
.criteria-icon.red   { background: #fee2e2; }
.criteria-icon.blue  { background: #dbeafe; }
.criteria-icon.green { background: #d1fae5; }
.criteria-title h4   { font-size: 15px; font-weight: 700; color: var(--navy); }
.criteria-title .desc { font-size: 12px; color: var(--gray-400); margin-top: 3px; }
.weight-tag { background: var(--navy); color: white; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 20px; margin-left: auto; flex-shrink: 0; }
.rating-bar { display: flex; gap: 6px; flex-wrap: wrap; }
.rating-btn {
  width: 38px; height: 38px; border-radius: 8px;
  border: 2px solid var(--gray-200); background: white;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 14px; font-weight: 700; cursor: pointer;
  transition: all .15s; color: var(--gray-600);
}
.rating-btn:hover { border-color: var(--teal); color: var(--teal); transform: translateY(-2px); }
.rating-btn.active { background: var(--teal); border-color: var(--teal); color: white; }
.score-display { margin-left: auto; font-size: 28px; font-weight: 800; color: var(--teal); min-width: 50px; text-align: right; }
.result-preview {
  background: linear-gradient(135deg, #f0f9ff, #e0f2fe);
  border: 2px solid #bae6fd; border-radius: 14px; padding: 20px;
  margin-top: 20px; display: flex; align-items: center; justify-content: space-between;
}
.result-preview .final-score { font-size: 40px; font-weight: 800; color: var(--teal); }
.result-preview .breakdown { font-size: 12px; color: var(--gray-600); }

/* EVAL LIST */
.eval-person-card.eval-hidden { display: none; }
.eval-list { display: flex; flex-direction: column; gap: 12px; }
.eval-person-card {
  background: white; border-radius: 12px;
  border: 2px solid var(--gray-200); padding: 16px 20px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; transition: all .2s;
}
.eval-person-card:hover { border-color: var(--teal); box-shadow: 0 4px 16px rgba(14,116,144,0.1); }
.eval-person-card.done { border-color: var(--green); background: #f0fdf4; cursor: default; }
.eval-person-card.done:hover { box-shadow: 0 4px 16px rgba(5,150,105,0.1); }
.person-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--teal));
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: 16px; flex-shrink: 0;
}
.person-info { flex: 1; }
.person-info .pname { font-weight: 700; font-size: 14px; color: var(--navy); }
.person-info .pmeta { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.person-status { flex-shrink: 0; }

/* MODAL */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 100;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 16px;
  width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
  animation: slideUp .25s ease;
}
.modal.modal-lg { max-width: 800px; }
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; gap: 12px; }
.modal-header h3 { font-size: 16px; font-weight: 800; color: var(--navy); flex: 1; }
.modal-close { background: none; border: none; cursor: pointer; font-size: 20px; color: var(--gray-400); transition: color .2s; }
.modal-close:hover { color: var(--red); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 10px; }

/* PROGRESS */
.progress { height: 8px; background: var(--gray-200); border-radius: 4px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--teal), var(--teal-light)); border-radius: 4px; transition: width .4s ease; }

/* NOTICE */
.notice { padding: 14px 18px; border-radius: 10px; font-size: 13px; display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; }
.notice.info    { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.notice.warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.notice.success { background: #f0fdf4; color: #065f46; border: 1px solid #bbf7d0; }
.notice.danger  { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

/* FILTER ROW */
.filter-row { display: flex; gap: 10px; margin-bottom: 16px; align-items: center; flex-wrap: wrap; }
.filter-row input, .filter-row select {
  padding: 8px 12px; border: 2px solid var(--gray-200);
  border-radius: 8px; font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 13px; outline: none; transition: border-color .2s;
}
.filter-row input:focus, .filter-row select:focus { border-color: var(--teal); }
.filter-row input { min-width: 200px; }

/* SCORE BREAKDOWN */
.score-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.score-row .label { width: 180px; font-size: 13px; color: var(--gray-600); }
.score-row .bar { flex: 1; }
.score-row .val { width: 40px; text-align: right; font-weight: 700; font-size: 13px; color: var(--navy); }

/* MY RESULT */
.my-score-big {
  background: linear-gradient(135deg, var(--navy), var(--teal));
  border-radius: 16px; padding: 32px; color: white; text-align: center;
}
.my-score-big .score-num { font-size: 64px; font-weight: 800; line-height: 1; }
.my-score-big .rank-badge {
  display: inline-block; margin-top: 12px;
  background: rgba(255,255,255,0.2); padding: 6px 20px;
  border-radius: 30px; font-size: 20px; font-weight: 700;
}
.my-score-big p { margin-top: 8px; opacity: 0.7; font-size: 13px; }

/* CHART */
.chart-wrap { height: 240px; position: relative; }

/* GUIDE TABLE */
.guide-table { width: 100%; border-collapse: collapse; }
.guide-table th { background: var(--gray-50); padding: 10px 14px; font-size: 12px; font-weight: 700; text-align: left; border: 1px solid var(--gray-200); color: var(--gray-600); }
.guide-table td { padding: 10px 14px; border: 1px solid var(--gray-200); font-size: 13px; }
.guide-table tr:nth-child(even) td { background: var(--gray-50); }

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 3px; }

/* PAGE HEADER */
.page-header { margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 800; color: var(--navy); }
.page-header p { font-size: 13px; color: var(--gray-400); margin-top: 4px; }

/* TOAST */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: white; border-radius: 12px; padding: 14px 18px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; font-weight: 600;
  animation: toastIn .3s ease; min-width: 280px;
  border-left: 4px solid var(--teal);
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--gold); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; transform: translateX(60px); } }

/* UTILS */
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-700 { font-weight: 700; }
.text-teal { color: var(--teal); }
.text-navy { color: var(--navy); }
.text-muted { color: var(--gray-400); }
.hidden { display: none !important; }

/* ================================================================
   RESPONSIVE – Hỗ trợ đầy đủ Mobile / Tablet / Desktop
   Breakpoints:
     xs  : max 480px  (điện thoại nhỏ)
     sm  : max 640px  (điện thoại lớn)
     md  : max 768px  (tablet đứng / điện thoại lớn)
     lg  : max 1024px (tablet ngang)
================================================================ */

/* ── SIDEBAR OVERLAY (dùng cho mobile) ── */
#sidebarBackdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 9;
  backdrop-filter: blur(2px);
}
#sidebarBackdrop.open { display: block; }

/* ── LG: Tablet ngang ≤ 1024px ── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-3     { grid-template-columns: 1fr 1fr; }
  #content    { padding: 20px; }
}

/* ── MD: Tablet đứng / phone lớn ≤ 768px ── */
@media (max-width: 768px) {

  /* --- Sidebar: chuyển sang overlay slide-in --- */
  #sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w) !important;
    transform: translateX(-100%);
    transition: transform .3s ease, width .3s ease;
    z-index: 10;
    box-shadow: 4px 0 24px rgba(0,0,0,0.3);
  }
  #sidebar.mobile-open {
    transform: translateX(0);
  }
  /* Không dùng .collapsed trên mobile – ẩn/hiện thay vì thu nhỏ */
  #sidebar.collapsed {
    width: var(--sidebar-w) !important;
  }

  /* --- Main area full width khi sidebar ẩn --- */
  #mainArea { width: 100%; }

  /* --- Topbar --- */
  #topbar { padding: 0 14px; gap: 10px; }
  .topbar-title { font-size: 14px; }
  .topbar-period { font-size: 11px; padding: 4px 10px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* --- Content --- */
  #content { padding: 14px; }

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

  /* --- Stats grid: 2 cột --- */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-box { padding: 14px; gap: 10px; }
  .stat-box-icon { width: 36px; height: 36px; font-size: 16px; border-radius: 10px; }
  .stat-box-info .num { font-size: 22px; }
  .stat-box-info .lbl { font-size: 11px; }

  /* --- Grids --- */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }

  /* --- Cards --- */
  .card-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .card-header h3 { font-size: 13px; }
  .card-body { padding: 14px; }

  /* --- Filter row: stack vertical --- */
  .filter-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-row input,
  .filter-row select { min-width: unset; width: 100%; }

  /* --- Tables: scroll ngang + ẩn bớt cột phụ --- */
  .tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table { min-width: 520px; }

  /* --- Forms --- */
  .form-row,
  .form-row.col3 { grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }

  /* --- Modal: full screen từ dưới lên --- */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    border-radius: 20px 20px 0 0 !important;
    max-width: 100% !important;
    max-height: 92vh;
    animation: slideUpMobile .3s ease;
  }
  .modal-body { padding: 16px; }
  .modal-header { padding: 16px; }
  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap; gap: 8px;
  }
  .modal-footer .btn { flex: 1; justify-content: center; min-height: 44px; }
  @keyframes slideUpMobile {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
  }

  /* --- Evaluation cards --- */
  .eval-person-card { padding: 12px 14px; gap: 10px; }
  .person-avatar { width: 38px; height: 38px; font-size: 14px; }
  .person-info .pname { font-size: 13px; }

  /* --- Rating bar: nút lớn hơn cho ngón tay --- */
  .rating-bar { gap: 5px; }
  .rating-btn {
    width: 36px; height: 44px; /* tối thiểu 44px cao cho touch */
    border-radius: 8px; font-size: 13px;
  }
  .score-display { font-size: 22px; min-width: 36px; }

  /* --- Eval target card --- */
  .eval-target-card { padding: 14px; gap: 12px; }
  .eval-target-avatar { width: 46px; height: 46px; font-size: 18px; }
  .eval-target-info h3 { font-size: 15px; }

  /* --- Criteria card --- */
  .criteria-card { padding: 14px; }
  .criteria-header { gap: 8px; flex-wrap: wrap; }

  /* --- Result preview --- */
  .result-preview { flex-direction: column; gap: 10px; text-align: center; padding: 14px; }
  .result-preview .final-score { font-size: 32px; }

  /* --- My score big --- */
  .my-score-big { padding: 24px 16px; }
  .my-score-big .score-num { font-size: 48px; }
  .my-score-big .rank-badge { font-size: 16px; }

  /* --- Toast: full width dưới màn hình --- */
  .toast-container { bottom: 0; right: 0; left: 0; padding: 0 0 env(safe-area-inset-bottom, 0); }
  .toast { min-width: unset; width: 100%; border-radius: 0; border-left: none; border-top: 4px solid var(--teal); }
  .toast.success { border-top-color: var(--green); }
  .toast.error   { border-top-color: var(--red); }
  .toast.warning { border-top-color: var(--gold); }

  /* --- Relation tabs: scroll ngang --- */
  .rel-tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .rel-tab { white-space: nowrap; padding: 8px 14px; font-size: 12px; }

  /* --- Buttons trong card-header --- */
  .card-header .btn { font-size: 11px; padding: 5px 10px; }

  /* --- Chart wrap thấp hơn --- */
  .chart-wrap { height: 180px; }
}

/* ── SM: Điện thoại ≤ 640px ── */
@media (max-width: 640px) {
  /* Stats: 1 cột trên màn hình rất nhỏ */
  .stats-grid { grid-template-columns: 1fr; }

  /* Login card */
  .login-card { padding: 32px 22px; border-radius: 16px; }
  .login-logo h1 { font-size: 18px; }
  .login-logo .uni-seal { width: 60px; height: 60px; }
  .login-logo .uni-seal i { font-size: 26px; }

  /* Page header nhỏ hơn */
  .page-header h2 { font-size: 16px; }

  /* Card header: nút thêm xuống dòng */
  .card-header { flex-wrap: wrap; }
  .card-header h3 { width: 100%; }
  .card-header .btn { margin-left: 0 !important; }

  /* Topbar title rút ngắn */
  .topbar-title { font-size: 13px; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Rating bar: scroll ngang thay vì wrap */
  .rating-bar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .rating-btn { flex-shrink: 0; }

  /* Criteria header: wrap */
  .criteria-header { flex-wrap: wrap; }
  .weight-tag { margin-left: 0; }

  /* Guide table */
  .guide-table { font-size: 12px; }
  .guide-table th, .guide-table td { padding: 7px 8px; }

  /* Badge – thu nhỏ một chút */
  .badge { font-size: 10px; padding: 2px 7px; }
}

/* ── XS: Điện thoại rất nhỏ ≤ 480px ── */
@media (max-width: 480px) {
  #topbar { padding: 0 10px; gap: 6px; }
  #content { padding: 10px; }
  .topbar-period { display: none; } /* ẩn kỳ trên topbar, xem ở dashboard */

  .eval-person-card { flex-wrap: wrap; }
  .person-status { width: 100%; text-align: right; margin-top: -4px; }

  .modal-footer .btn { font-size: 13px; }

  /* Form labels ngắn hơn */
  .form-group label { letter-spacing: 0; }
}

/* ── Đảm bảo safe area cho notch / home bar ── */
@supports (padding: env(safe-area-inset-bottom)) {
  #topbar  { padding-top: env(safe-area-inset-top, 0); }
  #content { padding-bottom: max(14px, env(safe-area-inset-bottom, 0)); }
}

/* ================================================================
   TABLE → CARD mode trên màn hình rất nhỏ (≤ 480px)
   Dùng data-label trên <td> để hiển thị nhãn cột
================================================================ */
@media (max-width: 480px) {
  /* Bảng nhân sự và bảng đánh giá chuyển sang dạng card */
  #userTable,
  #evalTable,
  #userTable thead,
  #evalTable thead,
  #userTable tbody,
  #evalTable tbody,
  #userTable tr,
  #evalTable tr,
  #userTable td,
  #evalTable td {
    display: block;
    width: 100%;
  }
  #userTable thead,
  #evalTable thead { display: none; }

  #userTable tbody tr,
  #evalTable tbody tr {
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    margin-bottom: 10px;
    padding: 10px 14px;
    background: white;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  }
  #userTable tbody tr:hover,
  #evalTable tbody tr:hover { background: #f0f9ff; }

  #userTable td,
  #evalTable td {
    padding: 5px 0;
    border: none;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
  }
  /* Cột số thứ tự ẩn */
  #userTable td:first-child,
  #evalTable td:first-child { display: none; }

  /* Nhãn cột từ data-label */
  #userTable td[data-label]::before,
  #evalTable td[data-label]::before {
    content: attr(data-label) ': ';
    font-weight: 700;
    font-size: 11px;
    color: var(--gray-400);
    text-transform: uppercase;
    min-width: 80px;
    flex-shrink: 0;
  }
  /* Cột action (nút) không cần label, căn phải */
  #userTable td:last-child,
  #evalTable td:last-child {
    justify-content: flex-end;
    padding-top: 8px;
    border-top: 1px solid var(--gray-100);
    margin-top: 4px;
  }
  #userTable td:last-child::before,
  #evalTable td:last-child::before { display: none; }
}

/* ================================================================
   RELATION MODAL – 2-column multi-select picker (v3)
   Desktop: 2 columns side by side, fixed heights → header/footer
            always visible regardless of data volume.
   Mobile : 1 column stacked.
================================================================ */

/* ── Modal size ── */
.modal.modal-rel            { max-width: 760px; }
.modal.modal-rel .modal-body { padding: 16px 20px; }

/* ── 2-column grid ── */
.rel-modal-body {
  display: grid;
  grid-template-columns: 1fr 32px 1fr;
  gap: 0 8px;
  align-items: start;
}

/* ── Each column ── */
.rel-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;          /* prevent overflow in grid cell */
}

/* ── Column header ── */
.rel-col-head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.rel-col-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 12px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.rel-col-title-wrap { display: flex; flex-direction: column; gap: 1px; }

.rel-col-title {
  font-size: 13px; font-weight: 700; color: var(--navy);
  display: flex; align-items: center; gap: 5px; flex-wrap: wrap;
}

.rel-col-hint {
  font-size: 11px; color: var(--gray-400);
}

/* Count badge */
.rel-count-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px;
  border-radius: 18px;
  background: var(--teal); color: #fff;
  font-size: 10px; font-weight: 700; padding: 0 4px;
  transition: all .2s;
}
.rel-count-badge:empty { display: none; }

/* ── Search input ── */
.rel-picker-search {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border: 2px solid var(--gray-200);
  border-radius: 8px;
  font-size: 13px;
  font-family: 'Be Vietnam Pro', sans-serif;
  outline: none;
  transition: border-color .2s;
  background: var(--gray-50) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E") no-repeat 9px center;
}
.rel-picker-search:focus { border-color: var(--teal); background-color: #fff; }

/* ── Scrollable list – FIXED HEIGHT keeps header/footer visible ── */
.rel-picker-list {
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  overflow-y: auto;
  height: 220px;         /* fixed, not max-height */
  background: #fff;
  -webkit-overflow-scrolling: touch;
}

/* ── List items ── */
.rel-picker-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  cursor: pointer;
  transition: background .12s;
  border-bottom: 1px solid var(--gray-100);
  user-select: none;
}
.rel-picker-item:last-child  { border-bottom: none; }
.rel-picker-item:hover:not(.selected) { background: #f0f9ff; }
.rel-picker-item.selected    { background: #ecfdf5; }

.rel-picker-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--navy), var(--teal));
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 11px;
  flex-shrink: 0;
}
.rel-picker-item.selected .rel-picker-avatar {
  background: linear-gradient(135deg, #059669, #10b981);
}

.rel-picker-info { flex: 1; min-width: 0; }

.rel-picker-name {
  font-size: 12.5px; font-weight: 700; color: var(--navy);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.rel-picker-meta {
  font-size: 11px; color: var(--gray-400); margin-top: 1px;
  display: flex; align-items: center; gap: 4px; flex-wrap: wrap;
}

/* Check icon – side A (single) */
.rel-picker-check {
  color: var(--green); font-size: 14px; flex-shrink: 0;
}

/* Checkbox – side B (multi) */
.rel-multi-check {
  width: 18px; height: 18px;
  border-radius: 4px;
  border: 2px solid var(--gray-300);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all .12s;
  font-size: 10px; color: #fff;
}
.rel-multi-check.checked { background: var(--green); border-color: var(--green); }

.rel-picker-loading,
.rel-picker-empty {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--gray-400); font-size: 13px; gap: 6px;
}
.rel-picker-empty i { font-size: 18px; }

/* ── Selected preview – side A (single) ── */
.rel-selected-preview {
  border: 2px dashed var(--gray-200);
  border-radius: 10px;
  min-height: 50px;
  display: flex; align-items: center;
  padding: 4px 8px;
  background: var(--gray-50);
  transition: border-color .2s, background .2s;
}
/* When it contains a .rel-picker-item (user is selected) */
.rel-selected-preview .rel-picker-item {
  border: none; padding: 5px 6px; cursor: default; width: 100%;
}
.rel-selected-preview:has(.rel-picker-item) {
  border-style: solid; border-color: var(--green); background: #ecfdf5;
}

/* ── Chips zone – side B (multi, scrollable) ── */
.rel-chips-zone {
  border: 2px dashed var(--gray-200);
  border-radius: 10px;
  min-height: 44px;
  max-height: 88px;       /* ~2 rows of chips, then scroll */
  overflow-y: auto;
  display: flex; flex-wrap: wrap; gap: 5px;
  padding: 6px 8px;
  align-content: flex-start;
  background: var(--gray-50);
  transition: border-color .2s, background .2s;
  -webkit-overflow-scrolling: touch;
}
.rel-chips-zone:has(.rel-chip) {
  border-style: solid; border-color: var(--teal); background: #f0f9ff;
}

.rel-chips-placeholder {
  color: var(--gray-400); font-size: 12px;
  width: 100%; text-align: center; align-self: center;
}

/* Chip */
.rel-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--teal); color: #fff;
  border-radius: 20px; padding: 3px 6px 3px 5px;
  font-size: 11px; font-weight: 600;
  max-width: 160px;
  animation: chipIn .15s ease;
  flex-shrink: 0;
}
@keyframes chipIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.rel-chip-avatar {
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 9px; font-weight: 800; flex-shrink: 0;
}

.rel-chip-name {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100px;
}

.rel-chip-remove {
  background: rgba(255,255,255,.2); border: none; cursor: pointer;
  width: 14px; height: 14px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 12px; line-height: 1; padding: 0;
  flex-shrink: 0; transition: background .12s;
}
.rel-chip-remove:hover { background: rgba(255,255,255,.45); }

/* ── Vertical divider between columns ── */
.rel-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: 32px;       /* align with list area */
  gap: 4px;
  height: 100%;
}

.rel-divider-line {
  width: 2px;
  flex: 1;
  background: var(--gray-200);
  max-height: 40px;
}

.rel-divider-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--teal);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px;
  box-shadow: 0 2px 6px rgba(14,116,144,.3);
  flex-shrink: 0;
}

/* ── Mobile: 1 column ── */
@media (max-width: 640px) {
  .modal.modal-rel { max-width: 100%; }

  .rel-modal-body {
    grid-template-columns: 1fr;
    gap: 10px 0;
  }

  .rel-divider {
    flex-direction: row;
    padding-top: 0;
    height: auto;
    gap: 6px;
  }
  .rel-divider-line {
    width: 40px; height: 2px; flex: none;
  }

  .rel-picker-list { height: 160px; }

  .rel-col-hint { display: none; }
}
