/* ==========================================================================
   Pires Embalagens — design system (mobile-first, sem dependências externas)
   ========================================================================== */
:root {
    --azul: #0d3b66;
    --azul-2: #144e8c;
    --azul-3: #1b62ad;
    --claro: #f5f7fa;
    --card: #ffffff;
    --txt: #1b1f24;
    --muted: #5a6672;
    --linha: #e3e8ef;
    --ok: #1c7c54;
    --ok-bg: #e6f4ec;
    --erro: #b3261e;
    --erro-bg: #fbe9e7;
    --raio: 14px;
    --sombra: 0 10px 30px rgba(13, 59, 102, .10);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--txt);
    background: var(--claro);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--azul-2); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Botões ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    font: inherit; font-weight: 600; cursor: pointer;
    padding: .7rem 1.2rem; border: 1px solid transparent; border-radius: 10px;
    transition: background .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--azul); color: #fff; width: 100%; }
.btn-primary:hover { background: var(--azul-2); text-decoration: none; }
.btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.btn-ghost:hover { background: rgba(255,255,255,.12); text-decoration: none; }

/* ---------- Alertas ---------- */
.alert { padding: .8rem 1rem; border-radius: 10px; font-size: .92rem; margin-bottom: 1rem; }
.alert-error { background: var(--erro-bg); color: var(--erro); }
.alert-success { background: var(--ok-bg); color: var(--ok); }

/* ---------- Formulários ---------- */
.field { display: block; margin-bottom: 1rem; }
.field span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .35rem; font-weight: 600; }
.field input, .field select, .field textarea {
    width: 100%; font: inherit; padding: .7rem .85rem;
    border: 1px solid var(--linha); border-radius: 10px; background: #fff; color: var(--txt);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--azul-3); box-shadow: 0 0 0 3px rgba(27,98,173,.15);
}

/* ==========================================================================
   Login
   ========================================================================== */
