:root {
  --bg: #f3f6f9;
  --bg-ambient: radial-gradient(1050px 440px at 12% -10%, rgba(13, 148, 136, 0.085), transparent 65%),
                radial-gradient(880px 380px at 92% -12%, rgba(14, 116, 144, 0.065), transparent 60%);
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.84);
  --surface-alt: #eef2f6;
  --surface-soft: #f8fafc;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-muted: #64748b;
  --primary: #0f766e;
  --primary-bright: #0d9488;
  --primary-hover: #115e59;
  --primary-soft: rgba(13, 148, 136, 0.09);
  --primary-grad: linear-gradient(135deg, #0d9488 0%, #0f766e 58%, #115e59 100%);
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --err: #be123c;
  --err-bg: #fff1f2;
  --info: #1d4ed8;
  --info-bg: #eff6ff;
  --female: #be185d;
  --female-bg: #fdf2f8;
  --male: #0369a1;
  --male-bg: #f0f9ff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.03), 0 8px 24px -8px rgba(15, 23, 42, 0.07);
  --shadow-elevated: 0 2px 6px rgba(15, 23, 42, 0.04), 0 16px 36px -12px rgba(15, 23, 42, 0.1);
  --shadow-primary: 0 4px 14px -3px rgba(15, 118, 110, 0.38);
  --radius: 14px;
  --radius-sm: 9px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg: #070d19;
  --bg-ambient: radial-gradient(960px 420px at 14% -8%, rgba(20, 184, 166, 0.12), transparent 65%),
                radial-gradient(820px 360px at 88% -12%, rgba(56, 189, 248, 0.08), transparent 60%);
  --surface: #0f172a;
  --surface-glass: rgba(15, 23, 42, 0.82);
  --surface-alt: #182338;
  --surface-soft: #131d31;
  --border: rgba(148, 163, 184, 0.13);
  --border-strong: rgba(148, 163, 184, 0.22);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #14b8a6;
  --primary-bright: #2dd4bf;
  --primary-hover: #2dd4bf;
  --primary-soft: rgba(20, 184, 166, 0.14);
  --primary-grad: linear-gradient(135deg, #14b8a6 0%, #0d9488 60%, #0f766e 100%);
  --ok: #34d399;
  --ok-bg: rgba(16, 185, 129, 0.14);
  --warn: #fbbf24;
  --warn-bg: rgba(245, 158, 11, 0.14);
  --err: #fb7185;
  --err-bg: rgba(244, 63, 94, 0.15);
  --info: #60a5fa;
  --info-bg: rgba(59, 130, 246, 0.14);
  --female: #f472b6;
  --female-bg: rgba(236, 72, 153, 0.16);
  --male: #38bdf8;
  --male-bg: rgba(14, 165, 233, 0.16);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-card: 0 2px 6px rgba(0, 0, 0, 0.25), 0 12px 28px -8px rgba(0, 0, 0, 0.45);
  --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.35), 0 20px 44px -12px rgba(0, 0, 0, 0.6);
  --shadow-primary: 0 6px 18px -4px rgba(20, 184, 166, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  max-width: 100vw;
  overflow-x: hidden;
  overflow-x: clip;
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg);
  background-image: var(--bg-ambient);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ===== FROSTED GLASS HEADER ===== */
.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 1;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-grad);
  color: #fff;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.brand-icon.has-custom-logo {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm);
  padding: 2px;
}

.brand-icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 7px;
  display: block;
}

.brand-inline {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
}

.unit-title-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 280px;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.16s var(--ease);
}

.unit-title-btn span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.unit-title-btn:hover {
  color: var(--primary);
}

.brand-subtitle {
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--text-muted);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
  background: var(--surface-alt);
  padding: 3px 4px;
  border-radius: 10px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-btn {
  padding: 6px 12px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.16s var(--ease);
  line-height: 1.25;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .tab-btn:hover {
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

[data-theme="dark"] .tab-btn.active {
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* Tinh giản tối đa: Ẩn số lượng danh mục tĩnh trên thanh tab (ICD-10, ICD-9, Đầu vào XML, Bẫy) */
.header-tabs .tab-badge#badgeIcd10Count,
.header-tabs .tab-badge#badgeIcd9Count,
.header-tabs .tab-badge#badgeCatalogCount,
.header-tabs .tab-badge#badgeTrapCount {
  display: none !important;
}

.tab-badge {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  opacity: 0.85;
}

.tab-btn.active .tab-badge {
  color: var(--primary);
  opacity: 1;
}

/* Badge số XML chỉ hiện khi có dữ liệu */
.header-tabs #badgeXmlCount {
  display: none;
  padding: 1px 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary);
  line-height: 1.2;
}

.header-tabs #badgeXmlCount:not(:empty):not(.is-zero) {
  display: inline-block;
}

/* Badge cảnh báo số văn bản/bẫy chờ Admin duyệt */
.header-tabs #badgeTrapPendingCount {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 17px;
  padding: 0 5px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  background: rgba(217, 119, 6, 0.16) !important;
  color: #b45309 !important;
  margin-left: 2px;
}

[data-theme="dark"] .header-tabs #badgeTrapPendingCount {
  background: rgba(245, 158, 11, 0.22) !important;
  color: #fbbf24 !important;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.18s var(--ease);
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--surface-alt);
  transform: translateY(-1px);
}

/* ===== MAIN CONTAINER ===== */
.main-wrap {
  max-width: 1260px;
  margin: 0 auto;
  padding: 18px 22px 36px;
}

.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.2s var(--ease); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes chipIn {
  from { opacity: 0; transform: translateY(4px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ===== UNIFIED CLINICAL RIBBON (TINH GỌN 1 HÀNG DUY NHẤT) ===== */
.unified-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  flex-wrap: nowrap;
  margin-bottom: 12px;
  padding: 3px 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  overflow-x: auto;
  overflow-y: visible;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.unified-bar::-webkit-scrollbar { display: none; }

.bar-left {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  flex-shrink: 1;
  min-width: 0;
}

.bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
  flex-shrink: 0;
  margin-left: auto;
}

.bar-divider {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 1px;
  flex-shrink: 0;
}

.segmented {
  display: inline-flex;
  align-items: center;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.5px;
  gap: 1px;
  flex-shrink: 0;
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  padding: 2.5px 6.5px;
  border-radius: 4px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s var(--ease);
  line-height: 1.25;
}

.seg-btn:hover { color: var(--text); }

.seg-btn.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mode-seg .seg-btn.active {
  color: var(--primary);
  font-weight: 700;
}

.select-clean {
  height: 25px;
  padding: 0 18px 0 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-alt) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 5px center;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

#specialtySelect {
  max-width: 118px;
  text-overflow: ellipsis;
  overflow: hidden;
}

#ageGroupSelect {
  max-width: 96px;
}

#vitalStatusSelect {
  max-width: 82px;
}

.select-clean:hover {
  border-color: var(--border-strong);
  background-color: var(--surface);
}

.select-clean:focus {
  border-color: var(--primary);
  background-color: var(--surface);
}

.select-clean.vital-deceased {
  background-color: #fee2e2;
  color: #b91c1c;
  border-color: #ef4444;
  font-weight: 700;
}

[data-theme="dark"] .select-clean {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

[data-theme="dark"] .select-clean.vital-deceased {
  background-color: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border-color: #ef4444;
}

.unified-bar .btn-subtle {
  background: var(--surface-alt);
  border-color: var(--border);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  height: 25px;
  padding: 0 6.5px;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.unified-bar .btn-subtle:hover {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
}

.bar-right .recent-anchor {
  flex-shrink: 0;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  max-width: 100%;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.18s var(--ease);
}

.btn:hover {
  background: var(--surface-soft);
  border-color: var(--border-strong);
  transform: translateY(-0.5px);
}

.btn:active { transform: translateY(0) scale(0.99); }

.btn-primary {
  background: var(--primary-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-primary), inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

.btn-primary:hover {
  background: var(--primary-grad);
  filter: brightness(1.06);
  border-color: transparent;
  box-shadow: 0 6px 20px -4px rgba(15, 118, 110, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.btn-danger-outline {
  border-color: var(--err);
  color: var(--err);
  background: var(--err-bg);
  box-shadow: none;
}

.btn-sm { padding: 5.5px 11px; font-size: 12px; border-radius: 8px; }

.btn-subtle {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-muted);
}

.btn-subtle:hover {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: var(--text-muted);
}

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

.text-link-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 5px;
  transition: background 0.15s;
}

.text-link-btn:hover { background: var(--primary-soft); }

/* ===== 2-COLUMN CLINICAL WORKBENCH ===== */
.workbench-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.42fr) minmax(340px, 1fr);
  gap: 20px;
  align-items: start;
}

@media (max-width: 940px) {
  .workbench-grid { grid-template-columns: 1fr; gap: 14px; }
  .wb-right { position: static; order: 0; }
}

.workbench-grid > *,
.two-col > *,
.bhyt-dashboard-cockpit > * {
  min-width: 0;
  max-width: 100%;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  min-width: 0;
  max-width: 100%;
}

.mode-pane { display: none; }
.mode-pane.active { display: block; animation: fadeIn 0.18s var(--ease); }

/* ===== LEFT FORM CARD ===== */
.clean-form-card { padding: 22px; }

.clean-field { margin-bottom: 16px; }
.clean-field:last-of-type { margin-bottom: 14px; }

.clean-field label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 7px;
  letter-spacing: -0.01em;
}

.field-tag {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.mini-note {
  font-weight: 500;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-left: 5px;
}

.extra-field {
  padding-top: 14px;
  border-top: 1px dashed var(--border-strong);
}

.extra-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
}

.extra-field-head label { margin-bottom: 0; }

