/* =============================================================================
   V2 Admin — Component classes (BEM-ish, semantic).
   Built on tokens.css. NO Tailwind utility classes used in component bodies —
   all design tokens. Keeps components portable + theme-aware.
   ============================================================================= */

/* ── Layout primitives ──────────────────────────────────────────────────── */

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--background);
}

.app-sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--duration) var(--ease-out);
}

.app-sidebar[data-collapsed="true"] { width: 56px; }
.app-sidebar[data-collapsed="true"] .sidebar-item-label,
.app-sidebar[data-collapsed="true"] .sidebar-section,
.app-sidebar[data-collapsed="true"] .sidebar-tenant,
.app-sidebar[data-collapsed="true"] .sidebar-meta { display: none; }

/* Top row: logo (left) + compact ☰ toggle (right) — icon only, no label. */
.sidebar-top {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-default);
}
.sidebar-top .sidebar-brand { flex: 1; min-width: 0; padding: 0; border-bottom: none; }
.sidebar-collapse-btn {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 36px; height: 36px; padding: 0; margin: 0;
  background: transparent; border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  color: var(--text-secondary); cursor: pointer;
  transition: background var(--duration) var(--ease-out), color var(--duration) var(--ease-out);
}
.sidebar-collapse-btn:hover { background: var(--surface-hover); color: var(--viasm-red); }
/* Khi gập (56px): ẩn logo, chỉ còn ☰ căn giữa trên cùng. */
.app-sidebar[data-collapsed="true"] .sidebar-top { justify-content: center; padding: var(--space-3) 0; }
.app-sidebar[data-collapsed="true"] .sidebar-brand { display: none; }

.app-main {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.app-content {
  max-width: 1200px;
  margin: 0 auto;
}

/* ── Sidebar internals ──────────────────────────────────────────────────── */

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;            /* center logo (text removed) */
  padding: var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--border-default);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration) var(--ease-out);
}
.sidebar-brand:hover { background: var(--surface-hover); }
.sidebar-brand:focus-visible {
  outline: 2px solid var(--viasm-red);
  outline-offset: -2px;
}
/* VIASM logo image (1005×283 icosahedron + wordmark) */
.sidebar-brand .brand-logo-img {
  height: 38px;
  width: auto;
  display: block;
  flex-shrink: 0;
}
:root[data-theme="dark"] .sidebar-brand .brand-logo-img {
  filter: brightness(1.05);
}

.sidebar-tenant {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
}
.sidebar-tenant-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-1);
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-2);
  overflow-y: auto;
}