.auth-body {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 1.5rem;
    background: linear-gradient(135deg, #0d3b66, #1b62ad);
}
.auth-card {
    background: var(--card); width: 100%; max-width: 460px;
    padding: 2.75rem 3rem; border-radius: 18px; box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
.auth-logo { display: block; width: 140px; margin: 0 auto 1.5rem; }
.auth-card h1 { font-size: 1.35rem; color: var(--azul); text-align: center; margin-bottom: 1.5rem; }
.auth-back { display: block; text-align: center; margin-top: 1.5rem; font-size: .9rem; color: var(--azul-2); }
.auth-back:hover { text-decoration: underline; }

@media (max-width: 480px) {
    .auth-card { padding: 2rem 1.5rem; }
}

/* ==========================================================================
   Layout do app (sidebar + conteúdo)
   ========================================================================== */
.app-body { display: flex; min-height: 100vh; }
.sidebar-backdrop {
    position: fixed; inset: 0; background: rgba(13,31,51,.5); z-index: 25;
    opacity: 0; visibility: hidden; transition: opacity .2s;
}
.app-body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }

.sidebar {
    width: 240px; flex-shrink: 0; background: var(--azul); color: #fff;
    display: flex; flex-direction: column; padding: 1.25rem 1rem;
    position: fixed; inset: 0 auto 0 0; z-index: 30;
    transform: translateX(-100%); transition: transform .2s ease;
    overflow-y: auto; overscroll-behavior: contain;
}
.sidebar-brand { display: flex; align-items: center; gap: .6rem; padding: .3rem .4rem 1.25rem; }
.sidebar-brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.sidebar-brand span { font-weight: 700; font-size: 1.05rem; }
.sidebar-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.nav-item {
    color: rgba(255,255,255,.85); padding: .65rem .75rem; border-radius: 9px;
    font-weight: 500; display: flex; align-items: center; gap: .6rem;
}
.nav-item:hover { background: rgba(255,255,255,.10); color: #fff; text-decoration: none; }
.nav-item.is-active { background: var(--azul-3); color: #fff; }
.sidebar-logout { padding-top: .6rem; }
.sidebar-logout .btn { width: 100%; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Botão flutuante que abre o menu no mobile (a topbar foi removida por completo). */
.nav-fab {
    position: fixed; top: 12px; left: 12px; z-index: 32;
    width: 44px; height: 44px; border-radius: 12px;
    background: var(--azul); color: #fff; border: none;
    font-size: 1.4rem; line-height: 1; cursor: pointer;
    box-shadow: 0 6px 16px rgba(13,59,102,.28);
}

/* Usuário no rodapé da sidebar (acima do botão Sair). */
.sidebar-user {
    padding: .75rem .5rem .6rem; margin-top: .4rem; font-size: .9rem;
    border-top: 1px solid rgba(255,255,255,.15);
}
.sidebar-user strong { display: block; color: #fff; }
.sidebar-user small { color: rgba(255,255,255,.65); text-transform: capitalize; }

/* Sem teto de largura: o conteúdo acompanha a janela.
   Havia um `max-width: 1100px` aqui, herdado da regra de leitura de "linha
   curta cansa menos a vista". Só que este é um painel de ERP — pedidos,
   roteiro, auditoria e Melhor Envio são TABELAS, e tabela espremida em 1100px
   com meia tela vazia ao lado é o pior dos dois mundos. Quem é texto corrido
   continua com o teto próprio (ver `.card-form`, 560px), que é onde a regra de
   leitura realmente vale. */
.content { padding: 1.5rem 1.25rem; width: 100%; }
.page-head { margin-bottom: 1.5rem; }
.page-head h1 { font-size: 1.4rem; color: var(--azul); }
.page-head p { color: var(--muted); }

/* Cards / KPIs */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }
.card {
    background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio);
    padding: 1.25rem; box-shadow: var(--sombra);
}
.card h2 { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin-bottom: .4rem; }
.card .kpi { font-size: 1.9rem; font-weight: 700; color: var(--azul); }
.badge {
    display: inline-block; padding: .25rem .7rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600; text-transform: capitalize;
    background: var(--ok-bg); color: var(--ok);
}

/* ---------- Sidebar aberta (toggle mobile) ---------- */
.app-body.sidebar-open .sidebar { transform: translateX(0); }

/* ---------- Desktop ---------- */
@media (min-width: 992px) {
    /* Trava a moldura na altura da tela: a sidebar fica PRESA (ocupa 100% da
       altura — sem faixa branca embaixo) e só o conteúdo do centro rola. */
    .app-body { height: 100vh; overflow: hidden; }
    .sidebar { position: sticky; transform: none; height: 100vh; top: 0; overflow-y: auto; }
    .app-main { height: 100vh; overflow: hidden; }
    .content { flex: 1; overflow-y: auto; }
    /* Sem barra de rolagem visível (a rolagem continua funcionando). */
    .sidebar, .content { scrollbar-width: none; -ms-overflow-style: none; }
    .sidebar::-webkit-scrollbar, .content::-webkit-scrollbar { width: 0; height: 0; }
    .sidebar-backdrop { display: none; }
    /* No desktop a sidebar fica sempre visível; o botão flutuante do menu some. */
    .nav-fab { display: none; }
}

/* No mobile, dá um respiro no topo do conteúdo para não ficar sob o botão ☰. */
@media (max-width: 991px) {
    .content { padding-top: 4.5rem; }
    /* Menu aberto: trava a rolagem do fundo (não rola "através" do menu). */
    .app-body.sidebar-open { overflow: hidden; height: 100vh; }
}

/* ==========================================================================
   Pedidos (Spec 3) — tabela, filtros, badges, detalhe, galeria
   ========================================================================== */
/* ---------- Configurações em abas ---------- */
.cfg-abas { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: 1.2rem; border-bottom: 1px solid var(--linha); }
.cfg-aba {
    border: none; background: none; cursor: pointer; font: inherit; font-size: .92rem; font-weight: 600;
    color: var(--muted); padding: .6rem .95rem; border-radius: 8px 8px 0 0;
    border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.cfg-aba:hover { color: var(--azul); background: var(--claro); }
.cfg-aba.is-ativa { color: var(--azul); border-bottom-color: var(--azul); background: none; }
/* Cada bloco traz o próprio título com margem de topo (quando eram empilhados);
   dentro da aba ele é o primeiro elemento e essa folga vira buraco. */
.cfg-painel > .page-head { margin-top: 0 !important; }

.page-head--row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
/* Mais de um CTA no cabeçalho (ex.: "Editar" + "Voltar" no detalhe do pedido). */
.page-head-acoes { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.btn-auto { width: auto; }
.btn-outline { background: #fff; color: var(--azul); border-color: var(--linha); }
.btn-outline:hover { background: var(--claro); text-decoration: none; }
.card-title { color: var(--azul); font-size: 1.05rem; margin-bottom: 1rem; }
.card-link { display: block; color: inherit; transition: box-shadow .15s, transform .05s; }
.card-link:hover { text-decoration: none; box-shadow: 0 14px 34px rgba(13,59,102,.16); transform: translateY(-2px); }
.card-form { max-width: 560px; }

.filtros { display: flex; gap: .6rem; margin-bottom: 1.25rem; flex-wrap: wrap; align-items: center; }
.filtros input[type="search"] { flex: 2 1 190px; min-width: 160px; padding: .6rem .8rem; border: 1px solid var(--linha); border-radius: 10px; font: inherit; background: #fff; }
.filtros input[type="text"], .filtros input[type="date"], .filtros select { flex: 1 1 150px; min-width: 130px; padding: .6rem .8rem; border: 1px solid var(--linha); border-radius: 10px; font: inherit; background: #fff; }
.filtros button[type="submit"] { flex: 0 0 auto; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--linha); border-radius: var(--raio); box-shadow: var(--sombra); }
.tabela { width: 100%; border-collapse: collapse; min-width: 560px; }
.tabela th, .tabela td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--linha); }
.tabela th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfd; }
.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tbody tr:hover { background: #fafbfd; }
.tabela .acao a { font-weight: 600; }
/* Alvo de toque confortável (>=44px) nos botões de ação das tabelas. */
.tabela .acao .btn { min-height: 44px; }
.tabela .vazio { text-align: center; color: var(--muted); padding: 2rem; }

/* Coluna de ação (Desativar, Abrir, Excluir...) — sempre a ÚLTIMA da linha.
   `width: 1%` não deixa a coluna com 1% de largura: em tabela auto-layout é o
   jeito de dizer "encolha até o conteúdo", e a sobra fica com as colunas de
   dados. Sem isso o navegador reparte o espaço livre entre todas, e o botão
   descola do canto e para no meio da tela — o que ficou visível quando o
   painel passou a usar a largura toda. `nowrap` impede que "Desativar" quebre
   em duas linhas quando a tabela aperta. */
.tabela .acao { text-align: right; width: 1%; white-space: nowrap; }

/* Botões da coluna de ação ficam LADO A LADO, nunca empilhados.
   Cada botão costuma vir no seu próprio <form> (POST + CSRF), e form é bloco:
   solto, cada um cai numa linha e estica a altura da linha inteira do grid.
   Como inline-block eles se alinham naturalmente, e o `nowrap` do td garante
   que continuem na mesma linha. */
.tabela .acao > * { display: inline-block; vertical-align: middle; margin: 0; }
.tabela .acao > * + * { margin-left: .4rem; }

/* Wrapper para quando os botões precisam de alinhamento próprio. No desktop
   `nowrap` é o que importa: com a coluna encolhida ao conteúdo (width: 1%),
   permitir quebra faria o flex empilhar tudo numa coluna estreita — que é
   exatamente o defeito que este bloco existe para evitar. */
.tabela .acao .acoes {
    display: flex; gap: .4rem; align-items: center;
    justify-content: flex-end; flex-wrap: nowrap;
}
.tabela .acao .acoes > * { margin: 0; }

.badge-pendente { background: #fff4e5; color: #9a5b00; }
.badge-entregue { background: var(--ok-bg); color: var(--ok); }

.dados { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; }
.dados > div { display: flex; flex-direction: column; }
.dados span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.dados strong { font-size: 1rem; color: var(--txt); margin-top: .15rem; }

.form-actions { display: flex; gap: .6rem; justify-content: flex-end; margin-top: .5rem; flex-wrap: wrap; }
.field .erro { display: block; color: var(--erro); font-size: .82rem; margin-top: .3rem; }
input[type="file"] { padding: .5rem; border: 1px dashed var(--linha); border-radius: 10px; width: 100%; background: #fff; }

.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: .75rem; }
.galeria img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--linha); }

.paginacao { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; color: var(--muted); font-size: .9rem; flex-wrap: wrap; }

/* Tabela responsiva: vira "cards" no mobile */
@media (max-width: 640px) {
    .tabela, .tabela thead, .tabela tbody, .tabela th, .tabela td, .tabela tr { display: block; }
    .tabela { min-width: 0; }
    .tabela thead { display: none; }
    .tabela tr { border-bottom: 1px solid var(--linha); padding: .5rem 0; }
    .tabela td { border: none; padding: .35rem 1rem; display: flex; justify-content: space-between; gap: 1rem; }
    .tabela td::before { content: attr(data-label); font-weight: 600; color: var(--muted); }
    /* Aqui a "tabela" virou card e cada td é um bloco flex: o `width: 1%` do
       desktop encolheria a linha inteira do botão. Volta para largura cheia. */
    .tabela .acao { justify-content: flex-end; width: auto; white-space: normal; }
    .tabela .acao::before { content: ""; }
    /* No card estreito o certo é o oposto do desktop: se não couber, quebra —
       botão cortado na borda da tela é pior que botão numa segunda linha. */
    .tabela .acao .acoes { flex-wrap: wrap; }
    /* Lista de pedidos: "Abrir" ocupa toda a largura do card (botao azul). */
    .tabela-pedidos .acao { padding-top: .55rem; padding-bottom: .65rem; }
    .tabela-pedidos .acao::before { display: none; }
    .tabela-pedidos .acao .btn-abrir { flex: 1; text-align: center; padding-top: .7rem; padding-bottom: .7rem; }
    /* Filtros empilhados full-width no celular (busca, selects e botão alinhados). */
    .filtros > * { flex: 1 1 100%; width: 100%; }
}

/* ==========================================================================
   Spec 4 — estágios, tempo/atraso, vitrine pública, stepper, timeline
   ========================================================================== */

/* Badges por estágio (ENTREGUE/PENDENTE reaproveitam os existentes) */
.badge.estagio-pendente  { background: #fff4e5; color: #9a5b00; }
.badge.estagio-separando { background: #e5efff; color: #1b4f8c; }
.badge.estagio-separado  { background: #ede7fb; color: #5b3fb0; }
.badge.estagio-pronto    { background: #dff5ee; color: #0f7a5a; }

/* Tempo decorrido / destaque de atraso (>3h) */
.tempo { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.tempo.is-atrasado { color: var(--erro); font-weight: 700; }

/* ---------- Stepper (detalhe do pedido) ---------- */
.stepper { display: flex; gap: .25rem; margin-bottom: 1.5rem; overflow-x: auto; padding-bottom: .35rem; }
.step { flex: 1 1 0; min-width: 92px; display: flex; flex-direction: column; align-items: center; gap: .4rem; position: relative; text-align: center; }
.step::before { content: ""; position: absolute; top: 15px; left: -50%; width: 100%; height: 2px; background: var(--linha); z-index: 0; }
.step:first-child::before { display: none; }
.step-dot { position: relative; z-index: 1; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: .85rem; font-weight: 700; background: #fff; border: 2px solid var(--linha); color: var(--muted); }
.step-label { font-size: .74rem; color: var(--muted); line-height: 1.2; }
.step.is-done .step-dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.is-done::before { background: var(--ok); }
.step.is-current .step-dot { background: var(--azul); border-color: var(--azul); color: #fff; box-shadow: 0 0 0 4px rgba(13,59,102,.15); }
.step.is-current .step-label { color: var(--azul); font-weight: 700; }

/* ---------- Linha do tempo (histórico de estágios) ---------- */
.timeline { display: flex; flex-direction: column; gap: .75rem; }
.tl-item { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.tl-info { font-size: .88rem; color: var(--muted); }
.tl-info em { color: var(--azul-2); font-style: normal; font-weight: 600; }

/* ---------- Switch (configurações) ---------- */
.switch-field { display: flex; align-items: flex-start; gap: .9rem; cursor: pointer; }
.switch-field input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch { flex-shrink: 0; width: 46px; height: 26px; border-radius: 999px; background: var(--linha); position: relative; transition: background .2s; margin-top: .1rem; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.switch-field input:checked + .switch { background: var(--ok); }
.switch-field input:checked + .switch::after { transform: translateX(20px); }
.switch-field input:focus-visible + .switch { box-shadow: 0 0 0 3px rgba(27,98,173,.25); }
.switch-label strong { display: block; color: var(--txt); }
.switch-label small { display: block; color: var(--muted); font-size: .85rem; margin-top: .25rem; line-height: 1.5; }

/* ==========================================================================
   Vitrine pública (home sem autenticação)
   ========================================================================== */
.pub-body { display: flex; flex-direction: column; min-height: 100vh; background: var(--claro); }
.pub-topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    background: var(--azul); color: #fff; padding: .9rem 1.25rem;
    position: sticky; top: 0; z-index: 10;
}
.pub-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; }
.pub-brand img { width: 38px; height: 38px; object-fit: contain; background: #fff; border-radius: 8px; padding: 3px; }
.pub-topbar .btn { width: auto; }

/* Largura livre: a vitrine roda em TV, então nada de coluna centralizada com sobra nas laterais. */
.pub-main { flex: 1; width: 100%; padding: 1.5rem clamp(1rem, 1.5vw, 2rem); }
.pub-head { margin-bottom: 1.25rem; }
.pub-head h1 { color: var(--azul); font-size: 1.6rem; }
.pub-head p { color: var(--muted); }

.pub-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); gap: 1rem; }
.pub-card {
    background: var(--card); border: 1px solid var(--linha); border-left: 5px solid var(--azul-3);
    border-radius: var(--raio); padding: 1.1rem 1.2rem; box-shadow: var(--sombra);
    display: flex; flex-direction: column; gap: .6rem;
    min-width: 0; overflow-wrap: anywhere;
}
.pub-card.is-atrasado { border-left-color: var(--erro); }
.pub-card-top { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.pub-num { font-weight: 700; color: var(--azul); font-size: 1.1rem; }
.pub-tipo { font-size: .8rem; color: var(--azul-2); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.pub-cliente { font-size: 1.05rem; color: var(--txt); font-weight: 600; }
.pub-meta { display: flex; align-items: center; justify-content: space-between; gap: .5rem; color: var(--muted); font-size: .9rem; }
.pub-tempo { white-space: nowrap; }
.pub-tempo.is-atrasado { color: var(--erro); font-weight: 700; }
.pub-transp { font-size: .92rem; color: var(--azul); font-weight: 600; display: flex; align-items: center; gap: .35rem; }
.pub-criador { font-size: .82rem; color: var(--muted); border-top: 1px solid var(--linha); padding-top: .5rem; }

.pub-vazio { text-align: center; color: var(--muted); padding: 4rem 1rem; background: var(--card); border: 1px solid var(--linha); border-radius: var(--raio); }
.pub-footer { text-align: center; color: var(--muted); padding: 1.25rem; }

/* TV e monitores grandes: cards mais largos e texto legível de longe. */
@media (min-width: 1600px) {
    .pub-topbar { padding: 1.1rem 2rem; }
    .pub-brand { font-size: 1.35rem; }
    .pub-brand img { width: 48px; height: 48px; }
    .pub-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.25rem; }
    .pub-head h1 { font-size: 2.1rem; }
    .pub-head p { font-size: 1.1rem; }
    .pub-num { font-size: 1.35rem; }
    .pub-tipo { font-size: .95rem; }
    .pub-cliente { font-size: 1.3rem; }
    .pub-transp { font-size: 1.1rem; }
    .pub-meta { font-size: 1.05rem; }
    .pub-criador { font-size: .95rem; }
}

@media (max-width: 480px) {
    .pub-brand span { display: none; }
    .step-label { font-size: .68rem; }
    /* Stepper: 5 etapas cabem sem rolagem (a atual fica sempre visível). */
    .stepper { overflow-x: visible; gap: .15rem; }
    .step { min-width: 0; }
    /* Ações de formulário viram bloco: CTA principal em cima, largura toda (toque fácil). */
    .form-actions { flex-direction: column-reverse; }
    .form-actions .btn { width: 100%; }
    .card-form > form > .btn { width: 100%; }
    /* CTA do cabeçalho ("+ Novo…", "← Voltar") ocupa a largura toda abaixo do título. */
    .page-head--row .btn-auto { width: 100%; }
    .page-head-acoes { width: 100%; }
}

/* ---------- Auditoria (badges por ação) ---------- */
.badge.acao-acesso      { background: #eef1f6; color: #47566b; }
.badge.acao-login       { background: var(--ok-bg); color: var(--ok); }
.badge.acao-logout      { background: #eef1f6; color: #47566b; }
.badge.acao-login_falho { background: var(--erro-bg); color: var(--erro); }
.badge.acao-criacao     { background: #e5efff; color: #1b4f8c; }
.badge.acao-alteracao   { background: #fff4e5; color: #9a5b00; }
.badge.acao-exclusao    { background: var(--erro-bg); color: var(--erro); }
.badge.acao-negado      { background: var(--erro-bg); color: var(--erro); }
.aud-rota { display: block; color: var(--muted); font-size: .78rem; margin-top: .15rem; word-break: break-all; }

/* ---------- Consulta de placa (retorno da API na baixa) ---------- */
.placa-info { margin-top: .5rem; font-size: .9rem; }
.placa-info.is-carregando { color: var(--muted); }
.placa-info.is-erro { color: var(--erro); }
.placa-info.is-ok {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: .6rem;
    padding: .8rem; background: var(--claro); border: 1px solid var(--linha); border-radius: 10px;
}
.placa-info.is-ok > div { display: flex; flex-direction: column; }
.placa-info.is-ok span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.placa-info.is-ok strong { color: var(--txt); margin-top: .1rem; }

/* Tela "Dar saída" (Melhor Envio) */
.saida-resultados { margin-top: .75rem; display: flex; flex-direction: column; gap: .4rem; max-height: 340px; overflow-y: auto; }
.saida-result {
    text-align: left; display: flex; flex-direction: column; gap: .15rem;
    padding: .6rem .8rem; border: 1px solid var(--linha); border-radius: 10px;
    background: #fff; font: inherit; cursor: pointer;
}
.saida-result:hover:not(:disabled) { border-color: var(--azul); background: var(--claro); }
.saida-result strong { color: var(--txt); }
.saida-result span { font-size: .82rem; color: var(--muted); }
.saida-result .saida-tag { font-size: .74rem; color: var(--muted); font-style: italic; margin-top: .1rem; }
.saida-result.is-off { opacity: .55; cursor: default; }

.saida-lista { display: flex; flex-direction: column; gap: .5rem; }
.saida-item {
    display: flex; align-items: center; justify-content: space-between; gap: .8rem;
    padding: .55rem .8rem; border: 1px solid var(--linha); border-radius: 10px; background: var(--claro);
}
.saida-item > div { display: flex; flex-direction: column; min-width: 0; }
.saida-item strong { color: var(--txt); }
.saida-item span { font-size: .82rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saida-remover {
    flex: 0 0 auto; width: 2rem; height: 2rem; border-radius: 50%;
    border: 1px solid var(--linha); background: #fff; color: var(--erro); cursor: pointer; font-size: 1rem; line-height: 1;
}
.saida-remover:hover { background: var(--erro-bg); border-color: var(--erro); }

.saida-sep { margin: 1rem 0 .5rem; font-weight: 600; color: var(--txt); }
.saida-aviso { margin: .75rem 0 0; color: var(--muted); font-size: .9rem; }
.saida-aviso.is-erro { color: var(--erro); }
.btn-mini { padding: .25rem .6rem; font-size: .78rem; }

/* ── Inventário de aparelhos (/dispositivos) ─────────────────────────────── */
/* Utilitários de texto: a tabela repete "cor apagada" e "cor de erro" em várias
   células, e o inline style dessas duas cores já se espalhava por outras views. */
.txt-muted { color: var(--muted); }
.txt-erro  { color: var(--erro); }

/* Versão do app instalada no aparelho. O vermelho é o ponto da tela: mostra num
   relance quem ainda não atualizou, sem precisar comparar número por número. */
.badge.app-ok    { background: var(--ok-bg);   color: var(--ok); }
.badge.app-velho { background: var(--erro-bg); color: var(--erro); }

.dispositivos-resumo { color: var(--muted); margin: -.75rem 0 1rem; font-size: .92rem; }

/* Ação destrutiva discreta na linha da tabela (mesmo tom do "Excluir" das
   outras telas, que hoje é feito com style inline). */
.btn-perigo { color: var(--erro); border-color: var(--erro); }
.btn-perigo:hover { background: var(--erro-bg); }

/* Renomear o aparelho: input e botão na mesma linha, dentro da célula. */
.form-nome { display: flex; gap: .35rem; align-items: center; margin: 0 0 .25rem; }
.form-nome input {
    flex: 1 1 auto; min-width: 0; max-width: 190px; padding: .35rem .5rem;
    border: 1px solid var(--linha); border-radius: 8px; font: inherit; font-size: .9rem; background: #fff;
}
/* O placeholder mostra o nome que o sistema deduziu; o campo vazio é normal. */
.form-nome input::placeholder { color: var(--muted); font-style: italic; }

/* Aparelho bloqueado: a linha inteira muda de cor, para achar de longe. */
.linha-bloqueada > td { background: var(--erro-bg); }
.tabela tbody tr.linha-bloqueada:hover > td { background: #f7ded9; }

/* Aparelhos: "Bloquear" vem com um campo de motivo junto, e ainda há o
   "Remover". Tudo numa linha só — empilhado, cada aparelho esticava a altura
   da linha do grid à toa. */
.acoes-aparelho { display: flex; flex-direction: row; gap: .4rem; align-items: center; justify-content: flex-end; }
.acoes-aparelho form { display: flex; gap: .35rem; align-items: center; margin: 0; flex-wrap: nowrap; justify-content: flex-end; }
.input-motivo {
    width: 150px; padding: .3rem .5rem; border: 1px solid var(--linha);
    border-radius: 8px; font: inherit; font-size: .85rem; background: #fff;
}

@media (max-width: 720px) {
    .form-nome input { max-width: none; }
    /* No celular volta a empilhar: o campo de motivo + dois botões não cabem
       lado a lado numa tela estreita sem espremer tudo. */
    .acoes-aparelho { flex-direction: column; align-items: stretch; }
    .acoes-aparelho form { justify-content: flex-start; flex-wrap: wrap; }
    .input-motivo { flex: 1 1 auto; width: auto; }
}

/* ==========================================================================
   Mercado Livre (/mercadolivre e /mercadolivre/produtos)

   Vive aqui, e não num <style> de cada view, porque as duas telas usam as
   mesmas peças — manter duplicado já tinha começado a divergir.
   ========================================================================== */
.ml-abas { display: flex; gap: .25rem; margin: 0 0 1.25rem; border-bottom: 2px solid var(--linha); flex-wrap: wrap; }
.ml-aba {
    padding: .6rem 1.1rem; font-weight: 600; font-size: .92rem; color: var(--muted);
    border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.ml-aba:hover { color: var(--azul); text-decoration: none; }
/* A aba ativa se sustenta na cor + na linha, não só na cor — daltônico também vê. */
.ml-aba.is-ativa { color: var(--azul); border-bottom-color: var(--azul); }

.ml-nota { margin: 0 0 1rem; padding: .55rem .8rem; border-radius: 8px; border: 1px solid #cfe0f2;
    background: #f2f7fd; color: #1c4e8a; font-size: .88rem; line-height: 1.5; }
.ml-nota--alerta { border-color: #f0c9c2; background: #fdf1ef; color: #8c3423; }
.ml-dica { display: block; margin: 0 0 1rem; color: var(--muted); font-size: .8rem; line-height: 1.5; }
.ml-sub { color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.ml-sub--erro { color: var(--erro); }

.ml-nova { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; margin: 0 0 .35rem; }
.ml-link { display: flex; gap: .4rem; align-items: center; }
.ml-link input { flex: 1 1 auto; min-width: 0; font-family: ui-monospace, Consolas, monospace; font-size: .78rem; }
.ml-link .btn { flex: 0 0 auto; }
.ml-urls { max-width: 720px; }
.ml-check { display: flex; align-items: center; gap: .4rem; font-size: .9rem; margin-bottom: .25rem; }
.ml-check input { width: auto; }

.ml-filtros { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .6rem; margin: 0 0 1rem; }
.ml-import { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; margin: 0 0 1rem; }
.ml-prog { flex: 1 1 260px; min-width: 200px; }
.ml-barra { height: 8px; border-radius: 999px; background: #e6ecf3; overflow: hidden; }
.ml-barra-fill { height: 100%; width: 0; background: var(--azul); transition: width .25s; }
.ml-foto { width: 46px; height: 46px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--linha); }
.ml-foto--vazia { background: #f1f4f8; }
.ml-vars { margin-top: .4rem; }
.ml-vars summary { cursor: pointer; color: var(--azul); font-size: .8rem; font-weight: 600; }
.ml-vars-tab { margin-top: .35rem; border-collapse: collapse; width: 100%; max-width: 620px; }
.ml-vars-tab td { padding: .25rem .6rem .25rem 0; font-size: .82rem; border-bottom: 1px solid var(--linha); }
.ml-tabela { min-width: 820px; }

/* Situação da conta e do anúncio compartilham as mesmas cores de badge. */
.ml-aguardando { background: #fff4d6; color: #7a5a00; }
.ml-conectada { background: #dff5e3; color: #1f6b32; }
.ml-erro { background: #fde3e0; color: #a3301f; }

@media (max-width: 768px) {
    .ml-nova .btn, .ml-filtros .btn, .ml-import .btn { width: 100%; }
    .ml-link { flex-wrap: wrap; }
    .ml-link .btn { width: 100%; }
    /* Abas roláveis em vez de quebradas: some o "Produtos" numa tela estreita
       se elas empilharem, e a segunda aba é justamente a mais usada. */
    .ml-abas { flex-wrap: nowrap; overflow-x: auto; }
}

/* Etiqueta da conta na linha do produto: com "Todas as contas" no filtro, é ela
   que responde "de quem é este anúncio" sem precisar voltar no filtro. */
.ml-conta-tag {
    display: inline-block; padding: .2rem .55rem; border-radius: 6px;
    background: #eef2f7; color: #3a4a5c; font-size: .78rem; font-weight: 600;
    white-space: nowrap;
}

/* Linha de produto dentro da venda (aba Compras): várias por célula, então
   precisam respirar sem virar parágrafo corrido. */
.ml-venda-item { font-size: .85rem; line-height: 1.5; padding: .15rem 0; }
.ml-venda-item + .ml-venda-item { border-top: 1px dashed var(--linha); }
