
/* =====================================================
   PRESTEC DESIGN TOKENS — file duy nhất khai báo màu/kích thước.
   CẤM hard-code màu ở bất kỳ chỗ nào khác.
   ===================================================== */
:root {
  --primary:        #F2711C;
  --primary-hover:  #DE5F0E;
  --primary-soft:   #FEF1E7;
  --primary-border: #F6B27E;

  --bg-page:    #F4F5F8;
  --bg-surface: #FFFFFF;
  --bg-subtle:  #F9FAFB;

  --text-primary:   #1F2937;
  --text-secondary: #6B7280;
  --text-muted:     #9CA3AF;

  --border:        #E5E7EB;
  --border-strong: #D1D5DB;

  --info:    #2F80ED;  --info-soft:    #EAF2FE;
  --success: #16A34A;  --success-soft: #E8F7EE;
  --purple:  #8B5CF6;  --purple-soft:  #F3EEFE;
  --warning: #F2994A;  --warning-soft: #FEF5EC;
  --danger:  #EF4444;

  --banner-bg: #FFF8E6; --banner-border: #FFE7A3;

  --radius-sm: 6px; --radius-md: 8px; --radius-lg: 12px; --radius-full: 999px;
  --shadow-card: 0 1px 2px rgba(16,24,40,.05);
  --shadow-dropdown: 0 4px 12px rgba(16,24,40,.10);

  --font: "Be Vietnam Pro", -apple-system, "Segoe UI", Roboto, sans-serif;
  --header-h: 64px;
  --sidebar-w: 240px;
  --control-h: 40px;
}

/* ===== RESET & NỀN ===== */
* { margin:0; padding:0; box-sizing:border-box; }
html, body { height:100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
.icon { width:20px; height:20px; stroke-width:2; flex-shrink:0; }
.icon-sm { width:16px; height:16px; }

/* =====================================================
   APP SHELL: header trên cùng + sidebar trái + nội dung
   ===================================================== */
.app { display:flex; flex-direction:column; height:100vh; }
.app-body { display:flex; flex:1; min-height:0; }

/* ===== HEADER ===== */
.header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
  padding: 0 24px; flex-shrink:0;
}
.header-left { display:flex; align-items:center; gap:16px; }
.btn-icon {
  background:none; border:none; color:var(--text-secondary);
  width:36px; height:36px; border-radius:var(--radius-md);
  display:inline-flex; align-items:center; justify-content:center;
}
.btn-icon:hover { background:var(--bg-subtle); color:var(--text-primary); }
.logo { font-size:20px; font-weight:700; font-style:italic; color:var(--primary); letter-spacing:.5px; }
.logo-img {
  display:block; width:132px; max-width:132px; height:36px;
  object-fit:contain; object-position:left center;
}
.header .logo-img { width:120px; max-width:120px; height:36px; }
.header-divider { width:1px; height:24px; background:var(--border); }
.header-title { font-size:15px; font-weight:600; }
.header-right { display:flex; align-items:center; gap:16px; }
.notif { position:relative; }
.notif-badge {
  position:absolute; top:2px; right:2px; min-width:16px; height:16px;
  background:var(--primary); color:var(--bg-surface); font-size:10px; font-weight:600;
  border-radius:var(--radius-full);
  display:flex; align-items:center; justify-content:center; padding:0 4px;
}
.user-chip { display:flex; align-items:center; gap:10px; cursor:pointer; }
.avatar {
  width:36px; height:36px; border-radius:var(--radius-full);
  background:var(--bg-subtle); border:1px solid var(--border);
  display:flex; align-items:center; justify-content:center; color:var(--text-muted);
}
.user-chip .name { font-weight:600; font-size:14px; line-height:1.2; }
.user-chip .role { font-size:12px; color:var(--text-secondary); }

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w); flex-shrink:0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display:flex; flex-direction:column; padding:16px 12px;
}
.nav { display:flex; flex-direction:column; gap:2px; flex:1; }
.nav-item {
  display:flex; align-items:center; gap:12px;
  height:44px; padding:0 12px;
  border-radius:var(--radius-md);
  color:var(--text-secondary); font-weight:500; font-size:14px;
  text-decoration:none; position:relative;
  border-top:1px solid var(--border); border-top:none; /* không viền giữa các mục */
}
.nav-item:hover { background:var(--bg-subtle); color:var(--text-primary); }
.nav-item.active {
  background:var(--primary-soft); color:var(--primary); font-weight:600;
}
.nav-item.active::before {
  content:""; position:absolute; left:-12px; top:8px; bottom:8px;
  width:3px; border-radius:0 3px 3px 0; background:var(--primary);
}
.nav-item + .nav-sep { height:1px; background:var(--border); margin:8px 4px; }
.sidebar-footer { padding-top:12px; }
.btn-logout {
  width:100%; height:var(--control-h);
  display:flex; align-items:center; justify-content:center; gap:8px;
  background:var(--bg-surface); border:1px solid var(--border-strong);
  border-radius:var(--radius-md); color:var(--text-primary); font-weight:600; font-size:14px;
}
.btn-logout:hover { background:var(--bg-subtle); }

