/* =============================================================================
   SIGAF CEAF · Abastecimento Inteligente — Design System 2.0
   Tema escuro executivo (aprovado na proposta): leitura rápida no topo,
   detalhe sob demanda no drawer. Identidade MG (verde) refinada.
   ========================================================================== */

:root {
  color-scheme: dark;

  /* superfícies */
  --bg: #0b1210;
  --surface: #101915;
  --surface-2: #15221c;
  --surface-3: #1a2a22;
  --line: rgba(233, 242, 236, 0.07);
  --line-strong: rgba(233, 242, 236, 0.14);

  /* texto */
  --tx: #e9f2ec;
  --tx-2: #9db3a6;
  --tx-3: #6d8177;

  /* semânticas */
  --accent: #8fc63d;
  --accent-deep: #5d8f1a;
  --danger: #ff7066;
  --warn: #f0a24b;
  --attention: #e5c65a;
  --good: #6fce97;
  --info: #64b8de;

  /* derivados de tema */
  --bar-bg: rgba(11, 18, 16, 0.86);
  --overlay: rgba(233, 242, 236, 0.04);
  --overlay-soft: rgba(233, 242, 236, 0.03);
  --track: rgba(233, 242, 236, 0.06);
  --backdrop: rgba(5, 9, 8, 0.55);
  --on-accent: #0b1210;
  --bg-glow: rgba(143, 198, 61, 0.06);

  /* texto dos chips por tom */
  --chip-danger-tx: #ffada7;
  --chip-warn-tx: #ffcf94;
  --chip-attention-tx: #f2dfa0;
  --chip-good-tx: #a9e6c4;
  --chip-accent-tx: #cbe698;
  --chip-info-tx: #aadcf1;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --font: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --font-display: "Space Grotesk", var(--font);
}

/* ===================== TEMA CLARO ===================== */
:root[data-theme="light"] {
  color-scheme: light;

  --bg: #f2f5f3;
  --surface: #ffffff;
  --surface-2: #f7faf8;
  --surface-3: #ecf2ee;
  --line: rgba(18, 34, 26, 0.09);
  --line-strong: rgba(18, 34, 26, 0.18);

  --tx: #16241d;
  --tx-2: #4f6358;
  --tx-3: #7d8e85;

  --accent: #679f1d;
  --accent-deep: #4c7a12;
  --danger: #d64a40;
  --warn: #c47a1c;
  --attention: #a98f14;
  --good: #248c54;
  --info: #2b7fa3;

  --bar-bg: rgba(255, 255, 255, 0.88);
  --overlay: rgba(18, 34, 26, 0.04);
  --overlay-soft: rgba(18, 34, 26, 0.03);
  --track: rgba(18, 34, 26, 0.08);
  --backdrop: rgba(20, 32, 26, 0.35);
  --on-accent: #ffffff;
  --bg-glow: rgba(103, 159, 29, 0.07);

  --chip-danger-tx: #a13029;
  --chip-warn-tx: #8f5a11;
  --chip-attention-tx: #7d690e;
  --chip-good-tx: #1c6e42;
  --chip-accent-tx: #4c7a12;
  --chip-info-tx: #22637f;

  --shadow: 0 18px 50px rgba(30, 48, 40, 0.18);
}

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

html { scroll-behavior: smooth; }

body {
  background:
    radial-gradient(1200px 500px at 85% -10%, var(--bg-glow), transparent 60%),
    var(--bg);
  color: var(--tx);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 100vh;
  min-width: 320px;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* =============================================================================
   TOPBAR
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 20px;
  height: 58px; padding: 0 22px;
  background: var(--bar-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand-block { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; font-family: var(--font-display);
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-mark img { width: 30px; height: 30px; object-fit: contain; display: block; }
.brand-text strong { font-size: 13px; letter-spacing: -0.01em; white-space: nowrap; }
.brand-text span { font-size: 10px; color: var(--tx-3); text-transform: uppercase; letter-spacing: 0.1em; }

.main-nav {
  display: flex; gap: 2px; padding: 3px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  overflow-x: auto; scrollbar-width: none;
}
.main-nav::-webkit-scrollbar { display: none; }
.nav-item {
  border: 0; background: none; color: var(--tx-2);
  font-size: 12.5px; font-weight: 500; padding: 7px 13px;
  border-radius: 8px; white-space: nowrap; transition: color .15s, background .15s;
}
.nav-item:hover { color: var(--tx); }
.nav-item.active { background: var(--surface-3); color: var(--tx); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line-strong); }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }

.global-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; padding: 0 12px; height: 36px; width: 300px;
  color: var(--tx-3); transition: border-color .15s;
}
.global-search:focus-within { border-color: var(--accent-deep); color: var(--tx-2); }
.global-search input {
  background: none; border: 0; outline: 0; color: var(--tx);
  font-size: 12.5px; width: 100%;
}
.global-search input::placeholder { color: var(--tx-3); }

