/* OmiMedicalDevices · theme.css
 * Design system cho bộ demo HTTT quản lý TBYT
 * Palette: Y-tế teal (phân biệt với HCMS police-blue), accent cyan, risk class A/B/C/D
 * Bám theo: docs/ux/PC_DESKTOP_UX_SPEC.md, docs/ux/I18N_AND_VIETNAMESE_CONTENT_SPEC.md
 */

:root {
  /* Primary — Medical teal (Y-tế / quản lý nhà nước hiện đại) */
  --primary-50:  #ECFDF5;
  --primary-100: #D1FAE5;
  --primary-200: #A7F3D0;
  --primary-300: #6EE7B7;
  --primary-500: #0D9488;   /* teal 600 */
  --primary-600: #0F766E;
  --primary-700: #115E59;
  --primary-900: #064E3B;

  /* Accent — Cyan/blue cho thông tin, liên kết, dữ liệu */
  --accent-50:  #ECFEFF;
  --accent-100: #CFFAFE;
  --accent-300: #67E8F9;
  --accent-500: #06B6D4;
  --accent-700: #0E7490;

  /* Neutral */
  --gray-50:  #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-400: #94A3B8;
  --gray-500: #64748B;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-900: #0F172A;

  /* Tokens */
  --surface:   #FFFFFF;
  --surface-2: var(--gray-50);
  --surface-3: var(--gray-100);
  --border:    var(--gray-200);
  --border-strong: var(--gray-300);
  --text:       var(--gray-900);
  --text-muted: var(--gray-500);
  --topbar-bg:  #0B3A36;        /* teal 950 */
  --topbar-fg:  #FFFFFF;

  /* Semantic */
  --success:    #15803D;
  --success-bg: #DCFCE7;
  --warning:    #B45309;
  --warning-bg: #FEF3C7;
  --danger:     #B91C1C;
  --danger-bg:  #FEE2E2;
  --info:       #1D4ED8;
  --info-bg:    #DBEAFE;
  --purple:     #6D28D9;
  --purple-bg:  #EDE9FE;
  --pink-bg:    #FCE7F3;

  /* Risk class TBYT (TT 05/2022/TT-BYT) — A → D = mức rủi ro tăng dần */
  --risk-A: #16A34A;   --risk-A-bg: #DCFCE7;
  --risk-B: #0891B2;   --risk-B-bg: #CFFAFE;
  --risk-C: #D97706;   --risk-C-bg: #FEF3C7;
  --risk-D: #DC2626;   --risk-D-bg: #FEE2E2;

  /* Lifecycle states cho hồ sơ lưu hành/giấy phép */
  --st-active:    #15803D;  --st-active-bg:    #DCFCE7;
  --st-pending:   #1D4ED8;  --st-pending-bg:   #DBEAFE;
  --st-suspended: #B45309;  --st-suspended-bg: #FEF3C7;
  --st-revoked:   #B91C1C;  --st-revoked-bg:   #FEE2E2;
  --st-expired:   #6B7280;  --st-expired-bg:   #E5E7EB;
  --st-draft:     #6B7280;  --st-draft-bg:     #F1F5F9;

  /* Spacing */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;

  /* Type — tăng nhẹ size để chữ tiếng Việt có dấu rõ ràng */
  --t-xs: 12px; --t-sm: 13px; --t-base: 14px; --t-md: 16px;
  --t-lg: 18px; --t-xl: 20px; --t-2xl: 24px; --t-3xl: 30px;

  /* Radius */
  --r-sm: 4px; --r-md: 6px; --r-lg: 10px; --r-xl: 14px;

  /* Shadow */
  --sh-card:  0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --sh-pop:   0 4px 14px rgba(15, 23, 42, 0.10);
  --sh-modal: 0 18px 48px rgba(15, 23, 42, 0.20);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  font-family: "Be Vietnam Pro", "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: var(--t-base);
  line-height: 1.55;
  color: var(--text);
  background: var(--surface-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--primary-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font: inherit; cursor: pointer; }
kbd {
  background: var(--surface-3); padding: 2px 6px; border-radius: 4px;
  font-family: "JetBrains Mono", monospace; font-size: 11px;
  border: 1px solid var(--border); border-bottom-width: 2px;
}

/* ===== Layout shell ===== */
.app {
  display: grid;
  grid-template-columns: 248px 1fr;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}
.app > .topbar { grid-column: 1 / -1; }
.app > .sidebar { grid-row: 2; }
.app > .main { grid-row: 2; padding: var(--s-6); padding-bottom: 80px; overflow: auto; }

/* Public portal layout: full-width without sidebar */
.app.public { grid-template-columns: 1fr; }
.app.public > .sidebar { display: none; }

/* Topbar */
.topbar {
  background: var(--topbar-bg);
  background-image: linear-gradient(180deg, #0B3A36 0%, #093633 100%);
  color: var(--topbar-fg);
  display: flex; align-items: center;
  padding: 0 var(--s-6); gap: var(--s-4);
  border-bottom: 1px solid #062825;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset;
}
.topbar .brand {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: var(--t-md); letter-spacing: 0.2px;
}
.topbar .brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, #14B8A6, #06B6D4);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
.topbar .brand .small {
  font-weight: 400; font-size: var(--t-sm); opacity: 0.7;
  margin-left: 2px; padding-left: 8px; border-left: 1px solid rgba(255, 255, 255, 0.18);
}
.topbar .scope-pill {
  margin-left: var(--s-4);
  background: rgba(255, 255, 255, 0.08);
  padding: 4px 12px; border-radius: 999px;
  font-size: var(--t-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.topbar .spacer { flex: 1; }
.topbar .topright { display: flex; align-items: center; gap: var(--s-3); }
.topbar .topright .user {
  background: rgba(255, 255, 255, 0.08);
  padding: 6px 12px; border-radius: 999px;
  font-size: var(--t-sm);
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.topbar .btn.sm {
  background: rgba(255, 255, 255, 0.06); color: #fff;
  border-color: rgba(255, 255, 255, 0.18);
}
.topbar .btn.sm:hover { background: rgba(255, 255, 255, 0.14); }
.topbar .btn.ghost { color: rgba(255, 255, 255, 0.85); }

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: var(--s-3); overflow: auto;
}
.sidebar .section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--text-muted);
  margin: var(--s-4) var(--s-3) var(--s-2);
  font-weight: 600;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px 12px; border-radius: var(--r-md);
  color: var(--gray-700); font-size: var(--t-sm);
  cursor: pointer; margin-bottom: 2px; text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar .nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.sidebar .nav-item.active {
  background: var(--primary-50); color: var(--primary-700);
  font-weight: 600; border-left-color: var(--primary-500);
}
.sidebar .nav-item .icon { width: 20px; text-align: center; font-size: 15px; }
.sidebar .nav-item .badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 600;
}
.sidebar .nav-item.active .badge { background: var(--primary-500); }
.sidebar .nav-item.muted { color: var(--text-muted); }
.sidebar .nav-item.nav-sub {
  padding: 5px 10px 5px 36px;
  font-size: 12px;
  margin-bottom: 0;
  color: var(--text-muted);
  border-radius: 0 var(--r-md) var(--r-md) 0;
  border-left: 2px solid var(--border);
  margin-left: 14px;
}
.sidebar .nav-item.nav-sub:hover { color: var(--primary-600); border-left-color: var(--primary-300); }
.sidebar .nav-item.nav-sub.active {
  background: var(--primary-50);
  color: var(--primary-700);
  border-left-color: var(--primary-500);
  font-weight: 600;
}
.sidebar .nav-item.nav-sub .icon { font-size: 11px; opacity: 0.7; }
@media (max-width: 1024px) { .sidebar .nav-item.nav-sub { display: none; } }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 0 14px; height: 36px; border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: var(--t-sm); font-weight: 500;
  background: var(--surface-3); color: var(--text);
  transition: background 120ms, border-color 120ms;
  white-space: nowrap; flex-shrink: 0;
}
.btn:hover { background: var(--gray-200); }
.btn.primary { background: var(--primary-600); color: #fff; }
.btn.primary:hover { background: var(--primary-700); }
.btn.outline { background: transparent; border-color: var(--border-strong); color: var(--text); }
.btn.outline:hover { background: var(--surface-2); border-color: var(--gray-400); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.danger:hover { background: #991B1B; }
.btn.success { background: var(--success); color: #fff; }
.btn.warning { background: var(--warning); color: #fff; }
.btn.ghost { background: transparent; color: var(--primary-600); }
.btn.ghost:hover { background: var(--primary-50); }
.btn.sm { height: 28px; padding: 0 10px; font-size: var(--t-xs); }
.btn.lg { height: 44px; padding: 0 18px; font-size: var(--t-md); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; }
.btn-group .btn:first-child { border-top-left-radius: var(--r-md); border-bottom-left-radius: var(--r-md); }
.btn-group .btn:last-child  { border-top-right-radius: var(--r-md); border-bottom-right-radius: var(--r-md); }

/* ===== Card ===== */
.card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  box-shadow: var(--sh-card);
}
.card .card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--s-3);
}
.card .card-head h3 { margin: 0; font-size: var(--t-md); font-weight: 600; }
.card .card-head .meta { font-size: var(--t-sm); color: var(--text-muted); }
.card .card-body { padding: 18px; }
.card .card-foot {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: var(--s-2);
  background: var(--surface-2);
  border-bottom-left-radius: var(--r-lg); border-bottom-right-radius: var(--r-lg);
}

/* ===== Form ===== */
.form-row { display: grid; grid-template-columns: 200px 1fr; gap: var(--s-4); align-items: center; margin-bottom: var(--s-3); }
.form-row.col { grid-template-columns: 1fr; align-items: stretch; }
.form-row label { font-size: var(--t-sm); color: var(--gray-700); font-weight: 500; }
.form-row label .req { color: var(--danger); margin-left: 2px; }
.input, .select, .textarea {
  width: 100%; height: 36px;
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  padding: 0 12px; font: inherit; background: var(--surface);
  color: var(--text);
}
.textarea { height: auto; padding: 8px 12px; min-height: 80px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid var(--primary-500); outline-offset: 1px;
  border-color: var(--primary-500);
}
.input.num { text-align: right; font-family: "JetBrains Mono", monospace; }
.input.invalid, .select.invalid { border-color: var(--danger); }
.help { font-size: var(--t-xs); color: var(--text-muted); margin-top: 4px; }
.error { font-size: var(--t-xs); color: var(--danger); margin-top: 4px; }

/* ===== Badges ===== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 999px;
  font-size: var(--t-xs); font-weight: 600;
  background: var(--surface-3); color: var(--gray-700);
  white-space: nowrap;
}
.badge.primary { background: var(--primary-50); color: var(--primary-700); }
.badge.success { background: var(--success-bg); color: var(--success); }
.badge.warning { background: var(--warning-bg); color: var(--warning); }
.badge.danger  { background: var(--danger-bg);  color: var(--danger); }
.badge.info    { background: var(--info-bg);    color: var(--info); }
.badge.purple  { background: var(--purple-bg);  color: var(--purple); }
.badge.pink    { background: var(--pink-bg);    color: #BE185D; }
.badge.outline { background: transparent; border: 1px solid var(--border-strong); color: var(--gray-700); }
.badge.lock::before { content: "🔒"; }
.badge.lg { padding: 4px 10px; font-size: var(--t-sm); }

/* Risk class chip — TT 05/2022/TT-BYT */
.risk {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 6px;
  font-weight: 700; font-size: var(--t-sm);
  font-family: "JetBrains Mono", monospace;
  color: #fff;
}
.risk.lg { width: 32px; height: 32px; font-size: var(--t-md); }
.risk-A { background: var(--risk-A); }
.risk-B { background: var(--risk-B); }
.risk-C { background: var(--risk-C); }
.risk-D { background: var(--risk-D); }
.risk.outline-A { background: var(--risk-A-bg); color: var(--risk-A); border: 1px solid var(--risk-A); }
.risk.outline-B { background: var(--risk-B-bg); color: var(--risk-B); border: 1px solid var(--risk-B); }
.risk.outline-C { background: var(--risk-C-bg); color: var(--risk-C); border: 1px solid var(--risk-C); }
.risk.outline-D { background: var(--risk-D-bg); color: var(--risk-D); border: 1px solid var(--risk-D); }

/* Lifecycle state pill */
.state {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: var(--t-xs); font-weight: 600;
  background: var(--gray-100); color: var(--gray-700);
}
.state::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.85;
}
.state.active    { background: var(--st-active-bg);    color: var(--st-active); }
.state.pending   { background: var(--st-pending-bg);   color: var(--st-pending); }
.state.suspended { background: var(--st-suspended-bg); color: var(--st-suspended); }
.state.revoked   { background: var(--st-revoked-bg);   color: var(--st-revoked); }
.state.expired   { background: var(--st-expired-bg);   color: var(--st-expired); }
.state.draft     { background: var(--st-draft-bg);     color: var(--st-draft); }

/* Severity for incidents */
.sev {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-sm);
  font-size: var(--t-xs); font-weight: 700;
  letter-spacing: 0.4px; text-transform: uppercase;
}
.sev.s-low  { background: var(--info-bg);    color: var(--info); }
.sev.s-mid  { background: var(--warning-bg); color: var(--warning); }
.sev.s-high { background: var(--danger-bg);  color: var(--danger); }
.sev.s-crit {
  background: linear-gradient(135deg, #B91C1C, #7F1D1D);
  color: #fff;
  box-shadow: 0 0 0 1px rgba(185, 28, 28, 0.3);
}

/* Source provenance — distinguish DVC / synced / manual */
.src {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--r-sm);
  font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--gray-700);
  font-family: "JetBrains Mono", monospace;
}
.src.dvc      { background: #EFF6FF; color: var(--info); }
.src.fhir     { background: #F5F3FF; color: var(--purple); }
.src.manual   { background: var(--surface-3); color: var(--gray-700); }
.src.kcb      { background: #FFF7ED; color: #C2410C; }
.src.imported { background: var(--success-bg); color: var(--success); }

/* ===== Tables ===== */
.table {
  width: 100%; border-collapse: collapse; background: var(--surface);
  font-size: var(--t-sm);
}
.table th, .table td {
  text-align: left; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table th {
  background: var(--surface-2); font-weight: 600; color: var(--gray-700);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  position: sticky; top: 0; z-index: 1;
  white-space: nowrap;
}
.table tbody tr:hover td { background: var(--primary-50); }
.table tr.selected td { background: var(--primary-100); }
.table .num { text-align: right; font-family: "JetBrains Mono", monospace; }
.table .id-col { font-family: "JetBrains Mono", monospace; font-size: var(--t-xs); color: var(--gray-700); }
.table-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden;
}
.table-wrap .table-head-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.table-wrap .table-head-row h3 { margin: 0; font-size: var(--t-md); }
.table-wrap .table-head-row .meta { font-size: var(--t-sm); color: var(--text-muted); }
.table-wrap .table-head-row .actions { margin-left: auto; display: flex; gap: 8px; }
.table-foot {
  padding: 10px 16px; display: flex; align-items: center; gap: var(--s-3);
  border-top: 1px solid var(--border); background: var(--surface-2);
  font-size: var(--t-sm); color: var(--text-muted);
}
.table-foot .pages { margin-left: auto; display: flex; gap: 4px; }
.table-foot .pages .page-btn {
  width: 28px; height: 28px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: var(--t-xs); cursor: pointer;
}
.table-foot .pages .page-btn.active { background: var(--primary-500); color: #fff; border-color: var(--primary-500); }

/* ===== Page header ===== */
.page-head {
  display: flex; align-items: center; gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.page-head h1 { font-size: var(--t-2xl); margin: 0; font-weight: 700; line-height: 1.25; }
.page-head .crumb { font-size: var(--t-sm); color: var(--text-muted); margin-bottom: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: var(--s-2); flex-wrap: wrap; }
.page-head .crumb a { color: var(--text-muted); }
.page-head .crumb a:hover { color: var(--primary-600); }

/* Toolbar / filter row */
.toolbar {
  display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap;
  margin-bottom: var(--s-4);
  background: var(--surface);
  padding: 12px 14px;
  border-radius: var(--r-lg); border: 1px solid var(--border);
}
.toolbar .input, .toolbar .select { height: 34px; }
.toolbar .input.search {
  min-width: 280px; max-width: 460px;
  padding-left: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-position: 12px center;
}
.toolbar .chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; font-size: var(--t-sm); color: var(--text);
  transition: background 120ms, border-color 120ms;
}
.toolbar .chip:hover { background: var(--surface-3); }
.toolbar .chip.active { background: var(--primary-50); color: var(--primary-700); border-color: var(--primary-300); font-weight: 600; }
.toolbar .right { margin-left: auto; display: flex; gap: var(--s-2); align-items: center; }
.toolbar .meta { font-size: var(--t-xs); color: var(--text-muted); }

/* ===== Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.stat-card {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  padding: 14px 16px;
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; top: 0; left: 0; bottom: 0;
  width: 3px; background: var(--primary-500);
}
.stat-card.warning::before { background: var(--warning); }
.stat-card.danger::before  { background: var(--danger); }
.stat-card.success::before { background: var(--success); }
.stat-card.info::before    { background: var(--info); }
.stat-card .label { font-size: var(--t-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.stat-card .value { font-size: var(--t-2xl); font-weight: 700; margin: 4px 0 2px; font-family: "JetBrains Mono", monospace; color: var(--text); }
.stat-card .delta { font-size: var(--t-xs); color: var(--text-muted); }
.stat-card .delta.up   { color: var(--success); font-weight: 600; }
.stat-card .delta.down { color: var(--danger);  font-weight: 600; }
.stat-card .icon-corner { position: absolute; top: 10px; right: 12px; font-size: 18px; opacity: 0.6; }

/* ===== Tabs ===== */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-4);
  overflow-x: auto;
  padding: 0;
}
button.tab, .tab {
  appearance: none;
  -webkit-appearance: none;
  border: 0;
  border-radius: var(--r-md) var(--r-md) 0 0;
  padding: 10px 16px;
  margin-bottom: -1px;
  font-size: var(--t-sm); font-weight: 500;
  color: var(--gray-700);
  border-bottom: 2px solid transparent;
  cursor: pointer; white-space: nowrap;
  background: transparent;
  line-height: 1.4;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--primary-600); background: var(--surface-2); }
.tab:focus { outline: 2px solid var(--primary-300); outline-offset: -2px; }
.tab.active {
  color: var(--primary-700);
  border-bottom-color: var(--primary-500);
  font-weight: 600;
  background: transparent;
}

/* ===== Demo strip + progress (tour) ===== */
.demo-progress {
  position: fixed; top: 0; left: 0; right: 0;
  height: 3px; background: var(--gray-200); z-index: 10000;
}
.demo-progress > .fill {
  height: 100%;
  background: linear-gradient(to right, var(--primary-500), var(--accent-500));
  transition: width 0.35s ease;
}
.demo-strip {
  position: fixed; bottom: 16px; right: 16px;
  background: linear-gradient(135deg, var(--primary-700), var(--primary-900));
  color: #fff;
  padding: 8px 12px; border-radius: 999px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--sh-modal);
  z-index: 9999; font-size: var(--t-sm); max-width: 92vw;
}
.demo-strip .step {
  font-weight: 700; font-family: "JetBrains Mono", monospace;
  background: rgba(0, 0, 0, 0.25); padding: 3px 8px; border-radius: 999px;
  white-space: nowrap;
}
.demo-strip .label {
  opacity: 0.95; font-weight: 500; max-width: 280px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.demo-strip a, .demo-strip button {
  color: #fff; padding: 4px 12px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px; font-weight: 600;
  text-decoration: none; transition: background 120ms;
  white-space: nowrap; border: 0; cursor: pointer; font: inherit;
}
.demo-strip a:hover, .demo-strip button:hover { background: rgba(255, 255, 255, 0.3); text-decoration: none; }
.demo-strip a.next { background: var(--accent-500); }
.demo-strip a.next:hover { background: var(--accent-700); }
.demo-strip a.disabled { opacity: 0.35; pointer-events: none; }

/* Demo callout banner */
.demo-callout {
  background: linear-gradient(90deg, var(--info-bg), var(--surface));
  border: 1px solid var(--info);
  border-left: 4px solid var(--info);
  border-radius: var(--r-md);
  padding: 12px 16px;
  margin-bottom: 16px;
  display: flex; gap: 12px; align-items: flex-start;
  font-size: var(--t-sm);
}
.demo-callout.warning { background: linear-gradient(90deg, var(--warning-bg), var(--surface)); border-color: var(--warning); border-left-color: var(--warning); }
.demo-callout.danger  { background: linear-gradient(90deg, var(--danger-bg), var(--surface));  border-color: var(--danger);  border-left-color: var(--danger); }
.demo-callout.success { background: linear-gradient(90deg, var(--success-bg), var(--surface)); border-color: var(--success); border-left-color: var(--success); }
.demo-callout .ic { font-size: 22px; flex-shrink: 0; line-height: 1; }
.demo-callout strong { color: var(--info); }
.demo-callout.warning strong { color: var(--warning); }
.demo-callout.danger  strong { color: var(--danger); }
.demo-callout.success strong { color: var(--success); }

/* ===== Cmd+K modal ===== */
.cmd-modal {
  position: fixed; inset: 0; display: none; z-index: 99000;
  align-items: flex-start; justify-content: center;
}
.cmd-modal.open { display: flex; }
.cmd-modal .cmd-backdrop {
  position: absolute; inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}
.cmd-modal .cmd-panel {
  position: relative; margin-top: 100px;
  width: min(680px, 92vw);
  background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--sh-modal);
  border: 1px solid var(--border);
  overflow: hidden;
}
.cmd-input {
  width: 100%; height: 56px; padding: 0 18px;
  border: 0; border-bottom: 1px solid var(--border);
  font-size: var(--t-md); background: transparent; color: var(--text);
  outline: none;
}
.cmd-list { max-height: 50vh; overflow: auto; padding: 6px; }
.cmd-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-md);
  text-decoration: none; color: var(--text);
}
.cmd-row.active, .cmd-row:hover { background: var(--primary-50); text-decoration: none; }
.cmd-row .cmd-icon { font-size: 18px; width: 24px; text-align: center; }
.cmd-row .cmd-body { flex: 1; min-width: 0; }
.cmd-row .cmd-title { font-weight: 600; font-size: var(--t-sm); }
.cmd-row .cmd-sub { font-size: var(--t-xs); color: var(--text-muted); }
.cmd-row .cmd-kind {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px;
  background: var(--surface-3); color: var(--text-muted);
  padding: 2px 6px; border-radius: 999px;
  font-weight: 600;
}
.cmd-empty { padding: 24px; text-align: center; color: var(--text-muted); font-size: var(--t-sm); }
.cmd-foot { border-top: 1px solid var(--border); padding: 8px 16px; font-size: var(--t-xs); color: var(--text-muted); }