/* ===== VÙNG NỘI DUNG ===== */
.main { flex:1; min-width:0; min-height:0; display:flex; flex-direction:column; overflow:hidden; }

/* ===== TAB BAR ===== */
.tabs {
  background:var(--bg-surface); border-bottom:1px solid var(--border);
  display:flex; overflow-x:auto; flex-shrink:0; padding:0 16px;
}
.tab {
  padding:14px 16px; font-size:14px; font-weight:500;
  color:var(--text-secondary); white-space:nowrap;
  border:none; background:none; position:relative;
}
.tab:hover { color:var(--text-primary); }
.tab.active { color:var(--primary); font-weight:600; }
.tab.active::after {
  content:""; position:absolute; left:12px; right:12px; bottom:0;
  height:3px; background:var(--primary); border-radius:3px 3px 0 0;
}

.content { flex:1; overflow-y:auto; padding:24px; display:flex; flex-direction:column; gap:16px; }
.main > #inventoryWorkspaceView.content {
  min-height:0; overflow-x:hidden; overflow-y:auto;
}

/* ===== CARD CHUẨN ===== */
.card {
  background:var(--bg-surface); border:1px solid var(--border);
  border-radius:var(--radius-lg); box-shadow:var(--shadow-card);
}

/* ===== PAGE HEADER ===== */
.page-header { padding:20px 24px; display:flex; align-items:center; justify-content:space-between; gap:16px; }
.page-header h1 { color:var(--text-primary); font-family:var(--font); font-size:24px; font-weight:700; }
.page-header .subtitle { font-size:13px; color:var(--text-secondary); margin-top:4px; }
.page-actions { display:flex; align-items:center; gap:12px; }
.page-actions .meta { font-size:13px; color:var(--text-secondary); white-space:nowrap; }

/* ===== BUTTONS ===== */
.btn {
  height:var(--control-h); padding:0 16px;
  display:inline-flex; align-items:center; gap:8px;
  border-radius:var(--radius-md); font-size:14px; font-weight:600;
  transition:background .15s, border-color .15s;
}
.btn--primary { background:var(--primary); border:1px solid var(--primary); color:var(--bg-surface); }
.btn--primary:hover { background:var(--primary-hover); }
.btn--outline { background:var(--bg-surface); border:1px solid var(--border-strong); color:var(--text-primary); }
.btn--outline:hover { background:var(--bg-subtle); }
.btn--outline-primary { background:var(--bg-surface); border:1px solid var(--primary-border); color:var(--primary); }
.btn--outline-primary:hover { background:var(--primary-soft); }
.btn--sm { height:32px; padding:0 12px; font-size:13px; }

/* ===== KPI CARDS ===== */
.kpi-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; }
.kpi-grid--two { grid-template-columns:repeat(2,1fr); }
.kpi-grid--five { grid-template-columns:repeat(5,minmax(0,1fr)); }
.kpi { padding:20px; display:flex; align-items:center; gap:16px; }
.kpi-icon {
  width:52px; height:52px; border-radius:var(--radius-full);
  display:inline-flex; align-items:center; justify-content:center;
  flex:0 0 52px; flex-shrink:0; line-height:0; padding:0;
}
.kpi-icon .icon { width:24px; height:24px; display:block; margin:0; flex-shrink:0; }
.kpi-icon--info    { background:var(--info-soft);    color:var(--info); }
.kpi-icon--success { background:var(--success-soft); color:var(--success); }
.kpi-icon--purple  { background:var(--purple-soft);  color:var(--purple); }
.kpi-icon--warning { background:var(--warning-soft); color:var(--warning); }
.kpi-label { font-size:14px; color:var(--text-secondary); }
.kpi-value { font-size:26px; font-weight:700; margin-top:2px; }
.kpi-value--warning { font-size:16px; color:var(--text-primary); }
.kpi-value--warning strong { color:var(--primary); font-size:20px; }

