/* Alfa NFS-e Online - mesmo tema do app (lib/telas/tema.dart): azul vivo com
   destaque ambar, cartoes arredondados com sombra suave, campos preenchidos. */
:root {
  --primaria: #2B59C3;
  --primaria-escura: #16337A;
  --destaque: #FFC145;
  --sucesso: #1E9E6A;
  --alerta: #E8833A;
  --roxo: #6C55C9;
  --despesa: #D64545;
  --perigo: #C62828;
  --tinta: #E9EFFC;
  --fundo: #F4F6FB;
  --texto: #1B2333;
  --suave: #6B7385;
  --borda: #E4E8F2;
  --borda-campo: #DCE2EE;
  --raio: 14px;
  --sombra: 0 2px 10px rgba(20, 35, 70, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fundo);
  color: var(--texto);
  font-size: 15px;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primaria); }
svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.oculto { display: none !important; }

/* ------------------------------------------------ barra de carregamento / aviso */
.carregando { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 300; overflow: hidden; background: rgba(43, 89, 195, .15); }
.carregando .barra { height: 100%; width: 40%; background: var(--primaria); animation: corre 1s infinite ease-in-out; }
@keyframes corre { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #1F2633; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 400; max-width: min(92vw, 520px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); font-weight: 600; transition: opacity .2s;
}
.toast.erro { background: #B3261E; }
.toast.oculto { opacity: 0; pointer-events: none; display: block !important; }

/* ------------------------------------------------ entrada */
.entrada {
  min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
  background: linear-gradient(135deg, var(--primaria), var(--primaria-escura));
}
.entrada .caixa { width: 100%; max-width: 400px; text-align: center; }
.entrada .logo { width: 96px; height: 96px; border-radius: 26px; box-shadow: 0 8px 18px rgba(0, 0, 0, .27); }
.entrada h1 { color: #fff; font-size: 28px; font-weight: 900; margin: 14px 0 2px; }
.entrada .sub { color: #C9D6F5; margin: 0 0 18px; }
.entrada .cartao { text-align: left; padding: 20px; }
.entrada .versao { color: #C9D6F5; font-size: 12px; margin-top: 14px; }
.entrada .link-alfa { color: #C9D6F5; font-size: 13px; background: none; border: 0; text-decoration: underline; cursor: pointer; margin-top: 6px; }

/* ------------------------------------------------ estrutura */
.topo {
  position: sticky; top: 0; z-index: 50; background: var(--fundo); display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px 16px; border-bottom: 1px solid transparent;
}
.topo .marca { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; text-decoration: none; color: inherit; }
.topo .marca img { width: 40px; height: 40px; border-radius: 10px; }
.topo .marca b { display: block; font-size: 17px; font-weight: 900; }
.topo .marca small { display: block; font-size: 10.5px; font-weight: 600; color: var(--suave); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.usuario-btn {
  display: flex; align-items: center; gap: 4px; max-width: 140px; padding: 7px 10px; border-radius: 12px; border: 0;
  background: var(--tinta); font-size: 12px; font-weight: 800; cursor: pointer;
}
.usuario-btn svg { width: 16px; height: 16px; color: var(--primaria); }
.usuario-btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layout { display: flex; min-height: calc(100vh - 56px); }
.conteudo { flex: 1; min-width: 0; padding: 6px 12px calc(96px + env(safe-area-inset-bottom)); max-width: 980px; margin: 0 auto; width: 100%; }
.navegacao {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: #fff; display: flex; justify-content: space-around;
  padding: 6px 2px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -2px 12px rgba(20, 35, 70, .09);
}
.navegacao a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0; text-decoration: none;
  color: var(--suave); font-size: 11px; font-weight: 600; position: relative; min-width: 0;
}
.navegacao a i { display: flex; align-items: center; justify-content: center; width: 54px; height: 30px; border-radius: 16px; position: relative; }
.navegacao a.ativo { color: var(--primaria); font-weight: 800; }
.navegacao a.ativo i { background: var(--tinta); }
.selo-qtd {
  position: absolute; top: -3px; right: 6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--despesa); color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; font-style: normal;
}
@media (min-width: 900px) {
  .navegacao {
    position: sticky; top: 64px; bottom: auto; flex-direction: column; justify-content: flex-start; align-self: flex-start;
    width: 210px; min-height: calc(100vh - 80px); background: transparent; box-shadow: none; padding: 8px 8px 8px 12px; gap: 4px;
  }
  .navegacao a { flex: none; flex-direction: row; gap: 10px; font-size: 14px; padding: 2px 6px; border-radius: 14px; }
  .navegacao a.ativo { background: var(--tinta); }
  .navegacao a.ativo i { background: transparent; }
  .navegacao a i { width: 36px; }
  .navegacao .selo-qtd { right: auto; left: 26px; }
  .conteudo { padding-bottom: 40px; padding-top: 10px; }
  .toast { bottom: 28px; }
}

/* ------------------------------------------------ componentes */
.cartao { background: #fff; border: 1px solid var(--borda); border-radius: 18px; box-shadow: var(--sombra); margin: 8px 0; }
.cartao.pad { padding: 14px; }
.cabecalho-pagina { display: flex; align-items: center; gap: 8px; margin: 6px 0 10px; }
.cabecalho-pagina h2 { margin: 0; font-size: 19px; font-weight: 900; flex: 1; min-width: 0; }
.cabecalho-pagina h2 small { display: block; font-size: 11px; font-weight: 600; color: var(--suave); }
.titulo-secao { display: flex; align-items: center; margin: 18px 0 8px; }
.titulo-secao h3 { margin: 0; font-size: 18px; font-weight: 900; flex: 1; }
.selo { display: inline-block; padding: 3px 8px; border-radius: 20px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.selos { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.suave { color: var(--suave); }
.pequeno { font-size: 12px; }
.negrito { font-weight: 800; }
.direita { text-align: right; }
.vazio { text-align: center; color: var(--suave); padding: 28px 12px; }
.linha { display: flex; gap: 8px; align-items: center; }
.linha > .cresce { flex: 1; min-width: 0; }
.grade2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grade3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 420px) { .grade3.quebra { grid-template-columns: 1fr 1fr; } }
.cortado { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--raio);
  padding: 13px 18px; font-weight: 800; cursor: pointer; background: var(--primaria); color: #fff; text-decoration: none; min-height: 46px;
}
.btn svg { width: 20px; height: 20px; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.contorno { background: transparent; color: var(--primaria); border: 1.2px solid var(--primaria); }
.btn.texto { background: transparent; color: var(--primaria); padding: 8px 10px; min-height: 0; }
.btn.perigo { background: var(--perigo); }
.btn.perigo.contorno, .btn.perigo.texto { background: transparent; color: var(--perigo); border-color: var(--perigo); }
.btn.sucesso { background: var(--sucesso); }
.btn.pdf { background: var(--despesa); }
.btn.destaque { background: var(--destaque); color: var(--primaria-escura); }
.btn.largo { width: 100%; }
.btn.pequeno { padding: 7px 12px; min-height: 36px; font-size: 13px; }
.icone-btn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 20px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--texto); flex: none; }
.icone-btn:hover { background: rgba(0, 0, 0, .05); }
.fab {
  position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 55; box-shadow: 0 6px 16px rgba(43, 89, 195, .35);
  border-radius: 18px;
}
@media (min-width: 900px) { .fab { bottom: 28px; right: max(28px, calc(50vw - 470px)); } }

.campo { display: block; margin-bottom: 10px; position: relative; }
.campo > span { display: block; font-size: 12px; font-weight: 700; color: var(--suave); margin: 0 0 4px 4px; }
.campo input, .campo select, .campo textarea {
  width: 100%; border: 1px solid var(--borda-campo); border-radius: var(--raio); background: #fff; padding: 12px 14px; outline: none;
  min-height: 46px;
}
.campo textarea { resize: vertical; min-height: 90px; }
.campo input:focus, .campo select:focus, .campo textarea:focus { border-color: var(--primaria); box-shadow: 0 0 0 1px var(--primaria); }
.campo input[readonly] { background: #EEF1F7; color: #4A5568; font-weight: 700; }
.campo .dica { display: block; font-size: 12px; color: var(--suave); margin: 4px 4px 0; }
.campo .erro-campo { display: block; font-size: 12px; color: var(--perigo); margin: 4px 4px 0; font-weight: 700; }
.campo.com-botao { display: flex; gap: 6px; align-items: flex-end; }
.campo.com-botao > label { flex: 1; }
.campo-senha { position: relative; }
.campo-senha input { padding-right: 48px; }
.ver-senha { position: absolute; right: 4px; bottom: 3px; }
.seletor {
  display: flex; align-items: center; gap: 10px; width: 100%; border: 1px solid var(--borda-campo); border-radius: var(--raio);
  background: #fff; padding: 10px 12px; cursor: pointer; text-align: left; min-height: 46px;
}
.seletor svg { color: var(--suave); }
.seletor .cresce { flex: 1; min-width: 0; }
.seletor small { display: block; font-size: 12px; color: var(--suave); font-weight: 700; }
.seletor b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.segmentos { display: flex; background: #fff; border: 1px solid var(--borda-campo); border-radius: 22px; padding: 3px; gap: 2px; margin: 6px 0; }
.segmentos button { flex: 1; border: 0; background: transparent; border-radius: 18px; padding: 9px 6px; font-weight: 800; cursor: pointer; color: var(--texto); }
.segmentos button.ativo { background: var(--tinta); color: var(--primaria-escura); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0; }
.chips button { border: 1px solid var(--borda-campo); background: #fff; border-radius: 20px; padding: 7px 14px; font-weight: 800; cursor: pointer; }
.chips button.ativo { background: var(--primaria); color: #fff; border-color: var(--primaria); }
.abas { display: flex; background: #fff; border-radius: 14px; margin: 4px 0 8px; overflow-x: auto; scrollbar-width: none; }
.abas::-webkit-scrollbar { display: none; }
.abas a { flex: 1; text-align: center; padding: 12px 8px; text-decoration: none; color: var(--suave); font-weight: 800; font-size: 13.5px; white-space: nowrap; border-bottom: 2.5px solid transparent; position: relative; }
.abas a.ativo { color: var(--primaria); border-bottom-color: var(--primaria); }
.abas .selo-qtd { top: 2px; right: 2px; }

/* lista (ListTile) */
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer; text-decoration: none; color: inherit; }
.item + .item { border-top: 1px solid #E8ECF4; }
.item .cresce { flex: 1; min-width: 0; }
.item .titulo { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .sub { font-size: 13px; color: var(--suave); overflow: hidden; text-overflow: ellipsis; }
.item .valor { font-weight: 900; white-space: nowrap; }
.item .bola { padding: 8px; border-radius: 12px; display: flex; }
.cartao.item { padding: 12px 14px; }
.cartao.item + .cartao.item { border-top: 1px solid var(--borda); }
.riscado { text-decoration: line-through; }

/* inicio */
.saudacao { font-size: 25px; font-weight: 900; margin: 8px 0 2px; }
.destaque-inicio {
  display: flex; align-items: center; gap: 12px; padding: 20px; border-radius: 24px; color: #fff; margin: 16px 0;
  background: linear-gradient(135deg, var(--primaria), var(--primaria-escura)); box-shadow: 0 10px 24px rgba(43, 89, 195, .2);
}
.destaque-inicio b { display: block; font-size: 20px; font-weight: 900; }
.destaque-inicio small { color: #C9D6F5; font-size: 12px; }
.indicadores { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 700px) { .indicadores { grid-template-columns: repeat(3, 1fr); } }
.indicador { padding: 15px; margin: 0; }
.indicador .bola { display: inline-flex; padding: 8px; border-radius: 12px; }
.indicador b { display: block; font-size: 19px; font-weight: 900; margin-top: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.indicador small { font-size: 11px; color: var(--suave); font-weight: 700; }
.atalhos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (min-width: 700px) { .atalhos { grid-template-columns: repeat(3, 1fr); } }
.atalho { display: flex; align-items: center; gap: 10px; padding: 14px; margin: 0; cursor: pointer; text-decoration: none; color: inherit; font-weight: 800; }
.atalho i { display: flex; padding: 7px; border-radius: 10px; background: var(--tinta); color: var(--primaria); }

.totais { display: flex; gap: 8px; margin: 6px 0; }
.totais .cartao { flex: 1; padding: 12px; margin: 0; min-width: 0; }
.totais b { display: block; font-size: 15px; font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.totais small { font-size: 11px; color: var(--suave); font-weight: 700; }
.mes { display: flex; align-items: center; }
.mes b { flex: 1; text-align: center; font-size: 16px; font-weight: 900; }
.faixa-aviso { display: flex; align-items: center; gap: 10px; padding: 10px 6px 10px 12px; border-radius: 18px; margin: 8px 0; font-weight: 800; cursor: pointer; }

/* grafico */
.pizza { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.pizza svg { width: 170px; height: 170px; flex: none; }
.legenda { flex: 1; min-width: 200px; }
.legenda div { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.legenda i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legenda span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.barras { width: 100%; height: auto; }

/* OS */
.barra-total {
  position: sticky; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 40; background: #fff; display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 18px; box-shadow: 0 -4px 16px rgba(0, 0, 0, .09); margin-top: 14px;
}
.barra-total b { display: block; font-size: 22px; font-weight: 900; }
@media (min-width: 900px) { .barra-total { bottom: 12px; } }
.qtd-item { min-width: 42px; text-align: center; background: var(--tinta); color: var(--primaria); font-weight: 900; border-radius: 10px; padding: 6px 4px; font-size: 13px; }
.carregando-tela { display: flex; justify-content: center; padding: 40px; color: var(--suave); }

/* dialogo */
.fundo-modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 200; display: flex; align-items: center; justify-content: center;
  padding: 16px; animation: aparece .15s;
}
@keyframes aparece { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 22px; width: 100%; max-width: 520px; max-height: calc(100dvh - 32px); display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .3);
}
.modal.largo { max-width: 760px; }
.modal h3 { margin: 0; padding: 20px 22px 6px; font-size: 19px; font-weight: 900; }
.modal .corpo { padding: 8px 22px; overflow-y: auto; }
.modal .acoes { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px 16px; flex-wrap: wrap; }
.modal .icone-topo { display: flex; justify-content: center; padding-top: 18px; }
.modal .icone-topo svg { width: 44px; height: 44px; }
.menu-flutuante { position: fixed; z-index: 210; background: #fff; border-radius: 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); min-width: 220px; padding: 6px 0; }
.menu-flutuante button { display: flex; width: 100%; align-items: center; gap: 12px; padding: 11px 16px; border: 0; background: none; cursor: pointer; text-align: left; font-weight: 600; }
.menu-flutuante button:hover { background: #F1F4FA; }
.menu-flutuante button svg { color: var(--primaria); }
.menu-flutuante button.perigo, .menu-flutuante button.perigo svg { color: var(--perigo); }
.menu-flutuante .cab { padding: 8px 16px; font-weight: 900; border-bottom: 1px solid #E8ECF4; margin-bottom: 4px; }
pre.suporte { white-space: pre-wrap; word-break: break-all; font-size: 11px; background: #F4F6FB; padding: 8px; border-radius: 10px; max-height: 200px; overflow: auto; }
details.avancado summary { cursor: pointer; font-weight: 800; padding: 10px 0; }
.marca-alfa { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; color: var(--suave); text-decoration: none; font-size: 13px; }
.marca-alfa i { background: #fff; border-radius: 8px; padding: 3px; display: flex; }
.marca-alfa img { height: 18px; }
.tabela-simples { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabela-simples th, .tabela-simples td { padding: 8px 10px; border-bottom: 1px solid #E8ECF4; text-align: left; }
.tabela-simples th { font-size: 12px; color: var(--suave); }
