/* Kiểm tra — Agribank UI (sidebar layout, bright theme) */

:root {
  --agri-green: #0d7a4c;
  --agri-green-dark: #0a5c38;
  --agri-green-light: #12a066;
  --agri-green-soft: #e8f5ef;
  --agri-gold: #c9a227;
  --bg: #f0f4f8;
  --surface: #ffffff;
  --card: #ffffff;
  --text: #1a2332;
  --muted: #5c6b7a;
  --border: #dce4ec;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(15, 60, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(15, 60, 40, 0.1);
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 0.75rem;
  --space-lg: 1rem;
  --space-xl: 1.5rem;
  --space-2xl: 2rem;
  --sidebar-w: 260px;
  --topbar-h: 56px;
  --font: "Segoe UI", system-ui, -apple-system, Tahoma, sans-serif;
}

* { box-sizing: border-box; }

html { font-size: 14px; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-body {
  min-height: 100vh;
}

a {
  color: var(--agri-green);
  text-decoration: none;
  transition: color 0.15s;
}

a:hover {
  color: var(--agri-green-dark);
  text-decoration: underline;
}

/* —— App shell & sidebar —— */
.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 800;
  background: rgba(15, 30, 45, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.app-shell.sidebar-open .sidebar-backdrop {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 900;
  width: var(--sidebar-w);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 16px rgba(0, 0, 0, 0.04);
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  height: 40px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.sidebar-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--agri-green-dark);
  line-height: 1.2;
}

.sidebar-sub {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-md) var(--space-sm);
  -webkit-overflow-scrolling: touch;
}

.sidebar-section {
  padding: var(--space-md) var(--space-sm) var(--space-xs);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0.55rem 0.75rem;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.12s, color 0.12s;
}

.sidebar-link:hover {
  background: var(--agri-green-soft);
  color: var(--agri-green-dark);
  text-decoration: none;
}

.sidebar-link.is-active {
  background: linear-gradient(135deg, var(--agri-green), var(--agri-green-light));
  color: #fff;
  box-shadow: 0 2px 8px rgba(13, 122, 76, 0.25);
}

.sidebar-link.is-active:hover {
  color: #fff;
  background: linear-gradient(135deg, var(--agri-green-dark), var(--agri-green));
}

.sidebar-icon {
  width: 1.25rem;
  text-align: center;
  font-size: 0.95rem;
  opacity: 0.85;
  flex-shrink: 0;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: var(--space-md);
  border-top: 1px solid var(--border);
  background: #fafcfd;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--agri-green), var(--agri-green-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.sidebar-user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  font-size: 0.8rem;
}

.sidebar-user-meta strong {
  font-size: 0.85rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-meta span {
  color: var(--muted);
  font-size: 0.75rem;
}

.sidebar-logout { margin: 0; }

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--agri-green-dark);
  font-size: 1.15rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s, border-color 0.12s;
}

.sidebar-toggle:hover {
  background: var(--agri-green-soft);
  border-color: var(--agri-green);
}

/* —— Main area —— */
.app-main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-height: var(--topbar-h);
  padding: 0 var(--space-xl);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.03);
}

.app-topbar-title {
  flex: 1;
  min-width: 0;
}

.app-page-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--agri-green-dark);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-topbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  flex-shrink: 0;
}

.app-content {
  flex: 1 0 auto;
  width: 100%;
  padding: var(--space-xl);
}

.app-content.shell {
  max-width: none;
  margin: 0;
}

/* —— Guest shell —— */
.guest-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
}

.guest-header {
  position: sticky;
  top: 0;
  z-index: 400;
  background: linear-gradient(135deg, var(--agri-green-dark), var(--agri-green));
  color: #fff;
  box-shadow: var(--shadow-md);
}

.guest-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-md) var(--space-xl);
  width: 100%;
}

.brand--guest {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  font-size: 1rem;
  color: #fff;
}

.brand--guest .logo {
  height: 36px;
  width: auto;
}

.guest-nav {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.guest-nav a {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.9rem;
}

.guest-nav a:hover {
  color: #fff;
  text-decoration: none;
}

.guest-nav .btn-primary {
  background: #fff;
  color: var(--agri-green-dark);
}

.guest-nav .btn-primary:hover {
  background: var(--agri-green-soft);
}

.guest-main {
  flex: 1;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: var(--space-xl);
}

/* —— Footer —— */
.site-footer {
  flex-shrink: 0;
  margin-top: auto;
  padding: var(--space-lg) var(--space-xl);
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  text-align: center;
}

.site-footer-inner {
  max-width: none;
  margin: 0 auto;
}

.site-footer-dev {
  margin: 0 0 0.25rem;
  color: var(--text);
  font-size: 0.82rem;
}

.site-footer-dev strong {
  color: var(--agri-green);
  font-weight: 600;
}

.site-footer-copy {
  margin: 0;
  font-size: 0.75rem;
  line-height: 1.45;
}

/* —— Shell (legacy + content padding) —— */
.shell {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

/* —— Cards —— */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: var(--space-lg) var(--space-xl);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: var(--space-lg);
}

.card-compact { padding: var(--space-md) var(--space-lg); }

.card-flush { padding: 0; overflow: hidden; }
.card-flush .card-body { padding: var(--space-md) var(--space-lg); }
.card-flush .table-wrap { margin: 0; border: none; border-radius: 0; }

/* —— Page header & hero —— */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.page-header h1 { margin: 0; }
.page-header .page-actions { margin: 0; }

/* Tiêu đề trang hiển thị trên app-topbar — tránh trùng h1 */
.app-content .page-header > h1 {
  display: none;
}

.page-hero {
  background: linear-gradient(135deg, var(--agri-green-dark) 0%, var(--agri-green) 55%, var(--agri-green-light) 100%);
  border: none;
  color: #fff;
  padding: var(--space-xl) var(--space-2xl);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-md);
}