.data-menu { position: relative; }
.data-menu summary {
  list-style: none; user-select: none;
  display: flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  color: var(--tx-2); font-size: 12.5px; font-weight: 500; cursor: pointer;
}
.data-menu summary::-webkit-details-marker { display: none; }
.data-menu summary::after { content: "▾"; font-size: 9px; opacity: .7; }
.data-menu[open] summary { color: var(--tx); border-color: var(--line-strong); }
.data-menu-panel {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 80;
  min-width: 240px; padding: 6px;
  background: var(--surface-2); border: 1px solid var(--line-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px;
}
.data-menu-panel button {
  text-align: left; background: none; border: 0; color: var(--tx-2);
  font-size: 12.5px; padding: 9px 12px; border-radius: 7px;
}
.data-menu-panel button:hover { background: var(--surface-3); color: var(--tx); }
.data-menu-panel hr { border: 0; border-top: 1px solid var(--line); margin: 4px 8px; }

.primary-button {
  height: 36px; padding: 0 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  border: 0; border-radius: 9px;
  color: var(--on-accent); font-size: 12.5px; font-weight: 700;
  transition: filter .15s;
}
.primary-button:hover:not(:disabled) { filter: brightness(1.08); }
.primary-button:disabled { opacity: 0.4; cursor: default; }

/* =============================================================================
   FILTERBAR
   ========================================================================== */
.filterbar {
  position: sticky; top: 58px; z-index: 50;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 22px;
  background: var(--bar-bg);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.chip-group { display: flex; gap: 6px; flex-wrap: wrap; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px; padding: 0 11px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 99px; color: var(--tx-2);
  font-size: 11.5px; font-weight: 500;
  transition: all .15s;
}
.chip:hover { color: var(--tx); border-color: var(--line-strong); }
.chip.active {
  background: rgba(143, 198, 61, 0.14); border-color: rgba(143, 198, 61, 0.5);
  color: var(--tx); font-weight: 600;
}
.chip strong { font-family: var(--font-display); font-size: 11px; opacity: .85; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; }
.dot.danger { background: var(--danger); }
.dot.warn { background: var(--warn); }
.dot.attention { background: var(--attention); }
.dot.good { background: var(--good); }

.filterbar-sep { width: 1px; height: 20px; background: var(--line-strong); }

.select-group { display: flex; gap: 6px; }
.select-group select {
  height: 28px; padding: 0 8px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; color: var(--tx-2); font-size: 11.5px; outline: 0;
}
.select-group select:hover, .select-group select:focus { color: var(--tx); border-color: var(--line-strong); }
.select-group select option { background: var(--surface-2); color: var(--tx); }

.text-action {
  background: none; border: 0; color: var(--tx-3);
  font-size: 11.5px; text-decoration: underline; text-underline-offset: 3px;
}
.text-action:hover { color: var(--tx); }

.filterbar-status {
  margin-left: auto; display: flex; flex-direction: column; align-items: flex-end;
  line-height: 1.25; font-size: 10px; color: var(--tx-3);
}
.filterbar-status small { font-size: 9.5px; }

/* =============================================================================
   WORKSPACE
   ========================================================================== */
.workspace {
  max-width: 1440px; margin: 0 auto;
  padding: 20px 22px 60px;
  display: flex; flex-direction: column; gap: 18px;
}

/* ---- KPIs ---- */
.status-strip {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px;
}
.metric {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px 12px;
  position: relative; overflow: hidden;
}
.metric::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--tx-3); opacity: .35;
}
.metric.danger::before { background: var(--danger); opacity: 1; }
.metric.warn::before { background: var(--warn); opacity: 1; }
.metric.accent::before { background: var(--accent); opacity: 1; }
.metric span {
  display: block; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--tx-2);
}
.metric strong {
  display: block; font-family: var(--font-display);
  font-size: 27px; font-weight: 700; letter-spacing: -0.02em; margin: 3px 0 1px;
}
.metric.danger strong { color: var(--danger); }
.metric.warn strong { color: var(--warn); }
.metric.accent strong { color: var(--accent); }
.metric small { font-size: 10.5px; color: var(--tx-3); }

