/* ==========================================================================
   BanHang Admin — CALM OPERATOR PATCH (layer 12, cuối cùng)
   Cách dùng: thêm 1 dòng vào public/admin/index.html, SAU /styles.css
     <link rel="stylesheet" href="/admin-calm.css?v=__UI_VERSION__" />
     <script src="/admin-calm.js?v=__UI_VERSION__" defer></script>
   Không sửa app.js, không đổi API / data key / autosave / DucViet / Shopbot.
   Chỉ override CSS + progressive enhancement DOM (bottom nav, title mirror).
   ========================================================================== */

/* ── 1. TOKENS: neutral/slate nền · accent có chủ đích ─────────────────── */
:root {
  --bg: #0b0f14;
  --bg-deep: #080b0f;
  --bg-subtle: #0f141a;
  --bg-elevated: #121821;
  --surface: #121821;
  --surface-2: #171e28;
  --surface-3: #1d2530;
  --surface-hover: #1a222c;
  --surface-active: #202935;

  --border: #232c38;
  --border-dim: #1b232d;
  --border-strong: #2e3947;
  --border-subtle: #1b232d;

  --text-primary: #e8edf4;
  --text: #e8edf4;
  --text-secondary: #9aa7b7;
  --text-tertiary: #6b7a8c;
  --text-muted: #6b7a8c;

  /* 1 accent duy nhất cho hành động chính */
  --accent: #d97757;
  --accent-hover: #c4633f;
  --accent-active: #ad5533;
  --accent-2: var(--accent);
  --accent-soft: rgba(217, 119, 87, 0.14);
  --accent-muted: rgba(217, 119, 87, 0.08);
  --accent-gradient: var(--accent);
  --accent-gradient-2: var(--accent);
  --accent-gradient-3: var(--accent);

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.13);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.13);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.13);
  --info: #7aa2c4;
  --info-soft: rgba(122, 162, 196, 0.12);

  /* Tím / vibrant: vô hiệu hoá, map về neutral */
  --vibrant-purple: var(--text-tertiary);
  --vibrant-pink: var(--accent);
  --vibrant-yellow: var(--warning);
  --vibrant-blue: var(--info);
  --vibrant-green: var(--success);
  --vibrant-orange: var(--accent);
  --accent-vibrant: var(--accent);
  --accent-vibrant-soft: var(--accent-soft);

  /* Radius: 3 bậc */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --radius-xl: 12px;

  /* Shadow: gần như phẳng, border làm việc chính */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.36);
  --shadow: var(--shadow-sm);
  --shadow-glow: none;
  --tf-glow: transparent;
  --tf-glow-violet: transparent;
  --neo-glow: var(--shadow-sm);

  --header-h: 56px;
  --row-h: 44px;
  --tap: 44px;
}

[data-theme="light"] {
  --bg: #f7f8fa;
  --bg-deep: #eef1f5;
  --bg-subtle: #f1f3f7;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #e9edf2;
  --surface-hover: #f1f4f8;
  --surface-active: #e6ebf1;

  --border: #dfe4ea;
  --border-dim: #e9edf2;
  --border-strong: #cbd3dc;
  --border-subtle: #eceff3;

  --text-primary: #0f172a;
  --text: #0f172a;
  --text-secondary: #55637a;
  --text-tertiary: #7a8798;
  --text-muted: #7a8798;

  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.1);
  --warning: #b45309;
  --warning-soft: rgba(180, 83, 9, 0.1);
  --danger: #b91c1c;
  --danger-soft: rgba(185, 28, 28, 0.09);

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.07);
  --shadow-md: 0 2px 6px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 8px 24px rgba(15, 23, 42, 0.12);
}

/* ── 2. GIẢM NOISE: gradient / glow / blur / lift ──────────────────────── */
.sm-kpi::after,
.sm-kpi::before,
.neo-priority-card::before,
.stat-card-glow,
.tf-spotlight-glow,
.sm-dash-hero::before,
.sm-dash-hero::after {
  display: none !important;
  content: none !important;
}

.sm-kpi,
.sm-dash .sm-kpi,
.sm-dash .sm-kpi.is-accent,
.sm-dash .sm-kpi.is-good,
.sm-dash .sm-kpi.is-warn,
.neo-priority-card,
.order-detail-hero,
.sm-ops-strip,
.sm-filter-rail,
.panel,
.card,
.modal,
.drawer,
.product-card {
  background: var(--surface) !important;
  background-image: none !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  transform: none !important;
}

/* Card lồng card: con nằm trong panel → bỏ khung, chỉ dùng divider */
.panel .sm-kpi,
.sm-ops-strip .sm-kpi,
.panel .card,
.card .card {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  padding: 12px 14px !important;
}
.sm-ops-strip .sm-kpi-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  gap: 0 !important;
  background: var(--bg-subtle);
}
.sm-ops-strip .sm-kpi + .sm-kpi {
  border-left: 1px solid var(--border) !important;
}
.orders-table tbody tr:hover,
.sm-lifetime .sm-life-row:hover {
  background: var(--surface-hover) !important;
  background-image: none !important;
  transform: none !important;
  box-shadow: inset 2px 0 0 var(--accent) !important;
}
.orders-table .user-avatar {
  background: var(--surface-3) !important;
  background-image: none !important;
  border: 1px solid var(--border) !important;
  color: var(--text-secondary);
}
.sm-health-ring,
.sm-kpi-value,
.stat-value {
  text-shadow: none !important;
  filter: none !important;
}

