/* ═══════════════════════════════════════════════════════════
   AudiStock — sistema visual v6
   Grafite e concreto, um laranja de sinalização (com texto preto,
   como placa de galpão) usado com parcimônia, números de etiqueta
   (IBM Plex Sans Condensed) e a régua de divergência.
   Contrastes de texto em AA (4,5:1) nos dois temas.
═══════════════════════════════════════════════════════════ */

:root, [data-theme="dark"] {
    color-scheme: dark;
    --bg: #111110; --surface: #1c1c1a; --surface-2: #232321; --surface-3: #2c2c29;
    --border: #2c2c29; --border-strong: #3d3d39; --border-input: #6a6862;
    --text: #eceae5; --text-muted: #aaa69d; --text-faint: #8d897f;
    --accent: #ff7a1a; --accent-hover: #ff9142; --accent-soft: rgba(255, 122, 26, .14); --accent-text: #ff9a4d; --on-accent: #1a1206; --foco: #ff7a1a; --accent-linha: #ff7a1a;
    --success: #6cc990; --success-soft: rgba(108, 201, 144, .13); --success-solid: #3fa968;
    --danger: #f37b76; --danger-soft: rgba(243, 123, 118, .13); --danger-solid: #c93c35;
    --warning: #e3b341; --warning-soft: rgba(227, 179, 65, .13); --warning-solid: #c99a2e;
    --backdrop: rgba(0, 0, 0, .55);
    --shadow-pop: 0 8px 24px rgba(0, 0, 0, .45);
    --shadow-modal: 0 16px 40px rgba(0, 0, 0, .55);
}
[data-theme="light"] {
    color-scheme: light;
    --bg: #f0f0ee; --surface: #ffffff; --surface-2: #f8f8f7; --surface-3: #e9e9e6;
    --border: #e1e0dc; --border-strong: #cbcac5; --border-input: #8f8d87;
    --text: #1c1b19; --text-muted: #5c5850; --text-faint: #6b675e;
    /* Claro: o laranja vivo nos preenchimentos (com texto preto) e nas barras,
       que sempre vêm com o número escrito ao lado; foco e texto em laranja
       usam o tom escuro, que passa de 4,5:1 sobre o fundo */
    --accent: #ff7a1a; --accent-hover: #f06800; --accent-soft: #fff0e2; --accent-text: #a85000; --on-accent: #1a1206; --foco: #a85000; --accent-linha: #ff7a1a;
    --success: #166534; --success-soft: #dcefe2; --success-solid: #22a05a;
    --danger: #b91c1c; --danger-soft: #f8e1e1; --danger-solid: #dc3c3c;
    --warning: #8a4a0b; --warning-soft: #f8ead0; --warning-solid: #b07214;
    --backdrop: rgba(28, 27, 25, .40);
    --shadow-pop: 0 8px 24px rgba(28, 27, 25, .10);
    --shadow-modal: 0 16px 40px rgba(28, 27, 25, .18);
}
:root {
    --font: 'IBM Plex Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
    --cond: 'IBM Plex Sans Condensed', 'IBM Plex Sans', system-ui, sans-serif;   /* números de etiqueta */
    --r-sm: 4px; --r: 6px; --r-lg: 10px;
    --sidebar-w: 232px; --topbar-h: 56px; --demo-h: 0px; --topo: calc(var(--topbar-h) + var(--demo-h));
    --t: 120ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--topo) + 16px); }
:root:has(body.com-demo) { --demo-h: 32px; }
body.com-demo { --demo-h: 32px; --topo: calc(var(--topbar-h) + 32px); }
/* Na demonstração, o lugar da faixa fica reservado desde o primeiro quadro
   (classe posta pelo script do tema): ela entra sem empurrar a tela */
html.demo-cedo body:not(.com-demo):has(.app-shell)::before { content: ''; display: block; height: 32px; }
/* A barra fixa de baixo (fechamento) não cobre o campo em foco */
html:has(.barra-acoes) { scroll-padding-bottom: 96px; }
body { font: 400 14px/1.5 var(--font); background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
a { color: var(--text); text-decoration-color: var(--accent); text-decoration-thickness: 2px; text-underline-offset: 3px; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { display: block; flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--foco); outline-offset: 2px; border-radius: var(--r-sm); }
::selection { background: var(--accent-soft); }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--text-muted); }
.nowrap { white-space: nowrap; }
.print-only { display: none !important; }
.pular { position: fixed; left: 12px; top: -100px; z-index: 600; padding: 8px 14px; border-radius: var(--r); background: var(--surface); color: var(--text); border: 1px solid var(--border-strong); }
.pular:focus { top: 8px; box-shadow: var(--shadow-modal); }
.topbar-titulo:focus { outline: none; }   /* o título recebe o foco na troca de tela, para ser anunciado */
.page-content:focus { outline: none; }
.so-celular, .so-celular-bloco { display: none !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }

/* ── LAYOUT ─────────────────────────────────────────────── */
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: var(--demo-h) auto 0 0; width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; z-index: 200; }
.sidebar-marca { display: flex; align-items: center; gap: 10px; height: var(--topbar-h); padding: 0 16px 0 20px; border-bottom: 1px solid var(--border); }
.marca-icone { width: 28px; height: 28px; border-radius: var(--r); background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.marca-icone svg { width: 17px; height: 17px; stroke-width: 2; }
.marca-nome { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; flex: 1; }
.sidebar .sidebar-fechar { display: none; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 12px 16px; }
.nav-grupo + .nav-grupo { margin-top: 16px; }
.nav-secao { font-size: 12px; font-weight: 500; color: var(--text-faint); padding: 0 10px 6px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 10px; border-radius: var(--r); color: var(--text-muted); font-weight: 500; text-decoration: none; transition: background var(--t), color var(--t); }
.nav-item svg { width: 18px; height: 18px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item[aria-current="page"] { background: var(--surface-3); color: var(--text); }
.nav-item[aria-current="page"]::before { content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 2px; border-radius: 2px; background: var(--accent-linha); }
.sidebar-rodape { border-top: 1px solid var(--border); padding: 12px; }
.usuario { display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 6px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-3); color: var(--text); font-weight: 600; display: grid; place-items: center; flex-shrink: 0; }
.usuario-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.usuario-nome { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-papel { font-size: 12px; color: var(--text-muted); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: var(--backdrop); z-index: 199; }
.sidebar-overlay.visible { display: block; }

.main { margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.topbar { position: sticky; top: var(--demo-h); z-index: 100; height: var(--topbar-h); display: flex; align-items: center; gap: 12px; padding: 0 32px; background: var(--bg); border-bottom: 1px solid var(--border); }
.topbar-titulo { flex: 1; min-width: 0; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .btn-hamburger { display: none; }
.page-content { flex: 1; width: 100%; max-width: 1280px; margin: 0 auto; padding: 28px 32px 48px; }

.demo-bar { position: sticky; top: 0; z-index: 300; display: flex; align-items: center; justify-content: center; gap: 14px; height: var(--demo-h); padding: 0 16px; font-size: 13px; background: var(--accent-soft); color: var(--text); border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; }
[data-theme="light"] .demo-bar { background: #ffe9d5; }
[data-theme="dark"] .demo-bar, :root:not([data-theme]) .demo-bar { background: #2a1c10; }
.offline-bar { display: none; align-items: center; justify-content: center; gap: 8px; padding: 6px 16px; font-size: 13px; background: var(--warning-soft); color: var(--warning); border-bottom: 1px solid var(--border); }
.offline-bar.visible { display: flex; }
.offline-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }

/* ── CABEÇALHO DE PÁGINA E BARRA DE FERRAMENTAS ─────────── */
.voltar { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); text-decoration: none; font-weight: 500; margin-bottom: 10px; min-height: 28px; }
.voltar svg { width: 16px; height: 16px; }
.voltar:hover { color: var(--text); }
.cabecalho { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.cabecalho-titulo { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font: 600 28px/1.15 var(--cond); letter-spacing: 0; }
.cabecalho-titulo .badge { font-family: var(--font); }
/* Os fatos da auditoria, lado a lado, separados por espaço */
.cabecalho-meta { display: flex; flex-wrap: wrap; gap: 4px 28px; margin-top: 6px; color: var(--text-muted); }
.cabecalho-meta > span { white-space: nowrap; }
.cabecalho > div:first-child { flex: 1 1 420px; min-width: 0; }
.cabecalho-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .espaco { flex: 1; }
.toolbar-acoes { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.toolbar .form-input { width: auto; }
.contador { color: var(--text-muted); font-size: 13px; margin: -6px 0 12px; }

/* ── BOTÕES ─────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 36px; padding: 0 14px; border: 1px solid transparent; border-radius: var(--r); font-weight: 500; line-height: 1; white-space: nowrap; cursor: pointer; text-decoration: none; transition: background var(--t), border-color var(--t), color var(--t); }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border-strong); color: var(--text); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-2); border-color: var(--text-faint); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--danger-solid); color: #fff; }
[data-theme="light"] .btn-danger { background: #c92a2a; }
.btn-danger:hover:not(:disabled) { filter: brightness(.93); }
.btn-perigo-texto { color: var(--danger); }
.btn-perigo-texto:hover:not(:disabled) { background: var(--danger-soft); color: var(--danger); }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-bloco { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-icone { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: var(--r); background: transparent; color: var(--text-muted); cursor: pointer; transition: background var(--t), color var(--t); }
.btn-icone svg { width: 18px; height: 18px; }
.btn-icone:hover { background: var(--surface-2); color: var(--text); }
.link { background: none; border: 0; padding: 0; color: var(--text); font-weight: 500; text-decoration: underline 2px var(--accent); text-underline-offset: 3px; cursor: pointer; }
kbd { font: 500 11px/1 var(--mono); padding: 3px 5px; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: var(--r-sm); color: var(--text-muted); }

/* ── FORMULÁRIOS ────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }
.form-label { font-size: 13px; font-weight: 500; color: var(--text-muted); }
.form-label .opcional { font-weight: 400; color: var(--text-faint); }
.form-input, .input-field { width: 100%; min-height: 38px; padding: 7px 12px; background: var(--surface); border: 1px solid var(--border-input); border-radius: var(--r); color: var(--text); outline: none; transition: border-color var(--t), box-shadow var(--t); }
textarea.form-input { min-height: 72px; resize: vertical; line-height: 1.45; }
.form-input::placeholder, .input-field::placeholder { color: var(--text-faint); }
.form-input:hover, .input-field:hover { border-color: var(--text-faint); }
.form-input:focus, .input-field:focus { border-color: var(--foco); box-shadow: 0 0 0 1px var(--foco), 0 0 0 4px var(--accent-soft); }
@media (forced-colors: active) { .form-input:focus, .input-field:focus { outline: 2px solid CanvasText; outline-offset: 1px; } }
.form-input[readonly] { background: var(--surface-2); color: var(--text-muted); border-color: var(--border-strong); cursor: default; }
.form-input:disabled { background: var(--surface-2); color: var(--text-muted); border-color: var(--border-strong); cursor: not-allowed; }
.form-input[aria-invalid="true"] { border-color: var(--danger); }
select.form-input { appearance: none; padding-right: 34px; cursor: pointer; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238d897f' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E") no-repeat right 12px center; }
input[type="number"].form-input, input[type="number"].input-field { appearance: textfield; -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="file"].form-input { padding: 6px; cursor: pointer; }
input[type="file"]::file-selector-button { margin-right: 12px; padding: 5px 12px; border: 1px solid var(--border-strong); border-radius: var(--r); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--foco); cursor: pointer; flex-shrink: 0; }
fieldset { border: 0; min-width: 0; }
legend { padding: 0; }
.checagem { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; color: var(--text-muted); cursor: pointer; user-select: none; }
.form-hint { font-size: 12px; color: var(--text-faint); }
.form-erro { font-size: 13px; color: var(--danger); }
.form-group .form-erro:empty { display: none; }
.grade-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grade-2 > .form-group:last-child, .grade-2 > .form-group:nth-last-child(2) { margin-bottom: 16px; }
.campo-busca { position: relative; }
.campo-busca svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--text-faint); pointer-events: none; }
.campo-busca .form-input { padding-left: 34px; width: 260px; max-width: 100%; }
.campo-busca .form-input::-webkit-search-cancel-button { -webkit-appearance: none; width: 14px; height: 14px; cursor: pointer; background: var(--text-faint); -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / 14px no-repeat; mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M18 6 6 18M6 6l12 12'/%3E%3C/svg%3E") center / 14px no-repeat; }
.zona-arquivo { display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 12px; border: 1px dashed var(--border-input); border-radius: var(--r); cursor: pointer; }
.zona-arquivo:hover { border-color: var(--accent-linha); }
.zona-arquivo:focus-within { border-color: var(--foco); box-shadow: 0 0 0 3px var(--accent-soft); }
.zona-arquivo-nome { color: var(--text-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zona-arquivo-nome.escolhido { color: var(--text); font-weight: 500; }

/* ── CARTÕES ────────────────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--r-lg); margin-bottom: 20px; min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; min-height: 64px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 13px; color: var(--text-muted); }
.card-body { padding: 20px; }
.card-body + .card-body { border-top: 1px solid var(--border); }
.duas-colunas { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.duas-colunas.topo-alinhado { align-items: start; }
.card > .tabela-wrap:first-child th:first-child { border-top-left-radius: var(--r-lg); }
.card > .tabela-wrap:first-child th:last-child { border-top-right-radius: var(--r-lg); }
.duas-colunas > .card { margin-bottom: 0; }

/* ── INDICADORES (faixa única, sem cartões repetidos) ───── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); background: var(--surface); border-radius: var(--r-lg); margin-bottom: 20px; overflow: hidden; }
.kpi { position: relative; padding: 16px 20px; border-left: 1px solid var(--border); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi-rotulo { font-size: 13px; color: var(--text-muted); }
.kpi-valor { font: 600 38px/1.1 var(--cond); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi-valor small { font: 500 15px var(--font); color: var(--text-muted); }
.kpi-apoio { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.kpi-destaque::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--accent-linha); }
.kpi-sobra .kpi-valor { color: var(--success); }
.kpi-falta .kpi-valor { color: var(--danger); }
.kpi-apoio.positivo, .kpi-apoio .positivo { color: var(--success); }
.kpi .kpi-valor.zero { color: var(--text-faint); }
.kpi-apoio .link { font-weight: 400; }
.campo-ordem { display: flex; align-items: center; gap: 8px; }
.campo-ordem .form-label { white-space: nowrap; margin: 0; }
.campo-ordem .form-input { width: auto; }
.campo-empresa { width: 240px; }
.resultado { display: inline-flex; flex-wrap: wrap; gap: 0 6px; }
.resultado .sep { color: var(--text-faint); }
.secao-nao-contados summary { cursor: pointer; list-style: none; border-bottom: 0; }
.secao-nao-contados details[open] > summary { border-bottom: 1px solid var(--border); }
.detalhes-rotulo { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-muted); }
.detalhes-rotulo svg { width: 16px; height: 16px; order: 1; transition: transform 150ms ease; }
details[open] .detalhes-rotulo svg { transform: rotate(180deg); }
@container tabela (min-width: 1000px) {
    /* Colunas fixas: a tabela não muda de largura ao trocar o filtro */
    .tabela-relatorio, .tabela-relatorio-simples { table-layout: fixed; }
    .tabela-relatorio col.c-codigo, .tabela-relatorio-simples col.c-codigo { width: 118px; }
    .tabela-relatorio col.c-num, .tabela-relatorio-simples col.c-num { width: 132px; }
    .tabela-relatorio col.c-dif { width: 196px; }
    .tabela-relatorio col.c-sit { width: 112px; }
}
.kpi-apoio a { color: inherit; }

/* ── BARRAS ─────────────────────────────────────────────── */
.barra { height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.barra > i { display: block; height: 100%; border-radius: 3px; background: var(--accent-linha); }
.importando { margin-bottom: 14px; }
.importando-linha { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.importando-linha strong { color: var(--text); font-variant-numeric: tabular-nums; }
.barra-empilhada { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--surface-3); gap: 2px; }
.barra-empilhada > i { display: block; height: 100%; }
.seg-ok { background: var(--text-faint); opacity: .45; }
.seg-sobra { background: var(--success-solid); }
.seg-falta { background: var(--danger-solid); }
.legenda { display: grid; gap: 10px; margin-top: 16px; }
.legenda-item { display: flex; align-items: center; gap: 10px; }
.legenda-item .ponto { width: 10px; height: 10px; border-radius: 2px; }
.legenda-item .nome { flex: 1; }
.legenda-item .valor { font: 600 16px var(--cond); font-variant-numeric: tabular-nums; }
.legenda-item .pct { font-variant-numeric: tabular-nums; color: var(--text-muted); width: 44px; text-align: right; }

/* ── SELOS ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 1px 8px; border-radius: var(--r-sm); font-size: 12px; font-weight: 500; line-height: 20px; white-space: nowrap; background: var(--surface-3); color: var(--text-muted); }
.badge-sucesso { background: var(--success-soft); color: var(--success); }
.badge-perigo { background: var(--danger-soft); color: var(--danger); }
.badge-aviso { background: var(--warning-soft); color: var(--warning); }
.badge-acento { background: var(--accent-soft); color: var(--accent-text); }
.badge-neutro { background: var(--surface-3); color: var(--text-muted); }
.badge-calmo { background: transparent; color: var(--text-muted); box-shadow: inset 0 0 0 1px var(--border-strong); }

/* ── CONTROLE SEGMENTADO (filtros, modos) ───────────────── */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 8px; max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button { flex: 1 0 auto; min-height: 30px; padding: 0 12px; border: 0; border-radius: var(--r); background: transparent; color: var(--text-muted); font-weight: 500; cursor: pointer; white-space: nowrap; transition: background var(--t), color var(--t); }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--border-strong); }
.seg .qtd { font-variant-numeric: tabular-nums; color: var(--text-muted); margin-left: 4px; font-weight: 400; }

/* ── TABELAS ────────────────────────────────────────────── */
.tabela-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; container: tabela / inline-size; }
/* Telas largas: em listas longas o cabeçalho da tabela fica preso sob o
   topo ao rolar. "clip" não cria área de rolagem, então o sticky segue a página. */
@media screen and (min-width: 1181px) {
    html { scroll-padding-top: calc(var(--topo) + 56px); }
    .tabela-wrap { overflow-x: clip; }
    .tabela-wrap > table > thead th { position: sticky; top: var(--topo); z-index: 2; }
}
/* Tabela estreita (tablet, notebook pequeno): as colunas secundárias saem e
   o que elas mostravam vai para a linha de baixo da coluna principal */
.so-medio-bloco { display: none !important; }   /* vence o display de .sub, que vem depois */
@container tabela (max-width: 999px) {
    .tabela-fixa, .tabela-relatorio, .tabela-relatorio-simples { table-layout: auto !important; }
    .tabela-fixa colgroup, .tabela-relatorio colgroup, .tabela-relatorio-simples colgroup { display: none; }
    .col-larga { display: none !important; }
    .so-medio-bloco { display: block !important; }
    .tabela-fixa td.email { min-width: 140px; }
    .tabela-lista .resultado { flex-direction: column; }   /* faltas e sobras uma embaixo da outra, sem "·" sobrando no fim da linha */
    .tabela-lista .resultado .sep { display: none; }
}
/* Lista estreita (até 700 px de largura útil, mesmo fora do celular: tablet
   pequeno, janela dividida): a tabela vira a lista de cartões do celular,
   em vez de rolar de lado */
@container tabela (max-width: 699px) {
    .tabela-lista thead, .tabela-lista colgroup { display: none; }
    .tabela-lista, .tabela-lista tbody { display: block; }
    .tabela-lista tr { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 4px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); }
    .tabela-lista tbody tr:last-child { border-bottom: 0; }
    .tabela-lista td { display: block; padding: 0 !important; border: 0; }
    .tabela-lista .so-desktop { display: none; }
    .tabela-lista .so-celular-bloco { display: block !important; }
    .tabela-lista span.so-celular, .tabela-lista .partes > .so-celular { display: inline !important; }
    .tabela-lista .so-medio-bloco:not(.so-celular-bloco) { display: none !important; }
    .tabela-lista td.l-titulo { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
    .tabela-lista td.l-linha { grid-column: 1 / -1 !important; justify-self: stretch !important; text-align: left !important; }
    .tabela-lista td.l-linha .acoes-linha { justify-content: flex-start; margin-top: 6px; }
    .tabela-lista td.l-linha .btn { flex: 1 1 0; }
    .tabela-lista .linha-link.cobre::after { content: ''; position: absolute; inset: 0; }
    .tabela-lista .resultado { justify-content: flex-end; flex-direction: column; align-items: flex-end; }
    .tabela-lista .resultado .sep { display: none; }
    .tabela-lista .sub .forte { color: var(--text); }
    .tabela-lista td.num { align-self: start; }
    .tabela-lista td:not(.l-titulo) { grid-column: 2; text-align: right; justify-self: end; }
    .tabela-lista .acoes-linha { justify-content: flex-end; }
}
/* Tabela pequena dentro de janela, no celular: só as colunas essenciais */
@container tabela (max-width: 479px) {
    .col-opcional { display: none; }
}
table { width: 100%; border-collapse: collapse; }
th { padding: 10px 16px; text-align: left; font-size: 12px; font-weight: 500; color: var(--text-muted); background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--t); }
tbody tr:hover { background: var(--surface-2); }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.codigo { font-family: var(--mono); font-size: 13px; color: var(--text-muted); white-space: nowrap; }
.forte { font-weight: 500; }
.sub { display: block; font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.sub .codigo { font-size: 12px; }
/* Trechos "a · b · c": a quebra cai entre trechos. Cada trecho leva o "·" à
   esquerda, e o começo de cada linha fica recortado: o "·" nunca aparece
   sozinho no fim nem no começo de uma linha (mesma ideia de .cabecalho-meta) */
.partes { display: flex; flex-wrap: wrap; margin-left: -14px; clip-path: inset(0 0 0 14px); }
.partes > *::before { content: '·'; display: inline-block; width: 14px; margin-left: -14px; text-align: center; color: var(--text-faint); }
/* O "·" fica no recuo do trecho: um trecho que quebra no meio continua
   alinhado ao texto, e não embaixo do recorte do começo da linha */
.partes > * { min-width: 0; padding-left: 14px; }
.un { font-size: 12px; color: var(--text-faint); margin-left: 2px; }
.num .un, .saldo-wrap .un { display: inline-block; min-width: 2.6em; text-align: left; margin-left: 4px; }
.tabela-fixa { table-layout: fixed; }
.tabela-fixa td { overflow-wrap: break-word; }
.dif-sobra { color: var(--success); font-weight: 500; }
/* Régua de divergência: o zero no meio; a falta cresce para a esquerda e a
   sobra para a direita, pelo tamanho em relação ao saldo (cheia a partir de 25%) */
.regua-linha { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.regua { position: relative; flex: none; width: 72px; height: 8px; border-radius: 1px; background: var(--surface-3); }
.regua::after { content: ''; position: absolute; left: calc(50% - 1px); top: -3px; width: 2px; height: 14px; border-radius: 1px; background: var(--text-muted); }
.regua > i { position: absolute; top: 0; bottom: 0; }
.regua-falta { right: 50%; background: var(--danger-solid); border-radius: 1px 0 0 1px; }
.regua-sobra { left: 50%; background: var(--success-solid); border-radius: 0 1px 1px 0; }
[data-theme="light"] .regua { background: #dddcd7; }
@media (max-width: 640px) { .regua { width: 56px; } }
.dif-falta { color: var(--danger); font-weight: 500; }
.dif-zero, .dif-nula { color: var(--text-faint); }
.dif-erro { display: inline-block; white-space: normal; text-align: right; max-width: 22ch; }   /* a célula numérica não quebra linha; a mensagem quebra */
.acoes-linha { display: flex; justify-content: flex-end; gap: 4px; }
tr.inativa td { color: var(--text-faint); }
tr.inativa .forte { color: var(--text-muted); }
tr.recente { animation: destaque 1.6s ease-out; }
@keyframes destaque { from { background: var(--success-soft); } to { background: transparent; } }
.tabela-rodape { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--border); color: var(--text-muted); font-size: 13px; }
.paginacao { display: flex; align-items: center; gap: 8px; }
.linha-link { color: inherit; text-decoration: none; }

summary::-webkit-details-marker { display: none; }
.detalhes-rotulo::after { content: 'Mostrar'; }
details[open] .detalhes-rotulo::after { content: 'Ocultar'; }

/* ── ESTADOS VAZIOS, CARREGAMENTO, AVISOS ───────────────── */
.vazio { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: 48px 24px; }
.vazio-compacto { padding: 28px 20px; }
.vazio-titulo { font-weight: 600; font-size: 15px; }
.vazio-texto { color: var(--text-muted); max-width: 440px; }
.vazio-acoes { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }
.skel { display: block; height: 12px; border-radius: 4px; background: var(--surface-3); animation: pulso 1.2s ease-in-out infinite alternate; }
.skel + .skel { margin-top: 12px; }
@keyframes pulso { from { opacity: .55; } to { opacity: 1; } }
.carregando-bloco { padding: 20px; }
.esqueleto-linhas { display: grid; align-content: center; gap: 8px; min-height: 40px; }
.esqueleto-linhas .skel + .skel { margin-top: 0; }
.aviso { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--border); background: var(--surface-2); margin-bottom: 16px; }
.aviso svg { width: 18px; height: 18px; margin-top: 1px; }
.aviso-perigo { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.aviso-aviso { background: var(--warning-soft); border-color: transparent; color: var(--warning); }
.aviso-sucesso { background: var(--success-soft); border-color: transparent; color: var(--success); }
.aviso p { color: var(--text); }
.aviso strong { color: inherit; }
.aviso > div { display: grid; gap: 6px; min-width: 0; }
.aviso[tabindex="-1"]:focus { outline: none; }   /* recebe o foco só para ser lido e ficar à vista */
.lista-simples { margin: 0; padding-left: 18px; color: var(--text); }
.lista-simples li + li { margin-top: 2px; }
.lista-erros { list-style: none; margin-top: 8px; display: grid; gap: 2px; font-size: 13px; color: var(--text); }

/* ── MODAIS ─────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 24px; background: var(--backdrop); overflow-y: auto; opacity: 0; transition: opacity 150ms ease; }
.modal-backdrop.active { opacity: 1; }
.modal { width: 100%; max-width: 480px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-modal); display: flex; flex-direction: column; max-height: calc(100vh - 48px); transform: translateY(6px); transition: transform 150ms ease; }
.modal-backdrop.active .modal { transform: none; }
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 560px; }
.modal-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 0 24px; }
.modal-titulo { font-size: 17px; }
.modal-sub { margin-top: 4px; color: var(--text-muted); font-size: 13px; }
.modal-x { margin: -6px -6px 0 0; }
.modal-corpo { padding: 18px 24px 4px; overflow-y: auto; }
.modal-texto { color: var(--text-muted); white-space: pre-line; }
.modal-texto strong { color: var(--text); font-weight: 500; }
.modal-rodape { display: flex; justify-content: flex-end; gap: 8px; padding: 18px 24px 20px; }

/* ── AVISOS FLUTUANTES ──────────────────────────────────── */
body:has(.barra-acoes) .toasts { bottom: 84px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 8px 6px 8px 14px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); box-shadow: var(--shadow-pop); opacity: 0; transform: translateY(6px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: none; }
.toast-icone { color: var(--tc); align-self: flex-start; margin-top: 4px; }
.toast-icone svg { width: 16px; height: 16px; }
.toast-msg { flex: 1; line-height: 1.45; padding: 3px 0; }
.toast-msg a { color: var(--accent-text); font-weight: 500; margin-left: 6px; white-space: nowrap; }
.toast-fechar { width: 26px; height: 26px; }
.toast-fechar svg { width: 14px; height: 14px; }
.toast-sucesso { --tc: var(--success-solid); }
.toast-erro { --tc: var(--danger-solid); }
.toast-aviso { --tc: var(--warning-solid); }
.toast-info { --tc: var(--text-muted); }

.loading-overlay { position: fixed; inset: 0; z-index: 2000; display: none; place-items: center; background: color-mix(in srgb, var(--bg) 55%, transparent); }
.loading-overlay.active { display: grid; }
.carregando { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); box-shadow: var(--shadow-pop); color: var(--text-muted); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--surface-3); border-top-color: var(--accent-linha); border-radius: 50%; animation: gira .7s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }

/* ── DASHBOARD ──────────────────────────────────────────── */
.lista-andamento { list-style: none; }
.lista-andamento li + li { border-top: 1px solid var(--border); }
.andamento { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; padding: 14px 20px; color: inherit; text-decoration: none; transition: background var(--t); }
.andamento:hover { background: var(--surface-2); }
.andamento .barra { grid-column: 1 / -1; }
.andamento-pct { font-variant-numeric: tabular-nums; color: var(--text-muted); font-size: 13px; }
.comecar { display: grid; gap: 4px; padding: 28px; background: var(--surface); border-radius: var(--r-lg); margin-bottom: 20px; }
.comecar h2 { font-size: 18px; }
.comecar p { color: var(--text-muted); max-width: 560px; }
.passos { list-style: none; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 16px; counter-reset: passo; }
.passos li { counter-increment: passo; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r); background: var(--surface-2); }
.passos strong { display: block; font-weight: 500; }
.passos span { color: var(--text-muted); font-size: 13px; }
.passos li::before { content: counter(passo); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); font-size: 12px; font-weight: 600; margin-bottom: 8px; }
/* Roteiro da demonstração: os três passos em sequência, cada um um link;
   o número em algarismo de etiqueta, sem caixas em volta */