/* ---- Insight cards ---- */
.view-insights {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px;
}
.view-insights:empty { display: none; }
.insight-card {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.insight-card > span {
  display: block; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em; color: var(--tx-2);
}
.insight-card > strong {
  display: block; font-family: var(--font-display);
  font-size: 21px; font-weight: 700; margin: 4px 0 2px; letter-spacing: -0.01em;
}
.insight-card > small { font-size: 11px; color: var(--tx-3); line-height: 1.45; display: block; }

/* gráfico de gargalos + matriz ocupam a linha inteira */
.insight-card.gargalo-chart { grid-column: 1 / -1; }

.gargalo-bars { display: flex; flex-direction: column; gap: 7px; margin: 10px 0 6px; }
.gargalo-row {
  display: grid; grid-template-columns: 170px 1fr 44px;
  align-items: center; gap: 12px; font-size: 12px;
}
.gargalo-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--tx-2); }
.gargalo-track { height: 9px; border-radius: 6px; background: var(--track); overflow: hidden; }
.gargalo-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--accent), var(--warn)); }
.gargalo-row strong { text-align: right; font-family: var(--font-display); font-size: 13px; }

/* ---- Painel de Abastecimento (visuais espelhados do Power BI da DDM) ---- */
.bi-legend {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  margin: 8px 0 2px; font-size: 11px; color: var(--tx-2);
}
.bi-legend-title { font-weight: 600; color: var(--tx-2); }
.bi-legend span { display: inline-flex; align-items: center; gap: 5px; }
.bi-legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.bi-legend .dot.good { background: var(--good); }
.bi-legend .dot.warn { background: var(--warn); }
.bi-legend .dot.danger { background: var(--danger); }

.bi-cols { display: flex; gap: 26px; align-items: flex-end; margin: 12px 4px 6px; }
.bi-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.bi-col b { font-family: var(--font-display); font-size: 14px; }
.bi-col-track {
  width: 100%; max-width: 120px; height: 110px; border-radius: 7px;
  background: var(--track); display: flex; align-items: flex-end; overflow: hidden;
}
.bi-col-fill { width: 100%; border-radius: 7px 7px 0 0; }
.bi-col-fill.tone-good { background: var(--good); }
.bi-col-fill.tone-warn { background: var(--warn); }
.bi-col-fill.tone-danger { background: var(--danger); }
.bi-col span { font-size: 11px; color: var(--tx-2); text-align: center; line-height: 1.3; }

.bi-stack { display: flex; flex-direction: column; gap: 7px; margin: 10px 0 6px; }
.bi-stack-row {
  display: grid; grid-template-columns: 230px 1fr 44px;
  align-items: center; gap: 12px; font-size: 12px;
}
.bi-stack-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--tx-2); }
.bi-stack-track { display: flex; height: 16px; border-radius: 5px; background: var(--track); overflow: hidden; }
.bi-seg {
  height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: #fff; min-width: 0;
}
.bi-seg.tone-good { background: var(--good); }
.bi-seg.tone-warn { background: var(--warn); }
.bi-seg.tone-danger { background: var(--danger); }
.bi-stack-row strong { text-align: right; font-family: var(--font-display); font-size: 13px; }

.bi-line-wrap { margin: 10px 0 4px; }
.bi-line-wrap svg { width: 100%; height: auto; display: block; }
.bi-line-mes { font-size: 9.5px; fill: var(--tx-3); }
.bi-line-end { font-size: 10px; font-weight: 700; }

@media (max-width: 760px) {
  .bi-stack-row { grid-template-columns: 120px 1fr 36px; }
  .bi-cols { gap: 12px; }
}