/* ===== PAGE SUB-TABS ===== */
.page-subtabs {
  background:var(--bg-surface); border:1px solid var(--border);
  border-radius:var(--radius-lg); box-shadow:var(--shadow-card);
  display:flex; gap:4px; padding:6px;
}
.page-subtab {
  height:36px; padding:0 14px; border:none; border-radius:var(--radius-md);
  background:transparent; color:var(--text-secondary);
  display:inline-flex; align-items:center; justify-content:center;
  font-family:inherit; font-size:13px; font-weight:600; text-decoration:none;
}
.page-subtab:hover { background:var(--bg-subtle); color:var(--text-primary); }
.page-subtab.active { background:var(--primary-soft); color:var(--primary); }

/* ===== BANNER ===== */
.banner {
  background:var(--banner-bg); border:1px solid var(--banner-border);
  border-radius:var(--radius-lg); padding:12px 16px;
  display:flex; align-items:flex-start; gap:12px;
}
.banner .icon { color:var(--warning); margin-top:1px; }
.banner-text { flex:1; font-size:13px; line-height:1.6; }
.banner-text .sub { color:var(--text-secondary); }
.banner .btn-icon { width:28px; height:28px; }

/* ===== FILTER CARD ===== */
.filter-card { padding:16px 24px 12px; }
.filter-row { display:flex; gap:16px; align-items:flex-end; }
.field { display:flex; flex-direction:column; gap:6px; }
.field label { font-size:13px; font-weight:500; }
.field--grow { flex:2; } .field--md { flex:1; }
.input-wrap { position:relative; }
.input-wrap .icon {
  position:absolute; left:12px; top:50%; transform:translateY(-50%);
  width:16px; height:16px; color:var(--text-muted); pointer-events:none;
}
.input, .select {
  height:var(--control-h); width:100%;
  border:1px solid var(--border-strong); border-radius:var(--radius-md);
  padding:0 12px; font-size:14px; font-family:inherit;
  color:var(--text-primary); background:var(--bg-surface);
}
.input-wrap .input { padding-left:36px; }
.input::placeholder { color:var(--text-muted); }
.input:focus, .select:focus {
  outline:none; border-color:var(--primary);
  box-shadow:0 0 0 3px var(--primary-soft);
}
/* select tùy biến: bỏ mũi tên native, vẽ chevron riêng */
.select {
  appearance:none; -webkit-appearance:none;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat:no-repeat; background-position:right 12px center;
  padding-right:36px;
}
.filter-hint { font-size:13px; color:var(--text-secondary); margin-top:12px; }
.filter-row + .filter-row { margin-top:12px; }
.filter-row--advanced {
  border-top:1px solid var(--border);
  padding-top:12px;
}
.my-warehouse-selection-actions { flex:1.6; }
.my-warehouse-action-group { display:flex; flex-wrap:wrap; gap:8px; }
.my-warehouse-action-group .btn { height:36px; padding:0 12px; }

/* ===== BẢNG DỮ LIỆU ===== */
.table-card { overflow:hidden; }
.table-wrap { overflow-x:auto; }
table { width:100%; border-collapse:collapse; font-size:14px; }
thead th {
  background:var(--bg-subtle); text-align:left;
  font-size:13px; font-weight:600; color:var(--text-primary);
  padding:14px 16px; border-bottom:1px solid var(--border); white-space:nowrap;
}
/* hàng lọc trong bảng */
.filter-tr td { padding:8px 16px; border-bottom:1px solid var(--border); background:var(--bg-surface); }
.filter-tr .select { height:32px; font-size:13px; }
tbody td { padding:14px 16px; border-bottom:1px solid var(--border); vertical-align:middle; }
tbody tr:last-child td { border-bottom:none; }
tbody tr:hover { background:var(--bg-subtle); }
td.num, th.num { text-align:right; }
td.center, th.center { text-align:center; }
.cell-strong { font-weight:600; }
.cell-empty { color:var(--text-muted); }
.cell-sub {
  color:var(--text-secondary);
  display:block;
  font-size:13px;
  line-height:1.45;
  margin-top:4px;
  overflow-wrap:anywhere;
}