/* Bỏ stagger/float khi vào trang — operator không cần chờ animation */
.stagger-list > *,
.animate-stagger > * {
  animation: none !important;
  opacity: 1 !important;
}

/* ── 3. TYPOGRAPHY & số ────────────────────────────────────────────────── */
body {
  font-size: 13.5px;
  letter-spacing: 0;
}
.sm-page-title,
.page-title {
  font-family: var(--font-sans);
  letter-spacing: -0.015em;
}
.sm-kpi-value,
.stat-value,
.td-num,
.td-mono,
.orders-table .td-num,
.sm-kpi-meta b,
.sm-method-pill b {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}
.sm-page-kicker,
.filter-bar-label,
.nav-group-label {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

/* ── 4. BUTTON: 1 CTA chính · rõ trạng thái ────────────────────────────── */
.btn {
  border-radius: var(--radius-sm) !important;
  min-height: 34px;
  font-weight: 550;
  box-shadow: none !important;
  background-image: none !important;
  transition: background 120ms var(--ease), border-color 120ms var(--ease);
}
.btn-sm { min-height: 30px; }
.btn-primary {
  background: var(--accent) !important;
  border: 1px solid var(--accent) !important;
  color: #fff !important;
}
.btn-primary:hover { background: var(--accent-hover) !important; border-color: var(--accent-hover) !important; }
.btn-primary:active { background: var(--accent-active) !important; }
.btn-ghost,
.btn-secondary {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
}
.btn-ghost:hover { background: var(--surface-hover) !important; border-color: var(--border-strong) !important; }
.btn:disabled,
.btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible,
.icon-btn:focus-visible,
.nav-item:focus-visible,
.fd-input:focus-visible,
.action-chip:focus-visible,
.alert-item:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: none !important;
}
/* Nhiều nút primary cạnh nhau → chỉ nút cuối là primary thật */
.sm-page-actions .btn-primary ~ .btn-primary { background: var(--surface-2) !important; border-color: var(--border) !important; color: var(--text-primary) !important; }

/* ── 5. BADGE / STATUS: semantic, phẳng ────────────────────────────────── */
.badge,
.fd-badge,
.status-badge,
.auto-tag,
.action-chip {
  border-radius: 999px !important;
  background-image: none !important;
  box-shadow: none !important;
  font-weight: 550;
  letter-spacing: 0;
}
.badge-success, .status-done, .badge.success { background: var(--success-soft) !important; color: var(--success) !important; border: 1px solid transparent !important; }
.badge-warning, .status-pending, .badge.warning { background: var(--warning-soft) !important; color: var(--warning) !important; border: 1px solid transparent !important; }
.badge-danger, .status-cancelled, .badge.danger { background: var(--danger-soft) !important; color: var(--danger) !important; border: 1px solid transparent !important; }
.action-chip {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border) !important;
  background: var(--surface-2) !important;
  color: var(--text-primary) !important;
}
.action-chip.success { background: var(--accent) !important; border-color: var(--accent) !important; color: #fff !important; }
.action-chip.danger { background: transparent !important; border-color: var(--border) !important; color: var(--danger) !important; }
.action-chip.danger:hover { background: var(--danger-soft) !important; }

/* ── 6. SIDEBAR: hierarchy rõ, active state 1 kiểu ─────────────────────── */
.sidebar {
  background: var(--bg-deep) !important;
  border-right: 1px solid var(--border) !important;
  box-shadow: none !important;
}
.nav-group + .nav-group { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-dim); }
.nav-item {
  min-height: 36px;
  border-radius: var(--radius-sm) !important;
  background: transparent !important;
  background-image: none !important;
  box-shadow: none !important;
  color: var(--text-secondary) !important;
  font-weight: 500;
  position: relative;
}
.nav-item:hover { background: var(--surface-2) !important; color: var(--text-primary) !important; }
.nav-item.active {
  background: var(--surface-2) !important;
  color: var(--text-primary) !important;
  font-weight: 600;
}
.nav-item.active::before {
  content: "";
  position: absolute;
  left: -6px; top: 8px; bottom: 8px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.nav-item .nav-icon svg { opacity: 0.85; }
.nav-badge {
  background: var(--surface-3) !important;
  color: var(--text-secondary) !important;
  border: 0 !important;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-badge,
.nav-badge[data-count]:not([data-count="0"]) { background: var(--warning-soft) !important; color: var(--warning) !important; }
.sidebar-footer { border-top: 1px solid var(--border-dim); }

/* ── 7. HEADER: không vỡ ở 1280 ───────────────────────────────────────── */
.workspace-header {
  height: var(--header-h) !important;
  background: var(--bg) !important;
  border-bottom: 1px solid var(--border) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  display: flex !important;
  align-items: center;
  gap: 12px !important;
  overflow: visible !important;
}
.header-left { flex: 1 1 auto; min-width: 0; max-width: none; }
.header-titles { min-width: 0; }
.page-title { font-size: 15px !important; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-crumb { font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-right { flex: 0 1 auto; min-width: 0; gap: 8px !important; overflow: visible !important; }
.header-search { flex: 0 1 240px !important; width: clamp(160px, 20vw, 260px) !important; max-width: 260px !important; }
.header-divider { display: none; }
.icon-btn {
  width: 34px; height: 34px;
  border-radius: var(--radius-sm) !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--text-secondary) !important;
  box-shadow: none !important;
}
.icon-btn:hover { background: var(--surface-2) !important; border-color: var(--border) !important; color: var(--text-primary) !important; }
/* < 1400: bỏ crumb; < 1280: bỏ autosave text + version; < 1120: bỏ clock */
@media (max-width: 1400px) { .page-crumb { display: none; } }
@media (max-width: 1280px) {
  .autosave-text { display: none; }
  .autosave { padding: 0 6px !important; }
  .version-badge { display: none !important; }
  .header-search { flex: 0 1 200px !important; }
}
@media (max-width: 1120px) {
  .bh-clock-btn, #topbar-clock, .refresh-pill { display: none !important; }
  .header-search { flex: 0 1 170px !important; }
}

/* ── 8. TABLE: density + sticky header + numeric alignment ─────────────── */
.table-wrap {
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  background: var(--surface) !important;
  box-shadow: none !important;
  overflow: auto;
}
.orders-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.orders-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 36px;
  padding: 0 12px !important;
  background: var(--bg-subtle) !important;
  color: var(--text-tertiary) !important;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border) !important;
  white-space: nowrap;
}
.orders-table td {
  height: var(--row-h);
  padding: 6px 12px !important;
  border-bottom: 1px solid var(--border-dim) !important;
  vertical-align: middle;
}
.orders-table .th-num, .orders-table .td-num { text-align: right; }
.orders-table .td-actions { text-align: right; white-space: nowrap; }
.orders-table .row-pending td { background: transparent !important; }
.orders-table .row-pending td:first-child { box-shadow: inset 2px 0 0 var(--warning) !important; }
.row-clickable { cursor: pointer; }
.empty-state { padding: 40px 20px !important; text-align: center; background: transparent !important; border: 0 !important; }

/* ── 9. FILTER RAIL: 1 hàng, không sticky-glass ────────────────────────── */
.sm-filter-rail {
  position: static !important;
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
  padding: 10px 12px !important;
}
.fd-tabs--line { gap: 2px; }
.fd-tab {
  min-height: 32px;
  border-radius: var(--radius-sm) !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--text-secondary) !important;
  box-shadow: none !important;
}
.fd-tab:hover { background: var(--surface-2) !important; color: var(--text-primary) !important; }
.fd-tab.active,
.fd-tab[aria-selected="true"] {
  background: var(--surface-2) !important;
  border-color: var(--border-strong) !important;
  color: var(--text-primary) !important;
  font-weight: 600;
}
.fd-tab .fd-badge { background: var(--surface-3) !important; color: var(--text-secondary) !important; }

