/* =============================================================================
   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 ──────────────────────────────────────────────────── */

/* Reset lề mặc định của <body> (8px của trình duyệt). Thiếu dòng này thì .app-shell
   {min-height:100vh} + 16px lề dọc = trang LUÔN dư 16px cuộn dọc, và mọi thứ bị thụt
   vào 8px nên không băng nào chạm được mép màn hình. (Dải 8px đó KHÔNG trắng — body
   đã được sơn var(--background) trong shared/viasm-tokens.css.) Đặt trong
   components.css (chỉ admin nạp) thay vì shared/viasm-tokens.css để không đụng
   chat + organizer đang dùng chung file token đó. */
body { margin: 0; }

.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);
  /* Pin the sidebar to the viewport so the logout footer (.sidebar-meta) is always
     reachable, even when the main content (e.g. 476 tài liệu) makes the page very
     long. align-self:flex-start stops the flex row from stretching the sidebar to
     the tall shell height (which would defeat sticky). .sidebar-nav (flex:1,
     overflow-y:auto) scrolls internally if the menu itself exceeds the viewport. */
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  max-height: 100vh;
}

.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; }

/* ── Overview — VIASM brand (màu logo: đỏ #D30A12 + đen than + trắng) ──────
   Dải nền đen than làm nổi donut đỏ. Token màu bám logo, tự đảo theo theme.
   ĐỎ CHỈ dùng cho dữ liệu (donut/sparkline/nhấn) — không bao giờ tô chữ tiêu đề. */
.ovb {
  --ovb-ink:#1c1a1b; --ovb-ink-2:#5f5b5a; --ovb-ink-3:#948f8c; --ovb-line:#eae5e2;
  --ovb-card:#ffffff; --ovb-sunken:#f6f3f1;
  --ovb-red:#d30a12; --ovb-red-soft:#fdecec;
  --ovb-band:#1c1a1b; --ovb-band-2:#232021; --ovb-band-ink:#f5f2f0; --ovb-band-ink-2:#b0aaa6; --ovb-band-ink-3:#847e7a; --ovb-band-line:rgba(255,255,255,.10);
  --ovb-seg1:#d30a12; --ovb-seg2:#dcd4cd; --ovb-seg3:#f07984; --ovb-seg4:#f6b3b8; --ovb-segK:#6f6a67;
  --ovb-sh:0 1px 2px rgba(28,26,27,.05),0 10px 24px -14px rgba(28,26,27,.16);
  --ovb-sh-band:0 20px 44px -22px rgba(211,10,18,.26),0 10px 30px -18px rgba(0,0,0,.4);
  max-width:1080px; margin:0 auto; color:var(--ovb-ink); font-variant-numeric:tabular-nums;
}
:root[data-theme="dark"] .ovb {
  --ovb-ink:#f2efed; --ovb-ink-2:#b4aeaa; --ovb-ink-3:#7f7975; --ovb-line:#2b2725;
  --ovb-card:#1e1b1a; --ovb-sunken:#252120;
  --ovb-red:#ef3b43; --ovb-red-soft:#371513;
  --ovb-band:#0e0c0c; --ovb-band-2:#181514;
  --ovb-seg1:#ef3b43; --ovb-seg2:#c7bdb5; --ovb-seg3:#c33d43; --ovb-seg4:#8f3034; --ovb-segK:#736e6b;
  --ovb-sh:0 1px 2px rgba(0,0,0,.4),0 12px 28px -16px rgba(0,0,0,.6);
  --ovb-sh-band:0 20px 44px -24px rgba(0,0,0,.7);
}
@media (prefers-color-scheme:dark){ :root:not([data-theme="light"]) .ovb {
  --ovb-ink:#f2efed; --ovb-ink-2:#b4aeaa; --ovb-ink-3:#7f7975; --ovb-line:#2b2725;
  --ovb-card:#1e1b1a; --ovb-sunken:#252120;
  --ovb-red:#ef3b43; --ovb-red-soft:#371513;
  --ovb-band:#0e0c0c; --ovb-band-2:#181514;
  --ovb-seg1:#ef3b43; --ovb-seg2:#c7bdb5; --ovb-seg3:#c33d43; --ovb-seg4:#8f3034; --ovb-segK:#736e6b;
  --ovb-sh:0 1px 2px rgba(0,0,0,.4),0 12px 28px -16px rgba(0,0,0,.6);
  --ovb-sh-band:0 20px 44px -24px rgba(0,0,0,.7);
}}