/* Bảng fit 9 cột: dùng khi nghiệp vụ không cho phép cuộn ngang. */
.card.table-card.table-card--fit {
  background:var(--bg-surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-card);
  max-height:none;
  overflow:hidden;
}
.table-card--fit.table-wrap,
.table-card--fit.inventory-list-table-wrap {
  overflow-x:hidden;
  overflow-y:visible;
}
.table-card--fit .table-wrap {
  background:transparent;
  border:none;
  border-radius:0;
  box-shadow:none;
  overflow-x:visible;
  overflow-y:visible;
  scrollbar-gutter:auto;
  width:100%;
}
.table-card--fit .department-table {
  border-collapse:collapse;
  box-sizing:border-box;
  table-layout:fixed;
  width:100%;
}
.table-card--fit .department-table th,
.table-card--fit .department-table td {
  border-bottom:1px solid var(--border);
  border-left:none;
  border-right:none;
  line-height:1.45;
  min-width:0;
  overflow:hidden;
  overflow-wrap:anywhere;
  padding:12px 14px;
  vertical-align:top;
}
.table-card--fit .department-table th {
  background:var(--bg-subtle);
  color:var(--text-primary);
  font-size:13px;
  font-weight:600;
  white-space:normal;
}
.table-card--fit .department-table tbody tr {
  min-height:64px;
}
.table-card--fit .department-table tbody tr:hover {
  background:var(--bg-subtle);
}
.table-card--fit .department-table tbody tr:last-child td {
  border-bottom:none;
}
.table-card--fit .department-table .col-stdCode { width:13%; }
.table-card--fit .department-table .col-item { width:21%; }
.table-card--fit .department-table .col-unit { width:5%; }
.table-card--fit .department-table .col-inventoryCategory { width:13%; }
.table-card--fit .department-table .col-actualQty { width:7%; }
.table-card--fit .department-table .col-rack { width:8%; }
.table-card--fit .department-table .col-holder { width:18%; }
.table-card--fit .department-table .col-status { width:8%; }
.table-card--fit .department-table .col-_actions { width:7%; }
.table-card--fit .my-warehouse-table .col-_selected { width:5%; }
.table-card--fit .my-warehouse-table .col-stdCode { width:12%; }
.table-card--fit .my-warehouse-table .col-item { width:20%; }
.table-card--fit .my-warehouse-table .col-unit { width:5%; }
.table-card--fit .my-warehouse-table .col-inventoryCategory { width:12%; }
.table-card--fit .my-warehouse-table .col-actualQty { width:6%; }
.table-card--fit .my-warehouse-table .col-rack { width:8%; }
.table-card--fit .my-warehouse-table .col-holder { width:18%; }
.table-card--fit .my-warehouse-table .col-status { width:7%; }
.table-card--fit .my-warehouse-table .col-_actions { width:7%; }
.table-card--fit .department-action-cell {
  white-space:normal;
}
.my-warehouse-select-cell { vertical-align:middle; }
.my-warehouse-checkbox {
  appearance:none; -webkit-appearance:none;
  width:18px; height:18px; border:1px solid var(--border-strong);
  border-radius:var(--radius-sm); background:var(--bg-surface);
  display:inline-grid; place-content:center;
}
.my-warehouse-checkbox::before {
  content:""; width:10px; height:10px; border-radius:3px;
  transform:scale(0); transition:transform .12s;
  background:var(--primary);
}
.my-warehouse-checkbox:checked { border-color:var(--primary); background:var(--primary-soft); }
.my-warehouse-checkbox:checked::before { transform:scale(1); }
.my-warehouse-checkbox:focus {
  outline:none; border-color:var(--primary);
  box-shadow:0 0 0 3px var(--primary-soft);
}
.table-card--fit .split-btn {
  justify-content:center;
  max-width:100%;
}
.table-card--fit .badge {
  justify-content:center;
  line-height:1.25;
  max-width:100%;
  text-align:center;
  white-space:normal;
}