/* ── 10. MODAL / FORM ─────────────────────────────────────────────────── */
.modal, .drawer, .cmd-panel, .shortcuts-panel {
  border-radius: var(--radius-lg) !important;
  box-shadow: var(--shadow-lg) !important;
}
.fd-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.fd-input, .fd-select, .fd-textarea, input, select, textarea {
  min-height: 38px;
  border-radius: var(--radius-sm) !important;
  background: var(--bg-subtle) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  color: var(--text-primary);
}
.fd-input[aria-invalid="true"], .fd-field.is-error .fd-input { border-color: var(--danger) !important; }
.fd-description, .fd-error { font-size: 11.5px; }
.fd-error { color: var(--danger); }
.modal-footer, .drawer-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px !important;
  background: var(--surface) !important;
  border-top: 1px solid var(--border) !important;
}

/* ── 11. MOBILE ≤760: không tràn ngang, tap 44px, bottom nav ───────────── */
@media (max-width: 760px) {
  html, body { overflow-x: hidden; max-width: 100vw; }
  .workspace, .workspace-main, .page, .sm-page { max-width: 100vw !important; overflow-x: clip; }
  .workspace-main {
    padding: 12px 12px calc(72px + env(safe-area-inset-bottom)) !important;
  }
  .icon-btn, .btn, .action-chip, .fd-tab, .nav-item { min-height: 44px !important; }
  .icon-btn { width: 44px !important; height: 44px !important; }
  .btn-sm { padding-inline: 12px !important; }

  /* Thứ tự nội dung: hàng đợi trước, KPI sau */
  .sm-page { display: flex; flex-direction: column; }
  .neo-priority-deck { order: -1; }
  .sm-ops-strip { order: 0; }
  .sm-ops-strip .sm-kpi-row { grid-template-columns: 1fr 1fr !important; }
  .sm-ops-strip .sm-kpi:nth-child(odd) { border-left: 0 !important; }
  .sm-ops-strip .sm-kpi { border-top: 1px solid var(--border) !important; }

  /* Filter rail cuộn ngang trong khung, không đẩy page */
  .sm-filter-rail { overflow: hidden; }
  .fd-tabs { display: flex; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .fd-tabs::-webkit-scrollbar { display: none; }

  /* Orders: table → card, 1 nguồn quy tắc duy nhất */
  #page-orders .table-wrap { overflow: visible !important; border: 0 !important; background: transparent !important; }
  .orders-table, .orders-table tbody { display: block !important; width: 100% !important; }
  .orders-table thead { display: none !important; }
  .orders-table tbody { padding: 0 !important; }
  .orders-table tbody tr {
    display: grid !important;
    grid-template-columns: 1fr auto;
    gap: 4px 10px;
    padding: 12px !important;
    margin: 0 0 8px !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    background: var(--surface) !important;
  }
  .orders-table td, .orders-table .row-pending td {
    display: block !important;
    height: auto !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    white-space: normal !important;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .orders-table .order-code-cell { grid-column: 1; }
  .orders-table .order-status-cell { grid-column: 2; text-align: right; }
  .orders-table .order-user-cell { grid-column: 1 / -1; }
  .orders-table .order-pay-cell { grid-column: 1; }
  .orders-table .order-time-cell { grid-column: 2; text-align: right; font-size: 11.5px; }
  .orders-table .order-total-cell,
  .orders-table .order-cost-cell,
  .orders-table .order-profit-cell {
    grid-column: auto;
    display: flex !important;
    justify-content: space-between;
    gap: 8px;
    padding-top: 6px !important;
    border-top: 1px solid var(--border-dim) !important;
    font-variant-numeric: tabular-nums;
  }
  .orders-table .order-total-cell::before { content: "Bán"; color: var(--text-tertiary); }
  .orders-table .order-cost-cell::before { content: "Vốn"; color: var(--text-tertiary); }
  .orders-table .order-profit-cell::before { content: "Lời"; color: var(--text-tertiary); }
  .orders-table .order-total-cell, .orders-table .order-cost-cell, .orders-table .order-profit-cell { grid-column: 1 / -1; }
  .orders-table .order-action-cell { grid-column: 1 / -1; padding-top: 8px !important; }
  .orders-table .row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .orders-table .row-actions .action-chip { width: 100%; justify-content: center; }
  .orders-table .row-pending { box-shadow: inset 3px 0 0 var(--warning) !important; }
  .orders-table .cell-stack .td-primary,
  .orders-table .cell-stack .td-muted { max-width: 100% !important; }

  /* Modal full-sheet + footer sticky, nút to */
  .modal, .drawer {
    position: fixed !important;
    inset: auto 0 0 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92dvh !important;
    border-radius: 14px 14px 0 0 !important;
  }
  .modal-body, .drawer-body { max-height: calc(92dvh - 132px); overflow-y: auto; }
  .modal-footer, .drawer-footer {
    flex-direction: column-reverse;
    padding-bottom: calc(12px + env(safe-area-inset-bottom)) !important;
  }
  .modal-footer .btn, .drawer-footer .btn { width: 100%; }
}

/* Bottom nav (dựng bởi admin-calm.js từ chính .nav-item[data-page]) */
.bh-bottom-nav { display: none; }
@media (max-width: 760px) {
  .bh-bottom-nav {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 55;
    background: var(--bg-elevated);
    border-top: 1px solid var(--border);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bh-bottom-nav button {
    appearance: none;
    display: grid;
    place-items: center;
    gap: 2px;
    min-height: 56px;
    padding: 6px 4px;
    background: transparent;
    border: 0;
    color: var(--text-tertiary);
    font: inherit;
    font-size: 10.5px;
    cursor: pointer;
  }
  .bh-bottom-nav button[aria-current="page"] { color: var(--accent); }
  .bh-bottom-nav svg { width: 20px; height: 20px; }
  .bh-bottom-nav .bh-bn-badge {
    position: absolute;
    transform: translate(14px, -14px);
    min-width: 16px; height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: var(--warning);
    color: #1a1206;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
  }
  .bh-bottom-nav button { position: relative; }
}

/* ── 12b. HERO — bỏ gradient lớn + vòng glow (từ screenshot 21:30) ────── */
.neo-hero,
.neo-hero.is-urgent {
  background: var(--surface) !important;
  background-image: none !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg) !important;
  box-shadow: none !important;
  padding: 20px 24px !important;
  gap: 20px !important;
}
.neo-hero::before,
.neo-hero::after,
.neo-orbit::before,
.neo-orbit::after { display: none !important; content: none !important; }
.neo-hero-title { font-size: 22px !important; font-weight: 650 !important; letter-spacing: -.015em; }
.neo-hero-title strong { color: var(--text-primary) !important; background: none !important; -webkit-text-fill-color: currentColor !important; }
.neo-hero-sub { font-size: 13px !important; color: var(--text-secondary) !important; max-width: 62ch; }
.neo-hero-eyebrow { font-size: 11px !important; letter-spacing: .06em; text-transform: uppercase; color: var(--text-tertiary) !important; }
/* Vòng biên lợi nhuận: nhỏ, phẳng, không glow */
.neo-orbit { background: none !important; box-shadow: none !important; }
.neo-orbit-core {
  width: 132px !important; height: 132px !important;
  background: var(--surface-2) !important;
  box-shadow: none !important;
  filter: none !important;
  border: 1px solid var(--border) !important;
}
.neo-orbit-core strong { font-size: 24px !important; }
.neo-orbit-node {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  color: var(--text-secondary) !important;
}

/* ── 12c. KPI / stat-card: bỏ nền màu trang trí, chỉ tô SỐ ───────────── */
.stat-card,
.stat-card.featured,
.stat-success, .stat-danger, .stat-warning, .stat-info, .stat-accent,
.sm-kpi.is-accent, .sm-kpi.is-good, .sm-kpi.is-warn {
  background: var(--surface) !important;
  background-image: none !important;
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
}
.stat-card .label,
.sm-kpi-label { color: var(--text-tertiary) !important; font-size: 11px; letter-spacing: .05em; text-transform: uppercase; }
.stat-card .value,
.sm-kpi-value { font-size: 22px !important; font-weight: 650 !important; font-variant-numeric: tabular-nums; }
.stat-success .value { color: var(--success) !important; }
.stat-danger .value { color: var(--danger) !important; }
.stat-warning .value { color: var(--warning) !important; }
.stat-icon, .sm-kpi-icon {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-tertiary) !important;
  box-shadow: none !important;
}

/* ── 12d. Snapshot vận hành: 6 card lồng → grid 2 cột phẳng ──────────── */
.sm-snapshot .sm-snap-item,
.sm-snapshot .sm-kpi,
.sm-snapshot > div > div {
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}
.sm-snapshot .sm-snap-grid,
.sm-snapshot > div {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  gap: 1px !important;
  background: var(--border-dim);
}
.sm-snapshot .sm-snap-item { padding: 10px 14px !important; background: var(--surface) !important; }

/* ── 12e. Bảng: cell thanh toán 1 dòng, hàng thấp hơn ────────────────── */
.orders-table .order-pay-cell .td-muted {
  display: inline-block;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
@media (min-width: 761px) {
  .orders-table .order-pay-cell { display: flex; align-items: center; gap: 6px; flex-wrap: nowrap; }
  .orders-table .user-avatar { width: 26px !important; height: 26px !important; font-size: 11px; }
  .orders-table .cell-stack .td-muted { font-size: 11.5px; }
}

/* ── 12f. Sản phẩm: thẻ phẳng, số liệu thẳng cột ─────────────────────── */
.product-card { padding: 14px !important; }
.product-card:hover { border-color: var(--border-strong) !important; transform: none !important; box-shadow: none !important; }
.product-card .stock-bar,
.product-card .progress,
.product-card [class*="bar-fill"] { background: var(--surface-3) !important; background-image: none !important; height: 4px !important; border-radius: 999px; }
.product-card input,
.product-card select { min-height: 34px; font-variant-numeric: tabular-nums; }
.product-card .btn { min-height: 32px; }

/* ── 12g. Trang trống / lỗi render: nhìn thấy được thay vì đen ───────── */
.page:empty::after {
  content: "Không tải được nội dung trang. Bấm Làm mới ở thanh bên.";
  display: block;
  margin: 40px auto;
  max-width: 420px;
  padding: 20px;
  border: 1px solid var(--border);
  border-left: 2px solid var(--warning);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-secondary);
  text-align: center;
}

/* ── 12h. Hero gọn (do admin-calm.js render) ────────────────────── */
.bh-hero {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px !important;
  min-height: 0 !important;
}
.bh-hero .neo-hero-title { font-size: 18px !important; margin: 2px 0 0 !important; }
.bh-hero-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }

/* ── 12i. Bulk bar + ô checkbox bảng đơn ────────────────────────── */
.bh-bulk-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent-muted);
}
.bh-bulk-count { font-size: 12.5px; font-weight: 600; margin-right: 4px; }
.bh-bulk-bar .bh-bulk-danger { color: var(--danger) !important; }
.bh-bulk-bar [data-act="clear"] { margin-left: auto; }
.bh-bulk-cell { width: 34px; text-align: center; }
.bh-bulk-cell input {
  width: 16px; height: 16px;
  min-height: 0 !important;
  accent-color: var(--accent);
  cursor: pointer;
}
@media (max-width: 760px) {
  .bh-bulk-bar { flex-wrap: wrap; }
  .bh-bulk-bar .btn { flex: 1 1 auto; }
  /* Phải là td./th. — rule card-mode `.orders-table .row-pending td` có
     specificity (0,2,1), cao hơn `.orders-table .bh-bulk-cell` (0,2,0),
     nên đúng các hàng pending sẽ lộ checkbox nếu viết thiếu tên thẻ. */
  .orders-table th.bh-bulk-cell,
  .orders-table td.bh-bulk-cell { display: none !important; }
  .bh-bulk-bar { display: none; }
}

/* ── 12j. Một ô tìm kiếm mọi trình ───────────────────────────── */
body.bh-hide-header-search .header-search { display: none !important; }

