/* Plan 2: focused engineering workspace and readable type. */
:root {
  /* 1. Typography Lock */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* 2. 7-Step Type Scale (Chuẩn chẵn tuyệt đối) */
  --text-2xs: 10px;
  --text-xs: 11px;
  --text-sm: 12px;
  --text-base: 13px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;

  /* 3. Màu Nền (Backgrounds - Slate Theme) */
  --bg-app: #070a0f;
  --bg-main: #0b0f17;
  --bg-surface: #0f172a;
  --bg-card: #111827;
  --bg-card-hover: #1e293b;
  --bg-input: #090d16;
  --bg-table-header: rgba(15, 23, 42, 0.95);
  --bg-row-hover: rgba(56, 189, 248, 0.04);

  /* 4. Màu Văn Bản */
  --text-heading: #ffffff;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  /* 5. Màu Ngữ Nghĩa Trạng Thái */
  --accent-sky: #38bdf8;
  --accent-sky-glow: rgba(56, 189, 248, 0.18);
  --accent-cyan: #0ea5e9;

  --state-success: #10b981;
  --state-success-text: #34d399;
  --state-success-bg: rgba(16, 185, 129, 0.10);
  --state-success-glow: rgba(16, 185, 129, 0.20);

  --state-input: #f59e0b;
  --state-input-text: #f8fafc; /* Trắng dịu, CẤM màu vàng chói */
  --state-legal: #fbbf24;
  --state-legal-bg: rgba(245, 158, 11, 0.08);

  --state-danger: #ef4444;
  --state-danger-text: #f87171;
  --state-danger-bg: rgba(239, 68, 68, 0.12);

  /* 6. Bo Góc Chuẩn */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-full: 9999px;

  /* 7. Đường viền */
  --border-color: rgba(255, 255, 255, 0.12);
  --border-focus: #38bdf8;
}
[data-theme="light"] {
  --bg-main: #f3f7fb;
  --bg-surface: #fff;
  --bg-card: #fff;
  --bg-input: #f7fafd;
  --text-secondary: #26364b;
  --text-muted: #53657a;
  --border-color: #d8e1eb;
}
html, body { min-width: 0; }
body { font-size: 15px; line-height: 1.5; }
.view-container.active, .tab-pane.active { animation: none !important; }
button, input, select { font: inherit; }
button, select, input { min-height: 38px; }
button:focus-visible, input:focus-visible, select:focus-visible, [role="button"]:focus-visible {
  outline: 3px solid #67d4ff; outline-offset: 2px;
}
button:disabled { opacity: .48; cursor: not-allowed; }
.view-container.active.zen-hub-screen { padding: 16px clamp(16px, 3vw, 48px) !important; gap: 14px !important; }
.zen-top-strip { padding: 14px 20px; border-radius: 14px; gap: 16px; }
.zen-hub-title { font-size: clamp(21px, 2vw, 27px); letter-spacing: -.02em; white-space: normal; }
.zen-badge-pill, .zen-badge-count, .zen-std-prefix, .zen-standards-row, .zen-std-tag { font-size: 12px; letter-spacing: 0; }
.zen-standard-details summary { color: var(--text-muted); font-size: 13px; cursor: pointer; width: fit-content; }
.zen-standard-details summary:hover { color: var(--text-primary); }
.zen-standard-details[open] .zen-standards-row { display: flex; margin-top: 7px; }
.zen-standards-row { gap: 7px; }
.zen-search-kbd { display: none; }
.zen-matrix-container { flex: 0 0 auto; min-height: auto; }
.zen-modules-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); grid-template-rows: auto auto; gap: 12px; flex: none; }
.zen-card { min-height: 0; padding: 16px; gap: 10px; justify-content: flex-start; border-radius: 12px; }
.zen-card-active { grid-column: 1 / -1; min-height: 180px; padding: 20px 24px; display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px 32px; }
.zen-card-active .zen-card-header { grid-column: 1 / -1; }
.zen-card-active .zen-card-main { grid-column: 1; }
.zen-card-active .zen-card-footer { grid-column: 2; grid-row: 2; flex-direction: column; align-items: flex-end; border: 0; }
.zen-card-active .zen-card-name { font-size: 23px; white-space: normal; }
.zen-card-active .zen-card-subname { font-size: 14px; white-space: normal; }
.zen-card-active .zen-card-desc { font-size: 15px; line-height: 1.5; max-width: 780px; -webkit-line-clamp: unset; display: block; }
.zen-last-project { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.zen-card-active .zen-btn-launch { min-height: 44px; font-size: 14px; padding: 8px 16px; }
.zen-card-roadmap { min-height: 0; padding: 10px 12px; gap: 5px; opacity: 1; }
.zen-card-roadmap .zen-card-header { align-items: flex-start; gap: 5px; flex-wrap: wrap; }
.zen-card-roadmap .zen-card-name { font-size: 15px; white-space: normal; overflow: visible; line-height: 1.35; }
.zen-card-roadmap .zen-card-subname, .zen-card-roadmap .zen-card-desc, .zen-card-roadmap .zen-chip-list, .zen-card-roadmap .zen-avail-status { display: none; }
.zen-card-roadmap .zen-card-footer { display: flex; justify-content: flex-start; padding: 0; border: 0; margin-top: auto; }
.zen-card-roadmap .zen-btn-scope { min-height: 30px; font-size: 12px; padding: 4px 9px; }
.zen-card-roadmap .zen-icon-title { align-items: flex-start; }
.zen-card-roadmap .zen-status-badge, .zen-status-badge { font-size: 11px; letter-spacing: 0; }
#warehouseWorkspaceView.active { overflow-x: hidden; }
.workspace-substrip { padding: 8px clamp(16px, 2vw, 32px); margin: 0; gap: 16px; flex-wrap: wrap; min-height: 54px; }
.substrip-left, .workspace-tools { display: flex; align-items: center; gap: 10px; min-width: 0; }
.workspace-tools { margin-left: auto; flex-wrap: wrap; }
.substrip-title { font-size: 14px; text-transform: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: min(35vw, 500px); }
.substrip-label, .btn-substrip-back { font-size: 13px; }
.calc-status { font-size: 13px; font-weight: 650; color: #afd7ed; }
.calc-status[data-state="warning"] { color: #fbbf24; }
.calc-status[data-state="error"] { color: #fb7185; }
.workspace-tools .btn-flat { min-height: 36px; font-size: 13px; padding: 6px 12px; }
.kpi-banner { max-width: none; margin: 0; padding: 12px clamp(16px, 2vw, 32px); gap: 10px; }
.kpi-card { padding: 7px 13px; border-radius: 10px; box-shadow: none; }
.kpi-header-row { margin: 0 0 2px; }
.kpi-label { font-size: 13px; font-weight: 600; }
.kpi-value-group { margin: 0; }
.kpi-number { font-size: 22px; }
.kpi-unit { font-size: 13px; }
.kpi-meter-bar { display: none; }
.kpi-sub { font-size: 12px; line-height: 1.35; }
.presets-toolbar { display: none; margin: 8px clamp(16px, 2vw, 32px); }
#warehouseWorkspaceView.show-presets .presets-toolbar { display: flex; }
.presets-label, .preset-chip { font-size: 13px; letter-spacing: 0; }
.workspace-grid { max-width: 1560px; margin: 0 auto; padding: 0 clamp(16px, 2vw, 32px) 24px; display: grid; grid-template-columns: minmax(0, 2.125fr) minmax(350px, 1fr); gap: 20px; align-items: start; }
.left-panel, .right-panel { min-width: 0; gap: 10px; }
#workspaceInspector { display: flex !important; flex-direction: column; position: sticky; top: 10px; max-height: calc(100vh - 120px); }
@media (max-width: 1024px) {
  .workspace-grid { grid-template-columns: 1fr; }
}
/* [Plan 20] Grid 7 cột: 6 bước tính + separator + 1 tab Thư viện */
.nav-tabs { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)) 2px minmax(0, 1.2fr); overflow: visible; margin: 0; gap: 2px; }
.wizard-tab-sep { background: rgba(56, 189, 248, 0.2); border-radius: 1px; align-self: stretch; margin: 6px 0; }
.tab-btn-library { background: rgba(56, 189, 248, 0.06) !important; border-left: 2px solid rgba(56, 189, 248, 0.25) !important; }
.tab-btn-library.active { background: rgba(56, 189, 248, 0.12) !important; border-left-color: #38bdf8 !important; }
.tab-btn-library .badge-library { background: rgba(56, 189, 248, 0.15); font-size: 14px; width: auto; height: auto; padding: 2px; }
.wizard-tabs { position: sticky; top: 0; z-index: 20; background: var(--bg-card); border-bottom: 1px solid var(--border-color); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25); }
.tab-btn { min-width: 0; min-height: 54px; white-space: normal; padding: 7px 5px; font-size: 13px; line-height: 1.25; }
.tab-btn .step-num-badge { display: inline-flex; width: 22px; height: 22px; font-size: 11px; margin-right: 4px; }
.tab-btn.highlight-tab:not(.active) { background: transparent; box-shadow: none; }
.field-citation-inline { display: none !important;  margin: 0; padding: 7px 11px; min-height: 34px; border-left: 3px solid #38bdf8; background: rgba(56,189,248,.07); color: var(--text-muted); font-size: 13px; }
.field-citation-inline:not(.active) { display: none; }
.tab-content-wrapper { padding: clamp(8px, 1.5vw, 16px); box-shadow: none; }
.wizard-nav-footer { position: sticky; bottom: 0; z-index: 15; min-height: 56px; margin-top: 18px; padding: 8px 4px; background: var(--bg-card); border-top: 1px solid var(--border-color); box-shadow: 0 -8px 20px rgba(8,18,30,.12); }
.wizard-nav-footer .btn-wizard-prev, .wizard-nav-footer .btn-wizard-next { min-height: 40px; font-size: 13px; }
.pane-title { font-size: clamp(18px, 1.6vw, 22px); line-height: 1.35; }
.label-row label, .form-group > label { font-size: 14px; }
.input-with-badge input, select { font-size: 15px; min-height: 42px; }
#inputProjectTitle { font-family: var(--font-sans); font-size: 15px; font-weight: 600; }
.field-hint, .audit-label, .audit-rule { font-size: 13px; line-height: 1.45; }
.step-formula { font-size: 14px; line-height: 1.55; }
.step-desc { font-size: 13px; }
.card-title { font-size: 16px; }
/* [Plan 20] Banner vàng vô hiệu hóa vĩnh viễn */
.warning-banner { display: none !important; }
.pipe-editor { padding: 14px; border: 1px solid var(--border-color); border-radius: 10px; background: rgba(42,77,110,.08); }
.pipe-editor-heading { display: flex; align-items: center; justify-content: flex-start; gap: 12px; margin-bottom: 8px; }
.pipe-editor-heading div { display: grid; gap: 2px; }
.pipe-editor-heading strong { font-size: 15px; }
.pipe-editor-heading span { color: var(--text-muted); font-size: 13px; }

/* [Plan 24.2] Khối 3 Tiêu Chí Vàng Chọn Đường Kính Ống Nhánh Thực Chiến */
.branch-criteria-box {
  margin: 6px 0 12px 0;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
}
.criteria-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
  gap: 6px;
}
.criteria-tag {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.criteria-sub {
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  color: #94a3b8;
}
.criteria-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 1100px) {
  .criteria-grid {
    grid-template-columns: 1fr;
  }
}
.criteria-card {
  background: rgba(11, 15, 23, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.criteria-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.criteria-num {
  font-family: var(--font-mono);
  color: #38bdf8;
  font-weight: 700;
  font-size: var(--text-sm);
}
.criteria-name {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  color: #f8fafc;
  flex: 1;
}
.criteria-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  line-height: 1.45;
}
.criteria-rule {
  color: #cbd5e1;
}
.criteria-rule strong, .criteria-practical strong {
  color: #94a3b8;
  font-weight: 600;
}
.criteria-practical {
  color: #94a3b8;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px 6px;
  border-radius: 4px;
  border-left: 2px solid #38bdf8;
}
.criteria-body code {
  font-family: var(--font-mono);
  color: #34d399;
  background: rgba(16, 185, 129, 0.12);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: var(--text-2xs);
}
.basis-link-badge-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 4px;
  color: #38bdf8;
  font-size: var(--text-2xs);
  font-family: var(--font-sans);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.basis-link-badge-mini:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #f8fafc;
}
[data-theme="light"] .branch-criteria-box {
  background: #f1f5f9 !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .criteria-card {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
}
[data-theme="light"] .criteria-name {
  color: #0f172a !important;
}

/* [Plan 25] 3 Tiêu Chí Vàng Chọn Đường Kính Trong Tab Căn Cứ */
.legal-criteria-block {
  margin: 10px 0 16px 0;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
}
.criteria-catalog-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.criteria-catalog-card {
  background: rgba(11, 15, 23, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: border-color 0.2s ease;
}
.criteria-catalog-card:hover {
  border-color: rgba(56, 189, 248, 0.35);
}
[data-theme="light"] .legal-criteria-block {
  background: #f8fafc !important;
  border-color: #cbd5e1 !important;
}
[data-theme="light"] .criteria-catalog-card {
  background: #ffffff !important;
  border-color: #e2e8f0 !important;
}
[data-theme="light"] .criteria-rule {
  color: #334155 !important;
}
[data-theme="light"] .criteria-practical {
  background: #f8fafc !important;
  color: #475569 !important;
}
.btn-add-pipe, .pipe-remove { padding: 6px 12px; border-radius: 7px; border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-secondary); cursor: pointer; white-space: nowrap; }
.btn-add-pipe { color: #69ceff; border-color: #387ca2; }
.pipe-rows { display: grid; gap: 6px; }
.pipe-rows:empty::after { content: "Chưa nhập đoạn ống — cột áp sẽ để trống."; color: var(--text-muted); font-size: 13px; }
.pipe-row { display: grid; grid-template-columns: minmax(100px,1fr) 100px minmax(115px,1fr) minmax(115px,1fr) auto; gap: 6px; }
.pipe-row input, .pipe-row select { width: 100%; min-width: 0; min-height: 39px; padding: 6px 10px; border: 1px solid var(--border-color); border-radius: 7px; background: var(--bg-input); color: var(--text-primary); }
.sizing-toggle { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 600; }
.sizing-toggle input, .sizing-lock input { width: auto !important; min-height: 0 !important; }
.sizing-rows { display: grid; gap: 7px; margin: 10px 0 16px; }
.sizing-row { display: grid; gap: 7px; align-items: end; padding: 8px; border: 1px solid var(--border-color); border-radius: 8px; }
.sizing-node-row { grid-template-columns: repeat(5, minmax(0,1fr)) auto; }
.sizing-segment-row { grid-template-columns: repeat(6, minmax(0,1fr)) 85px auto; }
.sizing-row label { display: grid; gap: 4px; font-size: 12px; color: var(--text-muted); min-width: 0; }
.sizing-row input, .sizing-row select { width: 100%; min-width: 0; min-height: 36px; padding: 5px 7px; border: 1px solid var(--border-color); border-radius: 6px; background: var(--bg-input); color: var(--text-primary); }
.sizing-row .sizing-lock { display: flex; align-items: center; gap: 5px; min-height: 36px; }
.sizing-result { margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--border-color); }
.sizing-result.hidden, #pipeSizingControls.hidden, #fullNetworkEditor.hidden { display: none !important; }
.sizing-table-scroll { overflow-x: auto; }
.sizing-output-table, .sizing-standard-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.sizing-output-table th, .sizing-output-table td, .sizing-standard-table th, .sizing-standard-table td { padding: 5px 7px; border: 1px solid var(--border-color); text-align: left; white-space: nowrap; }
.sizing-standard-table { margin-top: 8px; }
.step-standard-context { border-left: 3px solid #38bdf8; }
.step-standard-context summary { cursor: pointer; color: #69ceff; }
.step-standard-context details { max-width: 100%; overflow-x: auto; }
.standard-focus { color: #69ceff; }
.sizing-warning { color: #fbbf24; }
.sizing-head-detail { padding-left: 14px; font-size: 12px; }
[data-theme="light"] .pipe-row input, [data-theme="light"] .pipe-row select { color: #13243a; }
.flow-breakdown-panel { margin: 16px 0 0; }
[data-theme="light"] .workspace-substrip { background: #fff; }
[data-theme="light"] .substrip-title, [data-theme="light"] .kpi-number { color: #13243a !important; }
[data-theme="light"] .kpi-card, [data-theme="light"] .tab-content-wrapper, [data-theme="light"] .card, [data-theme="light"] .calc-step-card { background: #fff !important; border-color: #d8e1eb !important; color: #13243a !important; }
[data-theme="light"] .kpi-label, [data-theme="light"] .kpi-sub, [data-theme="light"] .pane-title, [data-theme="light"] .card-title, [data-theme="light"] .step-header { color: #26364b !important; }
[data-theme="light"] .nav-tabs { background: #eef4f9 !important; }
[data-theme="light"] .tab-btn { color: #41546b !important; }
[data-theme="light"] .tab-btn.active { color: #102a43 !important; }
[data-theme="light"] .label-row label, [data-theme="light"] .form-group > label { color: #26364b !important; }
[data-theme="light"] .input-with-badge input, [data-theme="light"] .form-group input, [data-theme="light"] select, [data-theme="light"] .pipe-row input, [data-theme="light"] .pipe-row select { background: #f7fafd !important; color: #13243a !important; border-color: #c7d4e1 !important; }
[data-theme="light"] .audit-item, [data-theme="light"] .pipe-editor { background: #f5f9fd !important; color: #13243a !important; border-color: #d8e1eb !important; }
[data-theme="light"] .audit-label, [data-theme="light"] .audit-val, [data-theme="light"] .audit-rule, [data-theme="light"] .pipe-editor-heading { color: #26364b !important; }
[data-theme="light"] .step-formula { background: #eef5fa !important; color: #13243a !important; }
[data-theme="light"] .warning-banner { background: #fff8eb !important; color: #8b4300 !important; }
[data-theme="light"] .wizard-nav-footer { background: #fff; }
@media (max-width: 1450px) {
  .zen-modules-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .zen-card-active { grid-column: 1 / -1; }
  .zen-card-roadmap { min-height: 115px; }
  .zen-top-strip { align-items: flex-start; }
}
@media (max-width: 1100px) {
  .sizing-node-row, .sizing-segment-row { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .header-center { display: none; }
  #warehouseWorkspaceView.show-inspector .workspace-grid { grid-template-columns: minmax(0,1fr); }
  .nav-tabs { grid-template-columns: repeat(6, minmax(0,1fr)); }
  .tab-btn { font-size: 12px; }
  .zen-card-active { grid-template-columns: 1fr; }
  .zen-card-active .zen-card-footer { grid-column: 1; grid-row: auto; flex-direction: row; align-items: center; }
}
@media (max-width: 900px) {
  .nav-tabs { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .kpi-banner { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 720px) {
  .sizing-node-row, .sizing-segment-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .app-header { padding: 0 8px; }
  .zen-modules-grid { grid-template-columns: 1fr; }
  .zen-card-active { min-height: 0; }
  .zen-card-roadmap { min-height: 0; }
  .workspace-substrip { align-items: flex-start; }
  .workspace-tools { margin-left: 0; width: 100%; }
  .substrip-title { max-width: 48vw; }
  .kpi-banner { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .nav-tabs { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .zen-standards-row { display: none; }
  .pipe-row { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .pipe-row .pipe-remove { grid-column: 1 / -1; }
  .wizard-step-info { display: none; }
  .wizard-nav-footer .btn-wizard-prev, .wizard-nav-footer .btn-wizard-next { font-size: 12px; padding: 7px 9px; }
}
/* Existing-system connection workflow */
.retrofit-panel.hidden, #ceilingEvidenceGroup.hidden, #ceilingSuitabilityGroup.hidden { display: none !important; }
.form-grid > .retrofit-panel.full-width { grid-column: 1 / -1; }
.retrofit-panel {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px;
  background: var(--bg-input, #0c1220);
  color: var(--text-primary);
  margin: 10px 0;
  min-width: 0;
}
.retrofit-panel h4 { margin: 0 0 8px; font-size: 15px; color: var(--text-primary); }
.retrofit-panel p { line-height: 1.5; }
.retrofit-panel .form-grid { margin-top: 14px; }
.retrofit-panel input, .retrofit-panel select, .retrofit-row input, .retrofit-row select {
  width: 100%;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: var(--bg-input, #0c1220);
  color: var(--text-primary);
  font: inherit;
}
.retrofit-evidence, .retrofit-row-fields {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
}
.retrofit-list-head { display: flex; align-items: center; justify-content: flex-start; gap: 10px; margin: 18px 0 8px; }
.retrofit-list-head button, .retrofit-remove {
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: transparent;
  color: var(--text-primary);
  padding: 7px 10px;
  cursor: pointer;
}
.retrofit-rows { display: grid; gap: 10px; }
.retrofit-row { border: 1px solid var(--border-color); border-radius: 9px; padding: 12px; display: grid; gap: 9px; min-width: 0; }
.retrofit-row label { display: grid; gap: 5px; font-size: 12px; color: var(--text-secondary); }
.retrofit-row-fields { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
.scenario-row .retrofit-row-fields { grid-template-columns: repeat(3, minmax(0, 1fr)) auto; }
.retrofit-remove { color: #ef4444; align-self: end; }
#retrofitStatusLabel { display: block; margin: 8px 0 12px; font-size: 16px; }
#retrofitMissing p { color: #f59e0b; }
#retrofitRecommendations p { color: var(--text-secondary); }
@media (max-width: 768px) {
  .retrofit-panel .form-grid, .retrofit-evidence, .retrofit-row-fields, .scenario-row .retrofit-row-fields { grid-template-columns: 1fr; }
  .retrofit-panel .form-group.full-width { grid-column: 1; }
}

/* ==========================================================
   CSS CHO BƯỚC 5: HƯỚNG DẪN XUẤT XỨ LƯU LƯỢNG & BẢNG THỦY LỰC
   ========================================================== */
.flow-origin-guide {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.08) 0%, rgba(30, 41, 59, 0.5) 100%);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 12px;
}
.guide-header {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.guide-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-base);
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.2px;
}
.guide-icon { font-size: 17px; }
.guide-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(52, 211, 153, 0.3);
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.guide-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 9px;
  padding: 12px 14px;
}
.guide-card-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}
.guide-tag {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 5px;
}
.branch-tag { background: rgba(59, 130, 246, 0.2); color: #60a5fa; border: 1px solid rgba(96, 165, 250, 0.3); }
.main-tag { background: rgba(245, 158, 11, 0.2); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.3); }
.guide-sub { font-size: var(--text-sm); color: var(--text-muted, #94a3b8); }
.guide-card-body p {
  font-size: var(--text-sm);
  color: var(--text-secondary, #cbd5e1);
  margin: 0 0 6px 0;
  line-height: 1.45;
}
.guide-flow-list {
  list-style: none;
  padding: 0;
  margin: 0 0 8px 0;
  font-size: 12px;
  color: var(--text-primary, #f1f5f9);
}
.guide-flow-list li {
  padding: 2px 0;
  font-family: 'JetBrains Mono', monospace;
}
.guide-flow-list strong { color: #38bdf8; }
.guide-main-highlight {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(30, 41, 59, 0.7);
  border-radius: 6px;
  margin-bottom: 6px;
}
.guide-main-highlight code {
  font-size: 14px;
  font-weight: 700;
  color: #f59e0b;
}
.highlight-desc { font-size: 11px; color: #94a3b8; }
.guide-note { font-size: 11px; color: #94a3b8; margin-top: 4px; }

/* Pipe Editor Header & Table Layout */
.pipe-editor-heading {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}
.pipe-editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-quick-fill {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.25) 0%, rgba(2, 132, 199, 0.35) 100%);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 7px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}
.btn-quick-fill:hover {
  background: rgba(14, 165, 233, 0.4);
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
}
.pipe-table-header {
  display: grid;
  grid-template-columns: minmax(75px,0.9fr) 95px minmax(95px,1fr) minmax(90px,1fr) minmax(150px,1.4fr) 55px;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
  border-radius: 7px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}
.pipe-row {
  display: grid !important;
  grid-template-columns: minmax(75px,0.9fr) 95px minmax(95px,1fr) minmax(90px,1fr) minmax(150px,1.4fr) 55px !important;
  gap: 6px !important;
  align-items: center;
}
.pipe-stat-cell {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  padding: 4px 8px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 7px;
  min-height: 39px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}
.pipe-stat-v {
  color: #34d399;
  font-weight: 500;
}
.pipe-stat-v.v-warn {
  color: #f59e0b;
}
.pipe-stat-v.v-alert {
  color: #ef4444;
  font-weight: 700;
}
.pipe-stat-p {
  color: #38bdf8;
}
.pipe-stat-empty {
  color: var(--text-muted, #64748b);
  font-style: italic;
  font-size: var(--text-xs);
}
@media (max-width: 768px) {
  .guide-grid { grid-template-columns: 1fr; }
  .pipe-table-header { display: none; }
  .pipe-row { grid-template-columns: 1fr 1fr !important; }
  .pipe-stat-cell, .pipe-row .pipe-remove { grid-column: 1 / -1; }
}

/* ==========================================================================
   PLAN 3: IN-RACK SPRINKLER LIVE MONITORING CARD (SP 241 TABLE 6.1)
   ========================================================================== */
.in-rack-live-card {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0 14px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.in-rack-live-card .live-card-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.in-rack-live-card .live-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #e2e8f0;
}
.in-rack-live-card .live-card-status-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  letter-spacing: 0.2px;
}
.in-rack-live-card .live-card-status-badge.badge-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.in-rack-live-card .live-card-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}
.in-rack-live-card .live-metric-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: rgba(30, 41, 59, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}
.in-rack-live-card .metric-label {
  font-size: 11px;
  color: #94a3b8;
}
.in-rack-live-card .metric-value {
  font-size: 14px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  margin: 1px 0;
}
.in-rack-live-card .metric-value.highlight-cyan {
  color: #38bdf8;
}
.in-rack-live-card .metric-value.highlight-green {
  color: #34d399;
}
.in-rack-live-card .metric-value.highlight-amber {
  color: #fbbf24;
}
.in-rack-live-card .metric-sub {
  font-size: 10px;
  color: #64748b;
}

/* ==========================================================================
   PLAN 3: PROTECTION SCHEME SELECTOR & ESFR CONFIGURATION CARD
   ========================================================================== */
.scheme-selector-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0 14px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
.scheme-selector-card .scheme-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  font-weight: 700;
  color: #38bdf8;
  letter-spacing: 0.3px;
  margin-bottom: 10px;
}
.scheme-radio-group {
  display: flex !important;
  flex-direction: column !important;
  gap: 7px !important;
  width: 100% !important;
}
.scheme-radio-item {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 8px 12px !important;
  background: rgba(15, 23, 42, 0.75) !important;
  border: 1.5px solid rgba(148, 163, 184, 0.25) !important;
  border-radius: var(--radius-md) !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
  width: 100% !important;
  box-sizing: border-box !important;
}
.scheme-radio-item:hover {
  border-color: rgba(56, 189, 248, 0.6) !important;
  background: rgba(30, 41, 59, 0.9) !important;
}
.scheme-radio-item.active {
  border-color: #38bdf8 !important;
  background: rgba(14, 165, 233, 0.15) !important;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25) !important;
}
.scheme-radio-item input[type="radio"] {
  width: 18px !important;
  min-width: 18px !important;
  max-width: 18px !important;
  height: 18px !important;
  min-height: 18px !important;
  max-height: 18px !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  accent-color: #38bdf8 !important;
  cursor: pointer !important;
  flex: 0 0 18px !important;
}
.scheme-radio-content {
  display: flex !important;
  flex-direction: column !important;
  gap: 2px !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
}
.scheme-title {
  font-size: var(--text-sm) !important;
  font-weight: 700 !important;
  color: #38bdf8 !important;
  white-space: normal !important;
  line-height: 1.35 !important;
}
.scheme-desc {
  font-size: var(--text-xs) !important;
  color: var(--text-muted) !important;
  line-height: 1.3 !important;
  white-space: normal !important;
}
.esfr-config-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 8px;
  padding: 12px 14px;
  margin: 10px 0 14px 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}
@media (max-width: 768px) {
  .scheme-radio-group { grid-template-columns: 1fr; }
}

/* ==========================================================================
   PLAN 4: UI/UX RESTRUCTURING & LEGAL CITATION ENGINE
   ========================================================================== */

/* 1. Ẩn Hàng 2 (Substrip) & Hàng 3 (KPI Banner) & các panel chiếm chỗ đỉnh */
.workspace-substrip,
.kpi-banner,
.flow-breakdown-panel,
.presets-toolbar {
  display: none !important;
}

/* Đưa không gian làm việc chính lên vị trí ưu tiên số 1 ngay sát Header */
#warehouseWorkspaceView {
  padding-top: 10px !important;
}
.workspace-grid {
  margin-top: 0 !important;
  align-items: start !important;
}

/* 2. Cột Bên Trái: 1 Hàng Dọc Tuần Tự (Single Linear Column) */
.form-grid {
  display: flex !important;
  flex-direction: column !important;
  gap: 12px !important;
}
.form-grid .form-group {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
}
.field-hint {
  display: none !important; /* Ẩn toàn bộ chữ nhỏ dài dòng dưới đáy ô theo Yêu cầu 4 */
}

/* 3. Phân biệt ô Kỹ Sư Nhập vs Ô Tự Động Tính */
.label-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  margin-bottom: 6px !important;
}
.field-role-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-left: 8px;
}
.badge-user-input {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.badge-auto-calc {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Ô Kỹ Sư Nhập: Viền Sky Blue nổi bật, nền input rõ nét */
.user-input-box input,
.user-input-box select {
  border-color: rgba(56, 189, 248, 0.45) !important;
  background: rgba(15, 23, 42, 0.75) !important;
}
.user-input-box input:focus,
.user-input-box select:focus {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3) !important;
}

/* Ẩn hoàn toàn icon info-bubble theo yêu cầu người dùng */
.info-bubble {
  display: none !important;
}

/* 5. Cột Bên Phải: Cột Cơ Sở Pháp Lý Động & Tab Switcher */
.inspector-tabs {
  display: flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.85);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 12px;
}
.insp-tab-btn {
  flex: 1;
  padding: 8px 6px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.insp-tab-btn.active {
  background: rgba(56, 189, 248, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.insp-pane {
  display: none;
}
.insp-pane.active {
  display: block;
}

.legal-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}
.legal-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.legal-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #f1f5f9;
}
.legal-status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 5px;
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.legal-section {
  margin-bottom: 14px;
}
.legal-sec-title {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.legal-sec-content {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  line-height: 1.5;
  color: #cbd5e1;
}
.legal-sec-content.highlight-box {
  border-left: 3px solid #38bdf8;
  background: rgba(14, 165, 233, 0.08);
}
.legal-sec-content.info-box {
  border-left: 3px solid #34d399;
  background: rgba(16, 185, 129, 0.08);
}
.legal-formula-code {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #38bdf8;
  background: rgba(15, 23, 42, 0.85);
  padding: 6px 10px;
  border-radius: 5px;
  margin-bottom: 6px;
}
.legal-section-footer {
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
  padding-top: 10px;
  margin-top: 14px;
}
.legal-footer-hint {
  font-size: 11px;
  font-style: italic;
  color: #64748b;
}

/* ==========================================================================
   PLAN 10: TỐI ƯU GIAO DIỆN ACCORDION & TRIỆT TIÊU CUỘN NGANG BẢNG TRA
   ========================================================================== */
#inspPaneLegal {
  overflow-y: auto;
  max-height: calc(100vh - 150px);
  padding-right: 2px;
}

/* Mode Switcher: Ô Đang Chọn vs Bách Khoa */
.legal-mode-bar {
  display: flex;
  gap: 6px;
  background: rgba(11, 15, 23, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(8px);
}

.legal-mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 6px 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}

.legal-mode-btn:hover {
  color: var(--text-primary);
  background: rgba(56, 189, 248, 0.08);
}

.legal-mode-btn.active {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.4);
  color: #38bdf8;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.legal-mode-btn .mode-icon {
  font-size: 13px;
}

.legal-mode-btn .mode-label {
  font-size: var(--text-xs);
  letter-spacing: -0.2px;
}

/* Quick-Jump Navigation */
.legal-quick-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  margin-bottom: 8px;
}

.legal-quick-nav .nav-title {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  margin-right: 2px;
}

.quick-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: #cbd5e1;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  text-decoration: none;
  transition: var(--transition);
}

.quick-chip:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
  transform: translateY(-1px);
}

/* Accordion Controls Bar */
.catalog-accordion-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 8px;
  margin-bottom: 10px;
  background: rgba(15, 23, 42, 0.45);
  border-radius: var(--radius-sm);
  border: 1px dashed rgba(255, 255, 255, 0.08);
}

.acc-status-text {
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  color: #94a3b8;
  font-style: italic;
}

.acc-btn-group {
  display: flex;
  gap: 5px;
}

.acc-btn {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 600;
  padding: 2px 7px;
  cursor: pointer;
  transition: var(--transition);
}

.acc-btn:hover {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
}

/* Catalog Cards & Accordion Behavior */
.catalog-card {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  scroll-margin-top: 52px;
  transition: border-color var(--transition);
}

.catalog-card:hover {
  border-color: rgba(56, 189, 248, 0.35);
}

.catalog-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(30, 41, 59, 0.6);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 10px;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition: background var(--transition);
}

.catalog-card-header:hover {
  background: rgba(56, 189, 248, 0.12);
}

.catalog-card-header .header-left {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.catalog-card-header .header-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.acc-icon {
  display: inline-block;
  font-size: 10px;
  color: #94a3b8;
  transition: transform 0.2s ease, color 0.2s ease;
}

/* Accordion Collapsed State */
.catalog-card.is-collapsed {
  margin-bottom: 8px;
}

.catalog-card.is-collapsed .catalog-card-header {
  border-bottom: none;
  background: rgba(30, 41, 59, 0.4);
}

.catalog-card.is-collapsed .catalog-card-body {
  display: none;
}

.catalog-card.is-collapsed .acc-icon {
  transform: rotate(-90deg);
  color: #64748b;
}

.step-badge {
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 800;
  padding: 2px 5px;
  border-radius: var(--radius-sm);
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.35);
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.catalog-card-header h4 {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  color: #f1f5f9;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legal-tag {
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
  white-space: nowrap;
}

.catalog-card-body {
  padding: 10px;
}

.catalog-intro {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.sub-table-header {
  margin-bottom: 4px;
}

.sub-table-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.sub-table-title {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.btn-table-zoom {
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-sm);
  color: #38bdf8;
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 700;
  padding: 2px 7px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-table-zoom:hover {
  background: #38bdf8;
  color: #070a0f;
  transform: scale(1.03);
}

/* Triệt tiêu 100% cuộn ngang: Bảng tự động vừa khít trong sidebar */
.legal-table-responsive {
  width: 100%;
  overflow-x: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 8px;
}

.legal-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  text-align: left;
  table-layout: auto;
}

.legal-table th {
  background: rgba(30, 41, 59, 0.85);
  color: #94a3b8;
  font-weight: 700;
  padding: 5px 7px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  font-size: var(--text-2xs);
  text-transform: uppercase;
}

.legal-table td {
  padding: 5px 7px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  vertical-align: middle;
  line-height: 1.35;
  word-break: break-word;
}

.legal-table tr:last-child td {
  border-bottom: none;
}

.legal-table tr:hover td {
  background: rgba(56, 189, 248, 0.04);
}

.legal-table .table-sub-note {
  font-size: var(--text-2xs);
  color: #64748b;
  display: block;
  margin-top: 1px;
  line-height: 1.25;
}

.text-mono-hl {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #38bdf8;
}

.text-success {
  color: #34d399 !important;
}

.text-warning {
  color: #fbbf24 !important;
}

.row-warning {
  background: rgba(245, 158, 11, 0.05);
}

/* Formula Blocks */
.legal-formula-block {
  background: rgba(11, 15, 23, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-left: 3px solid #38bdf8;
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  margin-top: 6px;
}

.legal-formula-block .formula-label {
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  font-weight: 700;
  color: #94a3b8;
  margin-bottom: 3px;
}

.text-mono-code {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  color: #38bdf8;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  line-height: 1.45;
  margin-bottom: 3px;
  overflow-x: auto;
}

.formula-note {
  display: block;
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  color: #64748b;
  font-style: italic;
  line-height: 1.35;
}

.mt-6 { margin-top: 6px !important; }
.mt-10 { margin-top: 10px !important; }

/* ZEN TABLE MODAL PHÓNG TO BẢNG TRA KỸ THUẬT */
.zen-table-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  animation: fadeInModal 0.2s ease-out;
}

/* Plan 19: CỘT DỌC TRA CỨU CĂN CỨ TINH GỌN (ZERO-SCROLL, KHỚP Ô BAO NỘI DUNG) */
.reference-viewer[hidden] { display: none !important; }
.reference-viewer {
  position: fixed;
  top: 123px; /* Khớp đúng mép trên của bước (dưới thanh tab các bước) */
  right: 14px;
  bottom: 63px; /* Khớp đúng mép dưới của bước (ngay trên thanh wizard footer) */
  left: auto;
  max-width: calc(100vw - 28px);
  width: min(480px, 33vw); /* Chuẩn hóa tỷ lệ theo cột căn cứ 34%, không tràn vào cột Giá trị */
  z-index: 1200;
  display: flex;
  justify-content: flex-end;
  align-items: stretch;
  background: transparent;
  pointer-events: none; /* Cho phép click xuyên qua bàn tính bên trái */
  font-family: var(--font-sans);
  transition: left 0.15s ease, width 0.15s ease, top 0.15s ease, bottom 0.15s ease, right 0.15s ease;
}
.reference-dialog {
  pointer-events: auto; /* Bật tương tác trên cột tra cứu */
  width: 100%;
  height: 100%;
  max-height: 100%;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border-default, #334155);
  border-radius: var(--radius-lg);
  background: var(--bg-main, #0b0f17);
  color: #f8fafc;
  box-shadow: -10px 12px 35px rgba(0, 0, 0, 0.7);
  animation: slideInFromRight 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideInFromRight {
  from {
    transform: translateX(30px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}
.reference-header, .reference-footer {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex: none; padding: 8px 12px;
  background: #0f172a;
}
.reference-header {
  border-bottom: 1px solid rgba(255,255,255,.08);
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
}
.reference-footer {
  border-top: 1px solid rgba(255,255,255,.08);
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}
.reference-header h2 {
  margin: 0;
  font: 700 var(--text-sm) var(--font-sans);
  color: var(--accent-sky);
  display: flex;
  align-items: center;
  gap: 6px;
}
.reference-header-actions { display: flex; gap: 6px; }
.reference-header button, .reference-footer button, .reference-tabbar button,
.reference-meta nav button {
  background: transparent; color: #f8fafc; border: 1px solid #334155;
  border-radius: var(--radius-md); padding: 4px 8px; cursor: pointer;
  font: 600 var(--text-xs) var(--font-sans);
  transition: all 0.15s ease;
}
.reference-header button:hover, .reference-footer button:hover,
.reference-tabbar button:hover, .reference-meta nav button:hover { border-color: #38bdf8; color: #38bdf8; }
.reference-header button:focus-visible, .reference-footer button:focus-visible,
.reference-tabbar button:focus-visible, .reference-meta nav button:focus-visible {
  outline: 2px solid #38bdf8; outline-offset: 1px;
}
.reference-tabbar {
  flex: none; display: flex; gap: 4px; align-items: center;
  overflow-x: auto;
  scrollbar-width: none !important; /* Ẩn triệt để thanh cuộn ngang xám trên Firefox */
  -ms-overflow-style: none !important;
  padding: 4px 10px;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid rgba(255,255,255,.08);
  min-height: 34px;
}
.reference-tabbar::-webkit-scrollbar {
  display: none !important; /* Ẩn triệt để thanh cuộn ngang xám trên Chrome/Edge/Brave */
  width: 0 !important;
  height: 0 !important;
}
.reference-tabbar [role="tab"] {
  white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; font-size: var(--text-2xs); border-radius: 4px;
}
.reference-tabbar [aria-selected="true"] {
  border-color: #38bdf8; color: #38bdf8; background: rgba(56,189,248,.15);
}
.reference-tabbar .reference-tab-remove {
  color: #f87171; padding: 0 2px; font-size: var(--text-xs);
}
.reference-meta {
  flex: none;
  padding: 8px 12px 6px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: rgba(15, 23, 42, 0.4);
}
.reference-meta-heading {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px;
}
.reference-meta h3 {
  margin: 0; font: 700 var(--text-sm) var(--font-sans); color: var(--accent-sky);
}
.reference-meta p {
  margin: 3px 0 0; color: #94a3b8; font-size: 11px;
}
/* Ẩn các nút tab con rườm rà theo yêu cầu kỹ sư */
.reference-meta nav { display: none !important; }

#referenceStatus {
  font-size: 10px; font-weight: 700; padding: 2px 6px; border-radius: 4px;
  background: rgba(251, 191, 36, 0.15); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.3);
}
#referenceStatus[data-status="checked"] {
  background: rgba(52, 211, 153, 0.15); color: #34d399; border-color: rgba(52, 211, 153, 0.3);
}
#referenceStatus[data-status="missing"] {
  background: rgba(248, 113, 113, 0.15); color: #f87171; border-color: rgba(248, 113, 113, 0.3);
}

/* Khu vực hiển thị nội dung cốt lõi: Zero Scroll, nằm trọn trong khung hình */
.reference-content {
  flex: 1; min-height: 0; min-width: 0; overflow-y: auto; padding: 10px 12px;
  font-size: var(--text-xs); line-height: 1.5;
}
.reference-content h4 {
  margin: 0 0 6px; font: 700 var(--text-xs) var(--font-sans); color: #38bdf8;
  display: flex; align-items: center; gap: 5px;
}
.reference-content p, .reference-content li {
  line-height: 1.5; color: #cbd5e1; margin: 4px 0; font-size: 11px;
}

/* Bảng tra kỹ thuật: co giãn tự động, vừa khít độ rộng cột, không cuộn ngang */
.reference-content .reference-table-wrap {
  width: 100%; overflow: hidden; margin: 6px 0 8px;
  border: 1px solid rgba(255,255,255,.1); border-radius: var(--radius-md);
  background: #090d16;
}
.reference-content table {
  border-collapse: collapse; width: 100%; table-layout: fixed;
  font: var(--text-xs) var(--font-sans);
}
.reference-content th, .reference-content td {
  padding: 6px 8px; border-bottom: 1px solid rgba(255,255,255,.06);
  border-right: 1px solid rgba(255,255,255,.06); vertical-align: middle;
  word-wrap: break-word; overflow-wrap: break-word;
}
.reference-content th {
  background: #172133; color: #38bdf8; font-weight: 700;
  font-size: 11px; text-transform: uppercase; text-align: left;
}
.reference-content th:not(:first-child) {
  text-align: center;
}
.reference-content td.reference-numeric,
.reference-content td:not(:first-child) {
  text-align: center;
}
.reference-content td.reference-numeric {
  font-family: var(--font-mono); color: #34d399; font-weight: 700;
}

/* Khối công thức toán học: màu xanh ngọc, giải thích biến bên dưới */
.reference-content .reference-formula-card {
  background: #090d16; border: 1px solid rgba(16, 185, 129, 0.25);
  border-left: 3px solid #10b981; border-radius: var(--radius-md);
  padding: 8px 10px; margin: 6px 0 8px;
}
.reference-content .reference-formula {
  display: block; font: var(--text-sm) var(--font-mono); font-weight: 700;
  color: #34d399; margin-bottom: 4px; overflow-wrap: anywhere;
}
.reference-content .reference-formula-explain {
  font-size: 11px; color: #94a3b8; font-style: italic; margin: 0;
}

.reference-content .reference-note {
  border-left: 3px solid #f59e0b; background: rgba(245, 158, 11, 0.08);
  padding: 6px 8px; color: #fbbf24; font-size: 11px; border-radius: 0 var(--radius-md) var(--radius-md) 0;
  margin: 6px 0;
}
.reference-content .reference-empty { color: #f87171; font-weight: 600; padding: 10px 0; }
.reference-content .reference-source-line { margin: 3px 0; font-size: 11px; color: #94a3b8; }
.reference-footer span { color: #64748b; font-size: 10px; }
@media (max-width: 768px) {
  .reference-dialog { width: calc(100dvw - 16px) !important; max-height: calc(100dvh - 16px); }
  .reference-dialog[data-size="expanded"] { height: calc(100dvh - 16px); }
  .reference-header, .reference-footer, .reference-meta { padding-left: 10px; padding-right: 10px; }
  .reference-content { padding: 10px; }
}

.zen-table-modal-dialog {
  background: #0f172a;
  border: 1px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-lg);
  width: 900px;
  max-width: 94vw;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.zen-table-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: rgba(30, 41, 59, 0.75);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-header-left .modal-icon {
  font-size: 20px;
}

.zen-table-modal-header h3 {
  margin: 0;
  font-size: var(--text-md);
  color: #f8fafc;
  font-weight: 800;
  font-family: var(--font-sans);
}

.modal-subtitle {
  font-size: var(--text-xs);
  color: #94a3b8;
  font-family: var(--font-sans);
}

.btn-close-modal {
  background: transparent;
  border: none;
  font-size: 16px;
  color: #94a3b8;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.btn-close-modal:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.15);
}

.zen-table-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.zen-table-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 18px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-footer-hint {
  font-family: var(--font-sans);
  font-size: var(--text-2xs);
  color: #64748b;
  font-style: italic;
}

.btn-zen-action {
  background: rgba(56, 189, 248, 0.2);
  border: 1px solid #38bdf8;
  color: #38bdf8;
  border-radius: var(--radius-md);
  padding: 5px 14px;
  font-weight: 700;
  font-size: var(--text-xs);
  font-family: var(--font-sans);
  cursor: pointer;
  transition: var(--transition);
}

.btn-zen-action:hover {
  background: #38bdf8;
  color: #070a0f;
}

/* KPI Mini Grid trong Tab 3 Cột phải */
.kpi-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.kpi-mini-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px;
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 8px;
}
.kpi-mini-title {
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
}
.kpi-mini-val {
  font-size: 18px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: #38bdf8;
  margin: 2px 0;
}
.kpi-mini-sub {
  font-size: var(--text-xs);
  color: #64748b;
}






/* ==========================================================================
   PLAN 4 ENHANCEMENT: RICH TOOLTIPS, LABEL ACTIONS & AUTO-CALC STYLES
   ========================================================================== */
.label-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  width: 100% !important;
  margin-bottom: 6px !important;
  gap: 8px !important;
}
.label-text {
  font-weight: 600;
  color: var(--text-primary, #e2e8f0);
  font-size: 13px;
  flex: 1;
}
.label-actions {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  flex-shrink: 0;
}
.field-role-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.badge-user-input {
  background: rgba(56, 189, 248, 0.15) !important;
  color: #38bdf8 !important;
  border: 1px solid rgba(56, 189, 248, 0.3) !important;
}
.badge-auto-calc {
  background: rgba(16, 185, 129, 0.15) !important;
  color: #34d399 !important;
  border: 1px solid rgba(16, 185, 129, 0.3) !important;
}

/* User Input Box focus & border */
.user-input-box input,
.user-input-box select {
  border-color: rgba(56, 189, 248, 0.45) !important;
  background: rgba(15, 23, 42, 0.75) !important;
}
.user-input-box input:focus,
.user-input-box select:focus {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3) !important;
}

/* Auto Calc Box & Card styling */
.auto-calc-box {
  border: 1px solid rgba(52, 211, 153, 0.35) !important;
  background: rgba(6, 78, 59, 0.12) !important;
  border-radius: 8px;
}
.auto-calc-box input,
.auto-calc-box select {
  border-color: rgba(52, 211, 153, 0.45) !important;
  background: rgba(6, 78, 59, 0.18) !important;
  color: #6ee7b7 !important;
}

/* Ẩn hoàn toàn icon info-bubble theo yêu cầu người dùng */
.info-bubble {
  display: none !important;
}


/* ==========================================================================
   PLAN 4: GOLDEN 68:32 RATIO & COLLAPSIBLE SIDEBAR STYLING
   ========================================================================== */
.workspace-grid {
  transition: grid-template-columns 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Sidebar Collapsed State (Full Width 100% for Left Column) */
.workspace-grid.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr) !important;
}
.workspace-grid.sidebar-collapsed #workspaceInspector {
  display: none !important;
}

/* Collapse Button inside Inspector Header Tabs */
.btn-collapse-sidebar {
  flex: 0 0 34px !important;
  max-width: 34px !important;
  padding: 8px 0 !important;
  background: rgba(255, 255, 255, 0.05) !important;
  color: #94a3b8 !important;
  font-weight: 800 !important;
  font-size: 13px !important;
  cursor: pointer !important;
  border-radius: 6px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  transition: all 0.2s ease !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}
.btn-collapse-sidebar:hover {
  background: rgba(56, 189, 248, 0.2) !important;
  color: #38bdf8 !important;
  border-color: rgba(56, 189, 248, 0.4) !important;
  transform: scale(1.08) !important;
}

/* [Plan 20] Floating Expand Pill Button — vô hiệu hóa vĩnh viễn */
.btn-sidebar-expand-pill {
  display: none !important;
  position: fixed;
  top: 62px;
  right: 24px;
  z-index: 100;
  align-items: center;
  gap: 7px;
  background: rgba(15, 23, 42, 0.95);
  color: #38bdf8;
  border: 1.5px solid rgba(56, 189, 248, 0.5);
  border-radius: 24px;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), 0 0 12px rgba(56, 189, 248, 0.25);
  backdrop-filter: blur(10px);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  animation: pulseGlow 2.5s infinite;
}
.btn-sidebar-expand-pill:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.7);
  transform: translateY(-2px);
}
.btn-sidebar-expand-pill.hidden {
  display: none !important;
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), 0 0 10px rgba(56, 189, 248, 0.25); }
  50% { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.55), 0 0 18px rgba(56, 189, 248, 0.55); }
}

/* ==========================================================================
   PLAN 5: TECH SPEC TABLE DESIGN SYSTEM (BẢNG THÔNG SỐ & TÍNH TOÁN KỸ THUẬT)
   ========================================================================== */

/* 1. Ẩn triệt để badge chữ [KỸ SƯ NHẬP] / [KỸ SƯ CHỌN] theo Yêu cầu 2 */
.field-role-badge,
.badge-user-input,
.badge-auto-calc {
  display: none !important;
}

/* 2. Container Bảng Kỹ Thuật */
.tech-table-container {
  width: 100%;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.22);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  margin-bottom: 16px;
  backdrop-filter: blur(12px);
}

/* Thanh chú thích màu sắc (Legend bar) - Ẩn theo yêu cầu người dùng */
.tech-table-legend {
  display: none !important;
}
.legend-items {
  display: flex;
  align-items: center;
  gap: 16px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
}
.dot-manual {
  background: rgba(245, 158, 11, 0.3);
  border: 1.5px solid #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.4);
}
.dot-auto {
  background: rgba(16, 185, 129, 0.25);
  border: 1.5px solid #10b981;
  box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
}
.legend-note {
  color: #94a3b8;
  font-style: italic;
  font-size: var(--text-xs);
}

/* Cấu trúc Table Chuẩn Hóa DS-PCCC-2026-v2.3 */
.tech-spec-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  text-align: left;
}

.tech-spec-table thead th {
  background: var(--bg-table-header) !important;
  color: var(--accent-sky) !important;
  font-family: var(--font-sans) !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  font-size: var(--text-xs) !important;
  letter-spacing: 0.5px !important;
  padding: 10px 10px !important;
  border-bottom: 1.5px solid rgba(56, 189, 248, 0.3) !important;
  vertical-align: middle !important;
}
.tech-spec-table thead th.col-stt {
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  text-align: center !important;
  color: var(--accent-sky) !important;
  font-size: var(--text-xs) !important;
  padding: 10px 4px !important;
}
.tech-spec-table td.col-stt {
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  text-align: center;
  color: var(--text-primary) !important;
  font-weight: 700;
  font-size: var(--text-xs);
  padding: 8px 4px;
}
.tech-spec-table thead th.col-name,
.tech-spec-table tbody td.col-name {
  width: 32% !important;
  min-width: 170px;
  font-size: var(--text-xs) !important;
  color: var(--accent-sky) !important;
}
.tech-spec-table th.col-unit,
.tech-spec-table td.col-unit {
  display: none !important;
}
.tech-spec-table thead th.col-val,
.tech-spec-table tbody td.col-val {
  width: 38% !important;
  min-width: 220px;
  font-size: var(--text-xs) !important;
  color: var(--accent-sky) !important;
}
.tech-spec-table thead th.col-basis,
.tech-spec-table tbody td.col-basis {
  width: 30% !important;
  min-width: 160px;
  font-size: var(--text-xs) !important;
  color: var(--accent-sky) !important;
}

/* Khung nhập liệu tích hợp đơn vị vào ô (Input With Unit - Liền khối không chia tách) */
.input-with-unit {
  display: flex;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input);
  border: 1.5px solid rgba(245, 158, 11, 0.5) !important;
  border-radius: var(--radius-md);
  padding: 0 10px 0 0;
  min-height: 38px;
  transition: all 0.2s ease;
}
.input-with-unit.compact {
  max-width: 150px;
}
.input-with-unit:focus-within {
  border-color: #f59e0b !important;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}
.input-with-unit input {
  flex: 1;
  min-width: 0;
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  padding: 6px 6px 6px 10px !important;
  color: var(--state-input-text) !important;
  font-family: var(--font-mono) !important;
  font-weight: 700 !important;
  font-size: var(--text-base) !important;
  outline: none !important;
}
.input-with-unit .unit-suffix {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 600;
  color: #94a3b8;
  background: transparent !important;
  padding: 0 2px 0 0 !important;
  border: none !important;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}

.tech-spec-table tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: background 0.15s ease;
}
.tech-spec-table tbody tr:hover {
  background: var(--bg-row-hover);
}
.tech-spec-table tbody tr:last-child {
  border-bottom: none;
}

.tech-spec-table td {
  padding: 8px 12px;
  vertical-align: middle;
}

/* Tiêu đề nhóm hàng trong bảng (Category Row) */
.tech-row-header td {
  background: rgba(30, 41, 59, 0.7);
  color: var(--accent-sky);
  font-weight: 700;
  font-size: var(--text-md);
  letter-spacing: 0.3px;
  padding: 7px 12px;
  border-top: 1px solid rgba(56, 189, 248, 0.2);
  border-bottom: 1px solid rgba(56, 189, 248, 0.2);
}

/* Tên thông số kèm ký hiệu */
.param-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--text-primary);
}
.param-symbol {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent-sky);
  font-size: var(--text-base);
  margin-left: 2px;
  margin-right: 0;
  white-space: nowrap;
}
.param-sub {
  display: block;
  font-size: var(--text-xs);
  color: #94a3b8;
  margin-top: 3px;
  font-weight: normal;
  line-height: 1.4;
}

/* 3. Ô Nhập Liệu Thủ Công (Khóa viền Amber-500 đồng đều 1.5px 4 cạnh) */
.cell-manual-input {
  background: transparent;
  border-left: none !important;
}
.cell-manual-input input:not([type="radio"]):not([type="checkbox"]):not([type="range"]) {
  width: 100%;
  box-sizing: border-box;
  background: var(--bg-input) !important;
  border: 1.5px solid rgba(245, 158, 11, 0.5) !important;
  color: var(--state-input-text) !important; /* #f8fafc trắng dịu, CẤM màu vàng chói */
  font-weight: 700 !important;
  font-size: var(--text-base) !important;
  padding: 7px 10px !important;
  min-height: 38px;
  border-radius: var(--radius-md) !important;
  transition: all 0.2s ease !important;
  font-family: var(--font-mono) !important;
}
.cell-manual-input input:not([type="radio"]):not([type="checkbox"]):not([type="range"]):focus {
  border-color: #f59e0b !important;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3) !important;
  background: var(--bg-input) !important;
  outline: none !important;
}
.cell-manual-input .input-with-unit input,
.cell-manual-input .input-with-unit input:not([type="radio"]):not([type="checkbox"]):not([type="range"]) {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 6px 6px 6px 10px !important;
  max-width: none !important;
  width: 100% !important;
}
.cell-manual-input .input-with-unit input:focus {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}
#inputProjectTitle {
  font-family: var(--font-sans) !important;
  font-size: var(--text-base) !important;
  font-weight: 700 !important;
  color: var(--text-primary) !important;
  border: 1.5px solid rgba(245, 158, 11, 0.5) !important;
}

/* Thẻ chọn <select> chống cắt chữ, dùng font-sans Inter, viền Amber đồng đều 1.5px */
.cell-manual-input select {
  width: 100%;
  box-sizing: border-box;
  font-family: var(--font-sans) !important; /* Dùng font Sans Inter, CẤM Monospace */
  font-size: var(--text-sm) !important; /* 12px */
  font-weight: 500 !important;
  color: var(--text-primary) !important; /* #f8fafc */
  background-color: var(--bg-input) !important; /* #090d16 */
  border: 1.5px solid rgba(245, 158, 11, 0.5) !important;
  border-radius: var(--radius-md) !important;
  padding: 7px 10px !important;
  min-height: 38px;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: all 0.2s ease !important;
}
.cell-manual-input select:focus {
  border-color: #f59e0b !important;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3) !important;
  outline: none !important;
}
.cell-manual-input select option {
  background: var(--bg-surface);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

.slider-sync-mini {
  margin-top: 4px;
  width: 100%;
  height: 4px;
  accent-color: var(--state-input);
  cursor: pointer;
}

/* 4. Ô Tự Động Tính / Diễn Giải Phép Tính Trực Tiếp Liền Mạch (Plan 22.2 Master Spec) */
.cell-auto-calc {
  background: transparent;
  border-left: none !important;
}
.calc-formula-display {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(16, 185, 129, 0.05);
  border: 1.5px solid rgba(16, 185, 129, 0.5) !important;
  border-radius: var(--radius-md);
  box-sizing: border-box;
  width: 100%;
  min-height: 38px;
  transition: all 0.2s ease;
}
.calc-formula-display.inherited {
  background: rgba(14, 165, 233, 0.05);
  border: 1.5px solid rgba(14, 165, 233, 0.5) !important;
}
.calc-expr {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: #cbd5e1;
  white-space: nowrap;
}
.calc-eq {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #94a3b8;
  margin: 0 1px;
  user-select: none;
}
.calc-result {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 700;
  color: #34d399;
  white-space: nowrap;
}
.calc-formula-display.inherited .calc-result {
  color: #38bdf8;
}

.auto-result-box {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  box-sizing: border-box;
  background: rgba(16, 185, 129, 0.06);
  border: 1.2px solid rgba(16, 185, 129, 0.3);
  border-left: 3px solid #10b981 !important;
  border-radius: var(--radius-md);
  padding: 6px 10px;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-base);
  color: #34d399;
}
.auto-result-box.highlight-blue,
.auto-result-box.inherited {
  background: rgba(14, 165, 233, 0.06);
  border-color: rgba(14, 165, 233, 0.3);
  border-left: 3px solid #0ea5e9 !important;
  color: #38bdf8;
}
.auto-result-box.highlight-amber {
  background: rgba(16, 185, 129, 0.06);
  border-color: rgba(16, 185, 129, 0.3);
  border-left: 3px solid #10b981 !important;
  color: #34d399;
}

/* Zero Text Tag & Zero Icon Rule (Khóa nhận diện màu thuần túy) */
.auto-calc-tag,
.tag-inherited,
.auto-tag {
  display: none !important;
}

/* 5. Cột Căn Cứ Tiêu Chuẩn & Công Thức Đầy Đủ */
.basis-cell-content {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.basis-std-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  color: var(--accent-sky);
  font-size: var(--text-xs);
}
.basis-desc {
  font-size: var(--text-xs);
  color: var(--text-muted);
  line-height: 1.35;
}
.basis-formula {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: #a5f3fc;
  background: rgba(6, 182, 212, 0.1);
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(6, 182, 212, 0.2);
  display: inline-block;
  margin-top: 2px;
}

/* 6. Contextual Warnings & Field Pulse Highlight */
@keyframes pulseHighlightField {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.8); border-color: #38bdf8; }
  50% { box-shadow: 0 0 0 8px rgba(56, 189, 248, 0.25); border-color: #0284c7; }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}
.field-highlight {
  animation: pulseHighlightField 1.4s ease-in-out 3;
  border-color: #38bdf8 !important;
  outline: none;
}
.btn-jump-step:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
  transition: all 0.15s ease;
}

/* ==========================================================================
   Plan 11: Step 1 Guided Ergonomics & UI Enhancements
   ========================================================================== */

/* 1. Step Goal Banner */
.step-goal-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-left: 3px solid var(--accent-sky);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin: 0 0 14px 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}
.step-goal-icon {
  font-size: var(--text-md);
  line-height: 1.2;
}
.step-goal-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.step-goal-title {
  color: var(--accent-sky);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
}
.step-goal-desc {
  color: #cbd5e1;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.4;
}

/* 2. Nhãn Tự Tính & Nút Mở Bảng Chọn */
.auto-calc-tag {
  display: inline-flex;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  font-weight: 700;
  color: #34d399;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(16, 185, 129, 0.35);
  border-radius: 3px;
  padding: 1px 5px;
  margin-right: 8px;
  letter-spacing: 0.3px;
}
.basis-cell-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 0;
}
.basis-link-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.30);
  color: #38bdf8;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  width: fit-content;
  max-width: 100%;
  text-align: left;
  line-height: 1.3;
  transition: all 0.15s ease;
  user-select: none;
}
.basis-link-badge:hover {
  background: rgba(56, 189, 248, 0.20);
  border-color: #38bdf8;
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(56, 189, 248, 0.25);
}
.basis-link-badge .link-icon {
  font-size: 11px;
  color: #7dd3fc;
  margin-left: 2px;
  font-weight: normal;
}
.basis-desc {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: #94a3b8;
  line-height: 1.45;
  display: block;
}
.basis-desc strong {
  color: #e2e8f0;
}
.basis-desc code {
  font-family: var(--font-mono);
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.10);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}
/* Modal Bullet List & Detail Section Styles */
.modal-bullet-box {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  margin-bottom: 12px;
}
.modal-bullet-title {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  color: #38bdf8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.modal-bullet-list {
  margin: 0;
  padding-left: 18px;
  list-style-type: disc;
}
.modal-bullet-list li {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: #cbd5e1;
  line-height: 1.55;
  margin-bottom: 4px;
}
.modal-bullet-list li:last-child {
  margin-bottom: 0;
}
.modal-bullet-list strong {
  color: #f8fafc;
}
.modal-table-section-title {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  color: #e2e8f0;
  margin: 12px 0 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* 3. Khối Kết Luận Trạng Thái Bước 1 (Step 1 Status Conclusion Card) */
.step-conclusion-card {
  margin-top: 14px;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid #1e293b;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.conclusion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 8px;
}
.conclusion-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.3px;
}
.conclusion-badge.status-pass {
  background: rgba(16, 185, 129, 0.15);
  border: 1.5px solid #10b981;
  color: #34d399;
}
.conclusion-badge.status-warning {
  background: rgba(245, 158, 11, 0.15);
  border: 1.5px solid #f59e0b;
  color: #fbbf24;
}
.conclusion-badge.status-danger {
  background: rgba(239, 68, 68, 0.15);
  border: 1.5px solid #ef4444;
  color: #f87171;
}
.conclusion-meta {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.conclusion-grid {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.conclusion-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: 1.4;
  color: #cbd5e1;
}
.cond-bullet {
  font-weight: 700;
  font-size: var(--text-sm);
  color: #34d399;
  flex-shrink: 0;
  margin-top: 1px;
}
.conclusion-action-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.1);
}
.conclusion-summary-note {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: #e2e8f0;
}
.conclusion-summary-note strong {
  color: var(--accent-sky);
  font-family: var(--font-mono);
}
.btn-step-next-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #0284c7, #0369a1);
  border: 1px solid #38bdf8;
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}
.btn-step-next-mini:hover {
  background: linear-gradient(135deg, #0369a1, #075985);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

/* ==========================================================================
   PLAN 13: CÁC TIỆN ÍCH DỮ LIỆU KẾ THỪA & THÔNG BÁO ESFR BƯỚC 2
   ========================================================================== */
.auto-calc-tag.tag-inherited {
  background: rgba(147, 51, 234, 0.15);
  border-color: rgba(147, 51, 234, 0.4);
  color: #c084fc;
}

.esfr-in-rack-notice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-left: 3px solid #10b981;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
}

.esfr-in-rack-notice.hidden {
  display: none !important;
}

.esfr-in-rack-notice .notice-icon {
  font-size: var(--text-lg);
  flex-shrink: 0;
  line-height: 1;
}

.esfr-in-rack-notice .notice-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.esfr-in-rack-notice .notice-body strong {
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: #34d399;
  letter-spacing: 0.02em;
}

.esfr-in-rack-notice .notice-body p {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  line-height: 1.5;
  color: #cbd5e1;
  margin: 0;
}

.esfr-in-rack-notice .notice-body .btn-step-next-mini {
  align-self: flex-start;
  margin-top: 4px;
}

/* ==============================================================
   [Plan 20] TAB 07 — THƯ VIỆN PHÁP LÝ & SƠ ĐỒ P&ID
   ============================================================== */

/* Library Sub-tabs */
.library-sub-tabs {
  display: flex;
  gap: 2px;
  padding: 4px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: 8px;
  margin-bottom: 12px;
}
.lib-sub-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.lib-sub-tab:hover {
  background: rgba(56, 189, 248, 0.06);
  color: var(--text-secondary);
}
.lib-sub-tab.active {
  background: rgba(56, 189, 248, 0.1);
  border-color: rgba(56, 189, 248, 0.3);
  color: #38bdf8;
}
.lib-tab-icon { font-size: 14px; }

/* Library Panes */
.lib-pane { display: none; }
.lib-pane.active { display: block; }

/* Library 2-Column Grid */
.library-grid-2col {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  min-height: 400px;
}

/* Sidebar Navigation */
.lib-catalog-nav {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}
.lib-nav-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  background: rgba(56, 189, 248, 0.06);
  border-bottom: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-secondary);
}
.lib-nav-icon { font-size: 14px; }
.lib-nav-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px;
}
.lib-nav-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-sans);
}
.lib-nav-item:hover {
  background: rgba(56, 189, 248, 0.06);
}
.lib-nav-item.active {
  background: rgba(56, 189, 248, 0.1);
  box-shadow: inset 3px 0 0 #38bdf8;
}
.lib-nav-badge {
  font-size: 11px;
  font-weight: 700;
  color: #38bdf8;
  font-family: var(--font-mono);
  letter-spacing: 0.3px;
}
.lib-nav-name {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}
.lib-nav-item.active .lib-nav-name { color: var(--text-secondary); }