.ovb-top{display:flex;justify-content:space-between;align-items:flex-start;gap:20px;flex-wrap:wrap}
.ovb-brand{display:flex;align-items:center;gap:14px}
.ovb-brand svg{display:block;width:50px;height:50px;flex:none;color:var(--ovb-red)}
.ovb-wm b{display:block;font-size:26px;font-weight:800;letter-spacing:.02em;color:var(--ovb-ink);line-height:1}
.ovb-wm span{display:block;font-size:9.5px;letter-spacing:.13em;text-transform:uppercase;color:var(--ovb-ink-3);font-weight:600;margin-top:4px}
.ovb-period{text-align:right;font-size:12.5px;color:var(--ovb-ink-2);line-height:1.6}
.ovb-period b{color:var(--ovb-ink);font-weight:700}
.ovb-refresh{margin-top:6px;background:none;border:none;padding:0;font:inherit;font-size:12px;color:var(--ovb-ink-3);cursor:pointer;display:inline-flex;align-items:center;gap:5px}
.ovb-refresh:hover{color:var(--ovb-red)} .ovb-refresh .icon{width:12px;height:12px}

.ovb-h1{font-size:32px;font-weight:800;letter-spacing:-.025em;margin:24px 0 0;line-height:1;color:var(--ovb-ink)}