.diag-input-row { position: relative; }

.input-lead-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  opacity: 0.7;
}

.clean-input {
  width: 100%;
  padding: 11px 36px 11px 14px;
  font-family: inherit;
  font-size: 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
  outline: none;
  transition: all 0.18s var(--ease);
}

.clean-input.has-icon { padding-left: 38px; }

.clean-input:hover { border-color: rgba(15, 118, 110, 0.35); }

.clean-input:focus {
  border-color: var(--primary-bright);
  background: var(--surface);
  box-shadow: 0 0 0 3.5px var(--primary-soft);
}

.clear-inline-btn {
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 4px 6px;
  border-radius: 6px;
  display: none;
}

.clear-inline-btn:hover { background: var(--surface-alt); color: var(--text); }
.clear-inline-btn.visible { display: block; }

.extra-toggles-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 8px;
}

.pill-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.16s var(--ease);
}

.pill-toggle:hover, .pill-toggle.active {
  border-style: solid;
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* Inline Suggestions */
.suggest-box:empty { display: none; }
.suggest-box {
  margin-top: 9px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 360px;
  overflow-y: auto;
  padding-right: 4px;
}

.suggest-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  padding: 0 2px 2px;
}

.suggest-subhead {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
}

.suggest-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 8.5px 11px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  transition: all 0.16s var(--ease);
}

.suggest-row:hover, .suggest-row.kb-focus {
  border-color: var(--primary);
  background: var(--primary-soft);
  transform: translateX(2px);
}

.suggest-row.status-error { border-left: 3px solid var(--err); }
.suggest-row.status-warn { border-left: 3px solid var(--warn); }

.suggest-main { min-width: 0; flex: 1; }

.suggest-title {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  font-size: 13px;
  font-weight: 500;
}

/* Quick Specialty Drawer */
.quick-sp-drawer {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.quick-sp-head {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 9px;
}

.quick-sp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(225px, 1fr));
  gap: 7px;
}

.quick-sp-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 12px;
  transition: border-color 0.15s;
}

.quick-sp-item:hover { border-color: var(--primary); }

.quick-sp-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Combination Alert */
.combo-alert-wrap:empty { display: none; }
.combo-alert-card {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--warn-bg);
  border: 1px solid rgba(180, 83, 9, 0.3);
  margin-bottom: 14px;
}

.combo-alert-title { font-size: 13px; font-weight: 700; color: var(--warn); margin-bottom: 4px; }
.combo-alert-detail { font-size: 12.2px; color: var(--text); margin-bottom: 9px; }

/* ===== ELEVATED CLINICAL CODING CARD (RIGHT PANE) ===== */
.case-sheet-clean {
  position: relative;
  overflow: hidden;
  padding: 20px;
  box-shadow: var(--shadow-elevated);
  border-color: var(--border-strong);
}

.case-sheet-clean::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3.5px;
  background: var(--primary-grad);
  transition: background 0.25s var(--ease);
}

.case-sheet-clean[data-verdict="pass"]::before {
  background: linear-gradient(90deg, #10b981, #059669);
}

.case-sheet-clean[data-verdict="warn"]::before {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.case-sheet-clean[data-verdict="fail"]::before {
  background: linear-gradient(90deg, #f43f5e, #be123c);
}

.sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.sheet-title-wrap { display: flex; flex-direction: column; gap: 2px; }

.sheet-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  color: var(--primary);
  text-transform: uppercase;
}

.sheet-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.status-pill {
  font-size: 11.5px;
  font-weight: 700;
  padding: 3.5px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.status-empty { background: var(--surface-alt); color: var(--text-muted); }
.status-pass { background: var(--ok-bg); color: var(--ok); }
.status-warn { background: var(--warn-bg); color: var(--warn); }
.status-fail { background: var(--err-bg); color: var(--err); }
.status-cdi { background: var(--info-bg); color: var(--info); border: 1px solid rgba(29, 78, 216, 0.22); }

.clean-slot {
  padding: 12px 0;
  border-top: 1px solid var(--border);
}

.clean-slot-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.chip-tray { display: flex; flex-direction: column; gap: 6px; }
.tray-placeholder { font-size: 12.5px; color: var(--text-muted); opacity: 0.8; }

.case-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 12.8px;
  animation: chipIn 0.2s var(--ease);
}

.case-chip strong {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--primary);
}

.case-chip.chip-warn { border-left: 3px solid var(--warn); }
.case-chip.chip-error { border-left: 3px solid var(--err); background: var(--err-bg); }
.case-chip.chip-error strong { color: var(--err); }
.case-chip.chip-icd9 { border-left: 3px solid var(--info); }
.case-chip.chip-icd9 strong { color: var(--info); }

.case-chip-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.case-chip-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

.chip-act-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.14s;
}

.chip-act-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

.chip-del-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 5px;
  border-radius: 5px;
}

.chip-del-btn:hover { color: var(--err); background: var(--err-bg); }

.sheet-actions { display: flex; gap: 7px; margin-top: 14px; }

.paste-drawer {
  margin-top: 11px;
  padding: 11px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
}

.paste-grid { display: flex; flex-direction: column; gap: 7px; }
.input-sm { padding: 7.5px 10px !important; font-size: 12.5px !important; }

.clean-audit-wrap:empty { display: none; }
.clean-audit-wrap { margin-top: 14px; }

.verdict-banner {
  padding: 9px 12px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 9px;
}

.verdict-pass { background: var(--ok-bg); color: var(--ok); }
.verdict-warn { background: var(--warn-bg); color: var(--warn); }
.verdict-fail { background: var(--err-bg); color: var(--err); }

.finding-card {
  border: 1px solid var(--border);
  border-left: 3.5px solid var(--warn);
  border-radius: 9px;
  padding: 9px 11px;
  margin-bottom: 7px;
  background: var(--surface-soft);
}

.finding-card.level-error { border-left-color: var(--err); }

.finding-header {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
  font-size: 12.2px;
  font-weight: 700;
}

.finding-detail { font-size: 11.8px; color: var(--text-muted); margin-top: 4px; }

.subtle-bridge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
}

.subtle-bridge-text {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== SUMMARY ANALYZER ===== */
.summary-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.summary-label { font-weight: 700; font-size: 13.5px; letter-spacing: -0.01em; }

.ai-pill {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3.5px 10px;
  border-radius: 999px;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: all 0.16s;
}

.ai-pill.ai-offline { background: var(--surface-alt); color: var(--text-muted); }
.ai-pill.ai-online { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

.summary-actions-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }

.analysis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.analysis-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.8px;
  font-weight: 700;
  color: var(--primary);
}

.analysis-section { margin-bottom: 13px; }
.analysis-section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 7px;
  text-transform: uppercase;
}

.mb-box {
  padding: 11px;
  border-radius: 10px;
  background: var(--primary-soft);
  border: 1px solid rgba(13, 148, 136, 0.35);
}

.mb-rule-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-grad);
  color: #fff;
  margin-bottom: 7px;
}

.tie-break-box {
  margin-top: 9px;
  padding: 10px 11px;
  border-radius: 9px;
  background: var(--warn-bg);
}

.tie-break-title { font-size: 12px; font-weight: 700; color: var(--warn); margin-bottom: 6px; }
.history-list { margin: 0; padding-left: 18px; font-size: 12.2px; color: var(--text-muted); }

/* ===== ICD-9-CM & CODE BADGES ===== */
.compact-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stats-bar { font-size: 12px; color: var(--text-muted); margin-bottom: 9px; }
.result-list { display: flex; flex-direction: column; gap: 8px; }

.result-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
  transition: all 0.16s var(--ease);
}

.result-item:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.result-item.in-case { border-color: var(--primary); background: var(--primary-soft); }

.result-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.result-title-block { flex: 1 1 260px; min-width: 0; }
.code-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.code-tag {
  font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 12.5px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--primary-soft);
  color: var(--primary);
  letter-spacing: -0.01em;
}

.code-tag.icd9-tag { background: var(--info-bg); color: var(--info); }
.vi-name { font-size: 13.5px; font-weight: 600; }
.en-name { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.result-actions { display: flex; align-items: center; gap: 5px; }
.badges-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
}

.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-error { background: var(--err-bg); color: var(--err); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-cdi { background: rgba(79, 70, 229, 0.11); color: #4338ca; border: 1px solid rgba(79, 70, 229, 0.24); }
[data-theme="dark"] .badge-cdi { background: rgba(129, 140, 248, 0.16); color: #a5b4fc; border-color: rgba(129, 140, 248, 0.3); }
.badge-female { background: var(--female-bg); color: var(--female); }
.badge-male { background: var(--male-bg); color: var(--male); }

.guidance-box {
  margin-top: 7px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-alt);
  font-size: 12px;
  color: var(--text-muted);
}

.child-pill {
  font-family: inherit;
  font-size: 11.5px;
  padding: 4.5px 9px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: all 0.14s;
}

.child-pill:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ===== RECENT CASES & CUSTOM SYNONYMS ===== */
.recent-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 7px;
  width: 315px;
  max-width: 90vw;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-elevated);
  padding: 6px;
  z-index: 90;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  transition: background 0.14s;
}

.recent-item:hover { background: var(--surface-alt); }

.syn-add-row { display: flex; gap: 6px; flex-wrap: wrap; }
.syn-add-row input { flex: 1 1 130px; }

.syn-chip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 12.5px;
  margin-bottom: 6px;
}

