/* ==========================================================================
   Atlas Tecnologia — "Bancada": identidade visual do painel de estoque
   Instrumento de laboratório: papel clínico + tinta grafite + genciana,
   números como leitura de instrumento (mono) e motivo de escala graduada.
   Design system independente do admin do Django.
   Seções: 1.Tokens 2.Base 3.Shell(sidebar/topbar) 4.Componentes 5.Dashboard
           6.Login 7.Responsivo 8.Filtros
   ========================================================================== */

/* 1. Tokens ---------------------------------------------------------------- */
:root {
  /* Tipos */
  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* Papel / tinta */
  --c-bg: #F4F5F3;
  --c-bg-alt: #ECEDE9;
  --c-surface: #FFFFFF;
  --c-surface-2: #F6F6F3;
  --c-ink: #16161A;
  --c-ink-2: #3A3A42;
  --c-muted: #6E6E78;
  --c-faint: #9A9AA2;
  --c-line: #E4E4DE;
  --c-line-soft: #EDEDE7;

  /* Acento — teal (identidade Atlas Tecnologia) */
  --c-brand: #0E8A9C;
  --c-brand-700: #0A6675;
  --c-brand-dark: #0A6675;
  --c-brand-50: #E6F5F8;
  --c-brand-light: #2FC0D3;
  --c-accent: #0E8A9C;
  --c-accent-700: #0A6675;

  /* Semânticos — verde/âmbar/vermelho preservados p/ status de estoque */
  --c-ok-bg: #E7F5EE;   --c-ok-fg: #0E7A54;
  --c-warn-bg: #FBF1E3; --c-warn-fg: #B45309;
  --c-danger-bg: #FBECEC; --c-danger-fg: #C02637;
  --c-danger: #C02637;  --c-danger-700: #9E1D2C;

  /* Sidebar — grafite quente (tinta), não azul-marinho */
  --side-bg: #16161A;
  --side-bg-2: #1D1D22;
  --side-ink: #B7B7BE;
  --side-ink-strong: #FFFFFF;
  --side-active: #0E8A9C;

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 10px;
  --r-pill: 999px;

  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px; --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

  --sh-sm: 0 1px 2px rgba(22, 22, 26, 0.05);
  --sh-md: 0 4px 20px rgba(22, 22, 26, 0.08), 0 1px 3px rgba(22, 22, 26, 0.05);
  --sh-lg: 0 24px 60px rgba(22, 22, 26, 0.20);
  --t: 0.16s ease;

  /* Motivo de escala graduada (assinatura) */
  --tick-h: repeating-linear-gradient(90deg, currentColor 0 1.5px, transparent 1.5px 9px);

  --side-w: 250px;
  --topbar-h: 64px;
}

/* 2. Base ------------------------------------------------------------------ */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  color: var(--c-ink);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.app-body {
  background: var(--c-bg);
}

a { color: var(--c-brand); text-decoration: none; }
a:hover { color: var(--c-brand-700); }

/* Foco de teclado visível (piso de acessibilidade) */
:focus-visible {
  outline: 2px solid var(--c-brand);
  outline-offset: 2px;
  border-radius: 2px;
}
.app-nav-item:focus-visible,
.app-nav-item.is-active:focus-visible { outline-color: var(--c-brand-light); }
h1, h2, h3 {
  margin: 0;
  color: var(--c-ink);
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

/* Números = leitura de instrumento */
.stat-value, .data-table .num, .panel-list .num, .filtro-input,
.modal-summary-item strong, .saldo-badge, .badge, .page-info {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* 3. Shell ----------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  min-height: 100vh;
}

/* Overlay do menu mobile — oculto e fora do fluxo do grid no desktop. */
.app-backdrop { display: none; }

/* Sidebar */
.app-sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--side-bg);
  color: var(--side-ink);
  border-right: 1px solid rgba(255, 255, 255, 0.07);
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-brand-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.app-brand-mark .brand-mark { width: 38px; height: 38px; display: block; }

.app-brand-text strong {
  display: block;
  font-family: var(--font-display);
  color: var(--side-ink-strong);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.1;
}
.app-brand-text strong .brand-accent,
.login-brand strong .brand-accent {
  display: inline;
  color: var(--c-brand-light);
  font-size: inherit;
}
.app-brand-text span {
  font-size: 11px;
  color: var(--c-faint);
  letter-spacing: 0.02em;
}

.app-nav {
  position: relative;
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px 16px 0;
  /* Régua de navegação (assinatura): trilho graduado vertical à esquerda.
     Fixo ao box da nav — os itens rolam, a escala permanece. */
  background-image: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.14) 0 2px, transparent 2px 8px);
  background-repeat: no-repeat;
  background-position: 21px 0;
  background-size: 2px 100%;
}
.app-nav-group {
  margin: 20px 12px 8px 34px;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #7C7C87;
}
.app-nav-group:first-child { margin-top: 4px; }