.mat-grid {
  display: grid; grid-template-columns: 120px repeat(3, 1fr);
  gap: 6px; margin: 12px 0 6px; font-size: 11px;
}
.mat-head {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--tx-3); text-align: center; padding: 4px 2px; align-self: end;
}
.mat-rot {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--tx-3); text-align: right; padding: 10px 6px; align-self: center;
}
.mat-cel {
  border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 4px; text-align: center; transition: border-color .15s;
}
.mat-cel:hover { border-color: var(--line-strong); }
.mat-cel b { display: block; font-family: var(--font-display); font-size: 19px; }
.mat-cel span { font-size: 8.5px; color: var(--tx-3); text-transform: uppercase; letter-spacing: 0.02em; }
.mat-verm { background: rgba(255, 112, 102, 0.16); border-color: rgba(255, 112, 102, 0.35); }
.mat-lar  { background: rgba(240, 162, 75, 0.13); border-color: rgba(240, 162, 75, 0.3); }
.mat-ama  { background: rgba(229, 198, 90, 0.10); }
.mat-verd { background: rgba(111, 206, 151, 0.09); }
.mat-neu  { background: var(--overlay-soft); }

/* ---- Painéis ---- */
.priority-panel, .query-panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}

.section-title, .query-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 14px; margin-bottom: 14px;
}
.section-title h1, .query-head h2 {
  font-family: var(--font-display); font-size: 15.5px; font-weight: 600;
  letter-spacing: -0.01em;
}
.section-title p, .query-head p { font-size: 11.5px; color: var(--tx-3); margin-top: 2px; }

/* ---- Fila de prioridade (cards horizontais) ---- */
.priority-queue {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(250px, 1fr);
  gap: 10px; overflow-x: auto; padding-bottom: 4px;
  scroll-snap-type: x mandatory; scrollbar-width: thin;
}
.priority-card {
  scroll-snap-align: start;
  text-align: left; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 14px; color: inherit;
  display: flex; flex-direction: column; gap: 7px;
  transition: border-color .15s, transform .15s;
}
.priority-card:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.priority-card h3 {
  font-size: 12.5px; font-weight: 600; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 2.6em;
}
.priority-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.priority-meta { font-size: 10.5px; color: var(--tx-3); line-height: 1.4; }
.priority-empty { color: var(--tx-3); font-size: 12px; padding: 14px; }

.coverage-line { margin-top: auto; }
.coverage-label {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--tx-3); margin-bottom: 4px;
}
.coverage-label strong { color: var(--tx-2); font-family: var(--font-display); }
.coverage-track { height: 6px; border-radius: 4px; background: var(--track); overflow: hidden; }
.coverage-fill { height: 100%; border-radius: 4px; background: var(--good); }
.coverage-fill.danger { background: var(--danger); }
.coverage-fill.warn { background: var(--warn); }
.coverage-fill.neutral { background: var(--tx-3); }