/* ===== NGƯỠNG TỒN KHO ===== */
.threshold-kpi {
  border:1px solid var(--border);
  color:var(--text-primary);
  text-align:left;
  width:100%;
}
.threshold-kpi:hover { border-color:var(--primary-border); }
.threshold-kpi.active {
  border-color:var(--primary-border);
  box-shadow:var(--shadow-card);
}
.threshold-kpi > span:not(.kpi-icon) { display:block; }
.threshold-page-header,
.threshold-kpi-grid,
.threshold-view-tabs,
.threshold-filter-card,
.threshold-table-card,
#thresholdMessage {
  flex:0 0 auto;
}
.threshold-view-tabs { flex-wrap:wrap; }
.filter-card .threshold-filter-actions {
  display:flex;
  flex:0 0 auto;
  flex-direction:column;
  gap:6px;
  justify-content:flex-start;
}
.threshold-filter-action-buttons { display:flex; gap:8px; }
.table-card--fit .threshold-table-wrap {
  max-height:none;
  overflow:visible;
}
.table-card--fit .threshold-summary-table {
  min-width:0;
  table-layout:fixed;
  width:100%;
}
.table-card--fit .threshold-table .col-threshold-code { width:12%; }
.table-card--fit .threshold-table .col-threshold-item { width:18%; }
.table-card--fit .threshold-table .col-threshold-unit { width:5%; }
.table-card--fit .threshold-table .col-threshold-qty { width:8%; }
.table-card--fit .threshold-table .col-threshold-rules { width:14%; }
.table-card--fit .threshold-table .col-threshold-gap { width:8%; }
.table-card--fit .threshold-table .col-threshold-holder { width:14%; }
.table-card--fit .threshold-table .col-threshold-status { width:10%; }
.table-card--fit .threshold-table .col-threshold-actions { width:11%; }
.table-card--fit .threshold-table .badge {
  box-sizing:border-box;
  max-width:none;
  min-height:26px;
  overflow:visible;
  padding:4px 12px;
  white-space:nowrap;
  width:auto;
}
.threshold-metric-stack {
  display:flex;
  flex-direction:column;
  gap:4px;
}
.threshold-metric-stack span {
  display:flex;
  justify-content:space-between;
  gap:8px;
}
.threshold-metric-stack em {
  color:var(--text-secondary);
  font-style:normal;
}
.threshold-metric-stack strong { font-weight:600; }
.threshold-source-line {
  display:block;
  margin-top:8px;
}
.threshold-actions-cell {
  white-space:normal;
}
.threshold-actions-cell .btn {
  justify-content:center;
  min-width:92px;
  padding:0 12px;
  white-space:nowrap;
  width:auto;
}
.threshold-actions-cell .btn + .btn { margin-top:6px; }
.threshold-empty-state {
  align-items:center;
  color:var(--text-secondary);
  display:flex;
  gap:8px;
  justify-content:center;
  min-height:72px;
  text-align:center;
}
.threshold-modal-card {
  max-width:720px;
  width:min(720px, calc(100vw - 48px));
}
.threshold-form .field span {
  color:var(--text-primary);
  font-size:13px;
  font-weight:500;
}
.threshold-form .input,
.threshold-form .select,
.threshold-form textarea.input {
  border:1px solid var(--border-strong);
  border-radius:var(--radius-md);
  color:var(--text-primary);
  font-family:inherit;
  min-height:var(--control-h);
  padding:0 12px;
}
.threshold-form input[readonly],
.threshold-form select:disabled {
  background:var(--bg-subtle);
  color:var(--text-secondary);
}
.threshold-form-grid {
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:14px;
}
.threshold-form-grid .wide { grid-column:1 / -1; }
.threshold-note-input {
  height:auto;
  min-height:88px;
  padding-top:10px;
  resize:vertical;
}
.threshold-modal-actions {
  display:flex;
  justify-content:flex-end;
  gap:8px;
  margin-top:16px;
}