.app-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px 9px 34px;
  margin: 2px 0;
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  color: var(--side-ink);
  font-weight: 500;
  transition: background var(--t), color var(--t);
}
.app-nav-item svg { width: 18px; height: 18px; flex: 0 0 18px; opacity: 0.7; transition: color var(--t), opacity var(--t); }
.app-nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--side-ink-strong);
}
.app-nav-item:hover svg { opacity: 1; }

/* Ativo = uma "leitura" marcada no trilho: ponto genciana sobre a régua +
   tinta suave que decai para a direita. Sem bloco cheio. */
.app-nav-item.is-active {
  background: linear-gradient(90deg, rgba(167, 139, 250, 0.20), rgba(167, 139, 250, 0.03) 72%);
  color: #fff;
}
.app-nav-item.is-active::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--c-brand-light);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.22);
}
.app-nav-item.is-active svg { color: var(--c-brand-light); opacity: 1; }

.app-side-foot {
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-faint);
}
.app-side-foot a { color: var(--c-brand-light); font-family: var(--font-body); }

/* Topbar */
.app-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.app-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  height: var(--topbar-h);
  padding: 0 28px;
  background: rgba(244, 245, 243, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--c-line);
}
.app-topbar-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.app-topbar-title small {
  display: block;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 400;
  color: var(--c-muted);
}
.app-topbar-actions { display: flex; align-items: center; gap: 12px; }

.app-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  background: var(--c-surface);
}
.app-user-name { font-weight: 600; font-size: 13px; }
.app-avatar {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--c-brand);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
}

.app-content {
  flex: 1;
  padding: 28px;
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
}

/* 4. Componentes ----------------------------------------------------------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--c-line-soft);
}
.card-head h2 { font-family: var(--font-display); font-size: 14px; font-weight: 600; letter-spacing: 0; }
.card-body { padding: 18px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  background: var(--c-brand);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--t), box-shadow var(--t), transform var(--t);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--c-brand-700); color: #fff; box-shadow: 0 6px 16px rgba(105, 38, 196, 0.24); transform: translateY(-1px); }
.btn-ghost {
  background: var(--c-surface);
  color: var(--c-ink-2);
  border-color: var(--c-line);
}
.btn-ghost:hover { background: var(--c-surface-2); color: var(--c-ink); box-shadow: none; }
.btn-accent { background: var(--c-accent); }
.btn-accent:hover { background: var(--c-accent-700); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-weight: 600;
}
.badge-ok { background: var(--c-ok-bg); color: var(--c-ok-fg); }
.badge-warn { background: var(--c-warn-bg); color: var(--c-warn-fg); }
.badge-danger { background: var(--c-danger-bg); color: var(--c-danger-fg); }

/* Tabela de dados */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
  border-bottom: 1px solid var(--c-line);
}
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--c-line-soft);
  color: var(--c-ink-2);
}
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr { transition: background var(--t); }
.data-table tbody tr:hover { background: var(--c-surface-2); }
.data-table .num { text-align: right; }
.data-table .col-barra { min-width: 120px; }   /* célula com barra de percentual */

/* Scroll horizontal padronizado para tabelas largas (essencial em mobile).
   As sombras laterais (background-attachment: local) sinalizam conteúdo oculto
   e somem ao chegar nas extremidades do scroll. */
.table-scroll {
  width: 100%;
  min-width: 0;   /* permite encolher dentro de grid/flex, sem estourar a coluna */
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(90deg, var(--c-surface) 30%, rgba(255, 255, 255, 0)),
    linear-gradient(90deg, rgba(255, 255, 255, 0), var(--c-surface) 70%) 100% 0,
    radial-gradient(farthest-side at 0 50%, rgba(22, 22, 26, 0.10), rgba(22, 22, 26, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(22, 22, 26, 0.10), rgba(22, 22, 26, 0)) 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
/* Tabela dentro do scroll não deve encolher abaixo do conteúdo */
.table-scroll > .data-table,
.table-scroll > table { min-width: max-content; }

.empty-state {
  padding: 28px;
  text-align: center;
  color: var(--c-muted);
}

/* 5. Dashboard ------------------------------------------------------------- */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  padding: 2px 0 18px;
  background: transparent;
  border: 0;
  border-radius: 0;
  position: relative;
}
/* Régua graduada sob o cabeçalho da página (assinatura) */
.page-head::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 6px;
  color: var(--c-line);
  background-image: var(--tick-h);
}
.page-head .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: none;
  color: var(--c-brand);
  margin-bottom: 6px;
}
.page-head h1 { font-family: var(--font-display); font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.page-head p { margin: 4px 0 0; color: var(--c-muted); font-size: 13px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
/* Modificadores de coluna (evita grid-template-columns inline, que impede o
   colapso responsivo por ter especificidade maior que as media queries) */
.stat-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stat-grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px 18px 20px 20px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  transition: box-shadow var(--t), transform var(--t);
}
/* Escala graduada vertical na borda esquerda (assinatura) */
.stat::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 5px;
  background-image: repeating-linear-gradient(180deg, var(--s-acc, var(--c-line)) 0 5px, transparent 5px 10px);
}
.stat:hover { box-shadow: var(--sh-md); transform: translateY(-2px); }