/* Content Viewer */
.lib-content-viewer {
  background: rgba(15, 23, 42, 0.3);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow-y: auto;
  max-height: calc(100vh - 260px);
}
.lib-content-header {
  padding: 12px 16px;
  background: rgba(56, 189, 248, 0.04);
  border-bottom: 1px solid var(--border-color);
}
.lib-content-header h4 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
  font-family: var(--font-sans);
}
.lib-content-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-sans);
}
.lib-content-body {
  padding: 12px 16px;
}

/* Library Sections */
.lib-section {
  margin-bottom: 16px;
}
.lib-section-title {
  font-size: 13px;
  font-weight: 700;
  color: #38bdf8;
  margin-bottom: 8px;
  font-family: var(--font-sans);
}

/* Library Tables */
.lib-table {
  font-size: 12px !important;
}
.lib-table th {
  font-size: 11px !important;
  padding: 6px 8px !important;
}
.lib-table td {
  padding: 5px 8px !important;
  font-size: 12px !important;
}

/* Library Formula Block */
.lib-formula-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 14px;
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-left: 3px solid #10b981;
  border-radius: 6px;
}
.lib-formula-block code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: #34d399;
  display: block;
  line-height: 1.5;
}

/* Placeholder for upcoming features */
.lib-diagram-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 300px;
  padding: 40px;
  text-align: center;
  background: rgba(15, 23, 42, 0.3);
  border: 2px dashed rgba(56, 189, 248, 0.15);
  border-radius: 12px;
}
.placeholder-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}
.lib-diagram-placeholder h4 {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-secondary);
  margin: 0 0 8px;
  font-family: var(--font-sans);
}
.lib-diagram-placeholder p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 500px;
  line-height: 1.5;
  font-family: var(--font-sans);
}
.placeholder-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* [Plan 20] Layout Full Width cho Tab 07 Thư Viện Pháp Lý */
.workspace-grid.tab-library-active {
  grid-template-columns: minmax(0, 1fr) !important;
}
.workspace-grid.tab-library-active #workspaceInspector {
  display: none !important;
}
.workspace-grid.tab-library-active .action-toolbar {
  display: none !important;
}