/* ===== TRAPS & RULES TAB ===== */
.two-col { display: grid; grid-template-columns: 1.15fr 1fr; gap: 20px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

.trap-group-header:hover {
  background: var(--surface-hover, rgba(255, 255, 255, 0.05)) !important;
  border-color: var(--border-strong, var(--border)) !important;
}

.trap-card {
  border: 1px solid var(--border);
  border-left: 3.5px solid var(--warn);
  border-radius: 10px;
  padding: 11px 13px;
  margin-bottom: 9px;
  background: var(--surface-soft);
}

.trap-card.level-error { border-left-color: var(--err); }

.rules-guide { display: flex; flex-direction: column; gap: 9px; }
.rule-item {
  padding: 11px 13px;
  border-radius: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  font-size: 12.5px;
}
.rule-item p { margin: 4px 0 0 0; color: var(--text-muted); }

/* ===== FORMS & MODAL ===== */
.form-field { margin-bottom: 12px; }
.form-field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 5px; }

.text-input, .textarea-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface-soft);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: all 0.16s var(--ease);
}

.text-input:focus, .textarea-input:focus {
  border-color: var(--primary-bright);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.help-text { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.modal-divider { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}

.modal-backdrop.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 450px;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 20px 22px;
  box-shadow: var(--shadow-elevated);
}

.modal-box h3 { margin: 0 0 14px 0; font-size: 16px; letter-spacing: -0.015em; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ===== MODULE CÀI ĐẶT HỆ THỐNG 5-STAR ENTERPRISE (CHUẨN MINIHIS_BA) ===== */
.modal-box-settings {
  max-width: 960px;
  width: min(95vw, 960px);
  height: min(88vh, 720px);
  max-height: 90vh;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--border-strong, var(--border));
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24), 0 4px 16px rgba(15, 23, 42, 0.08);
  background: var(--surface);
}
.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.settings-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.settings-header-icon {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #0ea5e9 0%, #4f46e5 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.28);
  flex-shrink: 0;
}
.settings-header-titles {
  min-width: 0;
}
.settings-header-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.settings-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}
.settings-enterprise-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(14, 165, 233, 0.12);
  color: #0369a1;
  border: 1px solid rgba(14, 165, 233, 0.28);
}
html[data-theme="dark"] .settings-enterprise-badge {
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
  border-color: rgba(56, 189, 248, 0.3);
}
.settings-header-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.settings-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.settings-close-x {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.14s ease;
}
.settings-close-x:hover {
  background: var(--surface-hover, rgba(148, 163, 184, 0.15));
  color: var(--text);
}
.settings-workspace-body {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.settings-sidebar {
  width: 256px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  overflow-y: auto;
}
.settings-tabs {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  border: none;
  background: transparent;
  margin: 0;
}
.settings-nav-group-label {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 4px 10px 4px;
  opacity: 0.85;
}
.settings-tab-btn {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  padding: 9px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.settings-tab-btn:hover {
  background: var(--surface-soft);
  color: var(--text);
}
.settings-tab-btn.active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.11) 0%, rgba(79, 70, 229, 0.09) 100%);
  border-color: rgba(14, 165, 233, 0.34);
  color: var(--primary);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.08);
}
.settings-nav-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: all 0.15s ease;
}
.settings-tab-btn.active .settings-nav-icon {
  background: linear-gradient(135deg, #0ea5e9 0%, #4f46e5 100%);
  color: #ffffff;
  box-shadow: 0 3px 8px rgba(79, 70, 229, 0.25);
}
.settings-nav-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.settings-nav-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.settings-tab-btn.active .settings-nav-title {
  color: var(--primary);
}
.settings-nav-sub {
  font-size: 10.5px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.3;
  margin-top: 2px;
}
.settings-content-scroll {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 18px 22px;
  background: var(--surface-soft);
}
.settings-pane { display: none; }
.settings-pane.active {
  display: block;
  animation: settingsFadeIn 0.16s ease;
}
@keyframes settingsFadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}
.settings-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.input-action-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.input-action-row .text-input { flex: 1; min-width: 0; }
.ai-status-banner {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.ai-status-banner.is-online {
  border-color: rgba(16, 185, 129, 0.45);
  background: rgba(16, 185, 129, 0.08);
}
.ai-test-result {
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1.45;
  display: none;
}
.ai-test-result.show { display: block; }
.ai-test-result.ok {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: var(--text);
}
.ai-test-result.err {
  background: rgba(239, 68, 68, 0.11);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: var(--text);
}
.ai-test-result.pending {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}
/* ===== DANH SÁCH NHIỀU API KEY (MULTI-PROVIDER POOL) ===== */
.ai-key-list-box {
  margin-top: 14px;
  padding: 12px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
.ai-key-list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 9px;
}
.ai-key-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 240px;
  overflow-y: auto;
}
.ai-key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: border-color 0.14s ease, box-shadow 0.14s ease;
}
.ai-key-row.is-primary {
  border-color: rgba(13, 148, 136, 0.45);
  box-shadow: 0 2px 8px -2px rgba(13, 148, 136, 0.16);
}
.ai-key-row.is-disabled {
  opacity: 0.6;
}
.ai-key-info {
  min-width: 0;
  flex: 1;
}
.ai-key-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.ai-provider-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: rgba(13, 148, 136, 0.12);
  color: var(--primary);
}
.ai-key-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 210px;
}
.ai-key-sub {
  margin-top: 3px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-key-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.ai-key-actions .btn-sm {
  padding: 4px 8px;
  font-size: 11px;
  min-height: 26px;
}
@media (max-width: 560px) {
  .ai-key-row {
    flex-direction: column;
    align-items: stretch;
  }
  .ai-key-actions {
    justify-content: flex-end;
  }
}
.settings-stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.settings-stat-card {
  padding: 11px 13px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}
.settings-stat-label { font-size: 11px; color: var(--text-muted); }
.settings-stat-val { font-size: 14px; font-weight: 800; margin-top: 3px; color: var(--text); }
.settings-section-box {
  padding: 15px 16px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
}
.settings-section-title {
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 10px 0;
}
.settings-check-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.settings-check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  cursor: pointer;
}
.settings-check-row input[type="checkbox"] {
  margin-top: 2px;
  cursor: pointer;
}
.settings-footer-bar {
  margin-top: 0;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-shrink: 0;
}
.cloud-role-badge.role-planning {
  background: rgba(14, 165, 233, 0.14);
  color: #0369a1;
  border-color: rgba(14, 165, 233, 0.32);
}
html[data-theme="dark"] .cloud-role-badge.role-planning {
  background: rgba(56, 189, 248, 0.16);
  color: #7dd3fc;
}
html[data-font-size="large"] {
  font-size: 17.5px;
}
html[data-font-size="large"] body {
  font-size: 15px;
}
html[data-font-size="large"] .result-title,
html[data-font-size="large"] .clean-input,
html[data-font-size="large"] .text-input,
html[data-font-size="large"] .select-clean {
  font-size: 14.5px;
}
@media (max-width: 780px) {
  .modal-box-settings {
    width: 97vw;
    height: 92vh;
  }
  .settings-workspace-body {
    flex-direction: column;
  }
  .settings-sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 8px 10px;
  }
  .settings-nav-group-label,
  .settings-nav-sub {
    display: none;
  }
  .settings-tabs {
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
  }
  .settings-tab-btn {
    width: auto;
    flex-shrink: 0;
    align-items: center;
    padding: 7px 10px;
  }
  .settings-content-scroll {
    padding: 14px;
  }
  .settings-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .settings-grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ===== TOAST & BANNERS ===== */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: #0f172a;
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.28);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: all 0.2s var(--ease);
  z-index: 300;
}

.toast.show { opacity: 1; transform: translateY(0); }

.empty-state {
  text-align: center;
  padding: 24px 16px;
  color: var(--text-muted);
  font-size: 13px;
}