/* ===== Modal generic ===== */
.modal {
  position: fixed; inset: 0; display: none; z-index: 98000;
  align-items: center; justify-content: center;
}
.modal.open { display: flex; }
.modal .modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.55); }
.modal .modal-panel {
  position: relative; background: var(--surface); border-radius: var(--r-lg);
  width: min(560px, 92vw); box-shadow: var(--sh-modal);
  border: 1px solid var(--border); overflow: hidden;
}
.modal .modal-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal .modal-head h3 { margin: 0; font-size: var(--t-md); flex: 1; }
.modal .modal-body { padding: 18px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }

/* ===== Empty state ===== */
.empty-state {
  padding: 56px 24px; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--r-lg);
  color: var(--text-muted); background: var(--surface);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.6; }
.empty-state h3 { margin: 0 0 6px; color: var(--text); }
.empty-state .actions { margin-top: 16px; display: flex; gap: 8px; justify-content: center; }

/* ===== Timeline (truy xuất nguồn gốc) ===== */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
  content: ""; position: absolute; top: 4px; bottom: 4px; left: 9px;
  width: 2px; background: var(--border-strong);
}
.timeline .tl-item { position: relative; margin-bottom: 18px; }
.timeline .tl-item::before {
  content: ""; position: absolute; left: -23px; top: 5px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--primary-500); box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--primary-200);
}
.timeline .tl-item.success::before { background: var(--success); box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--success-bg); }
.timeline .tl-item.warning::before { background: var(--warning); box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--warning-bg); }
.timeline .tl-item.danger::before  { background: var(--danger);  box-shadow: 0 0 0 3px var(--surface), 0 0 0 4px var(--danger-bg); }
.timeline .tl-time { font-size: var(--t-xs); color: var(--text-muted); font-family: "JetBrains Mono", monospace; }
.timeline .tl-title { font-weight: 600; margin: 2px 0 4px; color: var(--text); }
.timeline .tl-body { font-size: var(--t-sm); color: var(--gray-700); }