.sidebar-section {
  padding: var(--space-3) var(--space-3) var(--space-1);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  font-weight: var(--weight-semibold);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-body-sm);
  color: var(--text-secondary);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out);
}
.sidebar-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.sidebar-item.active {
  background: var(--brand-50);     /* red-50 sau realias */
  color: var(--brand-700);          /* red-dark text */
  font-weight: var(--weight-medium);
  position: relative;
}
.sidebar-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px; bottom: 6px;
  width: 3px;
  background: var(--viasm-red);     /* VIASM logo red left bar */
  border-radius: 0 2px 2px 0;
}
:root[data-theme="dark"] .sidebar-item.active {
  background: rgba(196, 30, 58, 0.18);
  color: var(--brand-700);
}
.sidebar-item .icon { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-item-label { flex: 1; }
.sidebar-badge {
  background: var(--warning-500);
  color: white;
  font-size: 10px;
  font-weight: var(--weight-semibold);
  padding: 1px 6px;
  border-radius: 9999px;
  min-width: 18px;
  text-align: center;
}
.sidebar-badge.hidden { display: none; }

/* Khi gập: icon căn giữa; badge "18" co thành chấm nhỏ ở góc icon (hết lòi cục vàng). */
.app-sidebar[data-collapsed="true"] .sidebar-item { justify-content: center; position: relative; }
.app-sidebar[data-collapsed="true"] .sidebar-badge {
  position: absolute; top: 3px; right: 9px;
  width: 9px; height: 9px; min-width: 0; padding: 0;
  font-size: 0; line-height: 0; border-radius: 50%;
}

.sidebar-meta {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-default);
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Page header ────────────────────────────────────────────────────────── */

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
.page-title {
  font-family: var(--font-serif);   /* VIASM academic heading — match chat + knowledge module */
  font-size: var(--font-h1);
  line-height: var(--lh-h1);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  display: flex; align-items: center; gap: var(--space-3);
}
.page-title .icon { width: 24px; height: 24px; color: var(--text-muted); }
.page-subtitle {
  font-size: var(--font-body-sm);
  color: var(--text-muted);
  margin-top: var(--space-1);
}
.page-actions { display: flex; gap: var(--space-2); align-items: center; flex-wrap: wrap; }

.breadcrumb {
  display: flex; align-items: center; gap: var(--space-2);
  font-size: var(--font-body-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text-primary); }
.breadcrumb .separator { color: var(--text-subtle); }

/* ── Buttons (4 variants × 3 sizes) ─────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-3);
  height: 32px;
  border-radius: var(--radius-sm);
  font-size: var(--font-body-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--duration-fast) var(--ease-out), color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; pointer-events: none; }
.btn .icon { width: 14px; height: 14px; }

.btn-sm { height: 26px; padding: 0 var(--space-2); font-size: var(--font-caption); }
.btn-sm .icon { width: 12px; height: 12px; }
.btn-lg { height: 40px; padding: 0 var(--space-4); font-size: var(--font-body); }

.btn-primary {
  background: var(--brand-600);
  color: white;
  border-color: var(--brand-600);
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--brand-700); border-color: var(--brand-700); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background: var(--surface-hover); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--surface);
  color: var(--text-danger);
  border-color: var(--danger-100);
}
.btn-danger:hover { background: var(--danger-50); border-color: var(--danger-500); }

.btn-danger-solid {
  background: var(--danger-600);
  color: white;
  border-color: var(--danger-600);
}
.btn-danger-solid:hover { background: var(--danger-700); border-color: var(--danger-700); }

/* Icon-only button */
.btn-icon { width: 32px; padding: 0; flex-shrink: 0; }
.btn-icon.btn-sm { width: 26px; }

/* ── Inputs ─────────────────────────────────────────────────────────────── */

.input, select.input, textarea.input,
input[type="text"], input[type="number"], input[type="search"], input[type="email"], input[type="url"], input[type="password"],
select, textarea {
  display: inline-block;
  width: 100%;
  /* Without this, width:100% is CONTENT width and the horizontal padding pushes the
     real width past the container — in the 2-col add-user form the two inputs
     overflowed their grid tracks and overlapped ("hai ô bị đè nhau"). */
  box-sizing: border-box;
  padding: 0 var(--space-3);
  height: 32px;
  background: var(--surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  font-size: var(--font-body-sm);
  font-family: var(--font-sans);
  transition: border-color var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
textarea, textarea.input { padding: var(--space-2) var(--space-3); height: auto; line-height: var(--lh-body); font-family: var(--font-mono-stack); }
.input:focus, input:focus, select:focus, textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgb(196 30 58 / 0.15); outline: none; }
.input:disabled { background: var(--surface-sunken); color: var(--text-muted); cursor: not-allowed; }
.input-sm { height: 26px; padding: 0 var(--space-2); font-size: var(--font-caption); }

label.field-label {
  display: block;
  font-size: var(--font-caption);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  margin-bottom: var(--space-1);
}
.field-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: var(--space-1);
  line-height: 1.4;
}

/* ── Cards ──────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card-clickable { cursor: pointer; transition: box-shadow var(--duration) var(--ease-out), transform var(--duration) var(--ease-out); }
.card-clickable:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Overview hero CTA → Knowledge (most-used feature; land + click straight in) */
.ov-hero {
  display: flex; align-items: center; gap: var(--space-4);
  background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
  color: #fff; text-decoration: none;
  border-radius: var(--radius-lg); padding: 20px 24px; margin-bottom: var(--space-6);
  box-shadow: 0 6px 18px -6px rgba(150, 20, 40, .45);
  transition: transform var(--duration-fast) var(--ease-out), box-shadow var(--duration-fast) var(--ease-out);
}
.ov-hero:hover { transform: translateY(-2px); box-shadow: 0 10px 26px -6px rgba(150, 20, 40, .55); }
.ov-hero:active { transform: translateY(0); }
.ov-hero-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 50px; height: 50px; border-radius: 14px;
  background: rgba(255, 255, 255, .18); flex-shrink: 0;
}
.ov-hero-body { flex: 1; min-width: 0; }
.ov-hero-title { display: block; font-family: var(--font-serif, inherit); font-size: 20px; font-weight: 700; line-height: 1.2; }
.ov-hero-sub { display: block; font-size: 13.5px; opacity: .92; margin-top: 4px; }
.ov-hero-cta {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; color: var(--brand-700); font-weight: 600; font-size: 14px;
  padding: 10px 18px; border-radius: var(--radius-md); flex-shrink: 0; white-space: nowrap;
}
@media (max-width: 640px) {
  .ov-hero { flex-wrap: wrap; }
  .ov-hero-cta { width: 100%; justify-content: center; }
}