/* Nút điều hướng sang Thư Viện tại Bước 6 */
.btn-go-library {
  font-family: var(--font-sans);
  font-size: 13px !important;
  font-weight: 600 !important;
  padding: 8px 14px !important;
  border-radius: 6px !important;
  cursor: pointer !important;
  transition: all 0.2s ease !important;
}
.btn-go-library:hover {
  background: rgba(56, 189, 248, 0.22) !important;
  border-color: #38bdf8 !important;
  color: #fff !important;
  transform: translateY(-1px);
}

/* ==========================================================================
   TAB 07 — PHÂN KHU 2: SƠ ĐỒ P&ID & MẶT CẮT 2D KỸ THUẬT
   ========================================================================== */
.lib-diagrams-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.lib-diagram-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}
.diagram-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: rgba(56, 189, 248, 0.05);
  border-bottom: 1px solid var(--border-color);
}
.diagram-card-header h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-sans);
}
.diagram-card-std {
  font-size: 11px;
  font-weight: 600;
  color: #38bdf8;
  font-family: var(--font-mono);
  background: rgba(56, 189, 248, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
}
.diagram-card-body {
  padding: 12px;
}
.lib-schematic-svg {
  width: 100%;
  height: auto;
  max-height: 420px;
  display: block;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.15);
}