/* ===== KV grid (key-value pair) ===== */
.kv-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 24px;
}
.kv { font-size: var(--t-sm); }
.kv .k { color: var(--text-muted); font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.kv .v { color: var(--text); font-weight: 500; margin-top: 2px; }
.kv .v.mono { font-family: "JetBrains Mono", monospace; }

/* ===== Section divider ===== */
.section-h {
  display: flex; align-items: center; gap: var(--s-3);
  margin: var(--s-5) 0 var(--s-3);
}
.section-h h2 {
  font-size: var(--t-lg); margin: 0; font-weight: 600; color: var(--text);
}
.section-h .meta { font-size: var(--t-sm); color: var(--text-muted); }
.section-h::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* ===== Public portal hero ===== */
.public-hero {
  background:
    radial-gradient(1200px 400px at 80% -20%, rgba(13, 148, 136, 0.18) 0%, transparent 60%),
    radial-gradient(1000px 300px at 0% -10%, rgba(6, 182, 212, 0.12) 0%, transparent 50%),
    linear-gradient(135deg, var(--primary-700), var(--primary-900));
  color: #fff; padding: 48px 32px;
}
.public-hero h1 { font-size: var(--t-3xl); margin: 0 0 8px; line-height: 1.2; }
.public-hero p { margin: 0; opacity: 0.9; max-width: 720px; }
.public-hero .search-card {
  margin-top: 24px;
  background: var(--surface);
  border-radius: var(--r-xl);
  padding: 18px;
  display: grid; grid-template-columns: 1fr auto;
  gap: 12px;
  box-shadow: var(--sh-modal);
  color: var(--text);
}
.public-hero .search-card .input { height: 52px; font-size: var(--t-md); }
.public-hero .search-card .btn { height: 52px; padding: 0 24px; font-size: var(--t-md); }

/* ===== Utility ===== */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-6 { gap: 24px; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.text-sm { font-size: var(--t-sm); }
.text-xs { font-size: var(--t-xs); }
.text-md { font-size: var(--t-md); }
.text-lg { font-size: var(--t-lg); }
.text-xl { font-size: var(--t-xl); }
.text-muted { color: var(--text-muted); }
.text-mono { font-family: "JetBrains Mono", monospace; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; } .mb-8 { margin-bottom: 32px; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.p-2 { padding: 8px; } .p-3 { padding: 12px; } .p-4 { padding: 16px; } .p-5 { padding: 20px; }
.w-full { width: 100%; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.divider { height: 1px; background: var(--border); margin: var(--s-4) 0; }
.divider-v { width: 1px; align-self: stretch; background: var(--border); margin: 0 var(--s-3); }
.muted { color: var(--text-muted); }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--s-4); }
@media (max-width: 1024px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 768px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ===== Charts (mocked SVG) ===== */
.chart {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 16px;
}
.chart h4 { margin: 0 0 8px; font-size: var(--t-sm); color: var(--gray-700); font-weight: 600; }
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.bar-row .bar-label { width: 140px; font-size: var(--t-xs); color: var(--gray-700); }
.bar-row .bar-track { flex: 1; height: 8px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.bar-row .bar-fill { height: 100%; background: linear-gradient(90deg, var(--primary-500), var(--accent-500)); border-radius: 999px; }
.bar-row .bar-fill.warning { background: var(--warning); }
.bar-row .bar-fill.danger { background: var(--danger); }
.bar-row .bar-fill.success { background: var(--success); }
.bar-row .bar-val { width: 60px; text-align: right; font-size: var(--t-xs); font-family: "JetBrains Mono", monospace; color: var(--gray-700); }

/* ===== Map placeholder (Bản đồ TBYT) ===== */
.map-canvas {
  position: relative;
  background:
    radial-gradient(circle at 30% 30%, rgba(13, 148, 136, 0.10) 0%, transparent 40%),
    radial-gradient(circle at 70% 60%, rgba(6, 182, 212, 0.10) 0%, transparent 40%),
    linear-gradient(135deg, #F0F9FF, #ECFDF5);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  height: 480px;
  overflow: hidden;
}
.map-pin {
  position: absolute; transform: translate(-50%, -100%);
  background: var(--primary-600); color: #fff;
  width: 28px; height: 28px; border-radius: 50% 50% 50% 0;
  transform: translate(-50%, -100%) rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.4);
  cursor: pointer; transition: transform 120ms;
}
.map-pin span { transform: rotate(45deg); font-size: var(--t-xs); font-weight: 700; }
.map-pin:hover { transform: translate(-50%, -100%) rotate(-45deg) scale(1.15); }
.map-pin.warning { background: var(--warning); }
.map-pin.danger { background: var(--danger); }
.map-legend {
  position: absolute; bottom: 16px; right: 16px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 10px 14px;
  font-size: var(--t-xs);
  box-shadow: var(--sh-card);
}
.map-legend .row { display: flex; align-items: center; gap: 6px; margin-bottom: 4px; }
.map-legend .row .swatch { width: 12px; height: 12px; border-radius: 4px; }

/* ===== Skeleton ===== */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  border-radius: var(--r-sm);
  display: inline-block;
  animation: skel 1.4s ease-in-out infinite;
  color: transparent !important;
}
.skeleton.line { height: 14px; width: 100%; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ===== Responsive shell ===== */
@media (max-width: 1280px) {
  .app { grid-template-columns: 220px 1fr; }
  .sidebar .section-title { margin: 12px 8px 4px; }
}
@media (max-width: 1024px) {
  .app { grid-template-columns: 64px 1fr; }
  .sidebar { padding: 8px 4px; }
  .sidebar .section-title { display: none; }
  .sidebar .nav-item { justify-content: center; padding: 12px 6px; gap: 0; border-left: 0; border-radius: var(--r-md); }
  .sidebar .nav-item span:not(.icon):not(.badge) { display: none; }
  .sidebar .nav-item .icon { font-size: 20px; }
  .sidebar .nav-item .badge { position: absolute; top: 4px; right: 4px; }
  .topbar .scope-pill { display: none; }
  .topbar .topright .user { display: none; }
}
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .topbar { padding: 0 12px; }
}

/* ===== Print — tối ưu cho hồ sơ in PDF/A ===== */
@media print {
  .topbar, .sidebar, .demo-strip, .demo-progress,
  .toolbar, .cmd-modal, .modal, .page-head .actions,
  .omd-notif-popover, button:not(.tab) { display: none !important; }
  .app { display: block; grid-template-columns: 1fr; }
  .main { padding: 0; overflow: visible; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 1px solid #888; break-inside: avoid; }
  .page-head h1 { font-size: 22pt; }
  .demo-callout { border-color: #888; background: #f5f5f5; }
  .timeline::before { background: #444; }
  .table { font-size: 10pt; }
  .table th { background: #eee !important; color: #000 !important; }
  .badge, .state, .risk { border: 1px solid #888; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
  .text-mono { font-family: monospace; }
  /* Hồ sơ chân trang */
  @page { size: A4; margin: 18mm 14mm; }
}

/* ===== A11y enhancements ===== */
:focus-visible { outline: 2px solid var(--primary-500); outline-offset: 2px; border-radius: var(--r-sm); }
.cmd-modal:focus-within .cmd-input { outline: none; }
.modal[role="dialog"] { outline: 2px solid var(--primary-500); outline-offset: -2px; }
[aria-hidden="true"] { display: none !important; }
.skip-link {
  position: absolute; left: -9999px;
  top: 0; padding: 8px 16px;
  background: var(--primary-700); color: #fff; z-index: 99999;
  text-decoration: none; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== Dark mode ===== */
[data-theme="dark"] {
  --surface:    #0F172A;
  --surface-2:  #0B1220;
  --surface-3:  #1E293B;
  --border:     #1E293B;
  --border-strong: #334155;
  --text:       #E2E8F0;
  --text-muted: #94A3B8;
  --gray-50:    #0B1220;
  --gray-100:   #131E32;
  --gray-200:   #1E293B;
  --gray-300:   #334155;
  --gray-400:   #475569;
  --gray-500:   #94A3B8;
  --gray-600:   #B6C0CC;
  --gray-700:   #CBD5E1;
  --gray-900:   #F1F5F9;
  --primary-50:  #064E3B;
  --primary-100: #115E59;
  --primary-200: #115E59;
  --primary-300: #14B8A6;
  --primary-500: #5EEAD4;
  --primary-600: #14B8A6;
  --primary-700: #99F6E4;
  --primary-900: #CCFBF1;
  --topbar-bg:   #061A18;
  --topbar-fg:   #E2E8F0;
  --info-bg:     #0F2A4F;
  --warning-bg:  #3B2509;
  --danger-bg:   #3F1414;
  --success-bg:  #0E2F1F;
  --st-active-bg:    #0E2F1F;
  --st-pending-bg:   #0F2A4F;
  --st-suspended-bg: #3B2509;
  --st-revoked-bg:   #3F1414;
  --st-expired-bg:   #1E293B;
  --st-draft-bg:     #1E293B;
  --risk-A-bg: #0E2F1F;
  --risk-B-bg: #0B3340;
  --risk-C-bg: #3B2509;
  --risk-D-bg: #3F1414;
  --sh-card:  0 1px 2px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.5);
  --sh-pop:   0 4px 14px rgba(0, 0, 0, 0.55);
  --sh-modal: 0 18px 48px rgba(0, 0, 0, 0.7);
  color-scheme: dark;
}
[data-theme="dark"] body { background: var(--surface-2); color: var(--text); }
[data-theme="dark"] .input,
[data-theme="dark"] .select,
[data-theme="dark"] .textarea { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
[data-theme="dark"] .public-hero { background: linear-gradient(135deg, #042F2C, #061A18); }
[data-theme="dark"] .map-canvas { background: linear-gradient(135deg, #0F1F2C, #07241F); }
[data-theme="dark"] .toolbar .input.search {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
}