/* Sistema de cores por KPI — família coesa, dessaturada */
.stat.c-blue    { --s-ico-bg: #EEF1FB; --s-ico-fg: #3D53B5; --s-acc: #3D53B5; }
.stat.c-emerald { --s-ico-bg: #E7F5EE; --s-ico-fg: #0E7A54; --s-acc: #0E7A54; }
.stat.c-violet  { --s-ico-bg: #F2ECFB; --s-ico-fg: #6926C4; --s-acc: #6926C4; }
.stat.c-amber   { --s-ico-bg: #FBF1E3; --s-ico-fg: #B45309; --s-acc: #C77812; }
.stat.c-cyan    { --s-ico-bg: #E4F3F4; --s-ico-fg: #0B7285; --s-acc: #0B7285; }
.stat.c-rose    { --s-ico-bg: #FBEBEE; --s-ico-fg: #B0304A; --s-acc: #B0304A; }
.stat.c-sky     { --s-ico-bg: #E9F1F8; --s-ico-fg: #2E6FA6; --s-acc: #2E6FA6; }

.stat-ico {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: var(--r-sm);
  background: var(--s-ico-bg, var(--c-brand-50));
  color: var(--s-ico-fg, var(--c-brand));
  flex: 0 0 44px;
}
.stat-ico svg { width: 22px; height: 22px; }
.stat-label {
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
}
.stat-value {
  display: block;
  margin-top: 6px;
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  color: var(--c-ink);
  white-space: nowrap;
  letter-spacing: -0.03em;
}
.stat-value.is-sm { font-size: 22px; }
.stat-value.is-money { font-size: 20px; }   /* valores BRL longos que não cabem em 30px */
.stat-sub { display: block; margin-top: 6px; font-size: 12px; color: var(--c-muted); }

/* Faixa secundária (KPIs menores) */
.stat-grid.is-secondary .stat { padding: 14px 14px 14px 16px; }
.stat-grid.is-secondary .stat-value { font-size: 21px; }
.stat-grid.is-secondary .stat-ico { width: 38px; height: 38px; flex: 0 0 38px; }
.stat-grid.is-secondary .stat-ico svg { width: 18px; height: 18px; }

.stat.is-alert { background: linear-gradient(180deg, #FDF4E7, #fff 62%); border-color: #F0D9AE; }
.stat.is-alert::before { background-image: repeating-linear-gradient(180deg, #C77812 0 5px, transparent 5px 10px); }
.stat.is-alert .stat-ico { background: #FBEBCF; color: #B45309; }
.stat.is-alert .stat-value { color: #B45309; }

.panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

/* Accent colorido nos painéis de atividade */
.panel-accent-blue  .card-head { border-top: 3px solid #3D53B5; border-radius: var(--r-md) var(--r-md) 0 0; }
.panel-accent-emerald .card-head { border-top: 3px solid #0E7A54; border-radius: var(--r-md) var(--r-md) 0 0; }
.panel-accent-violet .card-head { border-top: 3px solid #6926C4; border-radius: var(--r-md) var(--r-md) 0 0; }
.panel-accent-blue, .panel-accent-emerald, .panel-accent-violet { border-top: none; }

.panel-list { width: 100%; border-collapse: collapse; }
.panel-list td { padding: 10px 0; border-bottom: 1px solid var(--c-line-soft); font-size: 13px; }
.panel-list tr:last-child td { border-bottom: 0; }
.panel-list .t-strong { font-weight: 600; color: var(--c-ink); }
.panel-list .t-muted { color: var(--c-muted); }
.panel-list .num { text-align: right; }

.quick-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }

/* Hero "leitura de bancada" — estado do estoque agora ---------------------- */
.bench-hero {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 18px 24px;
  padding: 22px 24px 22px;
  margin-bottom: 22px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
  overflow: hidden;
  --st-c: #0E7A54;
  --st-halo: rgba(14, 122, 84, 0.14);
}
/* Estado do estoque — define a cor uma única vez para veredito e medidor */
.bench-hero.state-ok     { --st-c: #0E7A54; --st-halo: rgba(14, 122, 84, 0.14); }
.bench-hero.state-warn   { --st-c: #C77812; --st-halo: rgba(199, 120, 18, 0.16); }
.bench-hero.state-danger { --st-c: #C02637; --st-halo: rgba(192, 38, 55, 0.14); }
.bench-hero .eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: var(--c-brand);
  margin: 0 0 8px;
}
.bench-verdict {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--c-ink);
}
/* Ponto de status — semáforo de bancada */
.bench-verdict::before {
  content: "";
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--st-c);
  box-shadow: 0 0 0 4px var(--st-halo);
  flex: 0 0 12px;
}

.bench-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-self: end; }

/* Medidor graduado de saúde do estoque (assinatura) */
.gauge { grid-column: 1 / -1; margin-top: 2px; }
.gauge-track {
  position: relative;
  height: 16px;
  border-radius: var(--r-pill);
  background: var(--c-bg-alt);
  border: 1px solid var(--c-line);
  overflow: hidden;
}
.gauge-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--gauge-pos, 0%);
  background: var(--st-c);
  transition: width 0.6s ease;
}
/* Marcas graduadas por cima do trilho — leitura de instrumento */
.gauge-track::after {
  content: "";
  position: absolute; inset: 0;
  color: rgba(22, 22, 26, 0.16);
  background-image: var(--tick-h);
  pointer-events: none;
}
.gauge-scale {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-muted);
}
.gauge-readout { color: var(--st-c); font-weight: 600; }

/* Rodapé de indicadores operacionais do hero (Entradas/Saídas/Hoje) */
.bench-meta {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--c-line-soft);
}
.bench-meta-item { display: flex; flex-direction: column; gap: 3px; }
.bench-meta-item .k {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
}
.bench-meta-item .v { font-family: var(--font-mono); font-size: 18px; font-weight: 600; color: var(--c-ink); }

/* Grid intermediário: gráfico + lista acionável */
.dash-mid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 16px;
  margin-bottom: 22px;
}
.dash-mid .card { display: flex; flex-direction: column; }

/* Lista "Precisa de atenção" — itens abaixo do mínimo */
.atencao-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--c-line-soft);
  text-decoration: none;
  color: inherit;
}
.atencao-row:last-child { border-bottom: 0; }
.atencao-main { min-width: 0; flex: 1; }
.atencao-nome {
  font-weight: 600;
  font-size: 13px;
  color: var(--c-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.atencao-row:hover .atencao-nome { color: var(--c-brand); }
.atencao-cat { font-size: 11.5px; color: var(--c-muted); }
.atencao-ratio { font-family: var(--font-mono); font-size: 13px; font-weight: 600; white-space: nowrap; }
.atencao-ratio b { color: var(--c-danger-fg); font-weight: 600; }
.atencao-ratio span { color: var(--c-faint); }
.atencao-arrow { flex: 0 0 auto; display: grid; place-items: center; color: var(--c-faint); }
.atencao-arrow svg { width: 16px; height: 16px; }
.atencao-row:hover .atencao-arrow { color: var(--c-brand); }
.atencao-empty {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 2px;
  color: var(--c-ok-fg);
  font-size: 13px;
}
.atencao-empty svg { width: 20px; height: 20px; flex: 0 0 20px; }

/* 6. Login ----------------------------------------------------------------- */
body.login-body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  font-family: var(--font-body);
  color: var(--c-ink);
  background-color: #16161A;
  background-image:
    radial-gradient(120% 120% at 100% 0%, rgba(105, 38, 196, 0.38) 0%, transparent 46%),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.045) 0 1.5px, transparent 1.5px 26px);
}
.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--c-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-lg);
  padding: 34px 32px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.login-brand .app-brand-mark { width: 46px; height: 46px; }
.login-brand .app-brand-mark .brand-mark { width: 46px; height: 46px; }
.login-brand strong { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; color: var(--c-brand-700); }
.login-brand span { display: block; font-size: 12px; color: var(--c-muted); }
.login-card h1 { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -0.01em; margin-bottom: 4px; }
.login-card .sub { color: var(--c-muted); margin: 0 0 20px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 13px; color: var(--c-ink-2); }
.field input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  font-family: inherit;
  font-size: 15px;
  background: var(--c-surface-2);
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
}
.field input:focus {
  outline: none;
  border-color: var(--c-brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(105, 38, 196, 0.16);
}
/* Campos de formulário do painel (fora do login) */
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 5px; font-weight: 600; font-size: 13px; color: var(--c-ink-2); }
.field select,
.field textarea,
.field input[type="text"],
.field input[type="number"],
.field input[type="email"],
.field input[type="date"],
.field input[type="file"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--c-surface-2);
  color: var(--c-ink);
  transition: border-color var(--t), box-shadow var(--t);
}
.field select { height: 38px; }
.field textarea { resize: vertical; min-height: 80px; }
.field input[type="checkbox"] { width: auto; margin-right: 6px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--c-brand);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(105, 38, 196, 0.14);
}
.field.has-error input, .field.has-error select, .field.has-error textarea {
  border-color: var(--c-danger-fg);
}
.field-error { margin: 4px 0 0; font-size: 12px; color: var(--c-danger-fg); font-weight: 600; }
.field-help { margin: 4px 0 0; font-size: 12px; color: var(--c-muted); }

.login-card .btn { width: 100%; justify-content: center; height: 46px; font-size: 14px; }
.login-err {
  padding: 11px 14px;
  margin-bottom: 16px;
  border-radius: var(--r-sm);
  background: var(--c-danger-bg);
  color: var(--c-danger-fg);
  font-weight: 600;
  font-size: 13px;
}
.login-foot { margin-top: 18px; text-align: center; font-size: 12px; color: var(--c-faint); }

/* Mensagens (toasts flutuantes, auto-dismiss) */
.messages {
  list-style: none;
  padding: 0;
  margin: 0;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 200;
  width: 380px;
  max-width: calc(100vw - 32px);
  display: grid;
  gap: 10px;
}
.messages li {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border-radius: var(--r-md);
  font-weight: 500;
  font-size: 14px;
  border: 1px solid var(--c-line);
  border-left: 3px solid var(--c-faint);
  background: var(--c-surface);
  box-shadow: var(--sh-md);
  animation: toast-in 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
.messages li.is-leaving { animation: toast-out 0.3s ease forwards; }
.messages li .toast-body { flex: 1; }
.messages li.success { background: var(--c-ok-bg); color: var(--c-ok-fg); border-left-color: var(--c-ok-fg); }
.messages li.warning { background: var(--c-warn-bg); color: var(--c-warn-fg); border-left-color: var(--c-warn-fg); }
.messages li.error { background: var(--c-danger-bg); color: var(--c-danger-fg); border-left-color: var(--c-danger-fg); }
.msg-close {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: currentColor;
  opacity: 0.55;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: opacity var(--t);
}
.msg-close:hover { opacity: 1; }
@keyframes toast-in { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(24px); } }

/* Utilitários de grid (reusáveis) */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) {
  .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
}

/* Utilitários de espaçamento vertical (mapeados aos tokens --sp-*) — substitui
   margin-bottom inline avulso e padroniza o ritmo entre seções */
.mb-4 { margin-bottom: var(--sp-4); }
.mb-5 { margin-bottom: var(--sp-5); }
.mb-6 { margin-bottom: var(--sp-6); }
.mb-8 { margin-bottom: var(--sp-8); }

/* Contêiner responsivo de gráfico (altura fixa exigida por maintainAspectRatio:false) */
.chart-box { position: relative; height: 300px; }
.chart-box.is-sm { height: 280px; }
@media (max-width: 560px) {
  .chart-box, .chart-box.is-sm { height: 220px; }
}

/* Card interativo (link com hover) — substitui onmouseover inline */
.card-link {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  padding: 24px;
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--t), transform var(--t), border-color var(--t);
}
.card-link:hover {
  box-shadow: var(--sh-md);
  transform: translateY(-2px);
  border-color: var(--c-brand);
}
.card-link-ico {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: var(--r-sm);
  flex: 0 0 46px;
  background: var(--ci-bg, var(--c-brand-50));
  color: var(--ci-fg, var(--c-brand));
}
.card-link-ico svg { width: 23px; height: 23px; }
.card-link-title { display: block; font-family: var(--font-display); font-size: 15px; font-weight: 600; color: var(--c-ink); margin-bottom: 3px; }
.card-link-desc { font-size: 13px; color: var(--c-muted); line-height: 1.45; }
.ci-emerald { --ci-bg: #E7F5EE; --ci-fg: #0E7A54; }
.ci-blue    { --ci-bg: #EEF1FB; --ci-fg: #3D53B5; }
.ci-amber   { --ci-bg: #FBF1E3; --ci-fg: #B45309; }
.ci-cyan    { --ci-bg: #E4F3F4; --ci-fg: #0B7285; }
.ci-rose    { --ci-bg: #FBEBEE; --ci-fg: #B0304A; }
.ci-sky     { --ci-bg: #E9F1F8; --ci-fg: #2E6FA6; }
.ci-violet  { --ci-bg: #F2ECFB; --ci-fg: #6926C4; }

/* Spinner (feedback de carregamento) */
.spinner {
  display: inline-block;
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.is-loading { pointer-events: none; opacity: 0.75; }

/* Form groups */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--c-muted); }
.form-group input, .form-group textarea, .form-group select { padding: 8px 10px; border: 1px solid var(--c-line); border-radius: var(--r-sm); background: var(--c-surface); font-size: 14px; color: var(--c-ink); }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px var(--c-brand-50); }

/* Menu dropdown do usuário */
.app-user-menu { position: relative; }
.app-user-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 6px 5px 12px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  background: var(--c-surface);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: border-color var(--t), box-shadow var(--t);
}
.app-user-trigger:hover { border-color: var(--c-brand); box-shadow: var(--sh-sm); }
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--t), transform var(--t), visibility var(--t);
  z-index: 100;
}
.app-user-menu.is-open .user-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.user-dropdown-head { padding: 10px 12px 8px; border-bottom: 1px solid var(--c-line-soft); margin-bottom: 6px; }
.user-dropdown-head strong { display: block; font-size: 14px; color: var(--c-ink); }
.user-dropdown-head span { font-size: 12px; color: var(--c-muted); }
.user-dropdown a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--c-ink-2);
  text-decoration: none;
  transition: background var(--t);
}
.user-dropdown a:hover { background: var(--c-surface-2); }
.user-dropdown a.is-danger { color: var(--c-danger-fg); }
.user-dropdown a.is-danger:hover { background: var(--c-danger-bg); }
.user-dropdown a svg { width: 16px; height: 16px; }