/* Overview daily chat-volume bar chart */
.cv-chart { display: flex; align-items: stretch; gap: 6px; height: 180px; padding-top: 4px; }
.cv-col {
  flex: 1 1 0; min-width: 0; height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px;
}
.cv-count { font-size: 11px; font-weight: 600; color: var(--text-secondary); font-variant-numeric: tabular-nums; min-height: 14px; line-height: 1; }
.cv-bar-wrap { flex: 1 1 auto; width: 100%; display: flex; align-items: flex-end; min-height: 0; }
.cv-bar {
  width: 100%; border-radius: 5px 5px 0 0; min-height: 3px;
  background: linear-gradient(180deg, var(--brand-500), var(--brand-600));
  transition: height .55s var(--ease-out);
}
.cv-bar.zero { background: var(--border-default); min-height: 2px; }
.cv-col:hover .cv-bar:not(.zero) { background: linear-gradient(180deg, var(--brand-600), var(--brand-700)); }
.cv-day { font-size: 10.5px; color: var(--text-muted); white-space: nowrap; line-height: 1; }

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.card-title {
  font-family: var(--font-serif);   /* VIASM academic heading */
  font-size: var(--font-h3);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  display: flex; align-items: center; gap: var(--space-2);
}
.card-title .icon { width: 16px; height: 16px; color: var(--text-muted); }