.loading-banner {
  padding: 11px 16px;
  border-radius: 11px;
  margin-bottom: 14px;
  text-align: center;
  font-size: 13px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.loading-banner.banner-error {
  background: var(--err-bg);
  color: var(--err);
  border: 1px solid var(--err);
  text-align: left;
  line-height: 1.5;
}

/* ===== MOBILE & TABLET RESPONSIVE ===== */
.wb-right { position: sticky; top: 70px; }
.mobile-ctx-toggle-btn { display: none; }
.tab-label-short { display: none; }
.mobile-admin-nav-wrap { display: none; }

@media (max-width: 1140px) {
  .header-inner {
    flex-wrap: wrap;
    padding: 8px 14px;
    gap: 8px 10px;
  }
  .brand { min-width: 0; flex: 1; }
  .brand-inline { min-width: 0; flex: 1; }
  .unit-title-btn, .brand-subtitle { max-width: 100%; }
  .header-actions { flex-shrink: 0; }
  .header-tabs {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .header-tabs::-webkit-scrollbar { display: none; }
  .tab-btn {
    flex: 0 0 auto;
    justify-content: center;
    padding: 7px 10px;
    font-size: 12.5px;
  }
}

@media (max-width: 940px) {
  .wb-right { position: static; }
  .unit-title-btn { font-size: 14px; max-width: 100%; }
  .brand-subtitle { max-width: 100%; }
}

@media (max-width: 640px) {
  .main-wrap { padding: 10px 10px 28px; max-width: 100vw; }
  .card, .clean-form-card, .case-sheet-clean {
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 10px;
  }

  /* Header gọn tối đa, 0 tràn ngang, tab cuộn ngang 1 hàng mượt */
  .header-inner { padding: 7px 10px; gap: 6px 8px; }
  .brand { gap: 8px; min-width: 0; flex: 1; }
  .brand-icon { width: 30px; height: 30px; border-radius: 8px; }
  .brand-inline { flex-direction: column; align-items: flex-start; gap: 0; min-width: 0; flex: 1; }
  .unit-title-btn {
    max-width: 100%;
    width: 100%;
    font-size: 13.5px;
    line-height: 1.25;
  }
  .brand-subtitle {
    max-width: 100%;
    width: 100%;
    font-size: 10.5px;
    line-height: 1.2;
  }
  .header-actions { gap: 4px; }
  .icon-btn { width: 32px; height: 32px; }
  .header-tabs {
    padding: 2.5px;
    gap: 2px;
    border-radius: 10px;
    overflow: visible;
    -webkit-mask-image: none;
    mask-image: none;
  }
  .header-tabs > .tab-btn[data-admin-only="true"] { display: none !important; }
  .header-tabs .tab-label-full { display: none; }
  .header-tabs .tab-label-short { display: inline; }
  .header-tabs .tab-badge { display: none !important; }
  .header-tabs > .tab-btn {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    padding: 6.5px 4px;
    font-size: 12px;
    gap: 3px;
    white-space: nowrap;
  }
  .mobile-admin-nav-wrap {
    display: inline-flex;
    position: relative;
    flex: 0 0 auto;
  }
  .mobile-admin-nav-btn {
    padding: 6.5px 8px;
    font-size: 12px;
    gap: 3px;
    white-space: nowrap;
  }
  .mobile-admin-chevron {
    flex-shrink: 0;
    transition: transform 0.16s var(--ease);
  }
  .mobile-admin-nav-wrap.open .mobile-admin-chevron {
    transform: rotate(180deg);
  }
  .mobile-admin-nav-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 192px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 11px;
    box-shadow: var(--shadow-elevated);
    padding: 5px;
    z-index: 120;
    flex-direction: column;
    gap: 2px;
  }
  .mobile-admin-nav-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    white-space: nowrap;
    transition: background 0.14s var(--ease), color 0.14s var(--ease);
  }
  .mobile-admin-nav-item:hover,
  .mobile-admin-nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
  }
  .mobile-admin-item-badge {
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
  }
  .mobile-admin-nav-item.active .mobile-admin-item-badge {
    color: var(--primary);
  }

  /* Thanh ngữ cảnh 5 sao: thu gọn còn 1-2 dòng, bấm Bộ lọc để mở đầy đủ */
  .unified-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
    padding: 7px 8px;
    margin-bottom: 10px;
    overflow: visible;
  }
  .unified-bar .bar-divider { display: none; }
  #globalContextRibbon:not(.mobile-ctx-open) .bar-left > :not(#icd10ModeSeg) {
    display: none !important;
  }
  #globalContextRibbon.mobile-no-mode:not(.mobile-ctx-open) .bar-left {
    display: none !important;
  }
  .bar-left {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-auto-flow: dense;
    gap: 6px;
    width: 100%;
  }
  .bar-left .mode-seg,
  .bar-left #sexSeg {
    grid-column: 1 / -1;
    width: 100%;
    display: flex;
  }
  .bar-left .mode-seg .seg-btn { flex: 1 1 0; text-align: center; padding: 6.5px 6px; font-size: 12px; }
  .bar-left .segmented { width: 100%; display: flex; overflow: hidden; }
  .bar-left .segmented .seg-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 6px 4px;
    font-size: 11.5px;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .bar-left .select-clean {
    width: 100%;
    min-width: 0;
    height: 32px;
    font-size: 12px;
    padding: 0 22px 0 8px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .bar-right {
    width: 100%;
    margin-left: 0;
    display: flex;
    align-items: center;
    gap: 5px;
  }
  .mobile-ctx-toggle-btn {
    display: inline-flex !important;
    flex: 1 1 0;
    min-width: 0;
    height: 32px !important;
    padding: 0 8px !important;
    justify-content: space-between;
    color: var(--text) !important;
    font-weight: 600 !important;
    font-size: 11.5px !important;
  }
  #mobileContextSummaryText {
    flex: 1;
    min-width: 0;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .mobile-ctx-chevron {
    flex-shrink: 0;
    transition: transform 0.18s var(--ease);
  }
  #globalContextRibbon.mobile-ctx-open .mobile-ctx-chevron {
    transform: rotate(180deg);
  }
  #globalContextRibbon.mobile-ctx-open .mobile-ctx-toggle-btn {
    border-color: var(--primary) !important;
    color: var(--primary) !important;
    background: var(--primary-soft) !important;
  }
  .mobile-ctx-toggle-btn.has-alert {
    border-color: #ef4444 !important;
    color: #b91c1c !important;
    background: #fee2e2 !important;
  }
  .bar-right .recent-anchor {
    flex: 0 0 auto;
    display: inline-flex !important;
  }
  .bar-right #btnRecentCases,
  .bar-right #btnNewCase {
    flex: 0 0 auto;
    height: 32px;
    padding: 0 8px;
    justify-content: center;
    font-size: 11.5px;
  }
  .recent-menu {
    left: auto;
    right: 0;
    width: min(300px, calc(100vw - 24px));
    max-width: calc(100vw - 24px);
  }

  /* Chống iOS Safari auto-zoom nhưng giữ placeholder thanh thoát, không bị cắt cụt */
  .clean-input, .text-input, .textarea-input {
    font-size: 16px;
    padding: 10px 34px 10px 12px;
  }
  .clean-input.has-icon { padding-left: 34px; }
  .clean-input::placeholder,
  .text-input::placeholder,
  .textarea-input::placeholder {
    font-size: 13px;
    opacity: 0.82;
  }

  /* Nhãn ô nhập & thanh nút phụ 1 hàng gọn với hiệu ứng mờ mép phải tinh tế */
  .clean-field label { font-size: 12.5px; gap: 6px; }
  .clean-field label .field-tag {
    font-size: 10.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .extra-toggles-bar {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 5px;
    padding: 6px 18px 2px 0;
    -webkit-mask-image: linear-gradient(to right, #000 88%, transparent 100%);
    mask-image: linear-gradient(to right, #000 88%, transparent 100%);
  }
  .extra-toggles-bar::-webkit-scrollbar { display: none; }
  .extra-toggles-bar .pill-toggle {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 11.5px;
    padding: 5px 9px;
  }

  /* Thanh hành động cân đối 1 nút chính full-width + 2 nút phụ 50/50 */
  .mobile-action-bar {
    width: 100%;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 6px !important;
  }
  .mobile-action-bar > .btn-primary:first-child {
    grid-column: 1 / -1;
    min-height: 36px;
  }
  .mobile-action-bar > .btn,
  .mobile-action-bar > label.btn {
    width: 100%;
    justify-content: center;
    padding: 7px 8px;
    font-size: 12px;
    min-height: 34px;
  }
  #xmlDropZone,
  #bhytReportDropZone {
    padding: 14px 12px !important;
  }

  /* Thanh phân loại ICD-9 & chế độ XML giãn đủ 100% cân xứng */
  #icd9MethodSeg,
  #xmlSubModeGroup {
    display: flex !important;
    width: 100%;
  }
  #icd9MethodSeg .seg-btn,
  #xmlSubModeGroup .seg-btn {
    flex: 1 1 0 !important;
    justify-content: center;
    text-align: center;
    padding: 6.5px 4px;
  }

  /* Mọi thanh segmented / filter dài chuyển sang cuộn ngang 1 hàng mượt, tuyệt đối không tràn */
  .panel .segmented,
  .modal-box .segmented,
  .seg-group {
    display: inline-flex;
    flex-wrap: nowrap;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .panel .segmented::-webkit-scrollbar,
  .modal-box .segmented::-webkit-scrollbar,
  .seg-group::-webkit-scrollbar { display: none; }
  .panel .segmented .seg-btn,
  .modal-box .segmented .seg-btn,
  .seg-group .seg-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 6px 9px;
    font-size: 11.5px;
  }
  .compact-filters {
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
  }
  .compact-filters .select-clean {
    width: 100%;
    height: 34px;
    font-size: 12.5px;
  }

  /* Thẻ gợi ý & kết quả gọn gàng, tự bẻ từ dài tránh tràn ngang */
  .suggest-row {
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
    padding: 9px 10px;
  }
  .suggest-main,
  .result-title-block,
  .finding-card,
  .trap-card {
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
  }
  .suggest-title { gap: 5px; font-size: 12.5px; }
  .suggest-row > .btn,
  .suggest-row > div:last-child {
    align-self: flex-end;
  }
  .result-top { flex-direction: column; gap: 8px; }
  .result-title-block { flex: 1 1 auto; width: 100%; }
  .result-actions { width: 100%; justify-content: flex-end; flex-wrap: nowrap; overflow-x: auto; }

  .quick-sp-grid { grid-template-columns: 1fr; }
  .sheet-title-wrap { min-width: 0; flex: 1; }
  .sheet-title { font-size: 15px; }
  .case-chip { padding: 7px 9px; gap: 6px; }
  .case-chip-text {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.35;
  }
  .chip-act-btn { white-space: nowrap; }

  /* Nút hành động chính giữ 1 hàng gọn không rớt dòng */
  .sheet-actions { flex-wrap: nowrap; gap: 6px; }
  .sheet-actions .btn { flex: 1 1 auto; min-height: 38px; padding: 7px 10px; font-size: 12.5px; }
  .summary-top-row { flex-wrap: nowrap; gap: 6px; }
  .summary-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
  .ai-pill { white-space: nowrap; font-size: 11px; padding: 3px 8px; }
  .summary-actions-row { flex-wrap: nowrap; gap: 6px; }
  .summary-actions-row .btn { flex: 1 1 auto; padding: 8px 10px; font-size: 12.5px; }
  .subtle-bridge-row { flex-wrap: nowrap; gap: 8px; }
  .subtle-bridge-text { min-width: 0; flex: 1; }
  .subtle-bridge-row .text-link-btn { flex-shrink: 0; white-space: nowrap; }

  /* Ô tìm kiếm & form nội bộ không tràn min-width */
  #xmlQuickSearch,
  #bhytReportQuickSearch,
  #trapSearchInput,
  #inputPostAuditPaste,
  #inputHubLookupDocCode,
  #inputLookupDocCode {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }
  #bhytFilterDept,
  #bhytFilterDoctor {
    flex: 1 1 130px;
    max-width: none !important;
    min-width: 0;
    height: 32px;
    font-size: 12px;
  }
  .syn-add-row input { flex: 1 1 100%; max-width: 100% !important; }
  .syn-add-row .btn { width: 100%; }

  /* Chuyển lưới nhiều cột inline về 1 cột an toàn trên mobile */
  #panel-catalog [style*="grid-template-columns"],
  #bhytRoleContainer [style*="grid-template-columns"],
  #hubBrainAddForm > div,
  #regulatoryBrainAddForm > div,
  #postRuleModal [style*="grid-template-columns"],
  #learnedRuleDraftsList [style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  #bhytRoleContainer .card { overflow-x: auto; }

  /* Modal & Toast gọn vừa màn hình */
  .modal-backdrop { padding: 8px; align-items: flex-end; }
  .modal-box {
    width: 100% !important;
    max-width: 100% !important;
    padding: 14px;
    border-radius: 16px 16px 12px 12px;
  }
  .modal-box h3 { font-size: 14.5px; line-height: 1.3; }
  .modal-footer { flex-wrap: wrap; gap: 6px; }
  .modal-footer .btn { flex: 1 1 auto; min-height: 36px; padding: 7px 10px; font-size: 12px; }
  .toast {
    left: 10px;
    right: 10px;
    bottom: 12px;
    text-align: center;
  }
}