/* Botões de ação destrutiva */
.btn.is-danger { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn.is-danger:hover { background: var(--c-danger-700); box-shadow: 0 6px 16px rgba(192, 38, 55, 0.24); }
.btn.is-danger:disabled { opacity: 0.5; cursor: not-allowed; }

/* Breadcrumb */
.breadcrumb { display: flex; gap: 8px; font-size: 13px; color: var(--c-muted); margin-bottom: 12px; }
.breadcrumb ol { display: flex; gap: 8px; list-style: none; margin: 0; padding: 0; }
.breadcrumb li::after { content: "/"; margin-left: 8px; color: var(--c-line); }
.breadcrumb li:last-child::after { content: ""; }
.breadcrumb a { color: var(--c-brand); text-decoration: none; transition: color var(--t); }
.breadcrumb a:hover { color: var(--c-brand-dark); text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--c-ink); font-weight: 600; }

/* Componentes de formulário */
.required::after { content: "*"; color: var(--c-danger-fg); margin-left: 2px; }
.alert-error { padding: 12px 16px; background: var(--c-danger-bg); border: 1px solid #F3C9CE; border-radius: var(--r-sm); color: var(--c-danger-700); font-size: 14px; margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 14px; }
.saldo-badge { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: var(--r-sm); background: var(--c-bg-alt); font-size: 13px; font-weight: 600; color: var(--c-muted); min-width: 80px; justify-content: center; }
.item-controls { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-top: 1px solid var(--c-line-soft); }
.btn-add-row { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: var(--r-sm); border: 1px dashed var(--c-brand); background: transparent; color: var(--c-brand); font-size: 13px; font-weight: 600; cursor: pointer; transition: background var(--t); }
.btn-add-row:hover { background: var(--c-brand-50); }
.btn-remove-row { width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--c-line); background: transparent; color: var(--c-muted); cursor: pointer; font-size: 16px; display: flex; align-items: center; justify-content: center; transition: all var(--t); }
.btn-remove-row:hover { background: var(--c-danger-bg); border-color: var(--c-danger-fg); color: var(--c-danger-fg); }
.item-row-error { background: var(--c-danger-bg) !important; }
.page-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; }
.card-head-compact { padding-bottom: 0; border-bottom: none; display: flex; justify-content: space-between; align-items: baseline; }
.card-head-note { font-size: 12px; color: var(--c-muted); }