.page-hero-body { max-width: 100%; }

.page-hero-kicker {
  margin: 0 0 var(--space-xs);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
  font-weight: 600;
}

.page-hero-title {
  margin: 0 0 var(--space-md);
  font-size: 1.65rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.page-hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.page-hero-chip {
  display: inline-block;
  padding: 0.25rem 0.65rem;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  font-size: 0.8rem;
  color: #fff;
}

.page-hero .dash-role-badge {
  background: rgba(255, 255, 255, 0.95);
  color: var(--agri-green-dark);
}

h1 {
  font-size: 1.25rem;
  margin: 0 0 var(--space-md);
  color: var(--agri-green-dark);
  font-weight: 600;
  line-height: 1.25;
}

h2 {
  font-size: 1rem;
  margin: 0 0 var(--space-md);
  color: var(--agri-green-dark);
  font-weight: 600;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

/* —— Buttons —— */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}

.btn-primary {
  background: var(--agri-green);
  color: #fff;
  box-shadow: 0 2px 6px rgba(13, 122, 76, 0.2);
}

.btn-primary:hover {
  background: var(--agri-green-light);
  box-shadow: 0 4px 12px rgba(13, 122, 76, 0.28);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--agri-green-soft);
  border-color: #b8dfc8;
}

.btn-danger {
  background: #c62828;
  color: #fff;
}

.btn-danger:hover { background: #a31f1f; }

.btn-sm {
  font-size: 0.8rem;
  padding: 0.28rem 0.55rem;
}

.btn-block {
  width: 100%;
}

.btn-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
  margin-top: var(--space-lg);
}

.btn-group--tight { margin-top: var(--space-md); }

/* —— Forms —— */
.form-section {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--border);
}

.form-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.form-section > h2 {
  margin-bottom: var(--space-sm);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md) var(--space-lg);
}

.form-grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-row,
.field { margin-bottom: 0; }

.field-span-2 { grid-column: span 2; }
.field-span-full { grid-column: 1 / -1; }

label,
.field > label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
  font-weight: 500;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
input[type="file"],
select,
textarea {
  width: 100%;
  max-width: none;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-family: inherit;
  background: var(--surface);
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--agri-green);
  box-shadow: 0 0 0 3px rgba(13, 122, 76, 0.12);
}

textarea { min-height: 72px; resize: vertical; }
textarea.tall { min-height: 96px; }

select[multiple] {
  min-height: 120px;
  padding: 0.35rem;
  font-size: 0.84rem;
}

.help {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.2rem;
  line-height: 1.4;
}

.inline-check label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.88rem;
  color: var(--text);
  margin: 0;
}

/* —— Choice tabs —— */
.choice-tabs {
  display: inline-flex;
  gap: 0.25rem;
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
  background: var(--bg);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.choice-tab {
  padding: 0.35rem 0.8rem;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.84rem;
  font-family: inherit;
  color: var(--muted);
  font-weight: 500;
  transition: background 0.12s, color 0.12s;
}

.choice-tab:hover {
  color: var(--agri-green);
  background: var(--surface);
}

.choice-tab.active {
  background: var(--agri-green);
  color: #fff;
  box-shadow: 0 2px 6px rgba(13, 122, 76, 0.2);
}

.choice-panel { display: none; }
.choice-panel.active { display: block; }

.barem-picker-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

/* —— Alerts —— */
.alert {
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-md);
  font-size: 0.88rem;
}

.alert ul { margin: 0; padding-left: 1.15rem; }

.alert-success {
  background: #e8f5ef;
  border: 1px solid #a8d5bc;
  color: var(--agri-green-dark);
}

.alert-error {
  background: #fdecea;
  border: 1px solid #f5c2c0;
  color: #842029;
}

.alert-warn {
  background: #fff8e6;
  border: 1px solid #f0d78c;
  color: #7a5a00;
}

/* —— Tables —— */
.table-wrap {
  overflow-x: auto;
  margin: var(--space-sm) 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 0.65rem;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 600;
  background: #f4f8fb;
  font-size: 0.76rem;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fbfd; }

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}

.table-compact th,
.table-compact td { padding: 0.35rem 0.5rem; font-size: 0.84rem; }

.users-manage-intro { margin: 0 0 var(--space-sm); font-size: 0.86rem; }
.filter-bar--compact { margin-bottom: var(--space-sm); }
.users-manage-filters .field { min-width: 120px; max-width: 200px; }
.users-manage-filters .filter-bar-actions { min-width: auto; flex: 0 0 auto; }
.users-manage-table .col-cn {
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 600;
}
.users-manage-table .col-pb {
  min-width: 8rem;
  max-width: 14rem;
  font-size: 0.78rem;
  line-height: 1.35;
  white-space: normal;
}
.users-manage-table .col-email {
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
}
.users-manage-table .col-role { white-space: nowrap; }
.users-manage-table .col-name { max-width: 10rem; }
.users-manage-table .users-manage-actions {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.3rem;
}
.users-manage-table .users-manage-role-form {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  flex: 0 1 auto;
}
.users-manage-table .users-manage-role-form select {
  max-width: 8.5rem;
  min-width: 6.5rem;
  padding: 0.2rem 0.35rem;
  font-size: 0.78rem;
  height: auto;
  line-height: 1.3;
}
.users-manage-table .col-actions .btn-sm {
  padding: 0.2rem 0.45rem;
  font-size: 0.75rem;
  white-space: nowrap;
}

