/* ============================================================
   Vivara VIVA3 Equity Monitor — Styles
   ============================================================ */

:root {
  --primary:      #0f1923;
  --secondary:    #1a2738;
  --accent:       #c9a84c;
  --accent-light: #e8c96a;
  --card-bg:      #ffffff;
  --bg:           #f2f4f8;
  --text:         #1a2738;
  --text-sec:     #556070;
  --text-muted:   #8a96a3;
  --border:       #e2e6ea;
  --success:      #1a8754;
  --warning:      #d97706;
  --danger:       #c0392b;
  --info:         #1d6fa5;
  --purple:       #6d28d9;
  --shadow:       0 1px 8px rgba(0,0,0,0.07);
  --shadow-md:    0 4px 16px rgba(0,0,0,0.10);
  --radius:       10px;
  --font:         'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---- Header ---- */
header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  position: sticky;
  top: 0;
  z-index: 200;
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.header-left h1 span { color: var(--accent); }
.header-sub { font-size: 0.72rem; opacity: 0.6; letter-spacing: 1px; text-transform: uppercase; margin-top: 2px; }

.header-right { text-align: right; }
.header-meta { font-size: 0.78rem; opacity: 0.7; }
.run-badge {
  font-size: 0.72rem;
  margin-top: 3px;
  padding: 2px 8px;
  border-radius: 10px;
  display: inline-block;
}
.run-badge.status-success { background: #1a875422; color: #4ade80; border: 1px solid #1a8754; }
.run-badge.status-partial  { background: #d9770622; color: #fbbf24; border: 1px solid #d97706; }
.run-badge.status-failed   { background: #c0392b22; color: #f87171; border: 1px solid #c0392b; }

/* ---- Tab Nav ---- */
.tab-nav {
  background: var(--primary);
  display: flex;
  gap: 0;
  padding: 0 28px;
  border-bottom: 2px solid rgba(255,255,255,0.07);
}

.tab-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.55);
  padding: 10px 18px;
  font-size: 0.83rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.2px;
}
.tab-btn:hover { color: rgba(255,255,255,0.85); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* ---- Filters Bar ---- */
.filters-bar {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 10px 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.filter-group { display: flex; align-items: center; gap: 6px; }
.filter-group label { font-size: 0.78rem; font-weight: 600; color: var(--text-sec); white-space: nowrap; }

.filter-group input {
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  background: #fafbfc;
  color: var(--text);
  transition: border-color 0.15s;
}
.filter-group input { width: 160px; }
.filter-group input:focus { outline: none; border-color: var(--accent); }

/* ---- Multi-Select Filter ---- */
.multiselect { position: relative; }

.ms-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.82rem;
  background: #fafbfc;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s;
  white-space: nowrap;
  min-width: 100px;
  font-family: var(--font);
}
.ms-btn:hover, .ms-btn.open { border-color: var(--accent); outline: none; }
.ms-label { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; max-width: 100px; }
.ms-arrow { font-size: 0.7rem; color: var(--text-muted); transition: transform 0.15s; }
.ms-btn.open .ms-arrow { transform: rotate(180deg); }
.ms-count {
  background: var(--accent);
  color: var(--primary);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 0.68rem;
  font-weight: 700;
  flex-shrink: 0;
}

.ms-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 400;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  min-width: 160px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px 0;
}

.ms-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text);
  transition: background 0.1s;
  user-select: none;
}
.ms-item:hover { background: #f6f8fa; }
.ms-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.btn {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary { background: var(--accent); color: var(--primary); }
.btn-primary:hover { background: var(--accent-light); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text-sec); }
.btn-ghost:hover { background: #f0f2f5; }

/* ---- KPI Bar persistente ---- */
.kpi-bar {
  background: var(--bg);
  border-top: 1px solid var(--border);
  border-bottom: 2px solid var(--border);
  padding: 14px 28px;
}
.kpi-bar-inner {
  display: flex;
  gap: 14px;
  align-items: stretch;
  max-width: 1500px;
  margin: 0 auto;
  flex-wrap: wrap;
}
.kpi-bar-inner .kpi-card {
  flex: 1;
  min-width: 150px;
  margin-bottom: 0;
}
.kpi-bar-inner .kpi-value { font-size: 1.6rem; }

/* ---- Tab Content ---- */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ---- Main ---- */
.main {
  padding: 22px 28px;
  max-width: 1500px;
  margin: 0 auto;
}

/* ---- KPI Row ---- */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.kpi-card {
  background: white;
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid transparent;
  transition: transform 0.15s, box-shadow 0.15s;
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-card.blue   { border-left-color: var(--info); }
.kpi-card.green  { border-left-color: var(--success); }
.kpi-card.amber  { border-left-color: var(--warning); }
.kpi-card.red    { border-left-color: var(--danger); }
.kpi-card.purple { border-left-color: var(--purple); }

.kpi-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.kpi-label { font-size: 0.75rem; color: var(--text-muted); margin-top: 5px; }

/* ---- Section Block ---- */
.section-block {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  margin-bottom: 18px;
}

.section-header { margin-bottom: 14px; }
.section-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  display: block;
}
.section-hint { font-size: 0.76rem; color: var(--text-muted); display: block; margin-top: 2px; }

/* ---- Insight Box ---- */
.insight-box {
  background: linear-gradient(135deg, #0f1923, #1a3048);
  color: rgba(255,255,255,0.85);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-size: 0.82rem;
  line-height: 1.6;
  margin-bottom: 20px;
  border-left: 4px solid var(--accent);
}
.insight-box strong { color: var(--accent); }

/* ---- Grids ---- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}
.grid-2-1 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

/* ---- Charts ---- */
.chart-wrap { position: relative; width: 100%; }
.chart-wrap canvas { width: 100% !important; }
.h240 { height: 240px; }
.h280 { height: 280px; }
.h300 { height: 300px; }

.no-data {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 100px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
  text-align: center;
}

/* ---- Alerts ---- */
.alerts-list { display: flex; flex-direction: column; gap: 8px; }

.alert-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 7px;
  font-size: 0.82rem;
}
.alert-item.alert-up   { background: #fef2f2; border-left: 3px solid var(--danger); }
.alert-item.alert-down { background: #f0fdf4; border-left: 3px solid var(--success); }
.alert-item.alert-promo { background: #fffbeb; border-left: 3px solid var(--warning); }

.alert-icon { font-size: 1rem; flex-shrink: 0; }
.alert-name { font-weight: 600; color: var(--text); flex: 1; }
.alert-detail { color: var(--text-sec); white-space: nowrap; }

.no-data-inline {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
  padding: 12px 0;
}

/* ---- Mini Table ---- */
.mini-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.mini-table th {
  background: #f6f8fa;
  color: var(--text-sec);
  padding: 10px 12px;
  text-align: left;
  font-weight: 700;
  font-size: 0.75rem;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}
.mini-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.mini-table tr:last-child td { border-bottom: none; }
.mini-table tbody tr:hover td { background: #f8f9fc; }

.price-bold  { font-weight: 700; font-size: 0.92rem; }
.price-muted { color: var(--text-muted); text-decoration: line-through; }
.price-up    { color: var(--danger); font-weight: 600; }
.price-down  { color: var(--success); font-weight: 600; }
.price-same  { color: var(--text-muted); }
.price-saving { color: var(--success); font-weight: 600; }

.badge-discount {
  display: inline-block;
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fca5a5;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 0.73rem; font-weight: 600; }
.badge-disponivel   { background: #d1fae5; color: #065f46; }
.badge-indisponivel { background: #fee2e2; color: #991b1b; }

.item-link { cursor: pointer; font-weight: 600; color: var(--text); }
.item-link:hover { color: var(--accent); text-decoration: underline; }

/* ---- Runs table ---- */
.runs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.runs-table th {
  background: #f6f8fa;
  color: var(--text-sec);
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.runs-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f4f5f7;
}
.status-success { color: var(--success); font-weight: 600; }
.status-partial  { color: var(--warning); font-weight: 600; }
.status-failed   { color: var(--danger); font-weight: 600; }

/* ---- Promo Heatmap ---- */
.heatmap-scroll {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.heatmap-table {
  border-collapse: collapse;
  font-size: 0.78rem;
  min-width: 100%;
}
.heatmap-table th {
  padding: 8px 10px;
  background: #f6f8fa;
  color: var(--text-sec);
  text-align: center;
  font-weight: 700;
  border: 1px solid #edf0f4;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}
.heatmap-item-name {
  padding: 8px 12px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  border: 1px solid #edf0f4;
  background: #fafbfc;
  min-width: 220px;
  max-width: 260px;
  border-right: 2px solid var(--border);
}
.heatmap-td {
  padding: 6px 8px;
  text-align: center;
  border: 1px solid #edf0f4;
  cursor: default;
  font-weight: 600;
  font-size: 0.73rem;
  min-width: 54px;
}
.hm-none   { background: #f8f9fa; color: #ccc; }
.hm-low    { background: #fef9c3; color: #92400e; }
.hm-mid    { background: #fed7aa; color: #7c2d12; }
.hm-high   { background: #fca5a5; color: #7f1d1d; }

.heatmap-legend {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 0.73rem;
  font-weight: 600;
}

/* ---- Shipping Grid ---- */
.shipping-heatmap-outer { display: flex; flex-direction: column; gap: 14px; }
.shipping-region-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.shipping-cities {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.city-cell {
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 0.76rem;
  text-align: center;
  min-width: 110px;
  cursor: default;
}
.city-name  { font-weight: 700; display: block; }
.city-prazo { font-size: 1rem; font-weight: 700; display: block; margin: 2px 0; }
.city-avail { font-size: 0.68rem; opacity: 0.8; display: block; }

.hm-fast    { background: #d1fae5; color: #065f46; }
.hm-medium  { background: #fef3c7; color: #78350f; }
.hm-slow    { background: #fee2e2; color: #7f1d1d; }
.hm-unavail { background: #f3f4f6; color: #9ca3af; }

/* ---- Ship mini grid (in portfolio) ---- */
.ship-mini-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
.ship-cell {
  padding: 5px 8px;
  border-radius: 5px;
  font-size: 0.70rem;
  text-align: center;
  min-width: 80px;
}
.ship-city  { font-weight: 600; display: block; }
.ship-prazo { font-size: 0.85rem; font-weight: 700; display: block; }

/* ---- Portfolio Table ---- */
.table-wrapper {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
/* Full dark header only when table is inside .table-wrapper (Portfolio tab) */
.table-wrapper .items-table { border: none; border-radius: 0; }
.table-wrapper .items-table th {
  background: var(--primary);
  color: rgba(255,255,255,0.85);
}
.table-wrapper .items-table th:hover { background: var(--secondary); }

/* Light header when table is inside a .section-block (inline tables) */
.items-table th {
  background: #f6f8fa;
  color: var(--text-sec);
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.2px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
}
.items-table th:hover { background: #edf0f4; }
.items-table th.sorted-asc::after  { content: ' ↑'; color: var(--accent); }
.items-table th.sorted-desc::after { content: ' ↓'; color: var(--accent); }

.items-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.items-table tr:last-child td { border-bottom: none; }
.items-table tbody tr:hover td { background: #f8f9fc; }
.items-table tr.data-row:hover td { background: #fafbfc; }
.items-table tr.detail-row td { padding: 0; background: #f8f9fc; }

.btn-expand {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 2px 7px;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: all 0.15s;
}
.btn-expand:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* ---- Item Detail Panel ---- */
.chart-subtitle {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-sec);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.item-chart-wrap { height: 180px; position: relative; }

/* ---- Loading ---- */
.loading { text-align: center; padding: 60px 20px; color: var(--text-muted); }

/* ---- Badges ---- */
.badge-desc {
  display: inline-block;
  background: #fef2f2;
  color: var(--danger);
  border: 1px solid #fca5a5;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

/* ---- Run Badge ---- */
.badge-run {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
}
.badge-run-success { background: #1a875422; color: #4ade80; border: 1px solid #1a8754; }
.badge-run-partial  { background: #d9770622; color: #fbbf24; border: 1px solid #d97706; }
.badge-run-failed   { background: #c0392b22; color: #f87171; border: 1px solid #c0392b; }

/* ---- Alerts (sistema) ---- */
.alert-warn  { background: #fffbeb; border-left: 3px solid var(--warning); }
.alert-empty { color: var(--text-muted); font-size: 0.82rem; font-style: italic; padding: 12px 0; }

/* ---- Aba Alertas de disponibilidade ---- */
.badge-ok   { background: #d1fae5; color: #065f46; }
.badge-err  { background: #fee2e2; color: #991b1b; }
.badge-warn { background: #fef3c7; color: #92400e; }
.badge-muted { background: #e2e8f0; color: #64748b; font-size: 0.72rem; padding: 1px 5px; border-radius: 10px; }

.alert-row { font-size: 0.84rem; }
.alert-row:hover { background: #f8fafc; }
.alert-row-resolved { opacity: 0.55; }
.alert-row-resolved:hover { opacity: 0.8; background: #f8fafc; }
.alert-sev-high td:first-child { border-left: 3px solid #ef4444; }
.alert-sev-medium td:first-child { border-left: 3px solid #f59e0b; }

.alert-nome  { font-weight: 600; max-width: 220px; }
.alert-motivo { font-family: monospace; font-size: 0.78rem; background: #f1f5f9; padding: 1px 6px; border-radius: 4px; }
.alert-verif { font-size: 0.78rem; color: #475569; }
.alert-verif span { cursor: help; }
.alert-link  { color: var(--primary); font-size: 0.8rem; text-decoration: none; }
.alert-link:hover { text-decoration: underline; }

.brand-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

/* ---- Price cells ---- */
.price-current { font-weight: 700; font-size: 0.92rem; }
.item-name-cell { font-weight: 600; }

/* ---- Btn small ---- */
.btn-sm {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 2px 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  transition: all 0.15s;
}
.btn-sm:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* ---- Promo Calendar Heatmap ---- */
.promo-calendar {
  border-collapse: collapse;
  font-size: 0.73rem;
  min-width: 100%;
}
.promo-calendar th { padding: 0; }
.cal-prod-header {
  padding: 6px 10px;
  background: #f6f8fa;
  color: var(--text-sec);
  text-align: left;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
  min-width: 200px;
}
.cal-date {
  padding: 4px 2px;
  background: #f6f8fa;
  color: var(--text-muted);
  text-align: center;
  font-weight: 600;
  border: 1px solid var(--border);
  white-space: nowrap;
  min-width: 36px;
  font-size: 0.68rem;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  height: 48px;
}
.cal-item-name {
  padding: 4px 10px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  border: 1px solid var(--border);
  background: #fafbfc;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-cell {
  border: 1px solid var(--border);
  min-width: 36px;
  height: 22px;
  cursor: default;
}
.hm-no-data { background: #f8f9fa; }

/* ---- Shipping Heatmap Grid (Logística tab) ---- */
.ship-regiao { margin-bottom: 18px; }
.ship-regiao-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.ship-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
/* Override old .ship-cell to support new sub-elements */
.ship-cell {
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 0.76rem;
  text-align: center;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ship-city  { font-weight: 700; font-size: 0.78rem; }
.ship-uf    { font-size: 0.68rem; opacity: 0.7; }
.ship-days  { font-size: 0.88rem; font-weight: 700; }
.ship-avail { font-size: 0.68rem; opacity: 0.8; }

/* ---- Portfolio Detail Panel ---- */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  padding: 18px 20px;
  background: #f8f9fc;
  border-top: 2px solid var(--accent);
}
.detail-section-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-sec);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 10px;
}
.detail-ship-content { display: flex; flex-direction: column; gap: 10px; }
.detail-region { }
.detail-region-title { font-size: 0.72rem; color: var(--text-muted); display: block; margin-bottom: 5px; }
.detail-cities { display: flex; flex-wrap: wrap; gap: 4px; }
.detail-city {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 5px;
  font-size: 0.68rem;
  text-align: center;
  min-width: 68px;
  line-height: 1.4;
}

/* ---- Promo Weekly Heatmap ---- */
.promo-heatmap-grid {
  overflow-x: auto;
  margin-top: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.promo-heatmap-grid table {
  border-collapse: collapse;
  font-size: 0.78rem;
  min-width: 100%;
}
.promo-heatmap-grid th,
.promo-heatmap-grid td {
  padding: 8px 12px;
  border: 1px solid #edf0f4;
  text-align: center;
  white-space: nowrap;
}
.promo-heatmap-grid th {
  background: #f6f8fa;
  color: var(--text-sec);
  font-weight: 700;
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.2px;
  border-bottom: 2px solid var(--border);
}
.promo-heatmap-grid td.hm-cat {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  background: #fafbfc;
  min-width: 140px;
  border-right: 2px solid var(--border);
}
.hm-0   { background: #fafbfc;  color: #ccc; }
.hm-10  { background: #fef9c3; color: #92400e; }
.hm-20  { background: #fde68a; color: #78350f; }
.hm-40  { background: #fdba74; color: #7c2d12; }
.hm-60  { background: #f87171; color: #fff; }
.hm-80  { background: #dc2626; color: #fff; }

/* ---- Pass-Through Zone annotations ---- */
.passthrough-zones { font-size: 0.72rem; display: flex; gap: 12px; margin-top: 6px; }
.zone-label { display: inline-flex; align-items: center; gap: 4px; }
.zone-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.zone-green  { background: rgba(34,197,94,0.3); }
.zone-yellow { background: rgba(234,179,8,0.3); }
.zone-red    { background: rgba(239,68,68,0.3); }

/* ---- Brand KPI Table ---- */
.brand-kpi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}
.brand-kpi-table th {
  background: #f6f8fa;
  color: var(--text-sec);
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.2px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
  text-transform: uppercase;
}
.brand-kpi-table th:hover { background: #edf0f4; }
.brand-kpi-table th::after { content: ' \2195'; color: var(--text-muted); font-size: 0.65rem; }
.brand-kpi-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
.brand-kpi-table tr:last-child td { border-bottom: none; }
.brand-kpi-table tbody tr:hover td { background: #f8f9fc; }
.brand-kpi-table td:first-child { font-weight: 600; }

.brand-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
}

.brand-cell-good {
  background: rgba(16,185,129,0.12);
  color: #065f46;
  font-weight: 600;
}
.brand-cell-bad {
  background: rgba(239,68,68,0.10);
  color: #991b1b;
  font-weight: 600;
}

/* ---- Alerts ---- */
.alerts-list { display: flex; flex-direction: column; gap: 6px; }
.alert-item {
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.alert-system-error {
  background: rgba(239,68,68,0.10);
  border-left: 3px solid #dc2626;
  color: #7f1d1d;
}
.alert-system-warn {
  background: rgba(251,191,36,0.12);
  border-left: 3px solid #d97706;
  color: #78350f;
}
.alert-up   { background: rgba(239,68,68,0.08);  border-left: 3px solid #ef4444; color: #7f1d1d; }
.alert-down { background: rgba(34,197,94,0.08);  border-left: 3px solid #22c55e; color: #14532d; }
.alert-warn { background: rgba(251,191,36,0.10); border-left: 3px solid #f59e0b; color: #78350f; }
.alert-empty { color: #6b7280; font-size: 13px; padding: 8px 0; }
.alert-badge {
  font-weight: 700;
  font-size: 11px;
  white-space: nowrap;
}
.alert-date {
  margin-left: auto;
  font-size: 11px;
  color: #9ca3af;
  white-space: nowrap;
}

/* ---- Margin Proxy Lag Controls ---- */
.margin-proxy-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.margin-proxy-lag-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.margin-lag-btn {
  padding: 3px 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.margin-lag-btn:hover { border-color: var(--primary); color: var(--primary); }
.margin-lag-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.margin-lag-hint {
  font-size: 11px;
  color: var(--primary);
  font-style: italic;
}

/* ---- EW/VW Toggle ---- */
.weight-toggle-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.weight-toggle-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.weight-toggle-btn {
  padding: 4px 14px;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  transition: all 0.15s;
}
.weight-toggle-btn:hover { border-color: var(--primary); color: var(--primary); }
.weight-toggle-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.weight-toggle-hint {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
}

/* ---- Sensitivity Table ---- */
.sens-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.sens-period-toggle { display: flex; gap: 4px; }
.sens-period-btn {
  padding: 3px 10px;
  border: 1.5px solid var(--border);
  background: #fff;
  border-radius: 14px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
}
.sens-period-btn:hover { border-color: var(--primary); color: var(--primary); }
.sens-period-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.sens-context {
  font-size: 12px;
  color: var(--text);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
}
.sens-up { color: #dc2626; }
.sens-down { color: #16a34a; }
.sens-real-badge {
  font-size: 10px;
  font-weight: 600;
  background: rgba(37,99,235,0.10);
  color: var(--primary);
  border-radius: 10px;
  padding: 1px 7px;
  margin-left: 6px;
  vertical-align: middle;
}
.sens-inputs { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.sensitivity-input {
  width: 44px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
  color: var(--text);
}
.sensitivity-input:focus { outline: none; border-color: var(--primary); }
.sens-commodity-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 0;
}
.sensitivity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.sensitivity-table th {
  background: #f1f5f9;
  padding: 4px 6px;
  text-align: center;
  font-weight: 600;
  color: #475569;
  border: 1px solid var(--border);
}
.sensitivity-table td {
  padding: 3px 6px;
  text-align: center;
  border: 1px solid var(--border);
}
.sens-delta { font-weight: 600; color: var(--text); text-align: left !important; white-space: nowrap; }
.sens-cell { color: #374151; }
.sens-highlight-row { background: rgba(37,99,235,0.10); }
.sens-delta-active { color: var(--primary) !important; font-weight: 700; }
.sens-cell-active { font-weight: 700; color: var(--primary); }

/* ---- Mini-charts grid (Brand × Material) ---- */
.mini-chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 4px;
}
.mini-chart-wrap {
  background: #fafbfc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  height: 200px;
  display: flex;
  flex-direction: column;
}
.mini-chart-wrap canvas { flex: 1; min-height: 0; }
.mini-chart-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

/* ---- Same-Store Filter ---- */
.same-store-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.same-store-label input[type="checkbox"] { cursor: pointer; accent-color: var(--primary); }

/* ---- Comparable Brand Table ---- */
.comparable-note {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 8px;
}
.comparable-table-wrap {
  overflow-x: auto;
  max-height: 480px;
  overflow-y: auto;
}
.comparable-brand-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}
.comparable-brand-table th {
  background: #f1f5f9;
  padding: 6px 10px;
  text-align: center;
  font-weight: 600;
  color: #475569;
  border: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
.comparable-brand-table td {
  padding: 5px 10px;
  border: 1px solid var(--border);
  text-align: center;
}
.comp-produto { font-weight: 600; text-align: left !important; color: var(--text); }
.comp-material { color: var(--muted); text-align: left !important; font-size: 11px; }
.comp-empty { color: var(--muted); font-style: italic; }

/* ---- Responsive ---- */
@media (max-width: 1000px) {
  .grid-2, .grid-2-1 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  header { padding: 12px 16px; }
  .filters-bar { padding: 10px 16px; }
  .main { padding: 16px; }
}
@media (max-width: 600px) {
  .kpi-row { grid-template-columns: 1fr 1fr; }
  .items-table th:nth-child(n+4),
  .items-table td:nth-child(n+4) { display: none; }
}