/* Tabela de itens */
#itens-table { width: 100%; border-collapse: collapse; }
#itens-table thead tr { border-bottom: 2px solid var(--c-line); }
#itens-table th { padding: 10px 8px; padding-left: 18px; text-align: left; font-family: var(--font-display); font-size: 10.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--c-muted); }
#itens-table th:first-child { width: 36px; }
#itens-table tbody tr { border-bottom: 1px solid var(--c-line-soft); }
#itens-table td { padding: 8px; }
#itens-table td:first-child { padding: 12px 18px; color: var(--c-muted); font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
#itens-table td:nth-child(3), #itens-table td:nth-child(4), #itens-table td:nth-child(5) { text-align: center; }
#itens-table select, #itens-table input[type="number"] { width: 100%; padding: 7px 10px; border: 1px solid var(--c-line); border-radius: var(--r-sm); background: var(--c-surface); font-size: 14px; color: var(--c-ink); }
#itens-table select:focus, #itens-table input[type="number"]:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px var(--c-brand-50); }
#itens-table input[type="hidden"] { display: none; }
.product-field { position: relative; }

/* Tabela de edição de itens de entrada de NF */
.entrada-itens td { vertical-align: top; }
.entrada-itens select, .entrada-itens input { width: 100%; padding: 7px 10px; border: 1px solid var(--c-line); border-radius: var(--r-sm); background: var(--c-surface); font-size: 14px; color: var(--c-ink); }
.entrada-itens select:focus, .entrada-itens input:focus { outline: none; border-color: var(--c-brand); box-shadow: 0 0 0 3px var(--c-brand-50); }
.entrada-itens input[type="hidden"] { display: none; }
.row-num { width: 36px; }