.col-actions {
  width: 1%;
  white-space: nowrap;
  text-align: right;
}

.form-inline { display: inline; margin: 0; }

.text-ok { color: var(--agri-green-dark); }
.text-muted { color: var(--muted); }
.text-warn { color: #c62828; }

/* —— Barem tables —— */
.barem-table { margin: 0; }

.barem-table th,
.barem-table td { padding: 0.4rem 0.5rem; }

.barem-table .col-stt { width: 2.25rem; text-align: center; }
.barem-table .col-ans { width: 4.5rem; text-align: center; }
.barem-table .col-diff { width: 5.5rem; }
.barem-table .col-weight { width: 4rem; }
.barem-table .col-act { width: 7rem; white-space: nowrap; }
.barem-table .col-check { width: 3.75rem; text-align: center; }

.barem-table textarea {
  min-height: 44px;
  padding: 0.35rem 0.45rem;
  font-size: 0.84rem;
  line-height: 1.35;
}

.barem-table input[type="number"],
.barem-table select {
  padding: 0.3rem 0.4rem;
  font-size: 0.84rem;
}

.barem-table label { margin: 0; font-size: 0.78rem; display: inline; }

.barem-add-row td { background: #f0f7f4; }

/* Barem editor — bảng rộng, thêm inline */
.barem-title-form {
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: var(--space-md);
}

.barem-table-editor {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}

.barem-table-editor .col-idx { text-align: center; vertical-align: middle; }
.barem-table-editor .col-diff { vertical-align: middle; }
.barem-table-editor .col-weight { vertical-align: middle; text-align: center; font-size: 0.8rem; }
.barem-table-editor .col-act { vertical-align: middle; }
.barem-table-editor .col-desc,
.barem-table-editor .col-desc-section,
.barem-table-editor .col-expl,
.barem-table-editor .col-options { vertical-align: middle; }

.barem-table-editor thead th {
  background: linear-gradient(180deg, #e8f3ee 0%, #d6ebe3 100%);
  color: #145a38;
  font-weight: 600;
  font-size: 0.78rem;
  padding: 0.45rem 0.4rem;
  border-bottom: 2px solid #9fcfb8;
  white-space: nowrap;
  text-align: left;
}

.barem-table-editor thead th.col-idx,
.barem-table-editor thead th.col-weight,
.barem-table-editor thead th.col-act {
  text-align: center;
}

.barem-table-editor tbody td {
  border-bottom: 1px solid #e4eaed;
  padding: 0.35rem 0.4rem;
}

.barem-table-editor tbody td + td {
  border-left: 1px solid #eef2f4;
}

/* Cấp 2 */
.barem-level-2-table col.col-idx { width: 5%; }
.barem-level-2-table col.col-desc { width: 40%; }
.barem-level-2-table col.col-expl { width: 40%; }
.barem-level-2-table col.col-act { width: 15%; }

/* Cấp 1 */
.barem-level-1-table col.col-idx { width: 6%; }
.barem-level-1-table col.col-desc { width: 38%; }
.barem-level-1-table col.col-options { width: 36%; }
.barem-level-1-table col.col-act { width: 14%; }

.barem-text-input,
.barem-table-editor .barem-text-input {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-height: 0;
  height: 1.65rem;
  padding: 0.2rem 0.4rem;
  font-size: 0.82rem;
  line-height: 1.3;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.barem-table-editor .barem-desc-section {
  font-weight: 600;
  background: #f5faf8;
}

.barem-row-section td {
  background: #e8f3ee;
  border-top: 2px solid #c5ddd2;
}

.barem-row-section .barem-idx-label {
  font-size: 1rem;
  color: var(--brand, #0d7a4c);
}

.barem-row-child .col-desc {
  padding-left: 1.25rem;
  border-left: 3px solid #d0e8dc;
}

.barem-parent-hint {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.barem-toolbar-oneline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.barem-toolbar-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  line-height: 1;
  font-size: 0.95rem;
}

.barem-table-editor .col-act {
  text-align: center;
  white-space: nowrap;
}

.barem-act-bar {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 0.2rem;
  align-items: center;
  justify-content: center;
}

/* Nút icon thao tác barem */
.btn-barem-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 5px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  vertical-align: middle;
  line-height: 0;
}

.btn-barem-ico:hover {
  transform: translateY(-1px);
}

.btn-barem-ico:active {
  transform: translateY(0);
}

.barem-ico-svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  display: block;
}

.btn-barem-ico--plus {
  background: #e8f5e9;
  color: #2e7d32;
  border-color: #a5d6a7;
}

.btn-barem-ico--plus:hover {
  background: #c8e6c9;
  border-color: #66bb6a;
}

.btn-barem-ico--section {
  background: #fff3e0;
  color: #e65100;
  border-color: #ffcc80;
}

.btn-barem-ico--section:hover {
  background: #ffe0b2;
  border-color: #ffb74d;
}

.btn-barem-ico--save {
  background: #e3f2fd;
  color: #1565c0;
  border-color: #90caf9;
}

.btn-barem-ico--save:hover {
  background: #bbdefb;
  border-color: #64b5f6;
}

.btn-barem-ico--delete {
  background: #ffebee;
  color: #c62828;
  border-color: #ef9a9a;
}

.btn-barem-ico--delete:hover {
  background: #ffcdd2;
  border-color: #e57373;
}

.btn-barem-ico--close {
  background: #f5f5f5;
  color: #616161;
  border-color: #e0e0e0;
}

.btn-barem-ico--close:hover {
  background: #eeeeee;
  border-color: #bdbdbd;
}

a.btn-barem-ico-link {
  text-decoration: none;
  flex-shrink: 0;
}

.btn-barem-txt,
.barem-act-bar .btn-barem-txt {
  padding: 0.1rem 0.25rem;
  font-size: 0.72rem;
  line-height: 1.2;
  white-space: nowrap;
  min-height: 0;
  border: none;
  background: transparent;
  box-shadow: none;
}

.barem-act-bar .barem-delete-form {
  display: inline;
  margin: 0;
}

.barem-delete-form { margin: 0; }

.barem-inline-add-row td {
  background: #fffbea;
  border-top: 2px dashed #e6c200;
  border-bottom: 2px dashed #e6c200;
  padding: 0.85rem 1rem;
}

.barem-inline-add-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.barem-inline-add-title { font-size: 0.95rem; }

.barem-inline-add-body .barem-inline-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--muted);
}

.barem-inline-meta {
  margin: 0.75rem 0 0.5rem;
  max-width: 12rem;
}

.barem-inline-options .barem-options-editor {
  margin-top: 0.5rem;
}

.barem-inline-add-foot {
  margin-top: 0.75rem;
  display: flex;
  gap: 0.5rem;
}

.barem-empty-cell {
  padding: 2rem 1rem !important;
  text-align: center;
}

.barem-footer-add-cell {
  padding: 0.65rem 0.5rem;
  background: #f8fafb;
}

.barem-table-wrap-fit {
  overflow-x: hidden;
  overflow-y: auto;
  max-height: min(65vh, 620px);
}

.barem-item-form-anchor {
  display: none;
}

.barem-l1-options-card {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.76rem;
  min-width: 0;
  padding: 0.25rem 0.35rem;
  background: #fafcf9;
  border: 1px solid #d4e8dc;
  border-radius: var(--radius-sm);
}

.barem-l1-b2-compact {
  margin-top: 0.2rem;
  padding-top: 0.25rem;
  border-top: 1px dashed #dce8e0;
}

.barem-l1-b2-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.4rem;
  margin-bottom: 0.2rem;
}