/* ---- Chips de risco/status ---- */
.risk-chip, .status-chip {
  display: inline-flex; align-items: center;
  padding: 2px 9px; border-radius: 99px;
  font-size: 10px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.risk-chip.danger, .status-chip.danger { background: rgba(255, 112, 102, 0.16); color: var(--chip-danger-tx); }
.risk-chip.warn, .status-chip.warn { background: rgba(240, 162, 75, 0.16); color: var(--chip-warn-tx); }
.risk-chip.attention, .status-chip.attention { background: rgba(229, 198, 90, 0.15); color: var(--chip-attention-tx); }
.risk-chip.good, .status-chip.good, .risk-chip.ok, .status-chip.ok { background: rgba(111, 206, 151, 0.15); color: var(--chip-good-tx); }
.risk-chip.neutral, .status-chip.neutral { background: var(--overlay); color: var(--tx-2); }

/* ---- Lista principal (linhas tabulares) ---- */
.supply-list { display: flex; flex-direction: column; }

.supply-item {
  display: grid;
  grid-template-columns: 34px minmax(280px, 2.4fr) 110px 110px 150px minmax(120px, 1fr) 86px;
  gap: 14px; align-items: center;
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  cursor: pointer; transition: background .12s, border-color .12s;
}
.supply-item:last-child { border-bottom: 0; }
.supply-item:hover { background: var(--overlay-soft); }
.supply-item.selected { background: rgba(143, 198, 61, 0.06); border-left-color: var(--accent); }

.rank {
  font-family: var(--font-display); font-size: 11px; color: var(--tx-3);
  text-align: center; background: var(--surface-2);
  border-radius: 7px; padding: 5px 0;
}
.supply-item .item-top { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.supply-name { font-size: 12.5px; font-weight: 600; line-height: 1.3; }
.item-meta { font-size: 10.5px; color: var(--tx-3); margin-top: 1px; }

.data-cell span {
  display: block; font-size: 9px; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--tx-3);
}
.data-cell strong { font-size: 12.5px; font-family: var(--font-display); font-weight: 600; }

.cid-list { font-size: 10.5px; color: var(--tx-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.row-action {
  background: none; border: 1px solid var(--line);
  border-radius: 8px; color: var(--tx-2);
  font-size: 11px; font-weight: 600; padding: 6px 0;
  transition: all .15s;
}
.row-action:hover { border-color: var(--accent-deep); color: var(--tx); }

/* =============================================================================
   DRAWER — ficha do medicamento
   ========================================================================== */
.drawer-root { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.drawer-backdrop {
  position: absolute; inset: 0;
  background: var(--backdrop); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .22s ease;
}
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(680px, 94vw);
  background: var(--surface);
  border-left: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  transform: translateX(102%);
  transition: transform .26s cubic-bezier(.32,.72,.28,1);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 0 22px 30px;
}
.drawer-root.open { pointer-events: auto; }
.drawer-root.open .drawer-backdrop { opacity: 1; }
.drawer-root.open .drawer-panel { transform: translateX(0); }

.inspector-empty { color: var(--tx-3); font-size: 12.5px; padding: 26px 4px; }

.inspector-title {
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, var(--surface) 82%, transparent);
  padding: 20px 0 12px; margin-bottom: 4px;
}
.inspector-title .item-top { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; }
.inspector-title h2 {
  font-family: var(--font-display); font-size: 16.5px; font-weight: 600;
  line-height: 1.3; letter-spacing: -0.01em; padding-right: 30px;
}
.inspector-sub { font-size: 11px; color: var(--tx-3); margin-top: 5px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.drawer-close {
  position: absolute; top: 16px; right: 0;
  width: 30px; height: 30px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 8px; color: var(--tx-2); font-size: 15px; line-height: 1;
}
.drawer-close:hover { color: var(--tx); border-color: var(--line-strong); }

.inspector-tabs { display: none; }

.inspector-section {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface-2);
  padding: 13px 15px; margin-top: 10px;
}
.inspector-section h3 {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--tx-2); margin-bottom: 8px;
}
.inspector-section p { font-size: 12px; color: var(--tx-2); line-height: 1.55; }
.inspector-section p strong { color: var(--tx); }

.inspector-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.inspector-grid .inspector-section { margin-top: 0; }

.activity-list { display: flex; flex-direction: column; gap: 6px; }
.timeline-entry {
  background: var(--overlay-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 11px; font-size: 11.5px; color: var(--tx-2); line-height: 1.5;
}
.timeline-entry strong { color: var(--tx); font-weight: 600; }

.sparkline { display: flex; align-items: flex-end; gap: 8px; min-height: 112px; padding-top: 6px; }
.spark-point {
  flex: 1;
  min-width: 34px;
  height: 106px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}
.spark-value {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--tx-2);
  line-height: 1;
  white-space: nowrap;
}
.spark-bar {
  width: min(100%, 28px);
  min-height: 6px;
  border-radius: 5px 5px 2px 2px;
  background: var(--good); opacity: 0.9;
}
.spark-month {
  font-size: 9.5px;
  color: var(--tx-3);
  line-height: 1;
  white-space: nowrap;
}
.spark-bar.danger { background: var(--danger); }
.spark-bar.warn { background: var(--warn); }
.spark-bar.neutral { background: var(--tx-3); }

/* ---- Acompanhamento (form) ---- */
.tracking-form { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.tracking-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tracking-form select, .tracking-form input, .tracking-form textarea {
  background: var(--overlay);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--tx); font-size: 12px; padding: 8px 10px; width: 100%; outline: 0;
}
.tracking-form select option { background: var(--surface-2); }
.tracking-form :is(select, input, textarea):focus { border-color: var(--accent-deep); }
.tracking-form textarea { resize: vertical; }

.ghost-button {
  align-self: flex-start;
  background: rgba(143, 198, 61, 0.12);
  border: 1px solid rgba(143, 198, 61, 0.4);
  border-radius: var(--radius-sm);
  color: var(--accent); font-size: 11.5px; font-weight: 700; padding: 7px 14px;
  transition: all .15s;
}
.ghost-button:hover { background: rgba(143, 198, 61, 0.2); }

.tracking-entry { position: relative; }
.tracking-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.tracking-head small { color: var(--tx-3); font-size: 10px; }
.tracking-del {
  background: none; border: 0; color: var(--tx-3);
  font-size: 14px; line-height: 1; padding: 0 4px;
}
.tracking-del:hover { color: var(--danger); }
.tracking-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.chip-track {
  display: inline-block; padding: 1px 8px; border-radius: 99px;
  font-size: 10px; font-weight: 700;
}
.chip-track.cat { background: rgba(143, 198, 61, 0.16); color: var(--chip-accent-tx); }
.chip-track.prev { background: rgba(100, 184, 222, 0.16); color: var(--chip-info-tx); }

/* =============================================================================
   RESPONSIVO
   ========================================================================== */
@media (max-width: 1280px) {
  .status-strip { grid-template-columns: repeat(3, 1fr); }
  .view-insights { grid-template-columns: repeat(2, 1fr); }
  .supply-item { grid-template-columns: 34px minmax(220px, 2fr) 100px 100px minmax(100px, 1fr) 80px; }
  .supply-item .cid-list { display: none; }
  .global-search { width: 200px; }
}

@media (max-width: 900px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px; }
  .main-nav { order: 3; width: 100%; }
  .topbar-actions { margin-left: auto; }
  .filterbar { position: static; padding: 9px 14px; }
  .filterbar-status { display: none; }
  .workspace { padding: 14px; }
  .status-strip { grid-template-columns: repeat(2, 1fr); }
  .view-insights { grid-template-columns: 1fr; }
  .supply-item { grid-template-columns: minmax(180px, 1fr) 92px; }
  .supply-item .rank, .supply-item .data-cell, .supply-item .row-action, .supply-item .cid-list { display: none; }
  .supply-item { grid-template-columns: 1fr; }
  .mat-grid { grid-template-columns: 90px repeat(3, 1fr); }
  .gargalo-row { grid-template-columns: 110px 1fr 40px; }
  .inspector-grid { grid-template-columns: 1fr; }
  .tracking-row { grid-template-columns: 1fr; }
}