/* Stat card variant */
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}
.stat-label {
  font-size: var(--font-caption);
  color: var(--text-muted);
  font-weight: var(--weight-medium);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: var(--space-1);
}
.stat-value {
  font-size: 28px;
  line-height: 32px;
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.stat-delta { font-size: var(--font-caption); margin-top: var(--space-1); }
.stat-delta.up { color: var(--text-success); }
.stat-delta.down { color: var(--text-danger); }

/* ── Badges ─────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  line-height: 16px;
  font-weight: var(--weight-medium);
  white-space: nowrap;
}
.badge .icon { width: 10px; height: 10px; }
.badge-default { background: var(--surface-sunken); color: var(--text-secondary); border: 1px solid var(--border-default); }
.badge-success { background: var(--success-50); color: var(--success-700); }
.badge-warning { background: var(--warning-50); color: var(--warning-700); }
.badge-danger  { background: var(--danger-50); color: var(--danger-700); }
.badge-info    { background: var(--info-50); color: var(--info-700); }
.badge-brand   { background: var(--brand-50); color: var(--brand-700); }
:root[data-theme="dark"] .badge-success { background: rgba(16, 185, 129, 0.15); color: var(--success-500); }
:root[data-theme="dark"] .badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning-500); }
:root[data-theme="dark"] .badge-danger  { background: rgba(239, 68, 68, 0.15); color: var(--danger-500); }
:root[data-theme="dark"] .badge-info    { background: rgba(59, 130, 246, 0.15); color: var(--info-500); }
:root[data-theme="dark"] .badge-brand   { background: rgba(74, 85, 200, 0.18); color: var(--brand-300); }

/* ── Toggle switch ──────────────────────────────────────────────────────── */

.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--gray-300);
  border: none;
  cursor: pointer;
  transition: background var(--duration) var(--ease-out);
  flex-shrink: 0;
  vertical-align: middle;
}
:root[data-theme="dark"] .toggle { background: var(--gray-700); }
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration) var(--ease-out);
}
.toggle[aria-checked="true"] { background: var(--brand-600); }
.toggle[aria-checked="true"]::after { transform: translateX(16px); }
.toggle:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 2px; }
.toggle:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Tables ─────────────────────────────────────────────────────────────── */

/* Settings tables (.table) had no width rule → defaulted to auto-width and bunched
   to the left when content was short (e.g. the "Chờ duyệt" queue). Fill the row. */
.table { width: 100%; }
.table-wrap { width: 100%; overflow-x: auto; }
/* Header text-align defaults to center for <th>; cell content is left-aligned, so
   at full width the headers drift out of line with their column. Left-align them
   (a per-th inline text-align:right, e.g. the "Thao tác" column, still wins). */
.table th { text-align: left; }

.data-table { width: 100%; border-collapse: collapse; font-size: var(--font-body-sm); }
.data-table thead {
  position: sticky; top: 0;
  background: var(--surface-sunken);
  z-index: var(--z-sticky);
}
.data-table th {
  text-align: left;
  padding: var(--space-2) var(--space-3);
  font-weight: var(--weight-medium);
  font-size: var(--font-caption);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-default);
}
.data-table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--border-default);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-default);
  margin-bottom: var(--space-5);
}
.tab {
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-body-sm);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
  background: none;
  border-top: none; border-left: none; border-right: none;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--text-brand); border-bottom-color: var(--brand-600); }

/* ── Skeleton loader ────────────────────────────────────────────────────── */

@keyframes skeleton-shimmer {
  0% { background-position: -1000px 0; }
  100% { background-position: 1000px 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--surface-sunken) 0%, var(--gray-200) 50%, var(--surface-sunken) 100%);
  background-size: 1000px 100%;
  animation: skeleton-shimmer 2s infinite linear;
  border-radius: var(--radius-sm);
  display: block;
}
:root[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, var(--gray-800) 0%, var(--gray-700) 50%, var(--gray-800) 100%);
}
.skeleton-text { height: 14px; margin-bottom: var(--space-2); }
.skeleton-text-lg { height: 20px; }
.skeleton-card { height: 80px; }
.skeleton-stat { height: 60px; }

/* ── Modal / overlay ────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.45);
  backdrop-filter: blur(2px);
  z-index: var(--z-modal);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space-4);
  animation: fade-in var(--duration) var(--ease-out);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  /* Never exceed the viewport (overlay has space-4 padding top+bottom). A tall
     form scrolls inside .modal-body while header + footer stay pinned, so the
     action buttons are always reachable. */
  max-height: calc(100vh - 2 * var(--space-4));
  display: flex;
  flex-direction: column;
  animation: scale-in var(--duration) var(--ease-out);
}
.modal-lg { max-width: 600px; }
.modal-header {
  padding: var(--space-5) var(--space-5) var(--space-3);
  flex-shrink: 0;
}
.modal-title {
  font-family: var(--font-serif);   /* VIASM academic heading — match page/card titles */
  font-size: var(--font-h2);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
.modal-body {
  padding: 0 var(--space-5) var(--space-4);
  font-size: var(--font-body-sm);
  color: var(--text-secondary);
  overflow-y: auto;        /* long forms scroll here */
  flex: 1 1 auto;
  min-height: 0;           /* required so the flex child can shrink + scroll */
}
.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--space-2);
  padding: var(--space-3) var(--space-5) var(--space-5);
  flex-shrink: 0;          /* buttons stay pinned + always visible */
  border-top: 1px solid var(--border-subtle, var(--border-default));
}
.modal-xl { max-width: 880px; }