.barem-l1-b2-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.35rem;
  background: #e8f5ee;
  color: #145a38;
  border-radius: 3px;
}

.barem-l1-b2-name {
  font-size: 0.72rem;
  color: var(--muted);
}

.barem-l1-b2-mini-wrap {
  max-height: 4.5rem;
  overflow: auto;
  margin-bottom: 0.25rem;
}

.barem-l1-b2-mini {
  width: 100%;
  font-size: 0.7rem;
}

.barem-l1-b2-mini th,
.barem-l1-b2-mini td {
  padding: 0.12rem 0.25rem;
}

.barem-l1-b2-more {
  font-size: 0.68rem;
}

.barem-l1-b2-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.barem-l1-b2-draft-hint {
  margin: 0.15rem 0 0;
  font-size: 0.7rem;
}

.barem-modal {
  position: fixed;
  inset: 0;
  z-index: 1400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.barem-modal[hidden] {
  display: none !important;
}

.barem-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}

.barem-modal-panel {
  position: relative;
  z-index: 1;
  width: min(720px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.barem-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: #f4faf7;
  border-bottom: 1px solid #d4e8dc;
}

.barem-modal-heading {
  margin: 0;
  font-size: 1rem;
  color: #145a38;
}

.barem-modal-sub {
  margin: 0.15rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.barem-modal-close {
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0 0.25rem;
}

.barem-modal-body {
  padding: 0.75rem 0.85rem;
  overflow-y: auto;
}

.barem-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.75rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.barem2-modal-form .barem2-table-wrap {
  max-height: 50vh;
  overflow: auto;
}

body.barem-modal-open {
  overflow: hidden;
}

.barem-l1-apply-to {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.4rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px dashed #d4e8dc;
}

.barem-l1-context-text {
  font-weight: 600;
  color: #145a38;
  word-break: break-word;
}

.barem-l1-b2-zone {
  margin-top: 0.15rem;
  padding-top: 0.35rem;
  border-top: 1px solid #e8f0eb;
}

.barem-l1-b2-zone-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.8rem;
  color: #145a38;
}

.barem-l1-b2-hint {
  font-size: 0.72rem;
  font-weight: normal;
}

.barem-l1-b2-existing {
  margin-bottom: 0.4rem;
}

.barem-l1-b2-existing-label {
  font-size: 0.72rem;
  margin-bottom: 0.2rem;
}

.barem2-existing-table td {
  font-size: 0.74rem;
}

.barem2-quick--inline {
  padding: 0.35rem 0;
  background: #fffef8;
  border: 1px dashed #d0c89a;
  border-radius: var(--radius-sm);
}

.barem2-quick--inline .barem2-quick-head {
  padding: 0 0.35rem;
}

.barem2-inline-draft .barem2-quick-title {
  width: 100%;
  max-width: none;
  margin-bottom: 0.35rem;
}

.barem-l1-b2-draft-hint {
  margin: 0.35rem 0 0;
  font-size: 0.72rem;
}

.barem-inline-add-card {
  padding: 0.5rem 0.6rem;
  background: #fffef8;
  border: 1px dashed #c5b358;
  border-radius: var(--radius-sm);
}

.barem-inline-add-card--section {
  background: #f4faf7;
  border-color: #9fcfb8;
}

.barem-inline-add-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 0.4rem;
}

.barem-inline-add-top .barem-inline-desc {
  flex: 1 1 12rem;
  min-width: 0;
}