/* Bộ lọc chặn chọn nhầm Bệnh chính */
.clean-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.clean-field-head > label:first-child {
  margin-bottom: 0;
}
.main-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft, rgba(15, 118, 110, 0.08));
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 9px;
  cursor: pointer;
  user-select: none;
  margin-bottom: 0 !important;
}
.main-filter-toggle input {
  accent-color: var(--primary);
  margin: 0;
  cursor: pointer;
}
.filter-notice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 10px;
  margin-top: 6px;
  border-radius: 8px;
  border: 1px dashed var(--border);
  background: var(--bg-soft, rgba(239, 68, 68, 0.05));
  font-size: 12px;
  color: var(--text-muted);
}

/* ===== PHÂN HỆ GIẢI MÃ & CẢNH BÁO XUẤT TOÁN BHYT (CỔNG GIÁM ĐỊNH) - CLEAN UI PKBA ===== */
.bhyt-kpi-grid {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 10px;
  margin-top: 10px;
}
@media (max-width: 1080px) {
  .bhyt-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}
@media (max-width: 560px) {
  .bhyt-kpi-grid {
    grid-template-columns: 1fr !important;
  }
}
.bhyt-kpi-card {
  padding: 12px 15px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
  transition: transform 0.16s ease, box-shadow 0.16s ease, border-color 0.16s ease;
}
.bhyt-kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  border-color: var(--border-strong, var(--border));
}
.bhyt-kpi-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.35px;
  color: var(--text-muted);
  white-space: nowrap;
  gap: 6px;
}
.bhyt-kpi-num {
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text);
  line-height: 1.15;
  margin-top: 2px;
}
.bhyt-kpi-money {
  font-size: 13px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bhyt-kpi-fatal {
  border-top: 3px solid var(--err, #ef4444);
  border-left: 1px solid var(--border);
}
.bhyt-kpi-fatal .bhyt-kpi-money { color: var(--err, #ef4444); }

.bhyt-kpi-warn {
  border-top: 3px solid #f59e0b;
  border-left: 1px solid var(--border);
}
.bhyt-kpi-warn .bhyt-kpi-money { color: #d97706; }

.bhyt-kpi-syntax {
  border-top: 3px solid #10b981;
  border-left: 1px solid var(--border);
}
.bhyt-kpi-syntax .bhyt-kpi-money { color: #059669; }

.bhyt-kpi-total {
  border-top: 3px solid var(--primary, #0f766e);
  border-left: 1px solid var(--border);
}
.bhyt-kpi-total .bhyt-kpi-money { color: var(--primary, #0f766e); }

/* DASHBOARD COCKPIT 2 CỘT TẬP TRUNG (RỦI RO PARETO & TRÁCH NHIỆM KHOA/BÁC SĨ) */
.bhyt-dashboard-cockpit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 12px;
}
@media (max-width: 900px) {
  .bhyt-dashboard-cockpit {
    grid-template-columns: 1fr;
  }
}
.bhyt-visual-col, .bhyt-exec-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

/* 5-STAR EXECUTIVE DASHBOARD DONUT & UNIFIED BAR */
#bhytDonutCardWrap {
  border-radius: 12px !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
#bhytDonutCardWrap:hover,
.bhyt-pareto-card:hover,
.bhyt-cat-card:hover {
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.07);
}
}
#bhytDonutCardWrap:hover {
  box-shadow: var(--shadow-md, 0 6px 16px -2px rgba(0, 0, 0, 0.1));
}
#bhytDonutChartBox svg circle {
  transition: stroke-dasharray 0.6s ease, stroke-dashoffset 0.6s ease;
}


/* BẢNG DỮ LIỆU ĐIỀU HÀNH & BẢNG TÍNH CHI TIẾT (SPREADSHEET STANDARD) */
.bhyt-table-wrap {
  overflow-x: auto;
  max-height: 480px;
  overflow-y: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  max-width: 100%;
}
.bhyt-table-compact {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}
.bhyt-table-compact th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-soft, rgba(0, 0, 0, 0.03));
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-strong);
  text-align: left;
  user-select: none;
  white-space: nowrap;
}
.bhyt-table-compact td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.bhyt-table-compact tbody tr:hover {
  background: var(--surface-soft, rgba(0, 0, 0, 0.02));
}
.bhyt-table-compact tbody tr:last-child td {
  border-bottom: none;
}
.bhyt-col-money {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
}
.bhyt-col-nowrap {
  white-space: nowrap;
}
.bhyt-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-top: 8px;
  font-size: 12px;
}
.bhyt-page-btn-group {
  display: flex;
  align-items: center;
  gap: 4px;
}

