body {
  margin: 0;
  padding: 0;
  color: #1d1d1f;
  overflow-x: hidden;
}

/* ---- Page Layout ---- */
.page-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 48px;
}

/* ---- Header ---- */
.page-header {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid #e5e5e7;
}
.page-header h1 {
  color: #1d1d1f;
  font-size: 32px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.5px;
}
.page-header .subtitle {
  color: #86868b;
  margin: 6px 0 0;
  font-size: 15px;
}
.btn-logout {
  color: #86868b;
}

/* ---- Filter Panel ---- */
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: white;
  border: 1px solid #d2d2d7;
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: #1d1d1f;
  margin-bottom: 16px;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.filter-toggle:hover { background: #f5f5f7; border-color: #b0b0b5; }
.filter-toggle .chevron {
  font-size: 10px;
  color: #86868b;
  transition: transform 0.25s ease;
}
.filter-toggle .chevron.open { transform: rotate(180deg); }
.filter-badge {
  background: #0066cc;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}
.filter-panel {
  background: white;
  border: 1px solid #e5e5e7;
  border-radius: 14px;
  padding: 24px;
  margin-bottom: 20px;
  display: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.filter-panel.open { display: block; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}
.filter-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #86868b;
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.filter-group input,
.filter-group select {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: #f5f5f7;
  color: #1d1d1f;
  transition: all 0.2s;
}
.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: #0066cc;
  background: white;
  box-shadow: 0 0 0 3px rgba(0,102,204,0.12);
}
.filter-group input::placeholder { color: #b0b0b5; }
.filter-actions {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f2;
  display: flex;
  gap: 12px;
  align-items: center;
}
.btn-apply {
  background: #0066cc;
  color: white;
  border: none;
  padding: 9px 28px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.btn-apply:hover { background: #0055b3; }
/* Dirty-aware Apply + live column panel styles live in css/view-settings.css (#28). */

.btn-reset {
  background: none;
  border: none;
  color: #86868b;
  font-size: 14px;
  cursor: pointer;
  padding: 9px 16px;
  font-weight: 500;
  transition: color 0.2s;
}
.btn-reset:hover { color: #1d1d1f; }

/* ---- Tab Bar ---- */
.tab-bar {
  display: inline-flex;
  gap: 0;
  background: #f0f0f2;
  padding: 3px;
  border-radius: 10px;
  margin-bottom: 20px;
}
.tab-btn {
  padding: 9px 28px;
  font-size: 14px;
  border: none;
  background: transparent;
  color: #86868b;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.tab-btn:hover { color: #1d1d1f; }
.tab-btn.active {
  background: white;
  color: #1d1d1f;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  font-weight: 600;
}

/* ---- Results Toolbar ---- */
.results-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
  color: #86868b;
}
.results-count { font-weight: 600; color: #1d1d1f; }
.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.sort-control {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sort-control label {
  font-size: 13px;
  font-weight: 500;
  color: #86868b;
  white-space: nowrap;
}
.sort-control select {
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: white;
  color: #1d1d1f;
  cursor: pointer;
  transition: all 0.2s;
}
.sort-control select:focus {
  outline: none;
  border-color: #0066cc;
}
.sort-dir-btn {
  width: 34px;
  height: 34px;
  border: 1px solid #d2d2d7;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #1d1d1f;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.sort-dir-btn:hover { background: #f5f5f7; border-color: #b0b0b5; }
.btn-export {
  background: white;
  border: 1px solid #d2d2d7;
  padding: 7px 16px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  color: #1d1d1f;
  font-weight: 500;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn-export:hover { background: #f5f5f7; border-color: #b0b0b5; }

/* Saved-view lifecycle switcher styles live in css/view-settings.css (#28). */

/* ---- Table ---- */
.table-wrapper {
  max-height: 620px;
  overflow: auto;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  background: white;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
th {
  background: #0066cc;
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  color: white;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  position: sticky;
  top: 0;
  z-index: 10;
  cursor: default;
  user-select: none;
  border-bottom: none;
}
td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f2;
  color: #1d1d1f;
}
tbody tr:nth-child(even) td { background: #fafafa; }
tbody tr:hover td { background: #f0f4ff; }
tbody tr.row-not-on-ekuep td { background: #fff0f0 !important; }
tbody tr.row-on-ekuep td { background: #f0fff0 !important; }
td.num {
  text-align: right;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  letter-spacing: -0.2px;
}

/* Truncated text cells */
td .cell-truncate {
  display: block;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sticky first column */
th.col-sticky, td.col-sticky {
  position: sticky;
  left: 0;
  z-index: 5;
}
th.col-sticky {
  z-index: 15;
  background: #0066cc;
}
td.col-sticky { background: white; }
tbody tr:nth-child(even) td.col-sticky { background: #fafafa; }
tbody tr:hover td.col-sticky { background: #f0f4ff; }

/* ---- Pagination ---- */
.pagination-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 0;
  font-size: 13px;
  color: #86868b;
  flex-wrap: wrap;
  gap: 12px;
}
.pagination-info { font-weight: 500; color: #6e6e73; }
.pagination-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pg-btn {
  width: 34px;
  height: 34px;
  border: 1px solid #d2d2d7;
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 16px;
  color: #1d1d1f;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.pg-btn:hover { background: #f5f5f7; border-color: #b0b0b5; }
.pg-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.pg-input {
  width: 52px;
  text-align: center;
  padding: 6px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  font-size: 13px;
  background: #f5f5f7;
}
.pg-input:focus { outline: none; border-color: #0066cc; background: white; }
.pg-current {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #6e6e73;
}
.pagination-size select {
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: white;
  color: #1d1d1f;
  cursor: pointer;
}

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 72px 20px;
  color: #b0b0b5;
}
.empty-state .icon { font-size: 48px; margin-bottom: 16px; opacity: 0.6; }
.empty-state h3 {
  margin: 0 0 8px;
  color: #6e6e73;
  font-size: 17px;
  font-weight: 600;
}
.empty-state p { margin: 0; font-size: 14px; }

/* ---- Column Config Modal ---- */
.btn-columns {
  background: white;
  border: 1px solid #d2d2d7;
  padding: 7px 16px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  color: #1d1d1f;
  font-weight: 500;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.btn-columns:hover { background: #f5f5f7; border-color: #b0b0b5; }
.col-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.col-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.col-modal {
  background: white;
  border-radius: 14px;
  width: 440px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: scale(0.95);
  transition: transform 0.2s;
}
.col-modal-overlay.open .col-modal {
  transform: scale(1);
}
.col-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #f5f5f7;
  border-radius: 14px 14px 0 0;
  border-bottom: 1px solid #e5e5e7;
}
.col-modal-header span {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
}
.col-modal-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 20px;
  color: #86868b;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.col-modal-close:hover { background: #e5e5e7; color: #1d1d1f; }
.col-modal-views {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-bottom: 1px solid #f0f0f2;
}
.col-modal-views label {
  font-size: 13px;
  font-weight: 500;
  color: #86868b;
  white-space: nowrap;
}
.col-modal-views select {
  flex: 1;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: white;
  color: #1d1d1f;
  cursor: pointer;
}
.col-modal-views select:focus { outline: none; border-color: #0066cc; }
.col-view-btn {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.col-view-save {
  background: #0066cc;
  color: white;
}
.col-view-save:hover { background: #0055b3; }
.col-view-delete {
  background: transparent;
  color: #ff3b30;
}
.col-view-delete:hover { background: #fff0f0; }
.col-view-delete:disabled {
  color: #d2d2d7;
  cursor: not-allowed;
  background: transparent;
}
.col-modal-list {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  padding: 4px 0;
}
.col-modal-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  border-bottom: 1px solid #f5f5f7;
  transition: background 0.1s;
}
.col-modal-item:hover { background: #f5f5f7; }
.col-modal-item.dragging { opacity: 0.4; background: #e8f0fe; }
.col-modal-item.drag-over { box-shadow: 0 -2px 0 0 #0066cc inset; }
.col-modal-item.unchecked { opacity: 0.5; }
.col-modal-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: #0066cc;
  flex-shrink: 0;
}
.col-modal-item .col-label {
  flex: 1;
  font-size: 14px;
  color: #1d1d1f;
  user-select: none;
}
.col-drag-handle {
  cursor: grab;
  color: #b0b0b5;
  font-size: 15px;
  user-select: none;
  padding: 2px 4px;
  line-height: 1;
}
.col-drag-handle:active { cursor: grabbing; }
.col-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-top: 1px solid #e5e5e7;
  background: #f5f5f7;
  border-radius: 0 0 14px 14px;
}
.col-modal-footer .col-footer-left {
  display: flex;
  gap: 4px;
}
.col-footer-btn {
  background: none;
  border: none;
  color: #86868b;
  font-size: 13px;
  cursor: pointer;
  padding: 6px 12px;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s;
}
.col-footer-btn:hover { color: #1d1d1f; background: #e5e5e7; }
.col-apply-btn {
  background: #0066cc;
  color: white;
  border: none;
  padding: 8px 24px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}
.col-apply-btn:hover { background: #0055b3; }

/* ---- Analytics Dashboard ---- */
.analytics-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.kpi-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  text-align: center;
}
.kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.kpi-card .kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: #86868b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.kpi-card .kpi-detail {
  font-size: 11px;
  color: #86868b;
  margin-top: 4px;
}
.kpi-card.kpi-alert .kpi-value { color: #ff3b30; }
/* Analytics sub-tabs */
.analytics-sub-tabs {
  display: inline-flex;
  gap: 0;
  background: #f0f0f2;
  padding: 2px;
  border-radius: 8px;
  margin-bottom: 20px;
}
.analytics-sub-tab {
  padding: 7px 20px;
  font-size: 13px;
  border: none;
  background: transparent;
  color: #86868b;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}
.analytics-sub-tab:hover { color: #1d1d1f; }
.analytics-sub-tab.active {
  background: white;
  color: #1d1d1f;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  font-weight: 600;
}
/* Full-bleed analytics sub-section heading (shared by Key Items, Ekuep,
   Stock Changes, Reservations). Class names kept for backwards compatibility. */
.aclass-section-title {
  font-size: 20px;
  font-weight: 700;
  color: #1d1d1f;
  margin: 0 0 6px;
}
.aclass-section-desc {
  font-size: 13px;
  color: #6e6e73;
  margin: 0 0 20px;
}
/* Key Items section — the toolbar reuses the stock tables' results-toolbar
   skeleton; only the left side differs (count + transient add/remove status). */
.ki-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.key-items-add-msg {
  font-size: 13px;
  color: #6e6e73;
}
.key-items-add-msg.error { color: #d70015; }
/* Per-row remove: quiet ✕ that reveals itself on row hover */
.key-items-remove {
  background: none;
  border: none;
  border-radius: 6px;
  color: #86868b;
  cursor: pointer;
  padding: 0 6px;
  font-size: 17px;
  line-height: 1;
  opacity: 0.35;
  transition: all 0.15s;
}
#tableKeyItems tbody tr:hover .key-items-remove { opacity: 1; }
.key-items-remove:hover { color: #d70015; background: #ffe5e5; }
#tableKeyItems th.ki-sortable { white-space: nowrap; }
#tableKeyItems td.ki-col-remove { text-align: right; padding-left: 4px; padding-right: 10px; }
/* Denser cells than the global table base: 14 columns have to fit without
   horizontal scrolling at typical widths (values measured in-browser against
   a worst-case row with all 7 PO flags set) */
#tableKeyItems th { padding: 9px 8px; }
#tableKeyItems td { padding: 8px 8px; }
/* 200px: Category's freed space goes to product names (was 140px) */
#tableKeyItems td .cell-truncate { max-width: 200px; }
#tableKeyItems td.ki-col-brand { text-transform: uppercase; }
/* Status traffic-light pill (default sort column) */
.ki-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: help;
}
.ki-status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.ki-status-gap { background: #fff0f0; color: #c92a2a; }
.ki-status-gap .ki-status-dot { background: #d70015; }
.ki-status-order { background: #fff4e6; color: #d9480f; }
.ki-status-order .ki-status-dot { background: #e8590c; }
.ki-status-watch { background: #fff9db; color: #8a6d00; }
.ki-status-watch .ki-status-dot { background: #f0b400; }
.ki-status-ok { background: #ebfbee; color: #2b8a3e; }
.ki-status-ok .ki-status-dot { background: #2f9e44; }
.ki-status-overstock { background: #f1f3f5; color: #6e6e73; }
.ki-status-overstock .ki-status-dot { background: #adb5bd; }
.ki-status-none { color: #adb5bd; cursor: help; }
/* Gap pills keep their own red inside tinted no-stock rows */
#tableKeyItems tr.row-no-stock td .ki-status-gap { color: #c92a2a; }

/* 12-month demand-pattern chip (steady / intermittent / erratic / lumpy /
   sparse) — same pill idiom as the Status column, without the dot */
.ki-pattern {
  display: inline-flex;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  cursor: help;
}
.ki-pattern-steady { background: #ebfbee; color: #2b8a3e; }
.ki-pattern-intermittent { background: #e7f1fb; color: #1e5f9e; }
.ki-pattern-erratic { background: #fff9db; color: #8a6d00; }
.ki-pattern-lumpy { background: #fff0f0; color: #c92a2a; }
.ki-pattern-sparse { background: #f1f3f5; color: #6e6e73; }
/* Lumpy chips keep their own red inside tinted no-stock rows */
#tableKeyItems tr.row-no-stock td .ki-pattern-lumpy { color: #c92a2a; }
.ki-spark-empty { font-size: 11px; color: #adb5bd; }

/* PO pipeline flag badges — same look as the PO explorer's flags column,
   sized down a notch for the denser Key Items table */
.flags-cell { display: flex; gap: 2px; flex-wrap: nowrap; }
.flag-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 20px;
  font-size: 12px;
  cursor: help;
  border-radius: 5px;
  transition: background 0.15s;
}
.flag-badge:hover { background: #e8f0fe; }
/* Out-of-stock rows (was inherited from .analytics-table-card before the
   ekuep-brand-table restyle) */
#tableKeyItems tr.row-no-stock td { background: #fff5f5; color: #cc3333; }
#tableKeyItems td.ki-coverage-capped {
  color: #b25000;
  font-weight: 600;
}
#tableKeyItems td.ki-overdue {
  color: #d70015;
  font-weight: 600;
}
/* Expected column: stock arrived but held in the customs warehouse; keeps its
   own amber inside tinted no-stock rows */
.ki-clearance, #tableKeyItems tr.row-no-stock td .ki-clearance {
  color: #8a6d00;
  font-weight: 600;
  white-space: nowrap;
  cursor: help;
}
/* Add Key Items dialog */
.ki-add-search {
  display: flex;
  gap: 10px;
  padding: 14px 20px 4px;
}
.ki-add-search input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #d1d1d6;
  border-radius: 8px;
  font-size: 14px;
}
.ki-add-note {
  font-size: 12px;
  color: #86868b;
  margin-bottom: 10px;
}
/* Fixed layout so long product names ellipsize instead of overflowing the modal
   (which pushed the Add column off-screen). */
.ki-add-table { table-layout: fixed; width: 100%; }
.ki-add-table th:nth-child(1), .ki-add-table td:nth-child(1) { width: 120px; }
.ki-add-table th:nth-child(2), .ki-add-table td:nth-child(2) { width: 130px; }
.ki-add-table th:nth-child(3), .ki-add-table td:nth-child(3) { width: auto; }
.ki-add-table th:nth-child(4), .ki-add-table td:nth-child(4) { width: 90px; }
.ki-add-table th:nth-child(5), .ki-add-table td:nth-child(5) { width: 70px; }
.ki-add-table th:nth-child(6), .ki-add-table td:nth-child(6) { width: 80px; }
.ki-add-table th:nth-child(7), .ki-add-table td:nth-child(7) { width: 96px; }
.ki-add-table td.ki-add-product {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ki-add-table td.ki-add-action { text-align: right; white-space: nowrap; }
.ki-add-btn, .ki-remove-btn {
  border-radius: 6px;
  padding: 4px 14px;
  font-size: 13px;
  cursor: pointer;
}
.ki-add-btn { background: #0066cc; color: white; border: none; }
.ki-add-btn:hover { background: #0055b3; }
.ki-add-btn:disabled, .ki-remove-btn:disabled { opacity: 0.6; cursor: default; }
.ki-add-btn.ki-add-error { background: #d70015; }
.ki-remove-btn {
  background: white;
  color: #d70015;
  border: 1px solid #d1d1d6;
}
.ki-remove-btn:hover { background: #ffe5e5; }
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 900px) {
  .chart-row { grid-template-columns: 1fr; }
}
.chart-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.chart-card h3 {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
}
.chart-card canvas {
  max-height: 260px;
}
.analytics-tables-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
.analytics-tables-row .analytics-table-card {
  margin-bottom: 0;
}
@media (max-width: 1100px) {
  .analytics-tables-row { grid-template-columns: 1fr; }
}
.analytics-table-card {
  background: white;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  overflow-x: auto;
  margin-bottom: 16px;
}
.analytics-table-card h3 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: #1d1d1f;
}
.section-subtitle {
  font-weight: 400;
  font-size: 12px;
  color: #86868b;
}
.analytics-table-card table {
  font-size: 12px;
  white-space: nowrap;
}
.analytics-table-card th {
  background: #f5f5f7;
  color: #1d1d1f;
  font-size: 11px;
  padding: 8px 10px;
  position: static;
}
/* Column group divider */
.analytics-table-card .col-divider {
  border-left: 2px solid #d1d1d6;
}
/* No-stock row highlight */
.analytics-table-card .row-no-stock {
  background: #fff5f5;
}
.analytics-table-card .row-no-stock td {
  color: #cc3333;
}
/* No stock AND no PO — critical */
.analytics-table-card .row-no-stock-no-po {
  background: #ffe0e0;
}
.analytics-table-card .row-no-stock-no-po td {
  color: #aa1111;
  font-weight: 500;
}
/* Scrollable table card */
.analytics-table-scroll {
  display: flex;
  flex-direction: column;
}
.analytics-table-scroll h3 {
  flex-shrink: 0;
}
.table-scroll-wrap,
.bar-chart-wrap {
  overflow-y: auto;
  max-height: 480px;
  flex: 1;
}
/* Horizontal bar chart */
.hbar-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #f0f0f2;
  font-size: 12px;
}
.hbar-row:last-child { border-bottom: none; }
.hbar-label {
  width: 110px;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1d1d1f;
  font-weight: 500;
}
.hbar-track {
  flex: 1;
  position: relative;
  height: 22px;
  background: #f5f5f7;
  border-radius: 4px;
  overflow: hidden;
}
.hbar-fill {
  height: 100%;
  background: #0066cc;
  border-radius: 4px;
  min-width: 2px;
}
.hbar-value {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  font-weight: 600;
  color: #1d1d1f;
  white-space: nowrap;
}
.analytics-table-card td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0f2;
}
/* Clickable filter links in analytics tables */
.analytics-filter-link {
  cursor: pointer;
  color: inherit;
  padding: 2px 6px;
  margin: -2px -6px;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
}
.analytics-filter-link:hover {
  background: rgba(0, 102, 204, 0.08);
  color: #0066cc;
}
.analytics-filter-link:active {
  background: rgba(0, 102, 204, 0.15);
}
/* Keep hbar-label layout stable when it's also a filter link */
.hbar-label.analytics-filter-link {
  padding: 1px 4px;
  margin: -1px -4px;
  border-radius: 3px;
}
.analytics-loading {
  text-align: center;
  padding: 80px 20px;
  color: #86868b;
  font-size: 15px;
}
.analytics-loading::before {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  border: 2.5px solid #e5e5e7;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 14px;
}

/* ---- Multi-select ---- */
.multiselect-wrap { position: relative; }
.multiselect-trigger {
  width: 100%;
  padding: 9px 12px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: #f5f5f7;
  color: #1d1d1f;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s;
}
.multiselect-trigger:hover { border-color: #b0b0b5; }
.multiselect-trigger:focus { outline: none; border-color: #0066cc; background: white; box-shadow: 0 0 0 3px rgba(0,102,204,0.12); }
.multiselect-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #d2d2d7;
  border-top: none;
  border-radius: 0 0 8px 8px;
  z-index: 50;
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
  padding: 4px 0;
}
.multiselect-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #1d1d1f;
  transition: background 0.1s;
}
.multiselect-option:hover { background: #f0f4ff; }
.multiselect-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #0066cc;
  cursor: pointer;
}

/* ---- Autocomplete ---- */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #d2d2d7;
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}
.autocomplete-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  color: #1d1d1f;
}
.autocomplete-item:hover,
.autocomplete-item.active {
  background: #f0f4ff;
  color: #0066cc;
}
.autocomplete-item mark {
  background: transparent;
  color: #0066cc;
  font-weight: 600;
}

/* ---- Brand Sidebar ---- */
.sidebar-toggle {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 60px;
  background: #0066cc;
  border: none;
  border-radius: 0 4px 4px 0;
  color: white;
  font-size: 20px;
  cursor: pointer;
  z-index: 1000;
  transition: left 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.sidebar-toggle:hover {
  background: #0052a3;
}
.sidebar-toggle .notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  background: #ff4444;
  border-radius: 50%;
  border: 2px solid #0066cc;
  animation: pulse 2s ease-in-out infinite;
}
.sidebar-toggle:hover .notification-dot {
  border-color: #0052a3;
}
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7);
  }
  50% {
    transform: scale(1.2);
    box-shadow: 0 0 0 6px rgba(255, 68, 68, 0);
  }
}
.brand-sidebar {
  position: fixed;
  left: -320px;
  top: 0;
  width: 300px;
  height: 100vh;
  background: white;
  box-shadow: 2px 0 10px rgba(0,0,0,0.15);
  z-index: 999;
  transition: left 0.3s ease;
  display: flex;
  flex-direction: column;
}
.brand-sidebar.open {
  left: 0;
}
.brand-sidebar.open ~ .sidebar-toggle {
  left: 300px;
}
.sidebar-header {
  padding: 15px;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sidebar-header h3 {
  margin: 0;
  font-size: 16px;
  color: #333;
}
.sidebar-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0 5px;
  line-height: 1;
}
.sidebar-close:hover {
  color: #333;
}
.sidebar-controls {
  padding: 15px;
  border-bottom: 1px solid #eee;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-controls input {
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  width: 100%;
}
.sidebar-controls input:focus {
  outline: none;
  border-color: #0066cc;
}
.sidebar-sort-toggle {
  display: flex;
  background: #e9ecef;
  border-radius: 4px;
  overflow: hidden;
}
.sidebar-sort-toggle button {
  flex: 1;
  padding: 6px 10px;
  font-size: 13px;
  border: none;
  background: transparent;
  color: #666;
  cursor: pointer;
  transition: all 0.15s;
}
.sidebar-sort-toggle button.active {
  background: #0066cc;
  color: white;
}
.sidebar-sort-toggle button:hover:not(.active) {
  background: #dee2e6;
}
.sidebar-refresh {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  font-size: 14px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.sidebar-refresh:hover {
  background: #5a6268;
}
.sidebar-status {
  padding: 10px 15px;
  font-size: 13px;
  color: #666;
}
.sidebar-status.error {
  color: #dc3545;
  background: #f8d7da;
}
.sidebar-status.loading {
  color: #856404;
  background: #fff3cd;
}
.sidebar-status:empty {
  display: none;
}
.brand-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  padding: 0;
  margin: 0;
}
.brand-list-item {
  padding: 10px 15px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}
.brand-list-item:hover {
  background: #f8f9fa;
}
.brand-list-item .brand-name {
  font-weight: 500;
  color: #333;
}
.brand-list-item .brand-stock-value {
  color: #666;
  font-size: 12px;
}
.sidebar-cache-info {
  padding: 10px 15px;
  font-size: 11px;
  color: #999;
  border-top: 1px solid #eee;
  background: #f8f9fa;
}

/* ---- ABC Classification ---- */
.abc-section {
  margin-bottom: 32px;
}
.abc-cards {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.abc-card {
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  background: white;
  border: 1px solid #e5e5e7;
}
.abc-card.class-a {
  border-left: 4px solid #34c759;
}
.abc-card.class-b {
  border-left: 4px solid #ff9500;
}
.abc-card.class-c {
  border-left: 4px solid #ff3b30;
}
.abc-card-class {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 4px;
}
.abc-card-skus {
  font-size: 13px;
  color: #86868b;
  margin-bottom: 8px;
}
.abc-card-value {
  font-size: 18px;
  font-weight: 600;
}
.abc-card-pct {
  font-size: 13px;
  color: #86868b;
  margin-top: 4px;
}

/* ---- Section Title ---- */
.section-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ---- Zero-Cost Section ---- */
.zero-cost-section {
  border: 1px solid #ff3b30;
  border-radius: 12px;
  padding: 20px;
  margin-top: 32px;
  background: #fff5f5;
}
.zero-cost-header {
  color: #ff3b30;
  margin-top: 0;
  margin-bottom: 16px;
}

/* ---- Reliability Badge ---- */
.reliability-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}
.reliability-badge.reliable {
  background: #e8f5e9;
  color: #2e7d32;
}
.reliability-badge.unreliable {
  background: #fce4ec;
  color: #c62828;
}

/* ---- Row Highlighting ---- */
tr.row-unreliable td {
  background: #fff8f8;
}

/* ---- Cost Badge ---- */
.cost-badge.no-cost {
  color: #ff3b30;
  font-weight: 500;
}

/* ---- Bad Value ---- */
.bad-value {
  color: #ff3b30;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .abc-cards {
    grid-template-columns: 1fr;
  }
  .chart-row {
    grid-template-columns: 1fr;
  }
}

/* ---- Stock Tree ---- */
.tree-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.tree-level-config {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tree-level-label {
  font-size: 13px;
  font-weight: 500;
  color: #86868b;
  white-space: nowrap;
}
.tree-level-slots {
  display: flex;
  gap: 4px;
}
.tree-level-slot {
  min-width: 100px;
  min-height: 32px;
  border: 2px dashed #d2d2d7;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  transition: border-color 0.15s, background 0.15s;
}
.tree-level-slot.drag-over {
  border-color: #0066cc;
  background: rgba(0,102,204,0.06);
}
.tree-level-slot .tree-chip {
  border-style: solid;
}
.tree-level-bank {
  display: flex;
  gap: 4px;
  margin-left: 8px;
}
.tree-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #1d1d1f;
  background: #f0f0f2;
  border: 2px dashed #b0b0b5;
  border-radius: 8px;
  cursor: grab;
  user-select: none;
  white-space: nowrap;
  transition: background 0.15s, box-shadow 0.15s;
}
.tree-chip:active { cursor: grabbing; }
.tree-chip:hover { background: #e5e5e7; }
.tree-chip.dragging { opacity: 0.4; }
.tree-chip .chip-remove {
  font-size: 14px;
  line-height: 1;
  color: #86868b;
  cursor: pointer;
  padding: 0 2px;
}
.tree-chip .chip-remove:hover { color: #ff3b30; }
.btn-collapse-all {
  background: white;
  border: 1px solid #d2d2d7;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  color: #1d1d1f;
  transition: all 0.2s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  white-space: nowrap;
}
.btn-collapse-all:hover { background: #f5f5f7; border-color: #b0b0b5; }
.tree-search-wrap {
  margin-left: auto;
  position: relative;
}
.tree-suggestions {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 100%;
  max-height: 260px;
  overflow-y: auto;
  background: white;
  border: 1px solid #d2d2d7;
  border-top: none;
  border-radius: 0 0 8px 8px;
  padding: 4px 0;
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
  z-index: 100;
}
.tree-suggestions.hidden { display: none; }
.tree-suggestion-item {
  padding: 7px 12px;
  font-size: 13px;
  color: #1d1d1f;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-suggestion-item:hover,
.tree-suggestion-item.highlighted {
  background: #e9ecef;
}
.tree-suggestion-item mark {
  background: none;
  color: #0066cc;
  font-weight: 600;
}
.tree-suggestion-hint {
  padding: 5px 12px;
  font-size: 11px;
  color: #86868b;
  border-top: 1px solid #e8e8ed;
  margin-top: 2px;
}
.tree-search {
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: #f5f5f7;
  color: #1d1d1f;
  width: 220px;
  transition: all 0.2s;
}
.tree-search:focus {
  outline: none;
  border-color: #0066cc;
  background: white;
  box-shadow: 0 0 0 3px rgba(0,102,204,0.12);
}
.tree-search::placeholder { color: #b0b0b5; }
.tree-loading {
  text-align: center;
  padding: 60px 20px;
  color: #86868b;
  font-size: 15px;
}
.tree-loading::before {
  content: '';
  display: block;
  width: 28px;
  height: 28px;
  border: 2.5px solid #e5e5e7;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto 14px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.tree-container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.08);
  padding: 8px 0;
  outline: none;
  max-height: 70vh;
  overflow-y: auto;
}
.tree-container:empty { display: none; }
.tree-row {
  display: flex;
  align-items: center;
  padding: 6px 16px;
  cursor: default;
  border-radius: 0;
}
.tree-row:hover { background: #f5f5f7; }
.tree-row.tree-focused {
  background: #e8f0fe;
  outline: 2px solid #0066cc;
  outline-offset: -2px;
}
.tree-row.tree-focused:hover { background: #e8f0fe; }
.tree-row-group {
  font-weight: 600;
  font-size: 13px;
  color: #1d1d1f;
}
.tree-row-leaf {
  font-size: 13px;
  color: #1d1d1f;
}
.tree-indent {
  flex-shrink: 0;
}
.tree-toggle {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 10px;
  color: #86868b;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s, transform 0.15s;
}
.tree-toggle:hover { background: #e5e5e7; }
.tree-toggle.collapsed { transform: rotate(-90deg); }
.tree-group-label {
  flex: 1;
  margin: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-group-value {
  font-size: 12px;
  font-weight: 600;
  color: #6e6e73;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  white-space: nowrap;
}
.tree-leaf-id {
  width: 120px;
  flex-shrink: 0;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  color: #6e6e73;
  margin: 0 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tree-leaf-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-right: 12px;
}
.tree-leaf-qty {
  width: 70px;
  text-align: right;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  color: #6e6e73;
  flex-shrink: 0;
  margin-right: 12px;
}
.tree-leaf-value {
  width: 100px;
  text-align: right;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  font-weight: 600;
  color: #1d1d1f;
  flex-shrink: 0;
}
.tree-children.collapsed { display: none; }
.tree-highlight {
  background: #fff3cd;
  color: #856404;
  border-radius: 2px;
  padding: 0 1px;
}
.tree-no-results {
  text-align: center;
  padding: 40px 20px;
  color: #86868b;
  font-size: 14px;
}
.tree-copy-toast {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  background: #1d1d1f;
  color: white;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 10;
}
.tree-copy-toast.visible {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}
.tree-shortcuts {
  margin-top: 16px;
  font-size: 13px;
  color: #86868b;
}
.tree-shortcuts summary {
  cursor: pointer;
  font-weight: 500;
  color: #6e6e73;
  user-select: none;
  padding: 4px 0;
}
.tree-shortcuts summary:hover { color: #1d1d1f; }
.tree-shortcuts-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  align-items: center;
  margin-top: 10px;
  padding: 12px 16px;
  background: #f5f5f7;
  border-radius: 10px;
}
.tree-shortcuts-grid kbd {
  background: white;
  border: 1px solid #d2d2d7;
  border-radius: 5px;
  padding: 2px 8px;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  font-size: 12px;
  color: #1d1d1f;
  white-space: nowrap;
  box-shadow: 0 1px 0 #d2d2d7;
}
.tree-shortcuts-grid span {
  color: #6e6e73;
}

/* ---- Ekuep Potential ---- */
.ekuep-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.ekuep-controls label {
  font-size: 13px;
  font-weight: 500;
  color: #86868b;
  white-space: nowrap;
}
.ekuep-controls select {
  padding: 7px 12px;
  font-size: 13px;
  border: 1px solid #d2d2d7;
  border-radius: 8px;
  background: white;
  color: #1d1d1f;
  cursor: pointer;
  transition: all 0.2s;
}
.ekuep-controls select:focus {
  outline: none;
  border-color: #0066cc;
}
.ekuep-section-inner {
  max-width: 100%;
}
.ekuep-section-inner .table-wrapper {
  max-height: calc(100vh - 420px);
}
/* Brand table — uses the global th/td base styles (blue header) */
.ekuep-brand-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}
.ekuep-brand-table th {
  cursor: default;
}
.ekuep-sort-header {
  cursor: pointer !important;
  transition: background 0.15s;
}
.ekuep-sort-header:hover {
  background: #0055b3;
}
.ekuep-sort-header.active {
  background: #004999;
}
.ekuep-brand-row {
  cursor: pointer;
  transition: background 0.1s;
}
.ekuep-brand-row:hover td { background: #f0f4ff; }
.ekuep-brand-row.expanded td { background: #e8f0fe; }
.ekuep-brand-chevron {
  font-size: 10px;
  color: #86868b;
  text-align: center;
  transition: transform 0.15s;
}
.ekuep-brand-row.expanded .ekuep-brand-chevron { transform: rotate(90deg); display: inline-block; }
.ekuep-brand-name {
  font-weight: 600;
  color: #1d1d1f;
}
/* Item panel row — hidden by default */
.ekuep-items-panel-row {
  display: none;
}
.ekuep-items-panel-row.open {
  display: table-row;
}
.ekuep-items-panel-row > td {
  padding: 0 !important;
  border-bottom: 2px solid #e5e5e7;
}
/* Reservations copy button */
.res-copy-btn {
  background: none; border: none; cursor: pointer; font-size: 13px;
  opacity: 0.4; padding: 0 4px; vertical-align: middle;
}
.res-copy-btn:hover { opacity: 1; }

/* Nested reservations FSE table in client view */
.res-nested-table { margin: 0; border: none; }
.res-nested-table thead th { font-size: 11px; padding: 4px 8px; }

/* Reservations — Expected/Created date-basis switch (Age view only) */
.res-basis-control { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.res-basis-control.hidden { display: none; }
.res-anomaly-toggle { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; font-size: 13px; color: #444; cursor: pointer; user-select: none; }
.res-anomaly-toggle input { cursor: pointer; }

/* Reservations — Age (overdue) / Frozen Capital view */
.res-frozen-hero {
  background: #fff; border: 1px solid #e5e5e7; border-radius: 12px;
  padding: 16px 18px; margin-bottom: 14px;
}
.res-frozen-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px; color: #86868b; font-weight: 600; }
.res-frozen-basis { text-transform: none; letter-spacing: 0; font-weight: 500; color: #a0a0a5; }
.res-frozen-big { font-size: 34px; font-weight: 800; letter-spacing: -1px; color: #1d1d1f; line-height: 1.1; margin-top: 2px; }
.res-frozen-meta { color: #6b7280; font-size: 13px; margin-top: 6px; }
.res-frozen-caveat { margin-top: 10px; font-size: 11px; color: #9a8a3a; background: #fbf6e3; border: 1px solid #efe3b8; padding: 6px 10px; border-radius: 7px; display: inline-block; }
.res-age-bar { display: flex; height: 26px; border-radius: 7px; overflow: hidden; margin-top: 14px; border: 1px solid #e5e5e7; }
.res-age-bar > div { display: flex; align-items: center; justify-content: center; color: #fff; font-size: 10px; font-weight: 700; white-space: nowrap; min-width: 2px; }

/* Aging-bar segments + bucket-row accent dots */
.res-age-bar .res-age-365 { background: #7b241c; }
.res-age-bar .res-age-180 { background: #a93226; }
.res-age-bar .res-age-90 { background: #c0392b; }
.res-age-bar .res-age-61 { background: #e8590c; }
.res-age-bar .res-age-31 { background: #f0932b; }
.res-age-bar .res-age-0  { background: #b8860b; }
.res-age-row .ekuep-brand-name { font-weight: 700; }
.res-age-row .res-age-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 8px; vertical-align: middle; background: #6b7280; }
.res-age-row.res-age-365 .res-age-dot { background: #7b241c; }
.res-age-row.res-age-180 .res-age-dot { background: #a93226; }
.res-age-row.res-age-90 .res-age-dot { background: #c0392b; }
.res-age-row.res-age-61 .res-age-dot { background: #e8590c; }
.res-age-row.res-age-31 .res-age-dot { background: #f0932b; }
.res-age-row.res-age-0  .res-age-dot { background: #b8860b; }
.res-age-row.res-age-future .res-age-dot { background: #2f9e44; }
.res-age-row.res-age-nodate .res-age-dot { background: #6b7280; }

/* Item sub-table */
.ekuep-item-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
  background: #fafafa;
}
.ekuep-item-table th {
  background: #c8952e;
  color: white;
  font-size: 11px;
  padding: 8px 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  position: sticky;
  top: 37px;
  z-index: 9;
}
.ekuep-item-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0f2;
}
.ekuep-item-table .row-no-stock td { color: #999; }
.ekuep-item-table .row-new-item td {
  color: #8a6d00;
  background: #fffbeb;
}
.ekuep-item-sort {
  cursor: pointer !important;
  transition: background 0.15s;
}
.ekuep-item-sort:hover {
  background: #b0832a;
}
.ekuep-item-sort.active {
  background: #a07825;
}

/* ---- Ekuep Toggle Controls ---- */
.ekuep-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  margin-left: 8px;
}
.ekuep-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #0066cc;
  cursor: pointer;
  margin: 0;
}
.ekuep-toggle-label {
  font-size: 13px;
  font-weight: 500;
  color: #86868b;
  white-space: nowrap;
  user-select: none;
}

/* ---- Ekuep Presentation Mode ---- */
.ekuep-presentation .ekuep-brand-table {
  font-size: 17px;
}
.ekuep-presentation .ekuep-brand-table td.num {
  font-size: 17px;
}
.ekuep-presentation .ekuep-item-table {
  font-size: 16px;
}
.ekuep-presentation .ekuep-item-table td.num {
  font-size: 16px;
}
.ekuep-presentation .ekuep-item-table th {
  font-size: 15px;
}
/* Hide Product Name (col 2) and Category (col 3) in item detail */
.ekuep-presentation .ekuep-item-table th:nth-child(2),
.ekuep-presentation .ekuep-item-table td:nth-child(2),
.ekuep-presentation .ekuep-item-table th:nth-child(3),
.ekuep-presentation .ekuep-item-table td:nth-child(3) {
  display: none;
}

/* ---- Stock Changes Presentation Mode ---- */
.stockchanges-presentation .ekuep-brand-table {
  font-size: 17px;
}
.stockchanges-presentation .ekuep-brand-table td.num {
  font-size: 17px;
}
.stockchanges-presentation .ekuep-brand-table th {
  font-size: 15px;
}
/* Hide Product Name and Category columns in presentation mode (item-level) */
.stockchanges-presentation .sc-col-productname {
  display: none;
}
.stockchanges-presentation .sc-col-category {
  display: none;
}

/* ---- Key Items Presentation Mode ---- */
.keyitems-presentation .ekuep-brand-table {
  font-size: 17px;
}
.keyitems-presentation .ekuep-brand-table td.num {
  font-size: 17px;
}
.keyitems-presentation .ekuep-brand-table th {
  font-size: 15px;
}
/* Hide descriptive columns and the destructive per-row control on the big
   screen; Status, sparkline and PO flags stay — they are the story. */
.keyitems-presentation .ki-col-productName,
.keyitems-presentation .ki-col-remove {
  display: none;
}

/* ---- Ekuep Full-Screen ---- */
.ekuep-section-inner.view-expanded {
  position: fixed;
  top: 60px;
  left: 24px;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  background: #f5f5f5;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  padding: 16px 20px;
  overflow: hidden;
}
.ekuep-section-inner.view-expanded .ekuep-controls {
  flex-shrink: 0;
  margin-bottom: 12px;
}
.ekuep-section-inner.view-expanded .analytics-kpis {
  flex-shrink: 0;
  margin-bottom: 12px;
}
.ekuep-section-inner.view-expanded .table-wrapper {
  max-height: none;
  flex: 1;
  min-height: 0;
}

/* Reservation modal */
.res-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.res-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.res-modal {
  background: white;
  border-radius: 14px;
  width: 1000px;
  max-width: 94vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: scale(0.95);
  transition: transform 0.2s;
}
.res-modal-overlay.open .res-modal {
  transform: scale(1);
}
.res-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: #f5f5f7;
  border-radius: 14px 14px 0 0;
  border-bottom: 1px solid #e5e5e7;
}
.res-modal-title {
  font-size: 15px;
  font-weight: 600;
  color: #1d1d1f;
}
.res-modal-subtitle {
  font-size: 12px;
  color: #86868b;
  margin-left: 10px;
}
.res-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}
.res-loading {
  padding: 32px 20px;
  text-align: center;
  color: #86868b;
  font-size: 13px;
}
.res-summary {
  font-size: 13px;
  color: #86868b;
  margin-bottom: 12px;
  font-weight: 500;
}
.res-empty, .res-error {
  text-align: center;
  color: #86868b;
  font-size: 13px;
  padding: 24px 0;
}
.res-error { color: #ff3b30; }
.res-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.res-table th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: #6e6e73;
  padding: 8px 10px;
  border-bottom: 1px solid #d2d2d7;
  background: #f5f5f7;
  white-space: nowrap;
}
.res-table th.num { text-align: right; }
.res-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f0f2;
  color: #1d1d1f;
}
.res-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.res-table tr:hover { background: #f5f5f7; }
.res-type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  background: #e8f0fe;
  color: #1a56db;
  white-space: nowrap;
}

/* Row-selection column in the reservations table */
.res-table th.res-select-col,
.res-table td.res-select-col {
  width: 34px;
  text-align: center;
  padding-left: 12px;
  padding-right: 4px;
}
.res-table .res-select-col input[type="checkbox"] {
  cursor: pointer;
  margin: 0;
}

/* Modal footer with the "Send to ops on Slack" action */
.res-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 12px 20px;
  background: #f5f5f7;
  border-top: 1px solid #e5e5e7;
  border-radius: 0 0 14px 14px;
}
.res-send-status {
  font-size: 12px;
  color: #86868b;
  margin-right: auto;
}
.res-send-status.ok { color: #1a7f37; }
.res-send-status.error { color: #ff3b30; }
.res-send-btn {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: #4a1d96;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
}
.res-send-btn:hover:not(:disabled) { background: #3b1675; }
.res-send-btn:disabled {
  background: #c7c7cc;
  cursor: not-allowed;
}

/* Reserved qty link in tables */
a.qty-reserved-link {
  color: #0066cc;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px dashed #0066cc;
}
a.qty-reserved-link:hover {
  color: #0055b3;
  border-bottom-style: solid;
}

.hidden { display: none !important; }

/* =====================================================================
   MOBILE STOCK EXPERIENCE  (scoped under .is-mobile — desktop untouched)
   ===================================================================== */

/* ---- Hide desktop chrome on mobile ---- */
.is-mobile .brand-sidebar,
.is-mobile .sidebar-toggle { display: none !important; }
.is-mobile .filter-toggle,
.is-mobile .filter-panel { display: none !important; }
.is-mobile .results-toolbar { display: none; }
.is-mobile .pagination-controls { display: none !important; }
.is-mobile .table-wrapper { display: none; }

/* Table-view toggle: power-user horizontal-scroll table */
.is-mobile #detailView.m-show-table .table-wrapper,
.is-mobile #summaryView.m-show-table .table-wrapper { display: block; max-height: none; }
.is-mobile #detailView.m-show-table .m-cards,
.is-mobile #summaryView.m-show-table .m-cards,
.is-mobile #detailView.m-show-table .m-loadmore,
.is-mobile #summaryView.m-show-table .m-loadmore { display: none; }

/* ---- Layout ---- */
.is-mobile .page-container { padding: 16px 14px calc(24px + env(safe-area-inset-bottom)); }
.is-mobile .page-header { margin-bottom: 16px; padding-bottom: 14px; flex-wrap: wrap; gap: 8px; align-items: center; }
.is-mobile .page-header h1 { font-size: 24px; }
.is-mobile .page-header .subtitle { font-size: 13px; }
.is-mobile .btn-logout { padding: 6px 12px; font-size: 12px; }

/* ---- Tab bar ---- */
.is-mobile .tab-bar { display: flex; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.is-mobile .tab-bar::-webkit-scrollbar { display: none; }
.is-mobile .tab-btn { flex: 1 0 auto; padding: 9px 16px; white-space: nowrap; }
/* Only Detail + Summary are available on mobile — hide the desktop-only tabs. */
.is-mobile #tabTree,
.is-mobile #tabAnalytics { display: none; }

/* ---- Filter bar (button + chip strip) ---- */
.m-filterbar { display: none; }
.is-mobile .m-filterbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.m-filterbtn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff; border: 1px solid #d2d2d7; border-radius: 20px;
  padding: 8px 16px; font-size: 14px; font-weight: 600; color: #1d1d1f;
  flex-shrink: 0; box-shadow: 0 1px 3px rgba(0,0,0,0.06); cursor: pointer;
}
.m-filter-ico { font-size: 14px; }
.m-filtercount { background: #0066cc; color: #fff; border-radius: 10px; font-size: 11px; font-weight: 700; padding: 1px 7px; }
.m-chips { display: flex; gap: 6px; overflow-x: auto; -webkit-overflow-scrolling: touch; flex: 1; padding-bottom: 2px; }
.m-chips::-webkit-scrollbar { display: none; }
.m-chip-active {
  display: inline-flex; align-items: center; gap: 4px;
  background: #eef2f7; border-radius: 16px; padding: 5px 6px 5px 12px;
  font-size: 13px; white-space: nowrap; color: #1d1d1f; flex-shrink: 0;
}
.m-chip-x {
  border: none; background: rgba(0,0,0,0.08); width: 18px; height: 18px;
  border-radius: 50%; font-size: 14px; line-height: 1; color: #6e6e73;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}

/* ---- Result bar (count / Sort / Table / overflow) ---- */
.m-resultbar { display: none; }
.is-mobile .m-resultbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; gap: 8px; }
.m-count { font-size: 13px; font-weight: 600; color: #6e6e73; }
.m-resultbar-actions { display: flex; gap: 6px; }
.m-rb-btn { background: #fff; border: 1px solid #d2d2d7; border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 500; color: #1d1d1f; cursor: pointer; }
.m-rb-btn.on { background: #0066cc; color: #fff; border-color: #0066cc; }
.m-rb-more { padding: 7px 10px; }

/* ---- Cards ---- */
.m-cards { display: none; }
.is-mobile .m-cards { display: flex; flex-direction: column; gap: 10px; }
.m-card {
  background: #fff; border: 1px solid #ececef; border-radius: 14px;
  padding: 14px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); cursor: pointer;
}
.m-card:active { background: #fafafa; }
.m-card-main { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.m-card-id { min-width: 0; flex: 1; }
.m-card-title {
  font-size: 15px; font-weight: 600; color: #1d1d1f; line-height: 1.3;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.m-card-sub { font-size: 12px; color: #86868b; margin-top: 2px; }
.m-card-value { text-align: right; flex-shrink: 0; }
.m-card-value-num { font-size: 16px; font-weight: 700; color: #1d1d1f; white-space: nowrap; }
.m-card-value-label { font-size: 12px; color: #86868b; margin-top: 2px; }
.m-card-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.m-card-chip { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 10px; background: #eef2f7; color: #44546a; text-transform: uppercase; letter-spacing: 0.3px; }
.m-card-chip.bad { background: #fdecea; color: #c62828; }
.m-card-chip.ok { background: #e8f5e9; color: #2e7d32; }
.m-card-chip.muted { background: #f0f0f2; color: #86868b; }

/* Summary good/bad split */
.m-split { margin-top: 10px; }
.m-split-bar { display: flex; height: 6px; border-radius: 3px; overflow: hidden; background: #f0f0f2; }
.m-split-good { background: #34c759; }
.m-split-bad { background: #ff3b30; }
.m-split-nums { font-size: 12px; margin-top: 5px; color: #6e6e73; }
.m-split-nums .good { color: #2e7d32; font-weight: 600; }
.m-split-nums .bad { color: #c62828; font-weight: 600; }

/* Load-more */
.m-loadmore { display: none; }
.is-mobile .m-loadmore {
  display: block; width: 100%; margin-top: 14px; padding: 13px;
  background: #fff; border: 1px solid #d2d2d7; border-radius: 12px;
  font-size: 14px; font-weight: 600; color: #0066cc; cursor: pointer;
}
.is-mobile .m-loadmore:disabled { color: #86868b; }

/* ---- Filter sheet rows ---- */
.m-filter-row { display: flex; align-items: center; gap: 10px; padding: 14px 2px; border-bottom: 1px solid #f0f0f2; }
.m-filter-drill { width: 100%; background: none; border: none; border-bottom: 1px solid #f0f0f2; text-align: left; cursor: pointer; }
.m-filter-row-label { font-size: 14px; color: #1d1d1f; font-weight: 500; flex-shrink: 0; }
.m-filter-row-value { margin-left: auto; color: #86868b; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 55%; text-align: right; }
.m-filter-row-chev { color: #c7c7cc; font-size: 20px; margin-left: 8px; }
.m-filter-input { flex-direction: column; align-items: stretch; gap: 6px; }
.m-filter-input .m-filter-row-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; color: #86868b; }
.m-filter-text, .m-filter-select { width: 100%; padding: 11px 12px; font-size: 16px; border: 1px solid #d2d2d7; border-radius: 9px; background: #f5f5f7; color: #1d1d1f; }
.m-filter-company { flex-direction: column; align-items: stretch; gap: 8px; }
.m-company-chips { display: flex; gap: 8px; }
.m-company-chip { flex: 1; padding: 10px; border: 1px solid #d2d2d7; border-radius: 9px; background: #f5f5f7; font-weight: 600; font-size: 14px; color: #6e6e73; cursor: pointer; }
.m-company-chip.on { background: #0066cc; color: #fff; border-color: #0066cc; }
.m-filter-preset { flex-direction: row; flex-wrap: nowrap; align-items: center; gap: 8px; }
.m-filter-preset .m-filter-row-label { flex-shrink: 0; }
.m-filter-preset .m-filter-select { flex: 1; }
.m-preset-save { padding: 9px 14px; border: 1px solid #d2d2d7; border-radius: 9px; background: #fff; font-weight: 600; font-size: 14px; color: #0066cc; cursor: pointer; flex-shrink: 0; }

/* Filter sheet footer (Reset / Apply) */
.m-filter-footer { display: flex; gap: 10px; width: 100%; }
.m-sheet-reset { flex: 0 0 auto; padding: 14px 22px; border: 1px solid #d2d2d7; border-radius: 11px; background: #fff; font-weight: 600; font-size: 15px; color: #1d1d1f; cursor: pointer; }
.m-sheet-apply { flex: 1; padding: 14px; border: none; border-radius: 11px; background: #0066cc; color: #fff; font-weight: 700; font-size: 16px; cursor: pointer; }

/* ---- Multi-select sub-screen ---- */
.m-sub-wrap { display: flex; flex-direction: column; height: 60dvh; }
.m-sub-search { width: 100%; padding: 11px 12px; font-size: 16px; border: 1px solid #d2d2d7; border-radius: 9px; background: #f5f5f7; margin-bottom: 10px; flex-shrink: 0; }
.m-sub-list { overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.m-sub-item { display: flex; align-items: center; gap: 10px; padding: 12px 4px; border-bottom: 1px solid #f5f5f7; cursor: pointer; }
.m-sub-check { width: 20px; height: 20px; border: 1.5px solid #c7c7cc; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #fff; flex-shrink: 0; }
.m-sub-item.checked .m-sub-check { background: #0066cc; border-color: #0066cc; }
.m-sub-label { flex: 1; font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-sub-mode { flex-shrink: 0; padding: 3px 10px; border: none; border-radius: 7px; font-size: 11px; font-weight: 700; text-transform: uppercase; cursor: pointer; opacity: 0; pointer-events: none; }
.m-sub-item.checked .m-sub-mode { opacity: 1; pointer-events: auto; }
.m-sub-mode[data-mode="include"] { background: #e8f5e9; color: #2e7d32; }
.m-sub-mode[data-mode="exclude"] { background: #fdecea; color: #c62828; }
.m-sub-empty { padding: 24px; text-align: center; color: #86868b; }

/* ---- Sort sheet ---- */
.m-sort-dir { display: flex; gap: 8px; margin-bottom: 14px; }
.m-sort-dir-btn { flex: 1; padding: 11px; border: 1px solid #d2d2d7; border-radius: 10px; background: #f5f5f7; font-weight: 600; font-size: 14px; color: #6e6e73; cursor: pointer; }
.m-sort-dir-btn.on { background: #0066cc; color: #fff; border-color: #0066cc; }
.m-sort-list { display: flex; flex-direction: column; }
.m-sort-field { text-align: left; padding: 14px 6px; border: none; border-bottom: 1px solid #f0f0f2; background: none; font-size: 15px; color: #1d1d1f; cursor: pointer; }
.m-sort-field.on { color: #0066cc; font-weight: 700; }
.m-sort-field.on::after { content: '✓'; float: right; }

/* ---- Card detail sheet ---- */
.m-detail-list { display: flex; flex-direction: column; }
.m-detail-row { display: flex; justify-content: space-between; gap: 14px; padding: 12px 2px; border-bottom: 1px solid #f5f5f7; }
.m-detail-key { font-size: 13px; color: #86868b; flex-shrink: 0; }
.m-detail-val { font-size: 14px; color: #1d1d1f; text-align: right; font-weight: 500; word-break: break-word; }
.m-detail-val.bad { color: #c62828; }
.m-detail-row-res { cursor: pointer; }
.m-detail-row-res .m-detail-val { color: #0066cc; border-bottom: 1px dashed #0066cc; }
.m-detail-res { width: 100%; margin-top: 16px; padding: 13px; border: 1px solid #0066cc; border-radius: 11px; background: #fff; color: #0066cc; font-weight: 600; font-size: 15px; cursor: pointer; }

/* ---- Reservation sheet ---- */
.m-res-list { display: flex; flex-direction: column; gap: 10px; }
.m-res-loading, .m-res-empty { padding: 24px; text-align: center; color: #86868b; }
.m-res-summary { font-size: 13px; color: #6e6e73; font-weight: 600; padding: 4px 0 6px; }
.m-res-card { background: #f7f8fa; border-radius: 11px; padding: 12px; }
.m-res-card-top { display: flex; justify-content: space-between; gap: 10px; }
.m-res-party { font-weight: 600; font-size: 14px; color: #1d1d1f; }
.m-res-qty { font-weight: 700; color: #1d1d1f; }
.m-res-card-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; font-size: 12px; color: #86868b; }
.m-res-type { background: #eef2f7; padding: 1px 8px; border-radius: 8px; color: #44546a; }

/* ---- Overflow menu ---- */
.m-overflow-list { display: flex; flex-direction: column; }
.m-overflow-item { text-align: left; padding: 15px 6px; border: none; border-bottom: 1px solid #f0f0f2; background: none; font-size: 16px; color: #1d1d1f; cursor: pointer; }