.barem-l1-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.45rem;
}

.barem-l1-row-correct .barem-l1-radios {
  flex: 1;
  min-width: 0;
}

.barem-level1-config {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  font-size: 0.8rem;
}

.barem-l1-label {
  color: var(--muted);
  white-space: nowrap;
  font-size: 0.75rem;
}

.barem-l1-sep {
  color: #ccc;
  user-select: none;
}

.barem-l1-radios {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.25rem 0.6rem;
}

.barem-l1-opt {
  font-size: 0.78rem;
  white-space: nowrap;
}

.barem2-select {
  width: 100%;
  max-width: 7.5rem;
  font-size: 0.72rem;
  padding: 0.15rem 0.25rem;
}

.barem-create-form {
  grid-template-columns: 1fr auto auto;
  align-items: end;
  gap: var(--space-md);
  max-width: 640px;
}

.barem-create-form .field-narrow { max-width: 6rem; }

.barem-page-header {
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
}

.barem-title-form-oneline {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 12rem;
  max-width: 28rem;
  margin: 0;
}

.barem-title-input {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.barem-meta-inline {
  font-size: 0.78rem;
  white-space: nowrap;
}

.page-header .page-actions {
  margin: 0;
}

.barem-inline-add-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}

.barem-inline-add-title {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 600;
}

.barem-inline-add-grid {
  display: grid;
  gap: 0.4rem;
}

.barem-inline-add-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.barem-inline-add-line .barem-text-input {
  flex: 1 1 8rem;
  min-width: 0;
}

.barem-inline-add-actions {
  flex: 0 0 auto;
}

.barem-inline-level1-wrap {
  flex: 1 1 100%;
  min-width: 0;
}

/* Barem cấp 2 — tạo nhanh một mối */
.barem2-quick-card {
  margin-bottom: var(--space-md);
  border: 1px solid #9fcfb8;
  background: #f4faf7;
}

.barem2-quick-toolbar {
  margin-bottom: 0.5rem;
}

.exam-correct-section {
  margin-top: var(--space-md);
}

.exam-correct-panel {
  margin-top: 0.5rem;
}

.exam-correct-panel-title {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.exam-correct-table .exam-correct-select {
  width: 100%;
  max-width: 12rem;
  font-size: 0.82rem;
}

/* Barem cấp 2 — bảng tạo / xem trước */
.barem-l1-b2-block {
  flex: 1 1 100%;
  min-width: 0;
  margin-top: 0.25rem;
}

.barem-l1-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem 0.45rem;
}

.barem-level1-config {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
}

.barem2-table-wrap {
  overflow-x: auto;
  max-height: 12rem;
  margin-top: 0.35rem;
}

.barem2-quick-table,
.barem2-preview-table {
  width: 100%;
  table-layout: fixed;
  font-size: 0.8rem;
}

.barem2-quick-table .col-b2-idx,
.barem2-preview-table .col-b2-idx {
  width: 2rem;
  text-align: center;
}

.barem2-quick-table .col-b2-desc,
.barem2-preview-table .col-b2-desc {
  width: 42%;
}

.barem2-quick-table .col-b2-expl,
.barem2-preview-table .col-b2-expl {
  width: 42%;
}

.barem2-quick-table .col-b2-act {
  width: 2.5rem;
  text-align: center;
}

.barem2-quick-table .barem-text-input {
  width: 100%;
  font-size: 0.78rem;
}

.barem2-table-foot {
  margin-top: 0.35rem;
}

.barem2-preview-box {
  margin-top: 0.35rem;
  padding: 0.4rem 0.5rem;
  background: #f8fbfd;
  border: 1px solid #d8e4ea;
  border-radius: var(--radius-sm);
}

.barem2-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.barem2-preview-title {
  font-size: 0.8rem;
  color: #145a38;
}

.barem2-preview-empty {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
}

.barem2-create-panel,
.barem2-quick-row-panel {
  margin-top: 0.35rem;
  padding: 0.45rem;
  background: linear-gradient(180deg, #fffef8 0%, #fffbea 100%);
  border: 1px solid #e0d4a8;
  border-radius: var(--radius-sm);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.barem2-create-panel .barem2-quick {
  padding: 0.35rem 0.4rem;
}

.barem2-create-panel .barem2-quick-head {
  margin-bottom: 0.25rem;
}

.barem2-create-panel .barem2-quick-table {
  font-size: 0.76rem;
}

.barem2-quick-head .barem2-quick-title {
  flex: 1;
  min-width: 8rem;
  max-width: 14rem;
}

.col-options .barem-level1-config {
  font-size: 0.78rem;
}

.barem2-quick {
  padding: 0.65rem 0.75rem;
}

.barem2-quick-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.4rem;
}

.barem2-quick-label {
  font-size: 0.85rem;
  color: #145a38;
}

.barem2-quick-hint {
  font-size: 0.72rem;
}

.barem2-quick-hint code {
  font-size: 0.7rem;
  background: #fff;
  padding: 0.05rem 0.25rem;
  border-radius: 3px;
}

.barem2-quick-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: flex-start;
}

.barem2-quick-title {
  flex: 1 1 12rem;
  min-width: 8rem;
  max-width: 16rem;
}

.barem2-quick-text {
  flex: 1 1 100%;
  width: 100%;
  min-height: 4.5rem;
  padding: 0.4rem 0.5rem;
  font-size: 0.82rem;
  line-height: 1.4;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  resize: vertical;
}

.barem2-quick--compact .barem2-quick-text {
  min-height: 2.5rem;
}