/* ===== GIÁ VỐN TỒN CŨ ===== */
.cost-baseline-workspace,
.cost-baseline-page {
  display:flex;
  flex-direction:column;
  gap:16px;
  min-width:0;
}
.cost-baseline-subtabs,
.cost-baseline-page-header,
.cost-baseline-kpi-grid,
.cost-baseline-banner,
.cost-baseline-filter-card,
.cost-baseline-table-card {
  flex:0 0 auto;
}
.cost-baseline-limit-field { flex:0 0 112px; }
.cost-baseline-filter-actions { flex:0 0 auto; }
.cost-baseline-filter-buttons { display:flex; gap:8px; }
.cost-baseline-filter-buttons .btn { white-space:nowrap; }
.table-card--fit .cost-baseline-table-wrap {
  max-height:none;
  overflow:visible;
}
.table-card--fit .cost-baseline-table,
.table-card--fit .cost-baseline-audit-table {
  min-width:0;
  table-layout:fixed;
  width:100%;
}
.table-card--fit .cost-baseline-table .col-cost-status { width:12%; }
.table-card--fit .cost-baseline-table .col-cost-code { width:13%; }
.table-card--fit .cost-baseline-table .col-cost-item { width:18%; }
.table-card--fit .cost-baseline-table .col-cost-unit { width:7%; }
.table-card--fit .cost-baseline-table .col-cost-category { width:13%; }
.table-card--fit .cost-baseline-table .col-cost-qty { width:7%; }
.table-card--fit .cost-baseline-table .col-cost-rows { width:7%; }
.table-card--fit .cost-baseline-table .col-cost-holder { width:14%; }
.table-card--fit .cost-baseline-table .col-cost-actions { width:9%; }
.table-card--fit .cost-baseline-audit-table .col-audit-date { width:12%; }
.table-card--fit .cost-baseline-audit-table .col-audit-code { width:10%; }
.table-card--fit .cost-baseline-audit-table .col-audit-unit { width:5%; }
.table-card--fit .cost-baseline-audit-table .col-audit-category { width:12%; }
.table-card--fit .cost-baseline-audit-table .col-audit-price { width:9%; }
.table-card--fit .cost-baseline-audit-table .col-audit-qty { width:7%; }
.table-card--fit .cost-baseline-audit-table .col-audit-total { width:10%; }
.table-card--fit .cost-baseline-audit-table .col-audit-source { width:12%; }
.table-card--fit .cost-baseline-audit-table .col-audit-reason { width:14%; }
.table-card--fit .cost-baseline-audit-table .col-audit-user { width:9%; }
.cost-baseline-actions-cell .btn {
  justify-content:center;
  max-width:100%;
  white-space:nowrap;
}
.table-card--fit .cost-baseline-table .badge,
.table-card--fit .cost-baseline-audit-table .badge {
  max-width:none;
  min-height:26px;
  overflow:visible;
  padding:4px 10px;
  white-space:nowrap;
}
.table-card--fit .cost-baseline-table td:nth-child(1),
.table-card--fit .cost-baseline-table td:nth-child(4),
.table-card--fit .cost-baseline-table td:nth-child(5),
.table-card--fit .cost-baseline-table td:nth-child(9) {
  overflow:visible;
  overflow-wrap:normal;
}
.cost-baseline-status-cell,
.table-card--fit .cost-baseline-table td:first-child {
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}
.cost-baseline-empty-state { min-height:96px; }
.cost-baseline-modal-card {
  max-width:980px;
  width:min(980px, calc(100vw - 48px));
}
.cost-baseline-preview-grid {
  display:grid;
  grid-template-columns:minmax(280px, .9fr) minmax(320px, 1.1fr);
  gap:16px;
}
.cost-baseline-preview-grid > #costBaselineResult,
.cost-baseline-preview-grid > .inventory-item-modal-actions {
  grid-column:1 / -1;
}
.cost-baseline-key-section,
.cost-baseline-apply-section,
#costBaselineResult {
  min-width:0;
}
.cost-baseline-modal-table {
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  overflow:hidden;
}
.cost-baseline-modal-table th,
.cost-baseline-modal-table td {
  border-bottom:1px solid var(--border);
  padding:10px 12px;
  vertical-align:top;
}
.cost-baseline-modal-table th {
  background:var(--bg-subtle);
  color:var(--text-secondary);
  font-size:13px;
  font-weight:600;
  width:38%;
}
.cost-baseline-modal-table tr:last-child th,
.cost-baseline-modal-table tr:last-child td { border-bottom:none; }
.cost-baseline-textarea {
  height:auto;
  min-height:88px;
  padding-top:10px;
  resize:vertical;
}
.readonly-value {
  min-height:var(--control-h);
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  background:var(--bg-subtle);
  color:var(--text-primary);
  display:flex;
  align-items:center;
  padding:0 12px;
  font-weight:600;
}
.field-helper,
.form-mini-note,
.muted {
  color:var(--text-secondary);
  font-size:13px;
  line-height:1.5;
}
.compact-list {
  display:flex;
  flex-direction:column;
  gap:8px;
  list-style:none;
  margin-top:8px;
}
.compact-list li {
  color:var(--text-secondary);
  line-height:1.5;
}
.cost-baseline-message {
  border:1px solid var(--border);
  border-radius:var(--radius-md);
  padding:12px;
  font-size:13px;
  line-height:1.5;
}
.cost-baseline-message--error {
  background:var(--warning-soft);
  border-color:var(--primary-border);
  color:var(--text-primary);
}
.cost-baseline-message--success {
  background:var(--success-soft);
  border-color:var(--success);
  color:var(--text-primary);
}
.customer-modal-head .phase1j-title {
  display:flex;
  align-items:center;
  gap:8px;
}
.phase1j-help {
  position:relative;
}
.phase1j-help summary {
  width:24px;
  height:24px;
  border:1px solid var(--border-strong);
  border-radius:var(--radius-full);
  color:var(--text-secondary);
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  font-weight:700;
  list-style:none;
}
.phase1j-help summary::-webkit-details-marker { display:none; }
.phase1j-help > div {
  position:absolute;
  z-index:20;
  top:30px;
  right:0;
  width:320px;
  background:var(--bg-surface);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow-dropdown);
  padding:12px;
}
.inventory-item-modal-actions {
  display:flex;
  justify-content:flex-end;
  gap:8px;
}