/* ── 12k. Tiêu đề trang không lặp với header ───────────────────── */
.sm-page-head .sm-page-kicker,
.sm-page-head > .sm-page-head-copy > .sm-page-title { display: none !important; }
.sm-page-head {
  align-items: center !important;
  gap: 12px !important;
  padding-bottom: 4px !important;
  border-bottom: 0 !important;
}
.sm-page-sub { margin: 0 !important; font-size: 12.5px; color: var(--text-secondary) !important; }

/* ── 13. LOADING / ERROR states ───────────────────────────────────────── */
.skeleton-block {
  background: var(--surface-2) !important;
  background-image: linear-gradient(90deg, transparent, var(--surface-3), transparent) !important;
  background-size: 200% 100%;
  border-radius: var(--radius-md) !important;
}
.bh-error-state {
  display: grid;
  gap: 10px;
  justify-items: start;
  padding: 20px;
  border: 1px solid var(--danger-soft);
  border-left: 2px solid var(--danger);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.bh-error-state strong { color: var(--danger); font-size: 13.5px; }

/* Alias cho statCard đã sửa (patch/app.js-patches.md mục 3) */
.bh-value-success { color: var(--success) !important; }
.bh-value-danger { color: var(--danger) !important; }
.bh-value-warning { color: var(--warning) !important; }

/* ── 14. 1 CTA CHÍNH/MÀN — bổ sung (mục 4 nghiệm thu) ──────────────────
   Mục 4 gốc chỉ hạ cấp primary anh-em trong .sm-page-actions, nên nút lặp
   theo hàng bảng / thẻ sản phẩm / nút lưu trong panel vẫn tô accent:
   Sản phẩm 9 nút, Nhà cung cấp 16 nút, Thanh toán 2 nút.
   Chỉ CTA ở đầu trang (+ bulk bar, footer modal) giữ màu accent. */
.page tbody .btn-primary,
.page .pc-footer .btn-primary,
.page .product-card .btn-primary,
.page .row-actions .btn-primary,
.page .panel-body .content-actions .btn-primary,
.page .panel-body .field .btn-primary {
  background: var(--surface-2) !important;
  border: 1px solid var(--border) !important;
  color: var(--text-primary) !important;
}
.page tbody .btn-primary:hover,
.page .pc-footer .btn-primary:hover,
.page .product-card .btn-primary:hover,
.page .row-actions .btn-primary:hover,
.page .panel-body .content-actions .btn-primary:hover,
.page .panel-body .field .btn-primary:hover {
  background: var(--surface-hover) !important;
  border-color: var(--border-strong) !important;
}

/* ── 15. Bulk bar phải ẩn khi chưa chọn đơn (mục 6 nghiệm thu) ─────────
   Mục 12i đặt .bh-bulk-bar{display:flex} — luật author này thắng UA
   [hidden]{display:none}, nên bar.hidden=true trong admin-calm.js vô tác
   dụng và thanh bulk hiện thường trực với count rỗng. */
.bh-bulk-bar[hidden] { display: none !important; }

/* ══════════════════════════════════════════════════════════════════════
   15–18. AUDIT ROUND 2 — vá theo kết quả đo thực tế 1440 / 768 / 390
   ══════════════════════════════════════════════════════════════════════ */

/* ── 15. TABLET 761–900: sidebar thành rail, không có bottom nav ────────
   Ở 768 sidebar ăn 248px trong khi bảng cần 959px. Thu về rail 64px trả
   lại 184px cho nội dung. Không bật bottom nav ở dải này — rail đã là
   điều hướng, hai thanh nav cùng lúc là thừa. */
@media (min-width: 761px) and (max-width: 1024px) {
  /* Sidebar 248px → rail 64px, trả 184px lại cho bảng */
  .sidebar { width: 64px !important; overflow: hidden; }
  .sidebar .nav-text,
  .sidebar .nav-group-label,
  .sidebar .brand-text,
  .sidebar .nav-badge,
  .sidebar-footer .nav-item > span:not(.nav-icon) { display: none !important; }
  .sidebar .nav-item,
  .sidebar-footer .nav-item {
    display: grid !important;
    place-items: center !important;
    width: 44px !important;
    min-height: 44px !important;
    margin-inline: auto !important;
    padding: 0 !important;
    position: relative;
  }
  /* Nhãn đã ẩn → badge số thành chấm cảnh báo */
  .sidebar .nav-item:has(.nav-badge:not(.badge-zero))::after {
    content: "";
    position: absolute;
    top: 6px; right: 6px;
    width: 7px; height: 7px;
    border-radius: 999px;
    background: var(--warning);
  }

  /* Giữ dạng bảng (tablet quét theo hàng tốt hơn card), nhưng bỏ 3 cột
     kế toán ít dùng khi đang vận hành. Đo được: 959px tổng, bỏ Vốn(82) +
     Lời(77) + Thời gian(97) và siết padding → vừa khung 664px. */
  .orders-table th:nth-child(6), .orders-table td.order-cost-cell,
  .orders-table th:nth-child(7), .orders-table td.order-profit-cell,
  .orders-table th:nth-child(9), .orders-table td.order-time-cell {
    display: none !important;
  }
  .orders-table th, .orders-table td { padding-inline: 8px !important; }
  /* Kẹp ở <td> thôi thì .product-cell bên trong vẫn nở 145px và đè sang
     cột Thanh toán — phải cắt ở chính phần tử chữ. */
  .orders-table .order-user-cell { max-width: 118px; overflow: hidden; }
  /* 100% chứ không phải 118px: td rộng 118px đã gồm 2×8px padding, đặt cứng
     118px cho con là tràn đúng 8px sang cột Thanh toán. */
  .orders-table .order-user-cell .product-cell { max-width: 100%; min-width: 0; }
  .orders-table .order-user-cell .cell-stack { min-width: 0; overflow: hidden; }
  .orders-table .order-user-cell .td-primary,
  .orders-table .order-user-cell .td-muted {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  /* Bulk là thao tác desktop (cần chuột + nhiều hàng cùng lúc); ở tablet
     47px đó đáng giá hơn khi dành cho một cột dữ liệu. */
  .orders-table th.bh-bulk-cell,
  .orders-table td.bh-bulk-cell { display: none !important; }
  .bh-bulk-bar { display: none !important; }
}

/* ── 16. Rail thu gọn tay: vùng bấm 20px → 44px ────────────────────────
   .sidebar--collapsed chỉ đặt width:64px, không có rule nào canh lại
   nav-item nên nút co còn 20px và dồn trái. */
.sidebar--collapsed .nav-text,
.sidebar--collapsed .nav-group-label,
.sidebar--collapsed .brand-text,
.sidebar--collapsed .sidebar-footer .nav-item > span:not(.nav-icon) { display: none !important; }
.sidebar--collapsed { overflow: hidden; }
.sidebar--collapsed .nav-item,
.sidebar--collapsed .sidebar-footer .nav-item {
  display: grid !important;
  place-items: center !important;
  width: 44px !important;
  min-height: 44px !important;
  margin-inline: auto !important;
  padding: 0 !important;
  position: relative;
}

/* ── 17. Cột "Thao tác": không cho nút xuống dòng ──────────────────────
   Đo được: cột 124px, 2 nút (Giao TK + Huỷ) không vừa → wrap → hàng
   pending cao 82px trong khi hàng thường 50px. Đúng những hàng cần xử lý
   lại phá nhịp bảng và đẩy các hàng khác xuống. */
@media (min-width: 901px) {
  .orders-table th:last-child,
  .orders-table td.td-actions,
  .orders-table td.order-action-cell {
    width: 1%;
    white-space: nowrap !important;
  }
  .orders-table td.td-actions,
  .orders-table td.order-action-cell {
    display: table-cell !important;
    text-align: right;
  }
  .orders-table td.td-actions .action-chip,
  .orders-table td.order-action-cell .action-chip {
    display: inline-flex !important;
    vertical-align: middle;
    margin: 0 0 0 4px !important;
    min-height: 28px !important;
    padding-inline: 10px !important;
  }
  /* Hàng pending phải cùng chiều cao hàng thường để bảng giữ nhịp quét */
  .orders-table tbody tr { height: 50px; }
}

/* ── 18. Màu ngữ nghĩa cho action-chip ─────────────────────────────────
   Đang sai: .success render cam accent (trùng CTA chính), .danger render
   xám. Quy ước yêu cầu: xanh lá = thành công, đỏ = huỷ/lỗi. Dùng kiểu
   outline để không tranh vai CTA chính của trang. */
.action-chip.success {
  background: var(--surface-2) !important;
  border: 1px solid color-mix(in srgb, var(--success) 45%, var(--border)) !important;
  color: var(--success) !important;
  font-weight: 600;
}
.action-chip.success:hover {
  background: color-mix(in srgb, var(--success) 12%, var(--surface-2)) !important;
  border-color: var(--success) !important;
}
.action-chip.danger {
  background: var(--surface-2) !important;
  border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border)) !important;
  color: var(--danger) !important;
}
.action-chip.danger:hover {
  background: color-mix(in srgb, var(--danger) 12%, var(--surface-2)) !important;
  border-color: var(--danger) !important;
}