.ovb-band{margin-top:22px;background:linear-gradient(180deg,var(--ovb-band-2),var(--ovb-band));border-radius:20px;box-shadow:var(--ovb-sh-band);padding:32px 38px;display:grid;grid-template-columns:240px 1fr;gap:42px;align-items:center;color:var(--ovb-band-ink)}
.ovb-donut-box{position:relative;width:240px;height:240px;justify-self:center}
.ovb-donut{width:100%;height:auto;display:block;transform:rotate(-90deg)}
.ovb-donut .seg{transition:opacity .28s var(--ease-out),stroke-width .28s var(--ease-out);cursor:pointer}
.ovb-donut-box.hv .seg{opacity:.26} .ovb-donut .seg.on{opacity:1}
.ovb-seg1{stroke:var(--ovb-seg1)} .ovb-seg2{stroke:var(--ovb-seg2)} .ovb-seg3{stroke:var(--ovb-seg3)} .ovb-seg4{stroke:var(--ovb-seg4)} .ovb-segK{stroke:var(--ovb-segK)}
.ovb-donut-c{position:absolute;inset:0;display:flex;flex-direction:column;align-items:center;justify-content:center;pointer-events:none}
.ovb-donut-c .n{font-size:44px;font-weight:800;letter-spacing:-.03em;line-height:1;color:#fff}
.ovb-donut-c .c{margin-top:7px;font-size:10px;letter-spacing:.18em;text-transform:uppercase;color:var(--ovb-band-ink-3);font-weight:700}
.ovb-leg-h{font-size:11px;letter-spacing:.15em;text-transform:uppercase;color:var(--ovb-band-ink-3);font-weight:700;margin-bottom:6px}
.ovb-leg ul{list-style:none;margin:0;padding:0}
.ovb-leg li{display:grid;grid-template-columns:12px 1fr auto;gap:14px;align-items:center;padding:13px 0;border-top:1px solid var(--ovb-band-line);transition:opacity .25s}
.ovb-leg li:last-child{border-bottom:1px solid var(--ovb-band-line)}
.ovb-leg.hv li{opacity:.4} .ovb-leg li.on{opacity:1}
.ovb-leg .sw{width:12px;height:12px;border-radius:3px;align-self:center}
.ovb-sw1{background:var(--ovb-seg1)} .ovb-sw2{background:var(--ovb-seg2)} .ovb-sw3{background:var(--ovb-seg3)} .ovb-sw4{background:var(--ovb-seg4)} .ovb-swK{background:var(--ovb-segK)}
.ovb-leg .nm{font-size:14.5px;font-weight:650;color:var(--ovb-band-ink)}
.ovb-leg .mt{font-size:12px;color:var(--ovb-band-ink-2);margin-top:2px}
.ovb-leg .co{font-size:14px;font-weight:600;color:var(--ovb-band-ink-2);text-align:right}

.ovb-kpis{display:grid;grid-template-columns:repeat(4,1fr);gap:16px;margin-top:24px}
.ovb-kpi{background:var(--ovb-card);border:1px solid var(--ovb-line);border-radius:14px;padding:18px 18px 16px;box-shadow:var(--ovb-sh);position:relative;overflow:hidden}
.ovb-kpi::before{content:"";position:absolute;top:0;left:0;width:34px;height:3px;background:var(--ovb-red);border-radius:0 0 3px 0}
.ovb-kl{font-size:11px;letter-spacing:.05em;text-transform:uppercase;color:var(--ovb-ink-3);font-weight:700}
.ovb-kv{font-size:31px;font-weight:800;letter-spacing:-.03em;margin:12px 0 7px;line-height:1;color:var(--ovb-ink)}
.ovb-kv .u{font-size:.5em;font-weight:600;color:var(--ovb-ink-3);margin-left:2px}
.ovb-kf{font-size:12px;color:var(--ovb-ink-2);display:flex;align-items:center;gap:5px;flex-wrap:wrap}
.ovb-up{color:var(--ovb-red);font-weight:750;display:inline-flex;align-items:center;gap:3px}
.ovb-up .icon{width:12px;height:12px}

.ovb-trend{margin-top:24px;background:var(--ovb-card);border:1px solid var(--ovb-line);border-radius:14px;padding:20px 22px;box-shadow:var(--ovb-sh)}
.ovb-trend-h{display:flex;justify-content:space-between;align-items:baseline;gap:14px;margin-bottom:12px}
.ovb-trend-h h2{margin:0;font-size:12px;letter-spacing:.13em;text-transform:uppercase;color:var(--ovb-ink-3);font-weight:700}
.ovb-trend-h span{font-size:12.5px;color:var(--ovb-ink-2)}
.ovb-spark-wrap{width:100%;overflow-x:auto}
.ovb-spark{width:100%;height:auto;display:block;min-width:520px}
.ovb-s-base{stroke:var(--ovb-line);stroke-width:1}
.ovb-s-area{fill:var(--ovb-red-soft)}
.ovb-s-line{fill:none;stroke:var(--ovb-red);stroke-width:2.4;stroke-linejoin:round;stroke-linecap:round}
.ovb-s-dot{fill:var(--ovb-red)}
.ovb-s-peak{fill:var(--ovb-ink);font-size:15px;font-weight:700}
.ovb-s-x{fill:var(--ovb-ink-3);font-size:11.5px}
.ovb-trend-foot{margin-top:14px;padding-top:14px;border-top:1px solid var(--ovb-line);font-size:12.5px;color:var(--ovb-ink-2);line-height:1.6}
.ovb-trend-foot b{color:var(--ovb-ink);font-weight:700}

/* Tooltip renders OUTSIDE .ovb (fixed to viewport) so it can't inherit the scoped
   --ovb-* tokens — use the app's GLOBAL theme tokens so it stays readable: a light
   tooltip pops on the dark band (light theme), a dark one reads in dark mode.
   (Was var(--ovb-ink)/(--ovb-card) → undefined here → transparent bg + black text.) */
.ovb-tip{position:fixed;pointer-events:none;z-index:var(--z-toast);opacity:0;transform:translate(-50%,-120%);transition:opacity .12s;background:var(--surface-elevated);color:var(--text-primary);border:1px solid var(--border-default);padding:8px 11px;border-radius:8px;font-size:12.5px;line-height:1.4;white-space:nowrap;box-shadow:var(--shadow-lg)}
.ovb-tip.show{opacity:1} .ovb-tip b{font-weight:700}
.ovb-empty{padding:36px 2px;color:var(--ovb-ink-2);font-size:14px}

@media (max-width:820px){.ovb-band{grid-template-columns:1fr;gap:30px}.ovb-kpis{grid-template-columns:1fr 1fr}}
@media (max-width:480px){.ovb-kpis{grid-template-columns:1fr 1fr;gap:12px}}
@media (prefers-reduced-motion:reduce){.ovb-donut .seg{transition:none}}

.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); } }

/* ── Alert / acknowledgment modal (alertModal) ─────────────────────────────
   Centered, single-button dialog the operator must dismiss with "Đã hiểu" — it
   never auto-closes. Compact + content-centered so the message reads as a clear,
   blocking notice on top of whatever form is open underneath. */
/* Sits above an already-open form modal (--z-modal) and adds NO extra scrim, so the
   form stays readable underneath — the form's own backdrop provides the dimming. The
   transparent layer still intercepts clicks, forcing dismissal via the button. */