.roteiro { padding: 18px 24px 20px; }
.roteiro-topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.roteiro-topo h2 { font-size: 15px; }
.roteiro .passos { gap: 8px 28px; margin-top: 10px; }
.roteiro .passos li { padding: 0; border: 0; background: none; }
.roteiro .passos li::before { content: none; }
.roteiro .passos a { display: grid; grid-template-columns: auto 1fr; column-gap: 12px; color: inherit; text-decoration: none; border-radius: var(--r); }
.roteiro .passos a::before { content: counter(passo); grid-row: span 2; font: 600 24px/1 var(--cond); color: var(--text-faint); }
.roteiro .passos strong { text-decoration: underline 2px var(--border-strong); text-underline-offset: 3px; }
.roteiro .passos a:hover strong, .roteiro .passos a:focus-visible strong { text-decoration-color: var(--accent); }
.roteiro .passos .codigo { font-size: 12px; }

/* ── CONTAGEM ───────────────────────────────────────────── */
.count-layout { display: grid; grid-template-columns: minmax(320px, 380px) minmax(0, 1fr); gap: 20px; align-items: start; }
.count-panel { position: sticky; top: calc(var(--topo) + 16px); background: var(--surface); border-radius: var(--r-lg); }
.count-zona { padding: 16px 20px 20px; }
.count-zona .seg { display: flex; margin-bottom: 18px; }
.count-ajuda { font-size: 13px; color: var(--text-muted); margin: -8px 0 14px; }
.count-progresso { padding: 14px 20px; border-top: 1px solid var(--border); }
.count-progresso-linha { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); margin-bottom: 8px; }
.count-progresso-linha strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.busca-wrap { position: relative; }
.sug { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 20; list-style: none; max-height: 264px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r); box-shadow: var(--shadow-pop); padding: 4px; }
.sug li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: baseline; padding: 9px 10px; border-radius: var(--r-sm); cursor: pointer; }
.sug li[aria-selected="true"], .sug li:hover { background: var(--surface-3); }
.sug .un { margin: 0; }
.sug-vazia { padding: 12px; color: var(--text-muted); font-size: 13px; }
.prod-preview { margin: -8px 0 16px; font-size: 13px; color: var(--text-muted); }
.prod-preview-nome { font-weight: 600; margin: 2px 0; }
.prod-preview .ref { display: block; margin-top: 2px; }
.prod-preview-estado { font-size: 13px; color: var(--text-muted); }
.prod-preview-estado.ja { color: var(--warning); }
.qtd-wrap { position: relative; }
.qtd-input { font: 600 30px var(--cond) !important; text-align: right; font-variant-numeric: tabular-nums; padding-right: 56px !important; min-height: 52px !important; }
.qtd-un { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-weight: 500; pointer-events: none; }
.leitor-estado { display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.leitor-estado::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--success-solid); flex-shrink: 0; }
.leitor-estado.pausado { color: var(--warning); cursor: pointer; }
.leitor-estado.pausado::before { background: var(--warning-solid); }
.ultima-leitura { margin: -6px 0 14px; font-size: 13px; color: var(--text-muted); }
.ultima-leitura strong { color: var(--text); font-weight: 500; }
#scannerContainer { position: relative; background: #000; border-radius: var(--r); overflow: hidden; margin-bottom: 14px; }
#scannerVideo { width: 100%; max-height: 240px; object-fit: cover; display: block; }
#scannerOverlay { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
#scannerOverlay::before { content: ''; width: 64%; height: 40%; border: 2px solid rgba(255, 255, 255, .85); border-radius: 8px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45); }
#scannerStatus { position: absolute; bottom: 8px; width: 100%; text-align: center; color: #fff; font-size: 12px; }
.camera-indisponivel { padding: 14px 16px; border-radius: var(--r); background: var(--surface-2); margin-bottom: 14px; }
.camera-indisponivel p { color: var(--text-muted); font-size: 13px; margin: 4px 0 10px; }
.cabecalho-titulo-linha { display: flex; align-items: center; gap: 6px 12px; flex-wrap: wrap; }
.card-colado { margin: 0; }
.modal-texto-seguinte { margin-top: 10px; }
.modal-texto-antes { margin-bottom: 14px; }
.qtd-input::placeholder { font-weight: 400; font-size: 18px; color: var(--text-faint); }   /* menor e mais leve que um valor digitado, mas legível */
.motivo-recusa { color: var(--danger); }
.estado-conexao { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); }
.estado-conexao::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--success-solid); }
.estado-conexao.off { color: var(--warning); }
.estado-conexao.off::before { background: var(--warning-solid); }
.lista-contagem { max-height: calc(100vh - 260px); overflow-y: auto; }
.lista-contagem thead th { position: sticky; top: 0; z-index: 1; }
.count-layout .campo-busca .form-input { width: 220px; }