/* ── 19. Đơn không thao tác được: nói rõ vì sao ────────────────────────
   Chèn bởi admin-calm.js (mục 10). */
.bh-no-action {
  display: inline-block;
  font-size: 11.5px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

/* ── 20. Bảng tìm không ra kết quả ─────────────────────────────────────
   filterTable() chỉ ẩn hàng + đổi số đếm, không báo gì → bảng trống trơn. */
.bh-no-result-row td {
  padding: 28px 16px !important;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 13px;
}
.bh-no-result-row b { color: var(--text-primary); }

/* ══════════════════════════════════════════════════════════════════════
   21. V2 POLISH — nâng cấp thị giác & trải nghiệm (2026-07-27)
   Nguyên tắc: giữ bản sắc terracotta, phẳng, border làm việc chính;
   mọi thay đổi đều nhắm một khó chịu cụ thể đã đo được.
   ══════════════════════════════════════════════════════════════════════ */

/* ── 21a. Token tinh chỉnh ─────────────────────────────────────────────
   Light: nền ấm hơn 1 nấc, border dịu, chữ phụ đậm hơn (tương phản AA).
   Dark giữ nguyên slate đã chốt. */
[data-theme="light"] {
  --bg: #f5f6f8;
  --bg-subtle: #eef0f3;
  --border: #e2e6eb;
  --border-strong: #c9d1da;
  --text-secondary: #4b5565;
  --surface-hover: #f0f3f7;
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.07);
}
::selection { background: var(--accent-soft); color: var(--text-primary); }