/* ---- Alternância de tema ---- */
.theme-toggle {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 9px; color: var(--tx-2); transition: all .15s;
}
.theme-toggle:hover { color: var(--tx); border-color: var(--line-strong); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
:root[data-theme="light"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="light"] .theme-toggle .icon-moon { display: none; }


/* timeline de status mensal (painel oficial de abastecimento) */
.hist-bar { display: flex; gap: 3px; margin: 8px 0 4px; }
.hist-cell { flex: 1; height: 16px; border-radius: 3px; background: var(--surface-3); }
.hist-cell.tone-good { background: var(--ok, #22c55e); }
.hist-cell.tone-warn { background: var(--warn, #f59e0b); }
.hist-cell.tone-danger { background: var(--danger, #ef4444); }
.hist-cell.tone-neutral { background: var(--surface-3); }
.hist-legend { font-size: 10.5px; color: var(--tx-3); margin-bottom: 6px; }
.tone-danger { color: var(--danger, #ef4444); }


.mini-hist { display: inline-flex; gap: 2px; vertical-align: middle; }
.mini-hist i { width: 9px; height: 14px; border-radius: 2px; background: var(--surface-3); }
.mini-hist i.tone-good { background: var(--ok, #22c55e); }
.mini-hist i.tone-warn { background: var(--warn, #f59e0b); }
.mini-hist i.tone-danger { background: var(--danger, #ef4444); }
.select-control { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; color: var(--tx); font-size: 11.5px; padding: 6px 10px; }