.bhyt-visual-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.bhyt-pareto-card, .bhyt-cat-card {
  padding: 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.bhyt-pareto-title {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bhyt-pareto-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.bhyt-pareto-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-soft, rgba(0, 0, 0, 0.02));
  border: 1px solid var(--border);
}
.bhyt-pareto-item-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
}
.bhyt-pareto-bar-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
  margin-top: 3px;
}
.bhyt-pareto-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.3s ease;
}
.bhyt-pareto-bar-fill.fatal { background: var(--err, #ef4444); }
.bhyt-pareto-bar-fill.warn { background: #f59e0b; }
.bhyt-pareto-bar-fill.syntax { background: #10b981; }

.bhyt-record-item {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.bhyt-record-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.bhyt-record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.bhyt-record-badges {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.bhyt-badge-fatal {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border: 1px solid rgba(239, 68, 68, 0.25);
  font-weight: 700;
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  display: inline-block;
}
.bhyt-badge-warn {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.25);
  font-weight: 700;
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  display: inline-block;
}
.bhyt-badge-syntax {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-weight: 700;
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  display: inline-block;
}
.bhyt-record-title {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}
.bhyt-record-meta {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.bhyt-record-box {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface-soft, rgba(0, 0, 0, 0.02));
  border: 1px solid var(--border);
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bhyt-record-action {
  font-weight: 600;
  color: var(--primary);
  display: flex;
  align-items: flex-start;
  gap: 5px;
}
.bhyt-doc-preview {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: 8px;
  max-height: 55vh;
  overflow-y: auto;
  user-select: text;
}

.bhyt-matrix-card {
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.bhyt-matrix-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.bhyt-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  text-align: left;
}
.bhyt-matrix-table th {
  background: var(--surface-soft);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.bhyt-matrix-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.bhyt-matrix-table tr:hover td {
  background: var(--surface-soft, rgba(0, 0, 0, 0.02));
}
.bhyt-drilldown-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.bhyt-drilldown-btn:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

/* ==========================================================================
   PKBA SMART CLINICAL CONTEXT MENU (DESKTOP WORKSTATION)
   Tối giản, tinh gọn, tương thích hoàn hảo Dark/Light Mode & Glassmorphism
   Phục vụ thao tác sao chép & dán nhanh trên bàn khám, không gây phiền toái.
   ========================================================================== */
.pkba-context-menu {
  position: fixed;
  z-index: 10070;
  min-width: 220px;
  max-width: 320px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 28px -4px rgba(0, 0, 0, 0.22), 0 4px 10px -2px rgba(0, 0, 0, 0.12);
  padding: 6px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  animation: pkbaCtxFadeIn 0.1s ease-out;
  user-select: none;
}
@keyframes pkbaCtxFadeIn {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-2px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
.pkba-ctx-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
  outline: none;
  gap: 12px;
  font-family: inherit;
}
.pkba-ctx-item:hover:not([disabled]) {
  background: var(--primary-soft, rgba(14, 165, 233, 0.1));
  color: var(--primary, #0ea5e9);
}
.pkba-ctx-item[disabled] {
  opacity: 0.42;
  cursor: not-allowed;
}
.pkba-ctx-item-left {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pkba-ctx-item-left svg {
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color 0.12s ease;
}
.pkba-ctx-item:hover:not([disabled]) .pkba-ctx-item-left svg {
  color: var(--primary, #0ea5e9);
}
.pkba-ctx-kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-soft, rgba(0, 0, 0, 0.05));
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
}
.pkba-ctx-hint {
  font-size: 11px;
  color: var(--text-muted);
  padding: 5px 8px 2px;
  text-align: center;
  border-top: 1px dashed var(--border);
  margin-top: 4px;
}

/* ===== MOBILE CASCADE OVERRIDES (CHỐNG TRÀN & HẠN CHẾ RỚT DÒNG BHYT / FORM) ===== */
@media (max-width: 640px) {
  .clean-field-head {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .clean-field-head > label:first-child {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .clean-field-head .field-tag {
    display: none;
  }
  .main-filter-toggle {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 11px;
    padding: 2px 7px;
  }

  .bhyt-visual-grid {
    grid-template-columns: 1fr;
  }
  .bhyt-kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px;
  }
  .bhyt-kpi-card {
    padding: 8px 9px;
    gap: 3px;
  }
  .bhyt-kpi-head {
    font-size: 10px;
    letter-spacing: 0;
    gap: 4px;
  }
  .bhyt-kpi-head > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .bhyt-kpi-head > span:nth-child(2) {
    display: none;
  }
  #btnEditTotalClaim {
    flex-shrink: 0;
    font-size: 9.5px !important;
    padding: 1px 4px !important;
  }
  .bhyt-kpi-num {
    font-size: 15.5px;
    display: flex;
    align-items: baseline;
    flex-wrap: nowrap;
    gap: 3px;
    white-space: nowrap;
    overflow: hidden;
  }
  .bhyt-kpi-num small,
  #bhytKpiReviewPctBadge {
    font-size: 10px !important;
  }
  .bhyt-kpi-fatal .bhyt-kpi-num > span:last-child {
    display: none;
  }
  .bhyt-kpi-money {
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  #bhytKpiReviewItemsWrap {
    font-size: 10px !important;
  }
  .bhyt-kpi-card > div:last-of-type {
    font-size: 10px !important;
    line-height: 1.25 !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .bhyt-pareto-card,
  .bhyt-cat-card {
    padding: 11px;
  }
  .bhyt-pareto-title {
    gap: 6px;
    flex-wrap: wrap;
    font-size: 12.5px;
  }
  .bhyt-record-item {
    padding: 10px;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
  }
  .bhyt-record-meta {
    gap: 6px 10px;
    font-size: 11.5px;
  }
  .bhyt-pagination-bar {
    padding: 7px 9px;
    gap: 6px;
  }
  .bhyt-doc-preview {
    padding: 10px;
    font-size: 11.5px;
    word-break: break-word;
  }
  .cfo-kpi-strip {
    grid-template-columns: 1fr !important;
  }
  .cfo-trend-head {
    flex-direction: column;
    align-items: stretch !important;
  }
  .cfo-trend-actions {
    width: 100%;
    display: flex;
    gap: 6px;
  }
  .cfo-trend-actions .btn {
    flex: 1;
  }
}

/* ===== CFO CASH FLOW & ROI TREND LEDGER (ZERO-PII) ===== */
.cfo-trend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.cfo-trend-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.cfo-kpi-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.cfo-kpi-box {
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  min-width: 0;
}
.cfo-kpi-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cfo-kpi-val {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-top: 2px;
  line-height: 1.2;
}
.cfo-kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cfo-bars-wrap {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
.cfo-bars-grid {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 82px;
  padding-top: 14px;
  overflow-x: auto;
}
.cfo-bar-col {
  flex: 1 0 46px;
  max-width: 78px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  height: 100%;
  justify-content: flex-end;
}
.cfo-bar-pct {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.cfo-bar-fill {
  width: 100%;
  max-width: 34px;
  min-height: 4px;
  border-radius: 5px 5px 2px 2px;
  background: var(--primary-grad);
  transition: height 0.3s var(--ease);
}
.cfo-bar-fill.is-high { background: linear-gradient(180deg, #f43f5e, #be123c); }
.cfo-bar-fill.is-mid { background: linear-gradient(180deg, #f59e0b, #d97706); }
.cfo-bar-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ===== CLOUD AUTH GATE & USER MANAGEMENT ===== */
body.auth-locked .app-header,
body.auth-locked .main-wrap {
  display: none !important;
}

.cloud-auth-gate {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: var(--bg);
  background-image: var(--bg-ambient);
}

.cloud-auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px 24px 20px;
  box-shadow: var(--shadow-elevated);
}

.cloud-auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.cloud-auth-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.cloud-auth-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.cloud-auth-notice {
  margin-bottom: 12px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--warn-bg);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: var(--warn);
  font-size: 12px;
  line-height: 1.45;
}

.cloud-auth-warn-box {
  margin-bottom: 12px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--info-bg);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: var(--text);
  font-size: 12px;
  line-height: 1.45;
}

.cloud-auth-error {
  margin: 4px 0 10px;
  padding: 8px 10px;
  border-radius: 9px;
  background: var(--err-bg);
  border: 1px solid rgba(244, 63, 94, 0.35);
  color: var(--err);
  font-size: 12px;
  line-height: 1.4;
}

.cloud-auth-submit {
  width: 100%;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  justify-content: center;
}

.pwd-input-wrap {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
}

.pwd-input-wrap .text-input {
  width: 100%;
  padding-right: 40px;
}

.pwd-eye-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: color 0.14s ease, background 0.14s ease;
}

.pwd-eye-btn:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.pwd-eye-btn.is-visible {
  color: var(--primary);
}

.cloud-auth-hint {
  margin-top: 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.45;
}

.icon-btn.has-user-pill {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: auto;
  height: 34px;
  padding: 0 9px;
  gap: 6px;
  border-radius: 9px;
  white-space: nowrap;
}

.icon-btn.has-user-pill svg {
  flex-shrink: 0;
}

.auth-header-pill {
  font-size: 12px;
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1;
  letter-spacing: -0.01em;
}

.cloud-account-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* ===== LUXURY ACCOUNT & SECURITY MODAL (.modal-box-account) ===== */
.modal-box.modal-box-account {
  max-width: 448px;
  padding: 0;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.24);
  box-shadow: 0 24px 54px -14px rgba(15, 23, 42, 0.24), 0 4px 16px rgba(15, 23, 42, 0.08);
}
html[data-theme="dark"] .modal-box.modal-box-account {
  border-color: rgba(148, 163, 184, 0.16);
  box-shadow: 0 28px 64px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.account-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13, 148, 136, 0.05) 0%, transparent 100%);
}
.account-head-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.account-head-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  color: #ffffff;
  box-shadow: 0 6px 14px -4px rgba(13, 148, 136, 0.45);
}
.account-head-titles h3 {
  margin: 0;
  font-size: 15.5px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.account-head-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.2;
}
.account-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.account-close-btn:hover {
  background: var(--surface-soft);
  border-color: var(--border);
  color: var(--text);
}
.account-modal-body {
  padding: 18px 20px 20px;
}
.account-hero-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 15px;
  border-radius: 14px;
  border: 1px solid rgba(13, 148, 136, 0.22);
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.08) 0%, rgba(14, 165, 233, 0.04) 55%, var(--surface-soft) 100%);
  margin-bottom: 12px;
}
html[data-theme="dark"] .account-hero-card {
  border-color: rgba(45, 212, 191, 0.2);
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.16) 0%, rgba(15, 23, 42, 0.55) 100%);
}
.account-hero-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}
.account-hero-avatar {
  width: 44px;
  height: 44px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  flex-shrink: 0;
  background: linear-gradient(135deg, #0d9488 0%, #0f766e 100%);
  box-shadow: 0 8px 16px -6px rgba(13, 148, 136, 0.55);
}
.account-hero-avatar.is-admin {
  background: linear-gradient(135deg, #4f46e5 0%, #0d9488 100%);
}
.account-hero-avatar.is-director {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
}
.account-hero-info {
  min-width: 0;
  flex: 1;
}
.account-hero-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.account-hero-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.account-env-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: #10b981;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.22);
  flex-shrink: 0;
}
.account-hero-card .cloud-role-badge {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  border: 1px solid rgba(13, 148, 136, 0.22);
}
.account-action-tile {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.14s ease, box-shadow 0.16s ease;
}
.account-action-tile:hover {
  border-color: rgba(13, 148, 136, 0.45);
  background: rgba(13, 148, 136, 0.04);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px -6px rgba(13, 148, 136, 0.22);
}
.account-tile-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.account-tile-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(13, 148, 136, 0.12);
  color: var(--primary);
}
.account-tile-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}
.account-tile-desc {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}
.account-tile-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.15s ease, color 0.15s ease;
}
.account-action-tile:hover .account-tile-arrow {
  transform: translateX(2px);
  color: var(--primary);
}
.account-pwd-card {
  padding: 14px 15px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  margin-bottom: 14px;
}
.account-pwd-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 11px;
}
.account-pwd-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text);
}
.account-pwd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}
.pwd-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.pwd-input-wrap .text-input {
  padding-right: 34px;
}
.pwd-eye-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}
.pwd-eye-btn:hover {
  color: var(--text);
  background: var(--border);
}
.account-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
@media (max-width: 520px) {
  .account-pwd-grid {
    grid-template-columns: 1fr;
  }
}

.cloud-user-create-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cloud-users-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 280px;
  overflow-y: auto;
  padding-right: 2px;
}

.cloud-user-row {
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cloud-user-row:hover {
  border-color: var(--border-strong, rgba(14, 165, 233, 0.35));
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
}

.cloud-user-row.is-root-row {
  border-color: rgba(245, 158, 11, 0.32);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.04) 0%, var(--surface) 45%);
}

.cloud-user-row.is-locked {
  opacity: 0.72;
  background: var(--surface-soft);
}

.cloud-user-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cloud-user-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
  flex: 1;
}