/* ── FECHAMENTO (estoque do sistema) ────────────────────── */
.saldo-input { width: 140px; text-align: right; font-variant-numeric: tabular-nums; }
.saldo-wrap { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }
.barra-acoes { position: sticky; bottom: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 12px 32px; margin: 0 -32px -48px; background: var(--bg); border-top: 1px solid var(--border); }
.barra-acoes .resumo { color: var(--text-muted); }
.barra-acoes .resumo strong { color: var(--text); font-variant-numeric: tabular-nums; }
.barra-acoes-botoes { display: flex; gap: 8px; flex-wrap: wrap; }
.cabecalho-texto { margin-top: 8px; max-width: 680px; color: var(--text-muted); text-wrap: pretty; }

/* ── LOGIN E 404 ────────────────────────────────────────── */
.tela-central { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.tela-login { place-items: start center; padding-top: max(24px, 9vh); }
.login-wrap { width: 100%; max-width: 400px; }
.login-marca { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 28px; }
.login-marca .marca-icone { width: 36px; height: 36px; border-radius: 8px; }
.login-marca .marca-icone svg { width: 21px; height: 21px; }
.login-marca .marca-nome { font-size: 22px; flex: 0 0 auto; }
.login-box { background: var(--surface); border-radius: var(--r-lg); padding: 28px; }
.login-box h1 { font-size: 18px; margin-bottom: 4px; }
.login-box > p { color: var(--text-muted); margin-bottom: 22px; }
.login-box > p.login-demo-texto { margin: 10px 0 0; }
.login-demo-texto, .login-rodape, .vazio-texto, .modal-texto { text-wrap: pretty; }
.login-erro { display: none; margin-bottom: 16px; }
.login-erro.visible { display: flex; }
.divisor { display: flex; align-items: center; gap: 12px; margin: 20px 0; color: var(--text-faint); font-size: 13px; }
.divisor::before, .divisor::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.login-demo-texto { font-size: 13px; color: var(--text-muted); text-align: center; margin-top: 10px; text-wrap: balance; }
.login-rodape { text-align: center; font-size: 13px; color: var(--text-faint); margin-top: 20px; }
.login-rodape a { color: var(--text-muted); }
.login-rodape a:hover { color: var(--text); }
.login-demo-aberta > p { color: var(--text-muted); margin-bottom: 14px; }
.login-demo-aberta .btn + .btn { margin-top: 8px; }
.form-group-ultimo { margin-bottom: 20px; }

/* ── CONFIGURAÇÕES ──────────────────────────────────────── */
.config-grade { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.config-grade > .card, .config-grade > div > .card:last-child { margin-bottom: 0; }
.dados { display: grid; grid-template-columns: auto 1fr; gap: 10px 20px; }
.dados dt { color: var(--text-muted); }
.registro-erro { padding: 12px 0; border-top: 1px solid var(--border); }
.registro-erro:first-child { border-top: 0; padding-top: 0; }
.registro-erro-cab { display: flex; flex-wrap: wrap; margin-left: -18px; clip-path: inset(0 0 0 18px); font-size: 12px; color: var(--text-muted); }
.registro-erro-cab > span::before { content: '·'; display: inline-block; width: 18px; text-align: center; color: var(--text-faint); }
.registro-erro-msg .badge { margin-right: 4px; vertical-align: 1px; }
.card-texto { margin-bottom: 14px; }
.dados-perfil { margin: 4px 0 20px; }
.registro-erro-msg { margin-top: 2px; word-break: break-word; }
.registro-erro details { margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.registro-erro pre { white-space: pre-wrap; word-break: break-all; font: 12px/1.5 var(--mono); margin-top: 6px; }

/* ── RESPONSIVO ─────────────────────────────────────────── */
@media (max-width: 1100px) {
    .duas-colunas, .config-grade { grid-template-columns: 1fr; }
    .count-layout { grid-template-columns: 1fr; }
    .count-panel { position: static; }
    .lista-contagem { max-height: none; }
}
@media (max-width: 900px) {
    .sidebar { width: 280px; transform: translateX(-100%); visibility: hidden; transition: transform 200ms ease, visibility 0s 200ms; box-shadow: var(--shadow-modal); }
    .sidebar.open { transform: none; visibility: visible; transition: transform 200ms ease; }
    .sidebar .sidebar-fechar { display: inline-grid; }
    .main { margin-left: 0; }
    .topbar .btn-hamburger { display: inline-grid; margin-left: -6px; }
    .topbar { padding: 0 16px; gap: 8px; }
    .topbar-titulo { font-size: 17px; }
    .page-content { padding: 20px 16px 40px; }
    .barra-acoes { margin: 0 -16px -40px; padding: 12px 16px; }
    .passos { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .demo-bar-longo { display: none; }
    .cabecalho-titulo { font-size: 19px; }
    .cabecalho-acoes { width: 100%; }
    .cabecalho-acoes .btn { flex: 1; }
    .cabecalho-acoes:has(> :nth-child(4)) { display: grid; grid-template-columns: 1fr 1fr; }
    .toolbar > * { flex: 1 1 auto; }
    .toolbar .campo-busca, .toolbar .campo-busca .form-input, .toolbar > .form-input { width: 100%; flex-basis: 100%; }
    .toolbar .espaco { display: none; }
    .toolbar-acoes { width: 100%; margin-left: 0; }
    .toolbar-acoes .btn { flex: 1 1 auto; }
    .toolbar-acoes .btn-primary { order: -1; flex-basis: 100%; }
    .seg { display: flex; width: 100%; }
    .seg:has(> :nth-child(4)) { display: grid; grid-template-columns: 1fr 1fr; }
    .kpis { grid-template-columns: 1fr 1fr; }
    .kpi { padding: 12px 16px; border-left: 0; }
    .kpi:nth-child(even) { border-left: 1px solid var(--border); }
    .kpi:nth-child(n+3) { border-top: 1px solid var(--border); }
    .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
    .kpi-valor { font-size: 22px; }
    .card-header { padding: 12px 16px; flex-wrap: nowrap; align-items: flex-start; min-height: 0; }
    .card-header > div:first-child { flex: 1; min-width: 0; }
    .card-header > .btn-ghost, .card-header > span > .btn-ghost { margin: -4px -8px 0 0; flex-shrink: 0; }
    .grade-2:not(.grade-fixa) { grid-template-columns: 1fr; }
    .tabela-resp td[data-label] { min-width: 0; }
    .tabela-resp td[data-label] > * { min-width: 0; overflow-wrap: anywhere; text-align: right; }
    .vazio-acoes { flex-direction: column; align-self: stretch; }
    .vazio-acoes .btn { width: 100%; }
    body:has(.modal-backdrop.active) .toasts { top: 16px; bottom: auto; }
    body:has(.barra-acoes) .toasts { bottom: 128px; }
    .card-body { padding: 16px; }

    /* Tabela vira lista de cartões: título em cima, pares rótulo/valor e ações embaixo */
    .tabela-resp thead { display: none; }
    .tabela-resp, .tabela-resp tbody, .tabela-resp tr, .tabela-resp td { display: block; }
    .tabela-resp tr { display: flex; flex-direction: column; padding: 12px 16px; border-bottom: 1px solid var(--border); }
    .tabela-resp td.cel-titulo { order: -1; }
    .tabela-resp tbody tr:last-child { border-bottom: 0; }
    .tabela-resp td { padding: 3px 0 !important; border: 0; text-align: left; }
    .tabela-resp td[data-label] { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
    .tabela-resp td[data-label]::before { content: attr(data-label); color: var(--text-muted); font-size: 13px; font-weight: 400; white-space: nowrap; }
    .tabela-resp td.cel-titulo { font-size: 15px; padding-bottom: 6px !important; }
    .tabela-resp td.cel-acoes .acoes-linha { justify-content: flex-start; flex-wrap: wrap; margin-top: 8px; gap: 8px; }
    .tabela-resp td.cel-acoes .btn { min-height: 40px; flex: 1 1 auto; }
    .tabela-resp td:empty { display: none; }
    /* Lista longa compacta: nome e detalhe à esquerda, valor e ação à direita */
    span.so-celular { display: inline !important; }
    .so-celular-bloco { display: block !important; }
    .so-medio-bloco:not(.so-celular-bloco) { display: none !important; }
    .partes > .so-celular { display: inline !important; }
    .tabela-lista thead, .tabela-lista colgroup { display: none; }
    .card-header:has(> .campo-busca), .card-header-filtros { flex-wrap: wrap; }
    .card-header > .campo-busca, .card-header > .campo-busca .form-input { width: 100%; }
    .card-header-filtros .seg, .card-header-filtros .campo-ordem { width: 100%; }
    .card-header-filtros .campo-ordem .form-input { flex: 1; }
    .tabela-lista, .tabela-lista tbody { display: block; }
    .tabela-lista tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; row-gap: 4px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--border); }
    .tabela-lista tbody tr:last-child { border-bottom: 0; }
    .tabela-lista td { display: block; padding: 0 !important; border: 0; }
    .tabela-lista .so-desktop { display: none; }
    .tabela-lista td.l-titulo { grid-column: 1; grid-row: 1 / span 2; align-self: start; }
    .tabela-lista td.l-linha { grid-column: 1 / -1 !important; justify-self: stretch !important; text-align: left !important; }
    .tabela-lista td.l-linha .acoes-linha { justify-content: flex-start; margin-top: 6px; }
    .tabela-lista td.l-linha .btn { flex: 1 1 0; }
    .barra-acoes-botoes { width: 100%; }
    .barra-acoes-botoes .btn { flex: 1 1 auto; }
    .tabela-lista tr { position: relative; }
    .tabela-lista .linha-link.cobre::after { content: ''; position: absolute; inset: 0; }
    .tabela-lista .resultado { justify-content: flex-end; flex-direction: column; align-items: flex-end; }
    .tabela-lista .resultado .sep { display: none; }
    .tabela-lista .sub .forte { color: var(--text); }
    .tabela-lista td.num { align-self: start; }
    .tabela-lista td:not(.l-titulo) { grid-column: 2; text-align: right; justify-self: end; }
    .tabela-lista .acoes-linha { justify-content: flex-end; }
    .tabela-rodape { flex-direction: column; align-items: stretch; text-align: center; }
    .paginacao { justify-content: space-between; }

    .modal-backdrop { place-items: end stretch; padding: 0; }
    .modal, .modal-sm, .modal-lg { max-width: none; border-radius: 14px 14px 0 0; max-height: 92vh; border-bottom: 0; }
    .modal-cab { padding: 18px 16px 0 20px; }
    .modal-corpo { padding: 16px 20px 4px; }
    .modal-rodape { padding: 16px 20px calc(16px + env(safe-area-inset-bottom)); flex-direction: column-reverse; }
    .modal-rodape .btn { width: 100%; min-height: 44px; }
    .toasts { left: 16px; right: 16px; bottom: 16px; width: auto; }
}
@media (pointer: coarse) {
    .btn, .btn-sm { min-height: 40px; }
    .btn-icone { width: 40px; height: 40px; }
    .toast-fechar { width: 40px; height: 40px; margin: -8px -4px -8px 0; }
    .form-input, .input-field { min-height: 42px; }
    .seg button { min-height: 40px; }
    .nav-item { height: 42px; }
    .voltar { min-height: 40px; padding-right: 8px; }
    .checagem { min-height: 40px; }
    .tabela-resp td.cel-acoes .btn { min-height: 40px; }
}

/* ── IMPRESSÃO ──────────────────────────────────────────── */
@page { size: A4 portrait; margin: 14mm 12mm 16mm;
    @bottom-left { content: var(--rodape-folha, 'AudiStock'); font: 8pt 'IBM Plex Sans', Arial, sans-serif; color: #555; }
    @bottom-right { content: 'Página ' counter(page) ' de ' counter(pages); font: 8pt 'IBM Plex Sans', Arial, sans-serif; color: #555; }
}
.folha-cab { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 1px solid var(--border-strong); padding-bottom: 6px; margin-bottom: 8px; }
.folha-cab strong { font-size: 15pt; }
.folha-marca { color: var(--accent-text); font-weight: 600; }
.folha-dados { grid-template-columns: auto 1fr auto 1fr; gap: 2px 14px; font-size: 9pt; margin-bottom: 4px; }
.folha-obs { font-size: 9pt; color: var(--text-muted); margin-top: 4px; }
.folha-assinaturas { display: grid; grid-template-columns: 1fr 1fr; gap: 48px; margin-top: 36px; font-size: 9pt; color: var(--text-muted); }
.folha-assinaturas div { border-top: 1px solid var(--text-muted); padding-top: 4px; }
@media print {
    :root, [data-theme] {
        color-scheme: light;
        --bg: #fff; --surface: #fff; --surface-2: #f4f3f0; --surface-3: #ebe9e4; --border: #d6d2ca; --border-strong: #b8b3a9;
        --text: #111; --text-muted: #444; --text-faint: #555; --accent: #a85000; --accent-text: #a85000;
        --success: #15803d; --danger: #b91c1c; --warning: #8a4a0b; --success-soft: transparent; --danger-soft: transparent;
    }
    html, body { background: #fff; font-size: 10pt; }
    body { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .sidebar, .sidebar-overlay, .topbar, .demo-bar, .offline-bar, .toasts, .loading-overlay, .no-print, .voltar, .pular { display: none !important; }
    .print-only { display: block !important; }
    span.print-only { display: inline !important; }
    .folha-assinaturas.print-only { display: grid !important; }
    .tabela-relatorio, .tabela-relatorio-simples { table-layout: auto; }
    .tabela-relatorio col, .tabela-relatorio-simples col { width: auto !important; }
    .so-tela { display: none !important; }
    .detalhes-rotulo { display: none; }
    .folha { margin-bottom: 14px; }
    .secao-nao-contados > details > summary.card-header { display: block !important; padding: 16px 0 6px; border: 0 !important; }
    .secao-nao-contados .card-title { font-size: 11pt; }
    .kpi-apoio .link { color: inherit; text-decoration: none; }
    .main { margin: 0; }
    .page-content { padding: 0; max-width: none; }
    .card, .kpis { border: 0; border-radius: 0; margin-bottom: 12px; }
    .card-header { display: none; }
    .tabela-wrap { overflow: visible; }
    th { position: static !important; }
    table { font-size: 9pt; }
    thead { display: table-header-group; }
    tr { break-inside: avoid; }
    th { background: #ecebe7 !important; color: #222; border-bottom: 1px solid #999; padding: 5px 6px; }
    td { padding: 4px 6px; border-bottom: 1px solid #ddd; }
    th:first-child, td:first-child { padding-left: 0; }
    .badge { padding: 0; background: none !important; }
    .kpis { display: flex; border-top: 1px solid #999; border-bottom: 1px solid #999; }
    .kpi { flex: 1; padding: 6px 8px; }
    .kpi-valor { font-size: 14pt; }
    .kpi-destaque::before { display: none; }
}