/* ===== BADGES ===== */
.badge {
  display:inline-flex; align-items:center;
  padding:4px 12px; border-radius:var(--radius-full);
  border:1px solid transparent; font-family:inherit;
  font-size:12px; font-weight:600; white-space:nowrap;
}
.badge--info    { background:var(--info-soft); color:var(--info); }
.badge--neutral { background:var(--bg-subtle); color:var(--text-secondary); border:1px solid var(--border); }
.badge--warning-outline { background:var(--bg-surface); color:var(--warning); border:1px solid var(--warning); }

/* ===== SPLIT BUTTON "Xem ▾" ===== */
.split-btn { display:inline-flex; flex-wrap:nowrap; white-space:nowrap; }
.split-btn > button {
  height:32px; background:var(--bg-surface);
  border:1px solid var(--border-strong); font-size:13px; font-weight:600;
  color:var(--text-primary); display:inline-flex; align-items:center; white-space:nowrap;
}
.split-btn > button:hover { background:var(--bg-subtle); }
.split-btn .main-part { padding:0 14px; border-radius:var(--radius-md) 0 0 var(--radius-md); border-right:none; }
.split-btn .caret-part { padding:0 8px; border-radius:0 var(--radius-md) var(--radius-md) 0; }

/* ===== PAGINATION ===== */
.pagination {
  display:flex; align-items:center; justify-content:space-between;
  padding:12px 16px; border-top:1px solid var(--border);
}
.pagination-left { display:flex; align-items:center; gap:12px; font-size:13px; color:var(--text-secondary); }
.pagination-left .select { height:32px; width:72px; font-size:13px; }
.pagination-right { display:flex; align-items:center; gap:4px; }
.page-btn {
  width:32px; height:32px; border-radius:var(--radius-sm);
  background:none; border:1px solid transparent;
  color:var(--text-secondary); font-size:13px; font-weight:500;
  display:inline-flex; align-items:center; justify-content:center;
}
.page-btn:hover { background:var(--bg-subtle); color:var(--text-primary); }
.page-btn.active {
  background:var(--bg-surface); border:1.5px solid var(--primary);
  color:var(--primary); font-weight:600;
}
.page-btn:disabled { opacity:.4; cursor:default; }

@media (max-width:1279px) {
  .kpi-grid--five { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .kpi-grid--two { grid-template-columns:1fr; }
  .filter-row { flex-wrap:wrap; }
  .table-card--fit .department-table,
  .table-card--fit .department-table thead,
  .table-card--fit .department-table tbody,
  .table-card--fit .department-table tr,
  .table-card--fit .department-table th,
  .table-card--fit .department-table td {
    display:block;
    width:100%;
  }
  .table-card--fit .department-table thead { display:none; }
  .table-card--fit .department-table tr {
    border-bottom:1px solid var(--border);
    padding:12px 0;
  }
  .table-card--fit .department-table tbody tr:last-child { border-bottom:none; }
  .table-card--fit .department-table td {
    border-bottom:none;
    display:grid;
    gap:12px;
    grid-template-columns:132px minmax(0,1fr);
    padding:8px 16px;
  }
  .table-card--fit .department-table td::before {
    color:var(--text-secondary);
    content:attr(data-label);
    font-size:13px;
    font-weight:600;
  }
  .table-card--fit .department-table .department-action-cell {
    align-items:center;
  }
}