.btn-barem2-quick-submit {
  flex: 0 0 auto;
  align-self: flex-end;
}

.barem2-quick-row-panel {
  margin-top: 0.35rem;
  padding: 0.4rem;
  background: #fffbea;
  border: 1px dashed #c5b358;
  border-radius: var(--radius-sm);
}

.barem2-quick-row-panel .barem2-quick {
  padding: 0.35rem;
}

.barem2-quick-create-block {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px dashed var(--border);
}

.attempt-barem2-panel {
  margin-top: 0.35rem;
  padding: 0.5rem;
  background: #f5faf7;
  border: 1px solid #c5ddd2;
  border-radius: 6px;
}

.attempt-b2-table { font-size: 0.82rem; }
.attempt-b2-table input[type="text"] { width: 100%; min-width: 6rem; }

.quick-barem-toolbar,
.barem-editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
  font-size: 0.88rem;
}

.barem-editor-toolbar h2 {
  margin: 0;
  font-size: 1rem;
}

/* —— Dashboard stats —— */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: var(--space-md) var(--space-lg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.12s;
}

a.stat-card:hover {
  border-color: var(--agri-green);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
  text-decoration: none;
}

.stat-card__value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--agri-green);
}

.stat-card--warn .stat-card__value { color: #b36b00; }
.stat-card--ok .stat-card__value { color: var(--agri-green-dark); }

.stat-card__label {
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}

.dash-role-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  background: var(--agri-green);
  color: #fff;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.dash-quick h2 {
  font-size: 0.95rem;
  margin: 0 0 var(--space-sm);
}

.dash-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

/* —— Barem editor polish —— */
.barem-intro-card { max-width: 640px; }

.barem-page-header .barem-meta-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.chip {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  background: var(--agri-green-soft);
  border: 1px solid #b8dfc8;
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--agri-green-dark);
}

.chip-sm { font-size: 0.72rem; padding: 0.12rem 0.45rem; }

.barem-editor-card,
.barem-quick-card {
  border: 1px solid var(--border);
}

.barem-editor-card .table-wrap.barem-table-wrap-fit {
  overflow-x: hidden;
}

.barem-table-editor thead th {
  overflow: hidden;
  text-overflow: ellipsis;
}

.barem-table-editor .barem-difficulty-select {
  width: 100%;
  max-width: 100%;
  font-size: 0.72rem;
  padding: 0.15rem 0.2rem;
}

.barem-level1-config .barem-l1-opt {
  font-size: 0.7rem;
}

.barem-row-existing:nth-child(even) td { background: #f8fbfd; }

.barem-empty-cell {
  text-align: center;
  padding: var(--space-xl) !important;
  color: var(--muted);
}

.barem-empty-cell p { margin: 0; }

.barem-add-row td {
  background: #eef7f1 !important;
  border-top: 2px solid var(--agri-green);
}

.barem-add-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--agri-green);
  color: #fff;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 700;
}

.barem-check-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.78rem;
  margin: 0;
}

.barem-check-pill:has(input:checked) {
  background: var(--agri-green-soft);
  border-color: #a8d5bc;
  color: var(--agri-green-dark);
}

.barem-check-pill input { margin: 0; }

.barem-difficulty-select {
  width: 100%;
  min-width: 5rem;
}

.barem-picker-section .barem-picker-panel {
  padding: var(--space-md);
  background: #f8fbfd;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: var(--space-sm);
}

.barem-picker-section .input-lg {
  font-size: 0.92rem;
  padding: 0.5rem 0.65rem;
}

/* —— Gán thí sinh: 3 bảng riêng —— */
.assign-summary {
  margin-bottom: var(--space-md);
}

.assign-count-badge {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  background: var(--agri-green-soft);
  border: 1px solid #a8d5bc;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  color: var(--agri-green-dark);
}

.assign-count-badge strong {
  font-size: 1.15rem;
  color: var(--agri-green);
}

.assign-panels {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(180px, 1.2fr) minmax(220px, 1.6fr);
  gap: var(--space-md);
  align-items: start;
}

.assign-panel h3 {
  font-size: 0.92rem;
  margin: 0 0 var(--space-sm);
  color: var(--agri-green-dark);
}

.assign-panel-users h3 .help {
  font-weight: normal;
  font-size: 0.78rem;
}

.assign-user-toolbar {
  margin-bottom: var(--space-sm);
  font-size: 0.84rem;
}

.assign-table-wrap {
  max-height: min(48vh, 420px);
  overflow: auto;
}

.assign-table-wrap-users {
  max-height: min(52vh, 460px);
}

.assign-table .col-check {
  width: 2.25rem;
  text-align: center;
  vertical-align: middle;
}

.assign-table .col-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* —— Exam layout —— */
.exam-layout { margin-bottom: var(--space-md); }

.grid-2 {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: var(--space-lg);
  align-items: start;
}

.exam-layout .card { margin-bottom: 0; }

.exam-layout .card h2 { margin-bottom: var(--space-sm); }

.exam-layout .pdf-pane {
  min-height: 0;
  height: calc(100vh - 8rem);
  max-height: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #1a2332;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.exam-layout iframe {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border: 0;
  display: block;
}

.exam-form-sticky {
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
  padding-right: 0.25rem;
}

.exam-submit-bar {
  position: sticky;
  bottom: 0;
  background: linear-gradient(transparent, var(--surface) 28%);
  padding-top: var(--space-md);
  margin-top: var(--space-sm);
}

.tabs {
  display: flex;
  gap: 0.3rem;
  margin-bottom: var(--space-sm);
}