.cloud-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  font-weight: 800;
  color: #ffffff;
  flex-shrink: 0;
  background: linear-gradient(135deg, #64748b 0%, #475569 100%);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.12);
}

.cloud-user-avatar.is-root {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  font-size: 15px;
}

.cloud-user-avatar.is-admin {
  background: linear-gradient(135deg, #6366f1 0%, #4338ca 100%);
}

.cloud-user-avatar.is-director {
  background: linear-gradient(135deg, #0ea5e9 0%, #0369a1 100%);
}

.cloud-user-avatar.is-planning {
  background: linear-gradient(135deg, #06b6d4 0%, #0e7490 100%);
}

.cloud-user-avatar.is-accounting {
  background: linear-gradient(135deg, #10b981 0%, #047857 100%);
}

.cloud-user-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cloud-user-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 12.5px;
}

.cloud-user-name {
  font-weight: 700;
  color: var(--text);
}

.cloud-user-handle {
  font-size: 11.5px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

.cloud-user-sub {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

.cloud-user-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.cloud-user-role-sel {
  height: 28px;
  font-size: 11.5px;
  padding: 0 8px;
  border-radius: 7px;
}

.cloud-action-btn {
  padding: 4px 9px !important;
  font-size: 11.5px !important;
  border-radius: 7px !important;
  border: 1px solid var(--border) !important;
  background: var(--surface-soft);
  white-space: nowrap;
}

.cloud-action-btn:hover {
  background: var(--surface-hover, rgba(148, 163, 184, 0.14));
}

.cloud-root-lock-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 9px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.cloud-role-badge.role-root {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.34);
}

html[data-theme="dark"] .cloud-role-badge.role-root {
  background: rgba(245, 158, 11, 0.18);
  color: #fbbf24;
}

@media (max-width: 680px) {
  .cloud-user-row-top {
    flex-direction: column;
    align-items: flex-start;
  }
  .cloud-user-actions {
    width: 100%;
    flex-wrap: wrap;
    padding-left: 47px;
  }
}

.cloud-user-reset-inline {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 4px;
  border-top: 1px dashed var(--border);
}

.cloud-role-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--primary-soft);
  color: var(--primary);
}

.cloud-role-badge.role-cfo {
  background: var(--info-bg);
  color: var(--info);
}

.cloud-role-badge.role-staff {
  background: var(--surface-alt);
  color: var(--text-muted);
}

.cloud-status-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
  background: var(--ok-bg);
  color: var(--ok);
}

.cloud-status-badge.is-pending {
  background: var(--warn-bg);
  color: var(--warn);
}

.cloud-status-badge.is-locked {
  background: var(--err-bg);
  color: var(--err);
}

@media (max-width: 560px) {
  .cloud-user-create-grid {
    grid-template-columns: 1fr;
  }
  .auth-header-pill {
    display: none !important;
  }
}

/* ===== THỂ THỨC BÁO CÁO GIẢI TRÌNH CHUẨN NGHỊ ĐỊNH 30/2020/NĐ-CP ===== */
.bhyt-template-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding: 7px 10px;
  margin-bottom: 8px;
  border-radius: 9px;
  border: 1px dashed var(--border-strong);
  background: var(--surface-soft);
}
.bhyt-template-status {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bhyt-template-status.has-tpl {
  color: var(--ok);
  font-weight: 600;
}
.bhyt-template-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.bhyt-template-raw-preview {
  max-height: 150px;
  overflow-y: auto;
  margin: 0 0 8px 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
  color: var(--text);
}
.bhyt-doc-meta-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
.bhyt-meta-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.bhyt-meta-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bhyt-meta-input {
  padding: 5px 8px !important;
  font-size: 12px !important;
  height: 30px;
}
.bhyt-doc-preview.is-nd30 {
  white-space: normal;
  font-family: "Times New Roman", Times, serif;
  padding: 14px;
  background: var(--surface-alt);
}
.nd30-sheet {
  background: #ffffff;
  color: #111827;
  max-width: 794px;
  margin: 0 auto 18px auto;
  padding: 36px 34px 40px 54px;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  font-family: "Times New Roman", Times, serif;
  font-size: 13.5pt;
  line-height: 1.4;
}
[data-theme="dark"] .nd30-sheet {
  background: #181c24;
  color: #e5e7eb;
  border-color: #334155;
}
.nd30-appendix-sheet {
  max-width: 100%;
  padding: 28px 28px 34px 28px;
}
.nd30-head-table,
.nd30-sign-table {
  width: 100%;
  border-collapse: collapse;
  border: none;
  margin-bottom: 14px;
}
.nd30-head-table td,
.nd30-sign-table td {
  border: none;
  padding: 2px 4px;
}
.nd30-parent-agency {
  font-size: 11.5pt;
  font-weight: normal;
  text-transform: uppercase;
}
.nd30-unit-name {
  font-size: 11.5pt;
  font-weight: bold;
  text-transform: uppercase;
}
.nd30-quoc-hieu {
  font-size: 11.5pt;
  font-weight: bold;
  text-transform: uppercase;
}
.nd30-tieu-ngu {
  font-size: 12.5pt;
  font-weight: bold;
}
.nd30-line-short {
  width: 42%;
  height: 1px;
  background: currentColor;
  margin: 3px auto 5px auto;
}
.nd30-line-tieu-ngu {
  width: 55%;
  height: 1px;
  background: currentColor;
  margin: 3px auto 5px auto;
}
.nd30-doc-num {
  font-size: 12.5pt;
}
.nd30-date-line {
  font-size: 12.5pt;
  font-style: italic;
}
.nd30-doc-type {
  text-align: center;
  font-size: 14pt;
  font-weight: bold;
  margin-top: 14px;
}
.nd30-doc-subject {
  text-align: center;
  font-size: 13pt;
  font-weight: bold;
  margin-top: 2px;
}
.nd30-line-subject {
  width: 34%;
  height: 1px;
  background: currentColor;
  margin: 4px auto 12px auto;
}
.nd30-kinh-gui {
  text-align: center;
  font-size: 13.5pt;
  margin-bottom: 14px;
}
.nd30-p {
  text-align: justify;
  text-indent: 28px;
  margin: 0 0 7px 0;
  font-size: 13pt;
}
.nd30-h1 {
  text-align: justify;
  text-indent: 28px;
  font-weight: bold;
  font-size: 13pt;
  margin: 12px 0 6px 0;
}
.nd30-h2 {
  text-align: justify;
  text-indent: 28px;
  font-weight: bold;
  font-size: 13pt;
  margin: 8px 0 5px 0;
}
.nd30-data-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 10px 0;
  font-size: 10.5pt;
  line-height: 1.3;
}
.nd30-data-table th,
.nd30-data-table td {
  border: 1px solid #374151;
  padding: 5px 6px;
  vertical-align: middle;
}
.nd30-data-table th {
  background: #f3f4f6;
  font-weight: bold;
  text-align: center;
}
[data-theme="dark"] .nd30-data-table th,
[data-theme="dark"] .nd30-total-row td {
  background: #232936;
  border-color: #475569;
}
[data-theme="dark"] .nd30-data-table td {
  border-color: #475569;
}
.nd30-total-row td {
  background: #f9fafb;
}
.nd30-appendix-table {
  font-size: 9.5pt;
}
.nd30-sign-table {
  margin-top: 18px;
}

@media (max-width: 780px) {
  .bhyt-doc-meta-bar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .nd30-sheet {
    padding: 18px 14px;
    font-size: 11.5pt;
  }
}







