/* Inventory Control Tower — matches the Massanois visual language
 * (navy primary, tight layout, compact tables, subtle shadows). */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink:        #0f172a;
  --ink-soft:   #334155;
  --muted:      #64748b;
  --faint:      #94a3b8;
  --hair:       #e2e8f0;
  --hair-soft:  #f1f5f9;
  --surface:    #ffffff;
  --surface-2:  #f8fafc;
  --bg:         #f5f7fa;
  --accent:     #2F5496;
  --accent-dk:  #1a3a6e;
  --accent-soft:#e0e8f5;
  --good:       #15803d;
  --good-soft:  #dcfce7;
  --warn:       #b45309;
  --warn-soft:  #fef3c7;
  --bad:        #b91c1c;
  --bad-soft:   #fee2e2;
  --info:       #3730a3;
  --info-soft:  #e0e7ff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.hidden { display: none !important; }

/* ── Login ─────────────────────────────────────────────────────────────── */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #fff; padding: 40px; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,0.08); width: 360px; text-align: center; }
.login-box h1 { color: var(--accent); margin-bottom: 8px; font-size: 22px; font-weight: 700; }
.login-box .muted { color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-box input { width: 100%; padding: 12px; margin: 6px 0; border: 1px solid #d0d5dd; border-radius: 8px; font-size: 15px; }
.login-box button { width: 100%; padding: 12px; background: var(--accent); color: #fff; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; margin-top: 10px; font-weight: 600; }
.login-box button:hover { background: var(--accent-dk); }
.login-error { color: var(--bad); font-size: 12px; margin-top: 10px; min-height: 16px; }

/* ── Header ────────────────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dk) 100%);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 60;
}
.app-header-left { display: flex; align-items: center; gap: 18px; }
.hub-link { color: rgba(255,255,255,0.85); font-size: 12px; text-decoration: none; }
.hub-link:hover { color: #fff; }
.app-header h1 { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.sub-tagline { font-size: 11px; color: rgba(255,255,255,0.7); font-weight: 500; }
.app-header-right { display: flex; align-items: center; gap: 10px; }
.user-display { font-size: 12px; color: rgba(255,255,255,0.85); }
.btn-ghost { background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.25); color: #fff; padding: 5px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; }
.btn-ghost:hover { background: rgba(255,255,255,0.25); }

/* ── Filters bar ───────────────────────────────────────────────────────── */
.filters {
  background: var(--surface);
  border-bottom: 1px solid var(--hair);
  padding: 10px 20px 8px;
  position: sticky;
  top: 46px;
  z-index: 50;
  box-shadow: 0 1px 3px rgba(0,0,0,0.03);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.wh-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.wh-tab {
  padding: 5px 14px;
  border: 1px solid var(--hair);
  background: #fff;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.wh-tab:hover { background: var(--surface-2); color: var(--ink-soft); }
.wh-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 2px; }
.field label { font-size: 9px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.field select, .field input {
  padding: 5px 8px; border: 1px solid #cbd5e1; border-radius: 5px; font-size: 12px;
  background: #fff; height: 28px; color: var(--ink);
}
.field select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47, 84, 150, 0.15); }

/* Searchable filter combobox — wraps the native <select>, which stays hidden
   in the DOM and remains the source-of-truth for state.filters. The visual
   input is a freeform text box that filters options as the user types. */
.sbox { position: relative; }
.sbox-input {
  width: 100%;
  padding: 5px 22px 5px 8px;
  border: 1px solid #cbd5e1; border-radius: 5px;
  font-size: 12px; background: #fff; height: 28px;
  color: var(--ink);
}
.sbox-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(47,84,150,0.15); }
.sbox-input::placeholder { color: var(--faint); }
.sbox-caret {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  font-size: 9px; color: var(--muted); pointer-events: none;
}
.sbox-clear {
  position: absolute; right: 3px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; padding: 2px 5px;
  color: var(--muted); font-size: 15px; line-height: 1;
  cursor: pointer; border-radius: 3px;
}
.sbox-clear:hover { color: var(--bad); background: var(--hair-soft); }
.sbox-dropdown {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--hair); border-radius: 5px;
  box-shadow: 0 6px 20px rgba(15,23,42,0.12);
  max-height: 280px; overflow-y: auto;
  z-index: 80;
  font-size: 12px;
}
.sbox-option {
  padding: 5px 10px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sbox-option:hover, .sbox-option.active { background: var(--accent-soft); color: var(--accent-dk); }
.sbox-option.selected { font-weight: 700; }
.sbox-option.selected::before {
  content: '✓'; margin-right: 6px; color: var(--accent); font-weight: 700;
}
.sbox-empty { padding: 8px 10px; color: var(--muted); font-style: italic; font-size: 11px; }

.seg-toggle {
  display: flex;
  gap: 2px;
  background: #eef1f6;
  border-radius: 5px;
  padding: 2px;
  height: 28px;
}
.seg-toggle button {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-radius: 3px;
  padding: 0 10px;
}
.seg-toggle button.active {
  background: #fff;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.btn-reset { height: 28px; padding: 0 12px; border: 1px solid var(--hair); background: #fff; border-radius: 5px; font-size: 11px; color: var(--muted); cursor: pointer; font-weight: 600; }
.btn-reset:hover { background: var(--surface-2); color: var(--ink-soft); }

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 20px;
  border-bottom: 1px solid var(--hair);
  background: var(--surface);
  position: sticky;
  top: 140px;
  z-index: 48;
}
.tab { padding: 10px 16px; cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); border-bottom: 2px solid transparent; transition: color 0.12s; }
.tab:hover { color: var(--accent); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tab-disabled { color: var(--faint) !important; cursor: not-allowed; font-style: italic; }
.tab-disabled:hover { color: var(--faint) !important; }

/* ── Panels ────────────────────────────────────────────────────────────── */
.panel { padding: 16px 20px 40px; max-width: 1800px; margin: 0 auto; }

/* ── KPI Row ───────────────────────────────────────────────────────────── */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  position: relative;
  overflow: hidden;
}
.kpi.kpi-hero { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dk) 100%); color: #fff; border-color: var(--accent-dk); }
.kpi.kpi-hero .kpi-label { color: rgba(255,255,255,0.8); }
.kpi.kpi-hero .kpi-value { color: #fff; }
.kpi.kpi-hero .kpi-sub { color: rgba(255,255,255,0.75); }
.kpi-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.kpi-value { font-size: 20px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi-sub { font-size: 11px; color: var(--faint); margin-top: 1px; }
.kpi.kpi-drill { cursor: pointer; transition: transform 80ms ease, box-shadow 80ms ease, border-color 80ms ease; }
.kpi.kpi-drill:hover { transform: translateY(-1px); box-shadow: 0 2px 8px rgba(15,23,42,0.08); border-color: var(--accent); }
.kpi.kpi-drill:hover .kpi-arrow { opacity: 1; }
.kpi.kpi-hero.kpi-drill:hover { border-color: rgba(255,255,255,0.5); }
.kpi-arrow { opacity: 0; margin-left: 4px; transition: opacity 80ms ease; font-weight: 700; color: var(--accent); }
.kpi.kpi-hero .kpi-arrow { color: rgba(255,255,255,0.95); }

/* ── Watchlist strip ───────────────────────────────────────────────────── */
.watchlist-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.watch-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-left: 3px solid var(--faint);
  border-radius: 6px;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.watch-card.watch-bad    { border-left-color: var(--bad); }
.watch-card.watch-warn   { border-left-color: var(--warn); }
.watch-card.watch-info   { border-left-color: var(--info); }
.watch-card.watch-muted  { border-left-color: var(--faint); }
.watch-card .w-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.watch-card .w-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.watch-card .w-sub { font-size: 11px; color: var(--faint); }
.watch-card.watch-bad  .w-value { color: var(--bad); }
.watch-card.watch-warn .w-value { color: var(--warn); }
.watch-card.watch-info .w-value { color: var(--info); }

/* ── Cards / grid ──────────────────────────────────────────────────────── */
.grid-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (max-width: 1100px) { .grid-2col { grid-template-columns: 1fr; } }

.card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 6px;
  padding: 12px 16px 14px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 10px; }
.card-head h3 { font-size: 13px; font-weight: 700; color: var(--accent); }
.card-head .card-meta { font-size: 11px; color: var(--faint); display: flex; align-items: center; gap: 8px; }

/* ── Bar rows (horizontal value/cases) ─────────────────────────────────── */
.bars { display: flex; flex-direction: column; gap: 5px; }
.bar-row { display: flex; align-items: center; font-size: 12px; gap: 8px; cursor: pointer; padding: 2px 0; border-radius: 3px; }
.bar-row:hover { background: var(--surface-2); }
.bar-label { flex: 0 0 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-soft); font-weight: 500; }
.bar-track { flex: 1; background: var(--hair-soft); height: 16px; border-radius: 3px; position: relative; overflow: hidden; }
.bar-fill { background: linear-gradient(90deg, var(--accent), #3b82f6); height: 100%; border-radius: 3px; transition: width 0.3s ease; }
.bar-fill.fill-wh-SBC1 { background: linear-gradient(90deg, #1a3a6e, #2F5496); }
.bar-fill.fill-wh-CAW1 { background: linear-gradient(90deg, #0e7490, #0891b2); }
.bar-fill.fill-wh-ILW  { background: linear-gradient(90deg, #15803d, #22c55e); }
.bar-fill.fill-wh-ICW1 { background: linear-gradient(90deg, #a16207, #eab308); }
.bar-value { flex: 0 0 auto; width: 120px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.bar-sub { flex: 0 0 60px; text-align: right; font-variant-numeric: tabular-nums; font-size: 11px; color: var(--faint); }

/* ── Inbound chart (inline SVG columns) ────────────────────────────────── */
.inbound-chart { height: 170px; display: flex; align-items: flex-end; gap: 3px; padding: 8px 0 22px; position: relative; }
.inbound-chart-lg { height: 240px; display: flex; align-items: flex-end; gap: 4px; padding: 12px 0 30px; position: relative; }
.inb-col { flex: 1; min-width: 10px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; cursor: pointer; }
.inb-col-bar { width: 100%; background: var(--accent); border-radius: 2px 2px 0 0; transition: opacity 0.15s; }
.inb-col:hover .inb-col-bar { opacity: 0.82; }
.inb-col-label { position: absolute; bottom: -20px; font-size: 9.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.inb-col-val { position: absolute; top: -15px; font-size: 10px; color: var(--ink-soft); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inb-col-tip {
  position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 5px 8px; border-radius: 4px;
  font-size: 11px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity 0.12s; z-index: 20;
}
.inb-col:hover .inb-col-tip { opacity: 1; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.table-wrap { max-height: calc(100vh - 260px); overflow: auto; border: 1px solid var(--hair); border-radius: 6px; }
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 12px; }
th { background: var(--surface-2); padding: 6px 10px; font-weight: 600; font-size: 11px; color: var(--muted); border-bottom: 1px solid var(--hair); white-space: nowrap; position: sticky; top: 0; z-index: 2; cursor: pointer; user-select: none; text-align: left; }
th.num { text-align: right; }
th:hover { background: #eef2f7; }
th.sort-asc::after { content: ' ↑'; color: var(--accent); }
th.sort-desc::after { content: ' ↓'; color: var(--accent); }
td { padding: 5px 10px; border-bottom: 1px solid var(--hair-soft); white-space: nowrap; }
tr:hover td { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Warehouse comparison ──────────────────────────────────────────────── */
#wh-compare-table table { font-size: 13px; }
#wh-compare-table th { font-size: 11px; padding: 8px 12px; }
#wh-compare-table td { padding: 8px 12px; font-variant-numeric: tabular-nums; }
#wh-compare-table td.wh-label { font-weight: 700; color: var(--ink); padding-left: 14px; }
#wh-compare-table td.wh-label .wh-name { display: block; font-size: 10px; color: var(--faint); font-weight: 500; margin-top: 1px; }
#wh-compare-table .wh-row { cursor: pointer; }
#wh-compare-table .wh-row:hover td { background: var(--accent-soft); }
#wh-compare-table .pct-pill { display: inline-block; padding: 1px 7px; border-radius: 10px; background: var(--surface-2); color: var(--ink-soft); font-size: 10px; font-weight: 600; margin-left: 4px; }

.wh-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 12px; margin-top: 14px; }
.wh-detail-card { background: var(--surface); border: 1px solid var(--hair); border-radius: 6px; padding: 12px 16px; }
.wh-detail-card h4 { font-size: 13px; color: var(--accent); margin-bottom: 2px; font-weight: 700; }
.wh-detail-card .wh-sub { font-size: 11px; color: var(--faint); margin-bottom: 10px; }
.wh-detail-card .wh-kpi-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.wh-kpi-mini .mini-k { background: var(--surface-2); border-radius: 4px; padding: 6px 8px; }
.wh-kpi-mini .mini-k .k { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.wh-kpi-mini .mini-k .v { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--ink); }
.wh-detail-card h5 { font-size: 10px; color: var(--muted); text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; margin: 6px 0 4px; }

/* ── Inbound controls ──────────────────────────────────────────────────── */
.inbound-controls { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.inbound-controls .seg-toggle { min-width: 200px; height: 30px; }
.inline-search { padding: 4px 8px; border: 1px solid var(--hair); border-radius: 4px; font-size: 11px; height: 24px; min-width: 200px; }

/* ── Category grid ─────────────────────────────────────────────────────── */
.cat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 12px; }

/* ── Methodology ───────────────────────────────────────────────────────── */
.card-methodology { background: var(--surface-2); }
.methodology p { margin-bottom: 6px; line-height: 1.5; color: var(--ink-soft); }
.methodology p strong { color: var(--ink); font-weight: 600; }
.methodology .muted { color: var(--muted); }
.methodology .small { font-size: 11px; }

/* ── Loading ───────────────────────────────────────────────────────────── */
#loading-overlay {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  background: rgba(15, 23, 42, 0.85); color: #fff; padding: 12px 20px;
  border-radius: 8px; font-size: 13px; z-index: 200;
}

/* ── Misc ──────────────────────────────────────────────────────────────── */
.empty-state { padding: 40px 20px; text-align: center; color: var(--faint); font-size: 13px; }
.muted { color: var(--muted); }
.small { font-size: 11px; }

/* ── Inventory Health ──────────────────────────────────────────────────── */
.health-status-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  background: var(--surface);
  padding: 6px;
  border-radius: 6px;
  border: 1px solid var(--hair);
}
.health-status-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border: 1px solid var(--hair);
  background: var(--surface);
  border-radius: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.health-status-tab:hover { background: var(--surface-2); }
.health-status-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.health-status-tab.active .hs-count { background: rgba(255,255,255,0.25); color: #fff; }
.health-status-tab .hs-count {
  display: inline-block;
  min-width: 24px;
  padding: 1px 6px;
  background: var(--hair-soft);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.health-status-tab.hs-bad.active { background: var(--bad); border-color: var(--bad); }
.health-status-tab.hs-warn.active { background: var(--warn); border-color: var(--warn); }
.health-status-tab.hs-info.active { background: var(--info); border-color: var(--info); }
.health-status-tab.hs-good.active { background: var(--good); border-color: var(--good); }
.health-status-tab.hs-muted.active { background: var(--faint); border-color: var(--faint); }

.health-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

#health-table th { padding: 7px 8px; font-size: 10.5px; }
#health-table td { padding: 4px 8px; font-size: 11.5px; }

#programs-rollup-table tfoot td,
#programs-sku-table tfoot td,
#health-table tfoot td {
  background: #eef2f7;
  font-weight: 700;
  color: var(--accent-dk);
  border-top: 2px solid var(--accent);
  position: sticky;
  bottom: 0;
  z-index: 3;
  font-size: 12px;
  padding: 8px;
  font-variant-numeric: tabular-nums;
}
#health-table tfoot td:first-child,
#programs-rollup-table tfoot td:first-child,
#programs-sku-table tfoot td:first-child { color: var(--accent); }

#programs-rollup-table th { padding: 7px 8px; font-size: 10.5px; }
#programs-rollup-table td { padding: 5px 8px; font-size: 11.5px; }
#programs-rollup-table .program-row:hover td { background: var(--accent-soft); }
#programs-sku-table th { padding: 7px 8px; font-size: 10.5px; }
#programs-sku-table td { padding: 4px 8px; font-size: 11.5px; }

.program-pill {
  display: inline-block;
  padding: 1px 7px;
  background: #e0e8f5;
  color: var(--accent);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.pct-bar {
  display: inline-block;
  min-width: 32px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pct-high { color: var(--bad); font-weight: 700; }
.pct-mid  { color: var(--warn); font-weight: 600; }
.pct-low  { color: var(--muted); }

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}
.status-stockout_no_action { background: var(--bad-soft);    color: var(--bad); }
.status-stockout_bridged   { background: var(--info-soft);   color: var(--info); }
.status-overstock          { background: var(--warn-soft);   color: var(--warn); }
.status-slow_mover         { background: #fef3c7;            color: #a16207; }
.status-dead_stock         { background: #e2e8f0;            color: #475569; }
.status-healthy            { background: var(--good-soft);   color: var(--good); }

/* History trajectory chart on Overview — SVG line, grey pre-today, solid after */
.history-chart { width: 100%; min-height: 220px; display: block; padding: 8px 4px 0; }
.history-chart svg { overflow: visible; }
.history-legend { display: inline-flex; gap: 10px; align-items: center; font-size: 11px; color: var(--muted); }
.history-swatch { display: inline-block; width: 14px; height: 2px; margin-right: 4px; vertical-align: middle; }
.history-swatch.hist-reconstructed { border-top: 2px dashed #a9b0bc; height: 0; }
.history-swatch.hist-snapshot      { background: #2f7a4f; }
.history-caveat { margin: 4px 12px 4px; font-size: 11px; }

/* Status methodology card (Health tab) — one row per bucket with badge + rule */
.status-methodology { display: flex; flex-direction: column; gap: 14px; }
.status-rule { display: grid; grid-template-columns: 130px 1fr; gap: 14px; align-items: start; }
.status-rule > .status-badge { justify-self: start; margin-top: 2px; }
.status-rule-body strong { display: block; margin-bottom: 4px; color: var(--ink); }
.status-rule-body em { font-style: italic; color: var(--muted); }
.status-rule-body .muted { display: block; margin-top: 6px; }

/* Inline status legend on the Programs tab (compact) */
.program-legend {
  display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center;
  padding: 8px 16px 10px; border-bottom: 1px solid var(--hair);
  font-size: 11px; color: var(--muted);
}
.program-legend .status-badge { flex-shrink: 0; }

/* Vintage-count badge on program rollup rows — 2+ = legacy inventory present */
.vin-badge {
  display: inline-block;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 10px;
  background: #fef3c7;
  color: #a16207;
  font-size: 11px;
  font-weight: 700;
}

.gap-cell.gap-risky { color: var(--bad); font-weight: 700; }
.gap-cell.gap-ok    { color: var(--good); font-weight: 600; }

/* ── Action Center ─────────────────────────────────────────────────────── */
.actions-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.action-card {
  background: var(--surface);
  border: 1px solid var(--hair);
  border-radius: 8px;
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
}
.action-card.card-transfer  { border-left-color: var(--info); }
.action-card.card-stockout  { border-left-color: var(--bad); }
.action-card.card-over      { border-left-color: var(--warn); }
.action-card.card-dead      { border-left-color: var(--faint); }
.action-card.card-concent   { border-left-color: #9333ea; }

.action-card .a-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.action-card .a-head h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.action-card .a-head .a-sub {
  font-size: 11px;
  color: var(--muted);
}
.action-card .a-count {
  background: var(--surface-2);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-left: 8px;
}
.action-card .a-why {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  font-style: italic;
}

.action-card table { font-size: 12px; border: none; }
.action-card th { background: var(--surface-2); padding: 4px 8px; font-size: 10px; }
.action-card td { padding: 4px 8px; }
.action-card .suggested {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}

/* ── Inbound supplier drill-down ───────────────────────────────────────── */
.supplier-row {
  cursor: pointer;
}
.supplier-row .expand-icon {
  display: inline-block;
  width: 14px;
  font-size: 10px;
  color: var(--faint);
  transition: transform 0.15s;
  margin-right: 4px;
}
.supplier-row.expanded .expand-icon {
  transform: rotate(90deg);
  color: var(--accent);
}
.supplier-detail {
  background: #fafbfc;
  padding: 10px 14px 10px 40px;
  border-top: 1px solid var(--hair);
  border-bottom: 1px solid var(--hair);
  margin: 4px 0;
  border-radius: 0 0 4px 4px;
}
.supplier-detail table { font-size: 11px; background: transparent; border: 1px solid var(--hair); }
.supplier-detail th { background: #fff; padding: 4px 8px; }
.supplier-detail td { padding: 3px 8px; }

/* ── Brand drawer ──────────────────────────────────────────────────────── */
.drawer-overlay {
  position: fixed; inset: 0;
  background: rgba(15, 23, 42, 0.32);
  z-index: 95;
  animation: fadeIn 0.12s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(1100px, 92vw);
  background: var(--surface);
  z-index: 100;
  box-shadow: -4px 0 24px rgba(15, 23, 42, 0.18);
  display: flex; flex-direction: column;
  transform: translateX(0);
  animation: slideIn 0.18s ease-out;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--hair);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dk) 100%);
  color: #fff;
}
.drawer-title-wrap { min-width: 0; }
.drawer-eyebrow { font-size: 10px; letter-spacing: 0.8px; text-transform: uppercase; color: rgba(255,255,255,0.72); font-weight: 600; margin-bottom: 2px; }
.drawer-head h2 { font-size: 20px; font-weight: 700; letter-spacing: -0.2px; color: #fff; line-height: 1.2; }
.drawer-sub { font-size: 12px; color: rgba(255,255,255,0.8); margin-top: 4px; font-variant-numeric: tabular-nums; }
.drawer-head-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.btn-drawer {
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3);
  color: #fff; padding: 6px 12px; border-radius: 6px; font-size: 12px;
  font-weight: 600; cursor: pointer;
}
.btn-drawer:hover { background: rgba(255,255,255,0.25); }
.btn-icon {
  background: rgba(255,255,255,0.15); border: 1px solid rgba(255,255,255,0.3);
  color: #fff; width: 32px; height: 32px; border-radius: 6px;
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0;
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: rgba(255,255,255,0.25); }
.drawer-body {
  flex: 1; overflow-y: auto;
  padding: 16px 20px 40px;
  background: var(--bg);
}
.drawer-body .card { margin-bottom: 14px; }
.drawer-body .card:last-child { margin-bottom: 0; }

/* KPI strip inside the drawer */
.bd-kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 14px;
}
.bd-kpi {
  background: var(--surface); border: 1px solid var(--hair); border-radius: 8px;
  padding: 10px 12px;
}
.bd-kpi .k { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.bd-kpi .v { font-size: 18px; font-weight: 700; color: var(--ink); margin-top: 2px; font-variant-numeric: tabular-nums; }
.bd-kpi .s { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Per-WH matrix */
.bd-wh-matrix {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.bd-wh-cell {
  background: var(--surface); border: 1px solid var(--hair); border-radius: 8px;
  padding: 10px 12px; cursor: pointer; transition: border-color 0.1s, box-shadow 0.1s;
}
.bd-wh-cell:hover { border-color: var(--accent); box-shadow: 0 2px 8px rgba(47,84,150,0.12); }
.bd-wh-cell.bd-wh-empty { opacity: 0.55; cursor: default; }
.bd-wh-cell.bd-wh-empty:hover { border-color: var(--hair); box-shadow: none; }
.bd-wh-cell-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 6px;
}
.bd-wh-cell-head .wh-code { font-weight: 700; font-size: 13px; color: var(--ink); }
.bd-wh-cell-head .wh-skus { font-size: 10px; color: var(--muted); }
.bd-wh-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; font-size: 11px; }
.bd-wh-stats .k { color: var(--muted); }
.bd-wh-stats .v { color: var(--ink); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }

/* SKU table */
.bd-sku-table { font-size: 11px; }
.bd-sku-table th { cursor: pointer; user-select: none; white-space: nowrap; }
.bd-sku-table th.sorted { color: var(--accent); }
.bd-sku-table td.wh-cell { font-weight: 600; white-space: nowrap; }
.bd-sku-wh-chip {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.3px;
  background: var(--accent-soft); color: var(--accent-dk);
}

.bd-filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.bd-filter-bar input[type=search] {
  border: 1px solid var(--hair); border-radius: 6px; padding: 6px 10px;
  font-size: 12px; min-width: 200px;
}
.bd-status-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.bd-status-tabs button {
  padding: 4px 10px; border: 1px solid var(--hair); background: #fff;
  color: var(--muted); font-size: 11px; font-weight: 600;
  border-radius: 14px; cursor: pointer;
}
.bd-status-tabs button:hover { background: var(--hair-soft); color: var(--ink); }
.bd-status-tabs button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.bd-status-tabs .count { margin-left: 6px; opacity: 0.7; font-weight: 500; }