/* ==========================================================================
   TAB 07 — PHÂN KHU 3: CHECKLIST THẨM DUYỆT PCCC (COMPLIANCE RADAR)
   ========================================================================== */
.compliance-wrapper {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.compliance-summary-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}
.compliance-score-circle {
  display: flex;
  align-items: baseline;
  justify-content: center;
  min-width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(16, 185, 129, 0.1);
  border: 2px solid #10b981;
  padding-top: 18px;
}
.compliance-score-val {
  font-size: 20px;
  font-weight: 900;
  color: #34d399;
  font-family: var(--font-mono);
}
.compliance-score-max {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}
.compliance-summary-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.compliance-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.compliance-summary-header h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-sans);
}
.compliance-badge-status {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 12px;
  font-family: var(--font-sans);
}
.compliance-badge-status.status-perfect {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.compliance-badge-status.status-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.compliance-badge-status.status-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.compliance-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  overflow: hidden;
}
.compliance-progress-fill {
  height: 100%;
  background: #10b981;
  border-radius: 4px;
  transition: width 0.3s ease, background 0.3s ease;
}
.compliance-summary-desc {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  font-family: var(--font-sans);
}

/* Checklist Grid */
.compliance-checklist-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
@media (max-width: 900px) {
  .compliance-checklist-grid {
    grid-template-columns: 1fr;
  }
}
.compliance-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.compliance-item:hover {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(56, 189, 248, 0.3);
}
.compliance-item.passed {
  border-left: 3px solid #10b981;
}
.compliance-item.failed {
  border-left: 3px solid #ef4444;
  opacity: 0.65;
}
.compliance-chk {
  margin-top: 3px;
  width: 16px;
  height: 16px;
  accent-color: #10b981;
  cursor: pointer;
  flex-shrink: 0;
}
.compliance-item-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.compliance-item-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.compliance-item-title strong {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-sans);
}
.compliance-item-std {
  font-size: 10px;
  font-weight: 600;
  color: #38bdf8;
  font-family: var(--font-mono);
  background: rgba(56, 189, 248, 0.1);
  padding: 1px 6px;
  border-radius: 3px;
  white-space: nowrap;
}
.compliance-item-text {
  margin: 0;
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
  font-family: var(--font-sans);
}