/* Filtros de lista */
.filter-card { padding: 16px 18px; margin-bottom: 16px; }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 12px;
  align-items: end;
}
.filter-grid .field { margin: 0; }
.filter-grid label {
  display: block;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin-bottom: 5px;
}
.filter-grid input, .filter-grid select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  background: var(--c-surface);
  font-size: 14px;
  color: var(--c-ink);
}
.filter-grid input:focus, .filter-grid select:focus {
  outline: none;
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px var(--c-brand-50);
}
.filter-actions { display: flex; gap: 8px; }
@media (max-width: 900px) {
  .filter-grid { grid-template-columns: 1fr 1fr; }
  .filter-actions { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  .filter-grid { grid-template-columns: 1fr; }
}

/* Paginação */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 16px;
  border-top: 1px solid var(--c-line-soft);
}
.page-link {
  padding: 7px 14px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  color: var(--c-brand);
  text-decoration: none;
  transition: background var(--t), border-color var(--t);
}
.page-link:hover { background: var(--c-brand-50); border-color: var(--c-brand); }
.page-link.is-disabled { color: var(--c-faint); border-color: var(--c-line-soft); pointer-events: none; }
.page-info { font-size: 13px; color: var(--c-muted); font-weight: 500; }

/* Modal (confirmação) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(22, 22, 26, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop.is-open { display: flex; animation: fade-in 0.18s ease; }
.modal {
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: modal-pop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--c-line);
}
.modal-head h3 { font-family: var(--font-display); font-size: 17px; font-weight: 600; color: var(--c-ink); }
.modal-head p { font-size: 13px; color: var(--c-muted); margin-top: 2px; }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-summary {
  display: flex;
  gap: 18px;
  padding: 12px 14px;
  background: var(--c-surface-2);
  border-radius: var(--r-sm);
  margin-bottom: 14px;
}
.modal-summary-item strong { display: block; font-size: 20px; font-weight: 600; color: var(--c-ink); }
.modal-summary-item span { font-size: 12px; color: var(--c-muted); }
.modal table { width: 100%; border-collapse: collapse; font-size: 14px; }
.modal table th {
  text-align: left;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--c-line);
}
.modal table td { padding: 8px; border-bottom: 1px solid var(--c-line-soft); }
.modal-confirm-check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--c-ink-2);
  cursor: pointer;
}
.modal-confirm-check input { width: 17px; height: 17px; cursor: pointer; }
.modal-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--c-line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* 7. Responsivo ------------------------------------------------------------ */
.app-side-toggle { display: none; }