.tabs button {
  flex: 1;
  padding: 0.45rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  transition: background 0.12s, border-color 0.12s;
}

.tabs button.active {
  background: var(--agri-green);
  color: #fff;
  border-color: var(--agri-green);
}

.pane-mobile { display: none; }
.pane-mobile.active { display: block; }

/* —— Auth —— */
.auth-wrap {
  max-width: 420px;
  margin: var(--space-2xl) auto;
  padding: 0 var(--space-md);
}

.auth-wrap .card,
.auth-card {
  padding: var(--space-xl) var(--space-2xl);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.auth-card-head {
  margin-bottom: var(--space-lg);
  text-align: center;
}

.auth-card-head h1 {
  margin-bottom: var(--space-xs);
  font-size: 1.35rem;
}

.auth-card-head .help {
  margin: 0;
  font-size: 0.88rem;
}

/* —— Dashboard meta —— */
.dash-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm) var(--space-lg);
  font-size: 0.86rem;
  color: var(--muted);
  margin-bottom: var(--space-sm);
}

.dash-meta strong { color: var(--text); }

/* —— Filters bar —— */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: flex-end;
  margin-bottom: var(--space-md);
}

.filter-bar .field { min-width: 140px; flex: 1; }

/* —— Pagination (Laravel default) —— */
.pagination {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  list-style: none;
  padding: var(--space-md) 0 0;
  margin: 0;
}

.pagination li a,
.pagination li span {
  display: block;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
}

.pagination li.active span,
.pagination li a:hover {
  background: var(--agri-green-soft);
  border-color: var(--agri-green);
}

/* —— Lịch đề thi —— */
.exam-schedule-block { margin: var(--space-md) 0; }
.form-subtitle { font-size: 1rem; margin: 0 0 var(--space-sm); color: var(--agri-green-dark); }
.schedule-presets { flex-wrap: wrap; margin-bottom: var(--space-md); gap: var(--space-sm); }
.schedule-grid { grid-template-columns: repeat(2, 1fr); }
.schedule-preview { margin-top: var(--space-sm); font-weight: 500; color: var(--agri-green); }
.chip-open { background: var(--agri-green-soft); color: var(--agri-green-dark); border: 1px solid var(--agri-green-light); }
.chip-warn { background: #fff8e6; color: #8a6d00; border: 1px solid #e6d48a; }
.chip-muted { background: #eef2f6; color: var(--muted); border: 1px solid var(--border); }

.tick-choices { display: flex; flex-direction: column; gap: 0.4rem; min-width: 7.5rem; }
.tick-choice { display: flex; align-items: center; gap: 0.4rem; font-size: 0.86rem; cursor: pointer; white-space: nowrap; }
.tick-choice input { margin: 0; }

/* —— Chấm rọc phách —— */
.grading-item-card { margin-bottom: var(--space-lg); }
.grading-item-head { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.grading-item-desc { margin: 0 0 var(--space-sm); }
.grading-mc-compare {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  margin-bottom: var(--space-md);
}
.grading-mc-compare--match {
  background: #e8f5e9;
  border-color: #81c784;
}
.grading-mc-compare--mismatch {
  background: #ffebee;
  border-color: #e57373;
}
.grading-mc-compare--compact {
  margin-bottom: 0;
  padding: var(--space-xs) var(--space-sm);
}
.grading-mc-compare-title {
  margin: 0 0 var(--space-xs);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
}
.grading-mc-compare-line {
  margin: 0.2rem 0;
  font-size: 0.92rem;
}
.chip-ok {
  background: #c8e6c9;
  color: #1b5e20;
}
.grading-manual-block {
  background: var(--agri-green-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}
.grading-manual-block h3 { margin: 0 0 var(--space-sm); font-size: 0.98rem; color: var(--agri-green-dark); }
.grading-auto-ref {
  background: #f4f7fa;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
}
.grading-auto-ref h3 { margin: 0 0 var(--space-sm); font-size: 0.92rem; color: var(--muted); }
.auto-ref-scores { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.sim-compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-md); }
.sim-compare-col h4 { margin: 0 0 var(--space-xs); font-size: 0.86rem; color: var(--muted); }
.sim-text-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: var(--space-sm);
  font-size: 0.92rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 12rem;
  overflow-y: auto;
}
mark.sim-highlight {
  background: #ffe566;
  color: inherit;
  padding: 0 0.1em;
  border-radius: 2px;
}
.grading-summary-card { margin-top: var(--space-lg); border: 2px solid var(--agri-green-light); }
.grading-live-total { font-size: 1.1rem; margin: var(--space-sm) 0; }

.detail-warning-banner {
  color: #8a6d00;
  background: #fff8e6;
  padding: 0.55rem;
  border-radius: var(--radius-sm);
}
.attempt-detail-table .th-sub {
  font-weight: normal;
  font-size: 0.76rem;
  color: var(--muted);
}
.attempt-detail-table .detail-desc-cell {
  min-width: 10rem;
  max-width: 18rem;
}
.attempt-detail-table .detail-mc-cell,
.attempt-detail-table .detail-expl-cell {
  min-width: 9rem;
  vertical-align: top;
}
.attempt-detail-table .detail-subline {
  margin-bottom: 0.35rem;
}
.attempt-detail-table .detail-subline:last-child {
  margin-bottom: 0;
}

/* —— Barem options & criteria —— */
.barem-item-card {
  margin-bottom: var(--space-lg);
  border: 1px solid var(--border);
  position: relative;
}
.barem-item-card--new { border-style: dashed; }
.barem-item-card-head {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  margin-bottom: var(--space-sm);
}
.barem-item-num { font-weight: 600; color: var(--agri-green-dark); }
.barem-item-delete {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--border);
}
.barem-options-editor {
  margin: var(--space-md) 0;
  padding: var(--space-md);
  background: var(--agri-green-soft);
  border-radius: var(--radius-sm);
}
.barem-options-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}
.barem-option-block {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px dashed var(--border);
}
.barem-option-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.barem-option-row {
  display: grid;
  grid-template-columns: 1fr 8rem auto auto;
  gap: var(--space-sm);
  align-items: center;
}
.barem-opt-label { width: 100%; }
.barem-criteria-panel { margin-top: var(--space-sm); padding-left: var(--space-md); }
.barem-criteria-panel.is-hidden { display: none; }
.barem-criterion-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: var(--space-sm);
  margin-bottom: var(--space-xs);
}
.barem-criteria-preview { margin: 0; padding-left: 1.2rem; font-size: 0.86rem; }
.attempt-criteria-fields { margin-top: 0.35rem; }
.attempt-criteria-fields.is-hidden { display: none; }
.attempt-criterion-field { margin-bottom: 0.35rem; }
.attempt-criterion-field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}
.criterion-compare-block {
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}