/* ==========================================================================
   BƯỚC 5: MASTER SPEC THỦY LỰC & CỘT ÁP MÁY BƠM CHÍNH (PLAN 23)
   ========================================================================== */
.math-chain {
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(16, 185, 129, 0.05);
  border: 1.5px solid rgba(16, 185, 129, 0.5) !important;
  border-radius: var(--radius-md);
  box-sizing: border-box;
  width: 100%;
  min-height: 38px;
  transition: all 0.2s ease;
}
.cell-inherited .math-chain {
  background: rgba(14, 165, 233, 0.05);
  border: 1.5px solid rgba(14, 165, 233, 0.5) !important;
}
.cell-inherited .math-res {
  color: #38bdf8 !important;
}
.math-expr {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: #cbd5e1;
  white-space: nowrap;
}
.math-eq {
  font-family: var(--font-mono);
  font-weight: 700;
  color: #94a3b8;
  margin: 0 1px;
  user-select: none;
}
.math-res {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 700;
  color: #34d399;
  white-space: nowrap;
}
.unit-badge-mini {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: #94a3b8;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  margin-left: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.math-chain-sub {
  font-size: 11px;
  color: #94a3b8;
}
.pipe-editor-card {
  background: rgba(11, 15, 23, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px;
}
.pipe-editor-card .pipe-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
}
.pipe-editor-card .pipe-badge.branch {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}
.pipe-editor-card .pipe-badge.main {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.pipe-card-hint {
  font-size: 12px;
  color: #94a3b8;
}
#tableStep5 .row-highlight-result td {
  background: rgba(16, 185, 129, 0.04);
}