@media (max-width: 1100px) {
  .stat-grid,
  .stat-grid.cols-3,
  .stat-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panels { grid-template-columns: 1fr; }
  .dash-mid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .app-sidebar {
    position: fixed;
    z-index: 50;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }
  .app.nav-open .app-sidebar { transform: translateX(0); }
  .app-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(22, 22, 26, 0.5);
  }
  .app.nav-open .app-backdrop { display: block; }
  .app-side-toggle {
    display: inline-grid;
    place-items: center;
    width: 40px; height: 40px;
    border: 1px solid var(--c-line);
    border-radius: var(--r-sm);
    background: #fff;
    cursor: pointer;
  }
  .app-side-toggle svg { width: 20px; height: 20px; }
  .app-content { padding: 18px 16px; }
  .app-topbar { padding: 0 16px; }
  .app-user-name { display: none; }
}

@media (max-width: 560px) {
  .stat-grid,
  .stat-grid.cols-2,
  .stat-grid.cols-3,
  .stat-grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
  .page-head { flex-direction: column; align-items: flex-start; }
  .bench-hero { grid-template-columns: 1fr; }
  .bench-actions { justify-self: start; }
  .bench-verdict { font-size: 22px; }
  .bench-meta { gap: 22px; }
  /* Formulários de 2 colunas empilham em telas estreitas */
  .form-row { grid-template-columns: 1fr; }
  /* Conforto de toque (alvos >= ~40px) e menos padding lateral */
  .app-content { padding: 16px 14px; }
  .periodo-btn { padding: 9px 15px; }
  .page-link { padding: 10px 16px; }
  .app-nav-item { padding-top: 12px; padding-bottom: 12px; }
  /* Botões de ação no topo ocupam a largura e não espremem o texto */
  .quick-row { width: 100%; }
  .quick-row .btn { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ==========================================================================
   8. Barra de Filtros (_filtro_barra.html)
   ========================================================================== */
.filtro-barra {
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  justify-content: space-between;
}
.filtro-label {
  display: block;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--c-muted);
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.periodo-btns {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.periodo-btn {
  padding: 6px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  color: var(--c-ink-2);
  transition: background var(--t), color var(--t), border-color var(--t);
}
.periodo-btn:hover { background: var(--c-surface-2); border-color: var(--c-brand); }
.periodo-btn.is-active { background: var(--c-brand); color: #fff; border-color: var(--c-brand); }
.filtro-datas {
  display: none;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}
.filtro-datas.is-visible { display: flex; }
.filtro-input {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--c-ink);
  background: var(--c-surface);
}
.filtro-select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--c-ink);
  background: var(--c-surface);
  cursor: pointer;
  min-width: 160px;
}
@media (max-width: 700px) {
  .filtro-barra { flex-direction: column; align-items: stretch; }
  .periodo-btns { flex-wrap: wrap; }
  /* Campos de filtro ocupam a largura e não estouram por opção longa de select */
  .filtro-barra > div:first-child > div { flex: 1 1 100%; min-width: 0; }
  .filtro-select, .filtro-input { width: 100%; min-width: 0; max-width: 100%; }
}

/* ==========================================================================
   9. Painel de Decisões — leitura de instrumento (assinatura)
   "Onde o dinheiro está preso e por onde ele vaza." Herói = total em jogo;
   cada sinal é uma linha de leitura com faixa de referência e ação.
   ========================================================================== */

/* Herói — a leitura principal (total em R$) */
.decisao-hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 28px;
  margin-bottom: 22px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  box-shadow: var(--sh-sm);
  overflow: hidden;
}
/* Régua graduada tênue ao fundo, à direita — o "instrumento" */
.decisao-hero::after {
  content: "";
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 42%;
  color: var(--c-line-soft);
  background-image: repeating-linear-gradient(90deg, currentColor 0 1.5px, transparent 1.5px 13px);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000);
  mask-image: linear-gradient(90deg, transparent, #000);
  pointer-events: none;
}
.decisao-hero-main { position: relative; z-index: 1; }
.decisao-hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--c-brand);
  margin-bottom: 8px;
}
.decisao-hero-value {
  font-family: var(--font-mono);
  font-size: clamp(34px, 6vw, 46px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--c-ink);
}
.decisao-hero-sub {
  position: relative;
  z-index: 1;
  max-width: 260px;
  text-align: right;
  font-size: 12.5px;
  color: var(--c-muted);
  line-height: 1.5;
}
.decisao-hero-sub strong { color: var(--c-ink-2); font-weight: 600; }