/* ========================================================== */
/* CÂY PHÂN CẤP LÂM SÀNG 29 CỘT TINH GỌN (CLEAN UI PKBA)      */
/* ========================================================== */
.icd-tree-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface);
  border-radius: 8px;
}
.icd-tree-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.icd-tree-search-bar {
  display: flex;
  align-items: center;
  position: relative;
  flex: 1;
  min-width: 220px;
}
.tree-search-icon {
  position: absolute;
  left: 9px;
  color: var(--text-muted);
  pointer-events: none;
}
.icd-tree-input {
  width: 100%;
  height: 29px;
  padding: 3px 26px 3px 27px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  background: var(--bg-soft);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.icd-tree-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(2, 132, 199, 0.12);
  background: var(--surface);
}
.tree-clear-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.06);
  border: none;
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.15s;
  padding: 0;
}
.tree-clear-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #dc2626;
}
[data-theme="dark"] .tree-clear-btn {
  background: rgba(255, 255, 255, 0.1);
}
[data-theme="dark"] .tree-clear-btn:hover {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
}
.icd-tree-stats {
  display: flex;
  gap: 6px;
  align-items: center;
}
.tree-stat-badge {
  font-size: 11px;
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  white-space: nowrap;
}
.tree-action-btn {
  height: 26px;
  font-size: 11px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.tree-action-btn:hover {
  background: var(--bg-soft);
  color: var(--text-main);
  border-color: var(--primary);
}
.tree-render-cap-notice {
  font-size: 11.5px;
  color: #0369a1;
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  border-radius: 6px;
  padding: 6px 10px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  line-height: 1.4;
  flex-shrink: 0;
}
.tree-render-cap-notice strong {
  font-weight: 700;
  color: #0284c7;
}
[data-theme="dark"] .tree-render-cap-notice {
  color: #7dd3fc;
  background: rgba(2, 132, 199, 0.12);
  border-color: rgba(2, 132, 199, 0.28);
}
[data-theme="dark"] .tree-render-cap-notice strong {
  color: #38bdf8;
}
.icd-tree-body {
  max-height: calc(100vh - 215px);
  min-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 4px;
}
.tree-node {
  display: flex;
  flex-direction: column;
  border-radius: 4px;
}
.tree-node-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
  transition: background 0.15s, border-color 0.15s;
}
.tree-node-title:hover {
  background: var(--bg-soft);
}
.tree-chapter-title {
  height: 31px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  font-weight: 600;
  color: #0f172a;
}
.tree-chapter-title:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
[data-theme="dark"] .tree-chapter-title {
  background: #1e293b;
  border-color: #334155;
  color: #f1f5f9;
}
.tree-category-title {
  height: 27px;
  padding-left: 20px;
  font-size: 11.5px;
  font-weight: 500;
  border-left: 1px dashed #cbd5e1;
  margin-left: 10px;
  color: #334155;
}
[data-theme="dark"] .tree-category-title {
  border-left-color: #475569;
  color: #cbd5e1;
}
.tree-caret-wrap {
  width: 14px;
  height: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.tree-chevron {
  transition: transform 0.16s ease;
}
.tree-chevron.rotate-90 {
  transform: rotate(90deg);
}
.chapter-code-pill {
  font-family: monospace;
  font-size: 10.5px;
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  white-space: nowrap;
}
[data-theme="dark"] .chapter-code-pill {
  background: #0c4a6e;
  color: #7dd3fc;
  border-color: #0369a1;
}
.chapter-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: #1e293b;
}
[data-theme="dark"] .chapter-name {
  color: #e2e8f0;
}
.chapter-count {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: normal;
  white-space: nowrap;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
}
.category-code {
  font-family: monospace;
  font-weight: 700;
  color: var(--primary);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0 4px;
  border-radius: 3px;
  font-size: 11px;
}
.category-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-main);
  font-size: 11.5px;
}
.category-count {
  font-size: 10.5px;
  color: var(--text-muted);
}
.tree-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 8px 3px 32px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.03);
  font-size: 11.5px;
  transition: background 0.12s;
  min-height: 27px;
}
.tree-item-row:hover {
  background: rgba(2, 132, 199, 0.04);
}
.tree-item-boosted {
  background: rgba(2, 132, 199, 0.06);
  border-left: 3px solid #0284c7;
}
[data-theme="dark"] .tree-item-boosted {
  background: rgba(56, 189, 248, 0.1);
  border-left: 3px solid #38bdf8;
}
.tree-item-code-col {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 125px;
}
.tree-item-code {
  font-family: monospace;
  font-weight: 700;
  color: #0369a1;
  font-size: 12px;
}
[data-theme="dark"] .tree-item-code {
  color: #38bdf8;
}
.tree-item-info-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}
.tree-item-vi {
  color: var(--text-main);
  line-height: 1.3;
  font-size: 11.5px;
}
.tree-item-en {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-item-guidance {
  font-size: 10.5px;
  color: #b45309;
  background: #fef3c7;
  padding: 1px 5px;
  border-radius: 3px;
  margin-top: 1px;
}
.tree-item-actions {
  display: flex;
  gap: 3px;
  align-items: center;
}
.tree-btn {
  font-size: 10.5px;
  height: 21px;
  padding: 0 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  transition: all 0.15s;
}
.tree-btn:hover {
  background: var(--bg-soft);
  border-color: var(--primary);
}
.tree-btn-main {
  color: #0369a1;
  border-color: #bae6fd;
  background: #f0f9ff;
  font-weight: 600;
}
.tree-btn-main:hover {
  background: #0284c7;
  color: #ffffff;
}
.tree-btn-sec {
  color: #475569;
}
.tree-flag-badge {
  font-size: 9px;
  padding: 0 3px;
  border-radius: 2px;
  font-weight: 600;
  white-space: nowrap;
}
.flag-no-main { background: #fee2e2; color: #b91c1c; }
.flag-discourage { background: #ffedd5; color: #c2410c; }
.flag-death { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.flag-female { background: #fce7f3; color: #be185d; }
.flag-male { background: #e0f2fe; color: #0369a1; }
.flag-dagger { background: #e0e7ff; color: #4338ca; }
.flag-asterisk { background: #fef08a; color: #854d0e; }
.tree-empty {
  text-align: center;
  padding: 30px 15px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ========================================================== */
/* CHUỖI TỬ VONG WHO & ĐỊNH MỨC ALOS                          */
/* ========================================================== */
.vital-deceased {
  background-color: #fff1f2 !important;
  color: #b91c1c !important;
  border-color: #fca5a5 !important;
  font-weight: 600 !important;
}
.btn-danger-subtle {
  background: #fff1f2;
  color: #b91c1c;
  border: 1px solid #fecdd3;
  transition: all 0.15s;
}
.btn-danger-subtle:hover {
  background: #ffe4e6;
  border-color: #fda4af;
}

/* ========================================================== */
/* METABASE-STYLE BHYT DASHBOARD ENHANCEMENTS                 */
/* ========================================================== */
.bhyt-kpi-bar {
  height: 4px;
  width: 100%;
  background: var(--border, rgba(148, 163, 184, 0.25));
  border-radius: 999px;
  overflow: hidden;
  margin-top: 6px;
}
.bhyt-kpi-bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  width: 0%;
}

/* Active Filter Pills */
.bhyt-filter-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px 0;
  padding: 6px 10px;
  background: var(--surface-soft, rgba(15, 23, 42, 0.03));
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 11.5px;
}
.bhyt-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--primary-soft, rgba(15, 118, 110, 0.1));
  color: var(--primary, #0f766e);
  border: 1px solid rgba(15, 118, 110, 0.22);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s;
}
.bhyt-filter-pill:hover {
  filter: brightness(0.95);
}
.bhyt-filter-pill-x {
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  opacity: 0.75;
}

/* Inline Data Bars trong cột Tiền XT */
.bhyt-money-bar-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 3px 6px;
  border-radius: 5px;
  overflow: hidden;
  min-width: 96px;
}
.bhyt-money-bar-fill {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  border-radius: 5px;
  pointer-events: none;
  z-index: 0;
  transition: width 0.25s ease;
}
.bhyt-money-bar-fill.is-fatal { background: rgba(239, 68, 68, 0.14); }
.bhyt-money-bar-fill.is-warn  { background: rgba(217, 119, 6, 0.14); }
.bhyt-money-bar-fill.is-syntax{ background: rgba(5, 150, 105, 0.14); }
.bhyt-money-bar-val {
  position: relative;
  z-index: 1;
}

/* Clickable Mã LK & Quick Filter Chips */
.bhyt-lk-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid var(--border-strong, var(--border));
  background: var(--surface-soft);
  color: var(--primary);
  cursor: pointer;
  transition: all 0.14s;
}
.bhyt-lk-link:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.bhyt-quick-chip {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}
.bhyt-quick-chip:hover {
  background: var(--primary-soft, rgba(15, 118, 110, 0.12));
  color: var(--primary);
  text-decoration: underline;
}

/* Metabase Object Detail Drawer */
.bhyt-detail-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 9990;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.bhyt-detail-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}
.bhyt-detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(540px, 96vw);
  background: var(--surface, #ffffff);
  color: var(--text, #0f172a);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 32px rgba(15, 23, 42, 0.18);
  z-index: 9991;
  display: flex;
  flex-direction: column;
  transform: translateX(102%);
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}
.bhyt-detail-drawer.open {
  transform: translateX(0);
}
.bhyt-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-soft);
}
.bhyt-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bhyt-detail-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-soft);
}
.bhyt-detail-kv-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.bhyt-detail-kv-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.bhyt-detail-kv-val {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}
.bhyt-detail-section {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}
.bhyt-detail-section-title {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.bhyt-detail-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

/* ===== UNIFORM EXECUTIVE ACTION BAR FOR BRAIN RULE CARDS ===== */
.btn-xs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  border-radius: 7px;
  white-space: nowrap;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: all 0.16s var(--ease);
}

.btn-xs.btn-ghost {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  box-shadow: none;
  color: var(--text-muted);
}

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

.brain-card-actions {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex-shrink: 0;
  width: 204px;
}

.brain-card-actions-row {
  display: grid;
  gap: 5px;
  width: 100%;
}

.brain-card-actions-row.row-top,
.brain-card-actions-row.row-mid {
  grid-template-columns: 1fr 1fr;
}

.brain-card-actions-row.row-bottom {
  grid-template-columns: 1fr;
}

.brain-move-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 28px;
  padding: 0 22px 0 9px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  line-height: 26px;
  color: var(--text);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.16s var(--ease), background-color 0.16s var(--ease);
}

.brain-move-select:hover,
.brain-move-select:focus {
  border-color: var(--primary);
  outline: none;
}

/* ===== SETTINGS ALIGNED GRIDS (MÃ HÓA & HIS) ===== */
.settings-grid-2 {
  align-items: end;
}

.settings-grid-2 .form-field {
  margin-bottom: 0;
  min-width: 0;
}

.settings-grid-2 .select-clean,
.settings-grid-2 .text-input {
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 12.5px;
  border-radius: 8px;
  box-sizing: border-box;
}

.settings-grid-2 .select-clean {
  padding-right: 28px;
}

.settings-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
  margin-bottom: 10px;
}

.settings-grid-4 .form-field {
  margin-bottom: 0;
  min-width: 0;
}

.settings-grid-4 .form-field label,
.settings-grid-2 .form-field label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11.5px;
  font-weight: 600;
}

.settings-sub-divider {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted);
  margin: 10px 0 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

.settings-check-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.settings-check-grid-2 .settings-check-row {
  margin: 0;
  align-items: center;
  font-size: 12px;
  line-height: 1.3;
  min-width: 0;
}

.settings-check-grid-2 .settings-check-row span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 640px) {
  .settings-grid-4,
  .settings-check-grid-2 {
    grid-template-columns: 1fr;
  }
  .settings-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