/* ── Document content reading modal (click "Xem nội dung" in doc drawer) ── */
.k-content-open-btn {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  margin-top: 4px;
}
.k-content-modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
}
.k-content-modal-body {
  min-height: 55vh;        /* show large even for short docs */
}
/* The modal body owns a single scrollbar — let the text flow to full height
   (override the inline preview's own max-height/scroll). */
.k-content-modal-body .k-preview-text,
.k-content-modal-body .k-preview-text-extracted {
  max-height: none;
  font-size: 13.5px;
  line-height: 1.7;
}
.k-content-modal-body .k-preview-pdf { width: 100%; height: 70vh; border: 0; }
.k-content-modal .k-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; flex-shrink: 0;
  border: none; background: transparent; border-radius: var(--radius-md);
  cursor: pointer; color: var(--text-secondary);
  transition: background .14s, color .14s;
}
.k-content-modal .k-icon-btn:hover { background: var(--border-subtle, rgba(0,0,0,.06)); color: var(--text-primary); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes scale-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: scale(1); } }

/* ── Toast ──────────────────────────────────────────────────────────────── */

.toast-root {
  position: fixed; top: var(--space-4); right: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
  max-width: 420px;
  z-index: var(--z-toast);
  pointer-events: none;
}
.toast {
  background: var(--surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--text-muted);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  box-shadow: var(--shadow-lg);
  font-size: var(--font-body-sm);
  display: flex; align-items: flex-start; gap: var(--space-3);
  pointer-events: auto;
  animation: toast-in var(--duration) var(--ease-out);
}
.toast.success { border-left-color: var(--success-600); }
.toast.warn    { border-left-color: var(--warning-500); }
.toast.error   { border-left-color: var(--danger-500); }
.toast.info    { border-left-color: var(--info-500); }
.toast .toast-icon { width: 16px; height: 16px; flex-shrink: 0; margin-top: 2px; }
.toast .toast-content { flex: 1; min-width: 0; word-break: break-word; }
.toast .toast-title { font-weight: var(--weight-semibold); margin-bottom: 2px; }
.toast-close { background: none; border: none; cursor: pointer; color: var(--text-subtle); width: 16px; height: 16px; padding: 0; }
.toast-close:hover { color: var(--text-primary); }

@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ── Command palette ────────────────────────────────────────────────────── */

.cmdk-overlay {
  position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.4);
  backdrop-filter: blur(4px);
  z-index: var(--z-cmdk);
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 15vh;
  animation: fade-in var(--duration) var(--ease-out);
}
.cmdk {
  background: var(--surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 560px;
  overflow: hidden;
}
.cmdk-input {
  width: 100%;
  padding: var(--space-4) var(--space-5);
  border: none;
  border-bottom: 1px solid var(--border-default);
  background: transparent;
  font-size: var(--font-h3);
  outline: none;
  border-radius: 0;
}
.cmdk-list { max-height: 400px; overflow-y: auto; padding: var(--space-2); }
.cmdk-group-label { padding: var(--space-3) var(--space-3) var(--space-1); font-size: 10px; text-transform: uppercase; color: var(--text-subtle); font-weight: var(--weight-semibold); }
.cmdk-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--font-body-sm);
  cursor: pointer;
}
.cmdk-item:hover, .cmdk-item[aria-selected="true"] { background: var(--surface-hover); }
.cmdk-item .icon { width: 16px; height: 16px; color: var(--text-muted); flex-shrink: 0; }
.cmdk-item-title { flex: 1; color: var(--text-primary); }
.cmdk-item-hint { color: var(--text-muted); font-size: var(--font-caption); }
.cmdk-footer {
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border-default);
  font-size: var(--font-caption);
  color: var(--text-muted);
  display: flex; gap: var(--space-4); justify-content: space-between;
}
.kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: var(--radius-xs);
  background: var(--surface-sunken);
  border: 1px solid var(--border-default);
  font-family: var(--font-mono-stack);
  font-size: 10px;
  color: var(--text-secondary);
}