/* ── 21b. Scrollbar + chống giật layout ──────────────────────────────── */
.workspace-main { scrollbar-gutter: stable; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
*::-webkit-scrollbar-track { background: transparent; }

/* ── 21c. Hero: hết gãy dòng xấu ─────────────────────────────────────
   Đo được: .neo-hero-copy bị flex 0 1 auto bóp còn 269px ở 1440
   → "Có 3 việc đang chờ xử\nlý". */
.neo-hero-copy { flex: 1 1 auto !important; min-width: 0; }
/* styles.css đặt max-width:16ch (~194px) → tiêu đề ngắn cũng gãy 2 dòng */
.neo-hero-title, .bh-hero .neo-hero-title { max-width: none !important; }
.neo-hero-title { text-wrap: balance; letter-spacing: -0.015em; }
.neo-hero-eyebrow { letter-spacing: 0.07em; }
.bh-hero { padding: 18px 22px !important; }

/* ── 21d. Vòng % hoàn tất: 52px không đủ chỗ cho 2 dòng chữ ──────────── */
.sm-health-ring {
  width: 62px !important;
  height: 62px !important;
  flex: 0 0 62px;
  display: grid !important;
  place-content: center;
  text-align: center;
  border-radius: 999px;
  background:
    radial-gradient(closest-side, var(--surface) 78%, transparent 79% 100%),
    conic-gradient(var(--success) calc(var(--sm-health, 0) * 1%), var(--surface-3) 0) !important;
  border: 0 !important;
  box-shadow: none !important;
}
.sm-health-ring strong {
  font-size: 14px;
  font-weight: 750;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  text-shadow: none;
}
.sm-health-ring span {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
  line-height: 1.2;
}

/* ── 21e. Nút footer hàng đợi: 556px xám đặc quá nặng ────────────────── */
.alert-foot { display: flex; gap: 8px; }
.alert-foot .btn {
  flex: 1;
  justify-content: center;
  background: transparent !important;
  border: 1px dashed var(--border-strong) !important;
  color: var(--text-secondary) !important;
  min-height: 34px;
  font-weight: 550;
}
.alert-foot .btn:hover {
  border-style: solid;
  border-color: var(--accent) !important;
  color: var(--accent) !important;
  background: var(--accent-muted) !important;
}
.alert-foot .btn::after { content: " →"; opacity: 0.6; }

/* ── 21f. KPI card: chiều sâu khi hover, icon có sắc ─────────────────── */
.stat-card { transition: border-color 140ms var(--ease), background 140ms var(--ease); }
.stat-card:hover { border-color: var(--border-strong) !important; }
.stat-card .stat-icon {
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--accent-muted);
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
}
.stat-card .stat-icon svg { width: 17px; height: 17px; }
.stat-card .value { font-size: 26px; letter-spacing: -0.02em; }
.stat-card .label { font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-tertiary); font-weight: 650; }