.attempt-detail-table .detail-lbl {
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--muted);
  display: inline-block;
  min-width: 4.5rem;
}
.attempt-detail-table .detail-expl-body {
  display: inline;
  white-space: pre-wrap;
  word-break: break-word;
}
.attempt-detail-table .detail-student-expl .chip {
  display: inline-block;
  margin-left: 0.25rem;
  vertical-align: middle;
}
.attempt-detail-table .detail-max-cell {
  white-space: nowrap;
  text-align: center;
}
.attempt-detail-table .detail-max-split {
  display: block;
  font-size: 0.76rem;
  margin-top: 0.15rem;
}
.attempt-detail-table .detail-score-cell {
  text-align: center;
  white-space: nowrap;
}
.attempt-detail-table .detail-manual-score strong {
  color: var(--agri-green-dark);
}

/* —— Legacy topbar (backward compatibility) —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 400;
  background: linear-gradient(135deg, var(--agri-green-dark), var(--agri-green));
  color: #fff;
  min-height: var(--topbar-h);
  padding: 0 var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-md);
  box-shadow: var(--shadow-md);
}

.topbar-inner {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
  min-width: 0;
}

.topbar img.logo {
  height: 32px;
  width: auto;
  display: block;
  flex-shrink: 0;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.35rem 0.55rem;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}

.nav-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.4rem;
  flex: 1;
  justify-content: flex-end;
  min-width: 0;
}

.nav-link,
.nav-dropdown-toggle {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.86rem;
  padding: 0.35rem 0.55rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.nav-link:hover,
.nav-dropdown-toggle:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.14);
  text-decoration: none;
}

.nav-dropdown { position: relative; }

.nav-dropdown-toggle {
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 200px;
  padding: 0.35rem 0;
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border);
  z-index: 500;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu { display: block; }

.nav-dropdown-section {
  padding: 0.4rem 0.85rem 0.15rem;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 600;
}

.nav-dropdown-menu a {
  display: block;
  padding: 0.45rem 0.85rem;
  color: var(--agri-green-dark);
  font-size: 0.86rem;
}

.nav-dropdown-menu a:hover {
  background: var(--agri-green-soft);
  text-decoration: none;
}

/* —— Large desktop —— */
@media (min-width: 1100px) {
  .form-grid-dense {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

/* —— Tablet: sidebar overlay —— */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .app-shell.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-main {
    margin-left: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .form-grid,
  .form-grid-3,
  .form-grid-dense { grid-template-columns: 1fr 1fr; }
  .field-span-2 { grid-column: span 2; }
  .grid-2 { grid-template-columns: 1fr; }

  .exam-layout .pdf-pane {
    height: 50vh;
    max-height: none;
  }

  .exam-form-sticky {
    max-height: none;
    overflow: visible;
  }

  .assign-panels {
    grid-template-columns: 1fr 1fr;
  }

  .assign-panel-users {
    grid-column: 1 / -1;
  }
}

/* —— Mobile —— */
@media (max-width: 768px) {
  html { font-size: 13px; }

  .app-topbar {
    padding: 0 var(--space-md);
  }

  .app-content,
  .guest-main {
    padding: var(--space-md);
  }

  .page-hero {
    padding: var(--space-lg);
  }

  .page-hero-title {
    font-size: 1.35rem;
  }

  .card {
    padding: var(--space-md);
  }

  .form-grid,
  .form-grid-3,
  .form-grid-dense,
  .field-span-2 {
    grid-column: span 1;
    grid-template-columns: 1fr;
  }

  select[multiple] { min-height: 96px; }

  .page-header {
    flex-direction: column;
    align-items: stretch;
  }

  .exam-layout .desktop-split { display: none; }
  .pane-mobile { display: none; }
  .pane-mobile.active { display: block; }

  .barem-table .col-weight,
  .barem-table .col-diff { min-width: 4.5rem; }

  .sim-compare-grid { grid-template-columns: 1fr; }

  .barem-option-row {
    grid-template-columns: 1fr;
  }

  .auth-wrap .card,
  .auth-card {
    padding: var(--space-lg);
  }
}

@media (max-width: 640px) {
  .assign-panels {
    grid-template-columns: 1fr;
  }

  .schedule-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .btn-group .btn {
    flex: 1;
    min-width: calc(50% - 0.25rem);
  }

  .guest-header-inner {
    flex-wrap: wrap;
    padding: var(--space-sm) var(--space-md);
  }
}