/* Lista de leituras (sinais) — separadas por régua fina */
.leitura-lista {
  display: flex;
  flex-direction: column;
  margin-bottom: 22px;
}
.leitura {
  --sev: var(--c-muted);
  --sev-bg: var(--c-surface-2);
  display: grid;
  grid-template-columns: minmax(180px, 230px) 150px 1fr;
  align-items: center;
  gap: 18px;
  padding: 18px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-top: none;
  border-left: 3px solid var(--sev);
}
.leitura:first-child { border-top: 1px solid var(--c-line); border-radius: var(--r-md) var(--r-md) 0 0; }
.leitura:last-child { border-radius: 0 0 var(--r-md) var(--r-md); }
.leitura.is-ok       { --sev: #B4B4AE; --sev-bg: var(--c-surface-2); }
.leitura.is-atencao  { --sev: var(--c-warn-fg); --sev-bg: var(--c-warn-bg); }
.leitura.is-critico  { --sev: var(--c-danger-fg); --sev-bg: var(--c-danger-bg); }

.leitura-id { min-width: 0; }
.leitura-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--sev-bg);
  color: var(--sev);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.leitura-chip::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sev);
}
.leitura-titulo {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  color: var(--c-ink);
  letter-spacing: -0.01em;
}
.leitura-valor {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--c-ink);
  text-align: right;
  white-space: nowrap;
}
.leitura-valor small { display: block; font-size: 10.5px; font-weight: 500; color: var(--c-muted); letter-spacing: 0.04em; }
.leitura-corpo { min-width: 0; }
.leitura-resumo { font-size: 13px; color: var(--c-ink-2); margin-bottom: 8px; }
.leitura-track {
  position: relative;
  height: 7px;
  border-radius: var(--r-pill);
  color: var(--c-line);
  background-image: repeating-linear-gradient(90deg, currentColor 0 1.5px, transparent 1.5px 7px);
  margin-bottom: 4px;
}
.leitura-track-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--pct, 0%);
  min-width: 3px;
  border-radius: var(--r-pill);
  background: var(--sev);
}
.leitura-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 11.5px;
  color: var(--c-muted);
}
.leitura-acao { color: var(--sev); font-weight: 600; }
.leitura.is-ok .leitura-acao { color: var(--c-muted); }

/* Barra de percentual reutilizável (curva ABC, compras) */
.barra-pct {
  position: relative;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--c-line-soft);
  overflow: hidden;
}
.barra-pct-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--pct, 0%);
  background: var(--barra-cor, var(--c-brand));
  border-radius: var(--r-pill);
}

/* Etiquetas de classe ABC */
.abc-tag {
  display: inline-grid;
  place-items: center;
  width: 22px; height: 22px;
  border-radius: var(--r-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}
.abc-A { background: var(--c-brand); }
.abc-B { background: #2E6FA6; }
.abc-C { background: #B4B4AE; }

@media (max-width: 720px) {
  .decisao-hero { flex-direction: column; align-items: flex-start; }
  .decisao-hero-sub { text-align: left; max-width: none; }
  .decisao-hero::after { display: none; }
  .leitura {
    grid-template-columns: 1fr auto;
    grid-template-areas: "id valor" "corpo corpo";
    gap: 10px 14px;
  }
  .leitura-id { grid-area: id; }
  .leitura-valor { grid-area: valor; }
  .leitura-corpo { grid-area: corpo; }
}