/* ── 21g. Bảng: đầu bảng nhất quán, phân tách dịu ────────────────────── */
.orders-table thead th, .table-wrap thead th {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  color: var(--text-tertiary);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border) !important;
}
.orders-table tbody td, .table-wrap tbody td { border-bottom: 1px solid var(--border-dim); }
.orders-table tbody tr:last-child td { border-bottom: 0; }

/* ── 21h. Badge trạng thái: một hệ pill duy nhất ─────────────────────── */
.badge, .fd-badge {
  border-radius: 999px !important;
  padding: 3px 10px !important;
  font-size: 11.5px !important;
  font-weight: 650 !important;
  letter-spacing: 0 !important;
  border-width: 1px !important;
  line-height: 1.5 !important;
}

/* ── 21i. Input/select: cùng chiều cao, focus dịu ────────────────────── */
.fd-input, select.fd-input, .table-search input, .header-search input {
  min-height: 38px;
  border-radius: var(--radius-sm) !important;
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.fd-input:focus, .table-search input:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px var(--accent-muted) !important;
  outline: none;
}

/* ── 21j. Sidebar: active rõ hơn, hover mượt ─────────────────────────── */
.sidebar .nav-item { transition: background 120ms var(--ease), color 120ms var(--ease); position: relative; }
.sidebar .nav-item.active::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}
.sidebar .nav-item.active { background: var(--accent-muted) !important; color: var(--accent) !important; }
.sidebar .nav-item.active .nav-icon { color: var(--accent); }
.nav-group-label { margin-top: 6px; }

/* ── 21k. Bottom nav mobile: mục active có nền ───────────────────────── */
@media (max-width: 760px) {
  .bh-bottom-nav button[aria-current="page"] {
    background: var(--accent-muted);
    border-radius: 12px;
    margin: 4px 2px;
    min-height: 48px;
  }
}

/* ── 21l. Modal/drawer: bóng mềm, góc thống nhất ─────────────────────── */
.modal { border-radius: 14px !important; box-shadow: var(--shadow-lg) !important; }
.modal-backdrop, .drawer-backdrop { background: rgba(8, 11, 15, 0.55) !important; backdrop-filter: none !important; }

/* ── 21m. Nút: phản hồi khi bấm ──────────────────────────────────────── */
.btn:active:not(:disabled), .action-chip:active:not(:disabled) { transform: translateY(1px) !important; }
.btn:disabled { pointer-events: none; }

/* ── 21n. Filter chip active: nhận ra ngay ───────────────────────────── */
.fd-tab.active, .filter-chip.active {
  background: var(--accent-muted) !important;
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border)) !important;
  color: var(--accent) !important;
  font-weight: 650;
}

/* ── 21o. Empty state: gọn và ấm hơn ─────────────────────────────────── */
.empty-state { padding: 44px 20px !important; }
.empty-state .empty-icon { opacity: 0.5; margin-bottom: 10px; }
.empty-state h3 { font-size: 14.5px; margin-bottom: 4px; }
.empty-state p { font-size: 12.5px; color: var(--text-tertiary); }

/* ── 21p. Login: một điểm nhấn ───────────────────────────────────────── */
.login-card { box-shadow: var(--shadow-md) !important; }
.login-card .btn-primary { min-height: 40px; }

/* ── 21q. Panel head thống nhất mọi trang ────────────────────────────── */
.panel-head { font-size: 12.5px; font-weight: 700; letter-spacing: -0.01em; }