.alert-modal-overlay { background: transparent; backdrop-filter: none; z-index: var(--z-toast); }
.alert-modal { max-width: 420px; }
.alert-modal-body {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: var(--space-2);
  padding-top: var(--space-5);
}
.alert-modal-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; margin-bottom: var(--space-1);
}
.alert-modal-title {
  font-family: var(--font-serif);
  font-size: var(--font-h3, var(--font-h2));
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}
.alert-modal-message { color: var(--text-secondary); line-height: 1.6; }
.alert-modal-footer { justify-content: center; border-top: none; padding-top: var(--space-2); }
.alert-modal-footer .btn { min-width: 120px; }

/* ── Emoji quick-pick (bindEmojiPicker) ────────────────────────────────────
   One-click emoji shortcuts under an icon/emoji text field. */
.emoji-pick-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.emoji-pick {
  font-size: 18px; line-height: 1; padding: 5px 8px; cursor: pointer;
  background: var(--surface); color: inherit;
  border: 1px solid var(--border-default); border-radius: var(--radius-md);
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.emoji-pick:hover { background: var(--border-subtle, rgba(0,0,0,.06)); }
.emoji-pick.active {
  border-color: var(--text-brand);
  box-shadow: 0 0 0 2px rgb(192 57 43 / 0.18);
}

/* ── 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); }

/* ── Trợ lý AI builder layout (ADR-061) — responsive ────────────────────────
   Desktop: step-nav | panels | live test panel. Tablet: 2 cols (test panel
   full-width below). Mobile: single column, step-nav becomes a horizontal
   scroll bar, nothing sticky. (Was an inline grid → couldn't go responsive.) */
.builder-layout { display: grid; gap: 20px; align-items: start; grid-template-columns: 200px 1fr 320px; }
.builder-layout .builder-stepnav,
.builder-layout .builder-testpanel { position: sticky; top: 12px; }
@media (max-width: 1100px) {
  .builder-layout { grid-template-columns: 170px 1fr; }
  .builder-layout .builder-testpanel { grid-column: 1 / -1; position: static; }
}
@media (max-width: 768px) {
  .builder-layout { grid-template-columns: 1fr; }
  .builder-layout .builder-stepnav { position: static; display: flex; gap: 6px; overflow-x: auto; padding: 6px; -webkit-overflow-scrolling: touch; }
  .builder-layout .builder-stepnav .sidebar-item { flex: 0 0 auto; white-space: nowrap; }
  .builder-layout .builder-testpanel { position: static; }
}

/* ── Mobile navigation drawer (fix: sidebar toggle was unreachable on mobile) ─ */
.mobile-nav-toggle { display: none; }
.nav-backdrop { display: none; }
@media (max-width: 768px) {
  .mobile-nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    position: fixed; top: 10px; left: 10px; z-index: 1002;
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text-primary);
    border: 1px solid var(--border-default); box-shadow: var(--shadow-md); cursor: pointer;
  }
  .app-main { padding-top: 60px; }                 /* clearance for the fixed toggle */
  .app-sidebar { z-index: 1001; }                   /* above the backdrop */
  .nav-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; }
}

/* ── Ô mật khẩu kèm nút con mắt (formModal, app.js) ────────────────────────
   Nút nằm đè lên góc phải ô nhập; padding-right của input chừa chỗ cho nó
   nên chữ không bao giờ chạy xuống dưới biểu tượng. */
.pw-wrap { position: relative; display: block; }
.pw-wrap .input { padding-right: 38px; }
.pw-eye {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  background: none; border: 0; border-radius: var(--radius-sm, 5px);
  color: var(--text-muted); cursor: pointer;
}
.pw-eye:hover { color: var(--text-primary); background: var(--surface-hover); }
.pw-eye:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; }

/* ── Ô lọc cho danh sách checkbox dài (_checkFilter, settings.js) ──────────── */
.check-filter { width: 100%; }
/* BẮT BUỘC. `.checkbox-item { display: flex }` là quy tắc của tác giả nên thắng
   `[hidden] { display: none }` trong bảng mặc định của trình duyệt — đặt hidden
   bằng JS sẽ KHÔNG giấu được mục nào. Selector dài hơn để thắng về độ ưu tiên
   mà không cần !important. */
.checkbox-grid .checkbox-item[hidden] { display: none; }
.check-empty {
  grid-column: 1 / -1; padding: 8px 2px;
  color: var(--text-muted); font-size: var(--font-body-sm);
}