/* ── Empty state ────────────────────────────────────────────────────────── */

.empty {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: var(--space-12) var(--space-6);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--border-default);
  border-radius: var(--radius-md);
}
.empty-icon {
  width: 48px; height: 48px;
  color: var(--text-subtle);
  margin-bottom: var(--space-3);
}
.empty-title {
  font-family: var(--font-serif);   /* VIASM academic heading */
  font-size: var(--font-h3);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}
.empty-description {
  font-size: var(--font-body-sm);
  color: var(--text-muted);
  max-width: 400px;
  margin-bottom: var(--space-4);
  line-height: 1.5;
}

/* ── Status dot (in headers, etc.) ──────────────────────────────────────── */

.status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.ok    { background: var(--success-500); }
.status-dot.warn  { background: var(--warning-500); }
.status-dot.err   { background: var(--danger-500); }
.status-dot.idle  { background: var(--text-subtle); }
.status-dot.pulse { animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ── Misc utility ──────────────────────────────────────────────────────── */

.pre-wrap { white-space: pre-wrap; word-break: break-word; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hidden { display: none; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-subtle { color: var(--text-subtle); }
.text-success { color: var(--text-success); }
.text-danger { color: var(--text-danger); }
.text-warning { color: var(--text-warning); }
.text-brand { color: var(--text-brand); }
.text-caption { font-size: var(--font-caption); line-height: var(--lh-caption); }
.text-sm { font-size: var(--font-body-sm); line-height: var(--lh-body-sm); }
.text-h3 { font-size: var(--font-h3); line-height: var(--lh-h3); font-weight: var(--weight-semibold); }
.text-h2 { font-size: var(--font-h2); line-height: var(--lh-h2); font-weight: var(--weight-semibold); }
.text-h1 { font-size: var(--font-h1); line-height: var(--lh-h1); font-weight: var(--weight-semibold); }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid-cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid-cols-4 { grid-template-columns: repeat(4, 1fr); }
.col-span-2 { grid-column: span 2; }
.mb-1 { margin-bottom: var(--space-1); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.mb-6 { margin-bottom: var(--space-6); }
.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); }

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .app-sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: var(--z-sticky); transform: translateX(-100%); }
  .app-sidebar[data-open="true"] { transform: translateX(0); }
  .app-main { padding: var(--space-4); }
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
  .grid-cols-md-2 { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: stretch; }
  .modal { max-width: calc(100vw - 32px); }
}

@media (min-width: 769px) {
  .grid-cols-md-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-cols-md-3 { grid-template-columns: repeat(3, 1fr); }
}

/* ── Module 8 Settings: tab disabled + checkbox grid ───────────────────── */

.tab-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-2);
  padding: var(--space-2);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  background: var(--surface-sunken);
  max-height: 200px;
  overflow-y: auto;
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1);
  font-size: var(--font-body-sm);
  cursor: pointer;
  border-radius: var(--radius-xs);
}
.checkbox-item:hover { background: var(--surface-default); }
.checkbox-item input[type="checkbox"] { margin: 0; accent-color: var(--brand-600); }
