/* Grupo RF B2B — estilos do app. CELULAR PRIMEIRO; cores SÓ por token --ui-* (ui-padrao). */
:root {
  --bg: var(--ui-bg); --surface: var(--ui-surface); --surface2: var(--ui-surface2); --border: var(--ui-border);
  --accent: var(--ui-accent); --accent2: var(--ui-ok); --gold: var(--ui-warn); --danger: var(--ui-danger); --red: var(--ui-danger);
  --text: var(--ui-text); --muted: var(--ui-muted); --radius: var(--ui-radius); --shadow: var(--ui-shadow); --shadow-lg: var(--ui-shadow-lg);
  --topo-h: 56px; --nav-h: 62px; --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--text); font-family: var(--ui-font); min-height: 100vh; min-height: 100dvh; -webkit-font-smoothing: antialiased; font-size: 14px; }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.svg.p { width: 18px; height: 18px; }

/* ---------- botões e campos ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface2); color: var(--text); cursor: pointer; font-weight: 600; font-size: 14px;
  transition: border-color var(--ui-transicao), background var(--ui-transicao); white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--ui-accent-solid); border-color: var(--ui-accent-solid); color: var(--ui-accent-text); }
.btn.primary:hover { background: var(--ui-accent-hover); }
.btn.ghost { background: transparent; }
.btn.perigo { color: var(--ui-danger); }
.btn.perigo:hover { border-color: var(--ui-danger); }
.btn.xbtn { min-height: 32px; padding: 5px 10px; font-size: 12px; border-radius: 8px; }
.btn.xbtn.copy { padding: 5px 9px; font-size: 14px; line-height: 1; color: var(--muted); }
.btn.xbtn.ok { border-color: var(--accent2); color: var(--accent2); }
.btn.grande { min-height: 50px; font-size: 16px; width: 100%; border-radius: 12px; }
.campo { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.campo > span, .rot { font-size: 12px; font-weight: 600; color: var(--muted); }
.inp, .campo input, .campo select, .campo textarea { width: 100%; min-height: 42px; background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 10px; padding: 9px 12px; font-size: 15px; }
.campo textarea { min-height: 80px; resize: vertical; }
.inp:focus, .campo :is(input, select, textarea):focus { outline: none; border-color: var(--accent); box-shadow: var(--ui-focus); }
.grade-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.linha { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
  background: var(--ui-neutro-soft); color: var(--ui-neutro); }
.badge.ok { background: var(--ui-ok-soft); color: var(--ui-ok); } .badge.warn { background: var(--ui-warn-soft); color: var(--ui-warn); }
.badge.danger { background: var(--ui-danger-soft); color: var(--ui-danger); } .badge.info { background: var(--ui-info-soft); color: var(--ui-info); }
.badge.accent { background: var(--ui-accent-soft); color: var(--ui-accent); } .badge.neutro { background: var(--ui-neutro-soft); color: var(--ui-neutro); }

/* ---------- login ---------- */
#loginOverlay { position: fixed; inset: 0; z-index: 9500; background: var(--bg); display: flex; align-items: center; justify-content: center; padding: 20px; overflow: auto; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 30px 24px; width: 380px; max-width: 100%; box-shadow: var(--shadow-lg); }
.login-card .marca { display: block; width: 260px; max-width: 86%; margin: 0 auto 6px; }
.login-card h1 { text-align: center; font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 18px; }
.login-card .campo { margin-bottom: 12px; }
.login-card .btn { width: 100%; min-height: 50px; margin-top: 8px; font-size: 16px; }
#loginErr { color: var(--ui-danger); font-size: 13px; text-align: center; margin-top: 10px; min-height: 18px; }
.login-tema { margin-top: 14px; display: flex; justify-content: center; }

/* ---------- logos por tema (claro/negativo) ---------- */
.logo-claro { display: block; } .logo-escuro { display: none; }
[data-theme="dark"] .logo-claro, [data-theme="tech"] .logo-claro { display: none; }
[data-theme="dark"] .logo-escuro, [data-theme="tech"] .logo-escuro { display: block; }

/* ---------- topo ---------- */
.topo { position: sticky; top: 0; z-index: 300; background: var(--ui-topbar-bg, var(--surface)); color: var(--ui-topbar-text, var(--text));
  border-bottom: 1px solid var(--border); padding: calc(6px + var(--safe-t)) 12px 6px; display: flex; align-items: center; gap: 10px; min-height: var(--topo-h); }
.topo .marca { height: 30px; width: auto; flex: none; }
.topo .titulo-aba { font-weight: 700; font-size: 16px; }
.nav-topo { display: none; gap: 4px; margin-left: 8px; overflow-x: auto; }
.nav-topo button { background: none; border: 0; border-radius: 9px; padding: 8px 12px; cursor: pointer; font-weight: 600; color: var(--muted); white-space: nowrap; min-height: 38px; }
.nav-topo button:hover { color: var(--text); background: var(--surface2); }
.nav-topo button.active { color: var(--accent); background: var(--ui-accent-soft); }
#userBox { margin-left: auto; display: none; align-items: center; gap: 8px; }
#userBox .u-txt { text-align: right; line-height: 1.15; display: none; }
#userBox .u-nome { font-size: 13px; font-weight: 700; } #userBox .u-role { font-size: 11px; color: var(--muted); }
.btn-carrinho-topo { display: none; position: relative; }
.cont-bolha { position: absolute; top: -4px; right: -6px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--ui-accent-2); color: var(--ui-on-status);
  font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }

/* ---------- navegação inferior (celular) ---------- */
.nav-inferior { position: fixed; left: 0; right: 0; bottom: 0; z-index: 400; background: var(--surface); border-top: 1px solid var(--border);
  display: flex; padding-bottom: var(--safe-b); box-shadow: 0 -6px 20px rgba(0,0,0,.06); }
.nav-inferior button { flex: 1; background: none; border: 0; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600; cursor: pointer; position: relative; }
.nav-inferior button.active { color: var(--accent); }
.nav-inferior button .cont-bolha { top: 6px; right: calc(50% - 22px); }
main { padding: 14px 12px calc(var(--nav-h) + var(--safe-b) + 24px); max-width: 100%; }
main.com-barra-total { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 84px); }
.secao-aba > h2 { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.secao-aba > .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

/* ---------- folha "Mais" (menu) ---------- */
.folha-bg { position: fixed; inset: 0; z-index: 8000; background: rgba(2,8,14,.45); display: flex; align-items: flex-end; justify-content: center; }
.folha { background: var(--surface); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0; padding: 8px 14px calc(18px + var(--safe-b)); max-height: 92dvh; overflow: auto;
  box-shadow: var(--shadow-lg); animation: subir .2s ease-out; }
.folha .pega { width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 12px; }
.folha h3 { font-size: 17px; margin: 4px 4px 12px; }
.folha .item-menu { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 10px; border: 0; background: none; border-radius: 12px; cursor: pointer; text-align: left; font-size: 15px; font-weight: 600; min-height: 52px; }
.folha .item-menu:hover { background: var(--surface2); }
.folha .item-menu .svg { color: var(--accent); }
@keyframes subir { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }

/* ---------- cards / listas genéricas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 14px; }
.cards-forn { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.card-forn h3 { font-size: 16px; margin-bottom: 2px; }
.card-forn .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.card-forn .num b { display: block; font-size: 18px; } .card-forn .num span { font-size: 11px; color: var(--muted); }
.card-forn .acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.barra-acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.barra-acoes .inp { width: auto; flex: 1; min-width: 160px; }
.vazio { text-align: center; color: var(--muted); padding: 40px 16px; }
.vazio .svg { width: 42px; height: 42px; margin-bottom: 10px; opacity: .6; }

/* ---------- modal (tela cheia no celular) ---------- */
.modal-bg { position: fixed; inset: 0; z-index: 8500; background: rgba(2,8,14,.55); display: flex; align-items: flex-start; justify-content: center; padding: 0; overflow: auto; }
.modal { background: var(--surface); width: 100%; min-height: 100dvh; display: flex; flex-direction: column; }
.modal-cab { position: sticky; top: 0; z-index: 2; background: var(--surface); display: flex; align-items: center; gap: 10px; padding: calc(10px + var(--safe-t)) 14px 10px; border-bottom: 1px solid var(--border); }
.modal-cab h3 { font-size: 17px; flex: 1; min-width: 0; }
.modal-cab .fechar { background: none; border: 1px solid var(--border); border-radius: 10px; min-width: 40px; min-height: 40px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.modal-corpo { padding: 14px; flex: 1; }
.modal-rodape { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 10px 14px calc(10px + var(--safe-b)); display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal-rodape .btn { flex: 1; }
.passos { display: flex; gap: 6px; margin-bottom: 14px; overflow-x: auto; }
.passos span { flex: none; padding: 6px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; background: var(--surface2); color: var(--muted); }
.passos span.on { background: var(--ui-accent-soft); color: var(--accent); }
.passos span.feito { color: var(--ui-ok); }

/* ---------- toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); transform: translateX(-50%); z-index: 9800; background: var(--ui-tooltip-bg); color: var(--ui-tooltip-text);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); text-align: center; display: none; }
#toast.erro { background: var(--ui-danger); color: var(--ui-on-status); }

/* ---------- tabela padrão (admin) ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; -webkit-overflow-scrolling: touch; }
table.dt { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dt th, table.dt td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.dt th { background: var(--ui-th-bg, var(--surface2)); color: var(--ui-th-text, var(--muted)); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; position: sticky; top: 0; z-index: 1; user-select: none; }
table.dt th.num, table.dt td.num { text-align: right; }
table.dt tbody tr:hover { background: var(--ui-row-hover); }
table.dt tbody tr.sel { background: var(--ui-row-sel); }
table.dt th .th-lbl { cursor: pointer; } table.dt th .th-lbl:hover { color: var(--accent); }
.col-filter-btn { display: inline-flex; margin-left: 4px; cursor: pointer; color: var(--muted); opacity: .5; font-size: 10px; }
.col-filter-btn:hover, .col-filter-btn.ativo { opacity: 1; color: var(--accent); }
.filtro-pop { position: absolute; z-index: 9000; background: var(--surface); border: 1px solid var(--accent); border-radius: 10px; padding: 12px; box-shadow: var(--shadow-lg); display: none; min-width: 220px; }
.filtro-pop label { display: block; font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 4px; text-transform: uppercase; }
.filtro-pop input { width: 100%; background: var(--surface2); border: 1px solid var(--border); color: var(--text); border-radius: 7px; padding: 7px 9px; font-size: 13px; margin-bottom: 8px; }
.filtro-pop .fp-row { display: flex; gap: 6px; } .filtro-pop .fp-acoes { display: flex; gap: 6px; }
.cp-row { display: flex; align-items: center; gap: 6px; padding: 3px 2px; font-size: 13px; }
.tbl-toolbar { display: flex; gap: 6px; justify-content: flex-end; margin-bottom: 6px; }
table.dt.resizable th { padding-right: 12px; position: sticky; }
table.dt.resizable td { white-space: normal; overflow-wrap: anywhere; }
.col-resizer { position: absolute; right: 0; top: 0; height: 100%; width: 7px; cursor: col-resize; }
.col-resizer:hover { background: var(--accent); opacity: .5; }
.exp-grp { display: inline-flex; gap: 6px; align-items: center; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 10px; }
.filtros .campo { min-width: 150px; flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: var(--surface2); padding: 8px 12px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); min-height: 40px; }
.seg button.on { background: var(--ui-accent-soft); color: var(--accent); }
.barra-massa { position: sticky; top: var(--topo-h); z-index: 50; background: var(--ui-accent-soft); border: 1px solid var(--ui-accent-soft-2); border-radius: 12px; padding: 8px 10px; margin-bottom: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ok-txt { color: var(--ui-ok); } .warn-txt { color: var(--ui-warn); } .danger-txt { color: var(--ui-danger); }

/* ---------- importação ---------- */
.zona-arquivo { border: 2px dashed var(--border); border-radius: 16px; padding: 30px 16px; text-align: center; cursor: pointer; display: block; }
.zona-arquivo:hover, .zona-arquivo.arrastando { border-color: var(--accent); background: var(--ui-accent-soft); }
.mapa { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.mapa .campo.obrig > span::after { content: ' *'; color: var(--ui-danger); }
.mapa .campo.achou select { border-color: var(--ui-ok); }
.degrau-linha { display: grid; grid-template-columns: 90px 1fr 120px 36px; gap: 6px; align-items: end; margin-bottom: 6px; }
.resumo-imp { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin: 12px 0; }
.resumo-imp .card b { display: block; font-size: 22px; }
.resumo-imp .card span { font-size: 12px; color: var(--muted); }
.progresso { height: 10px; background: var(--surface2); border-radius: 6px; overflow: hidden; margin: 12px 0; }
.progresso > div { height: 100%; background: var(--ui-accent-solid); width: 0; transition: width .25s; }

/* ---------- prazos ---------- */
.tab-prazos { width: 100%; border-collapse: collapse; }
.tab-prazos td, .tab-prazos th { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; font-size: 14px; }
.tab-prazos th { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.tab-prazos .inp { min-height: 40px; }

/* ---------- desktop ---------- */
@media (min-width: 1024px) {
  .nav-inferior { display: none; }
  .nav-topo { display: flex; }
  .btn-carrinho-topo { display: inline-flex; }
  #userBox .u-txt { display: block; }
  main { padding: 20px 24px 60px; }
  main.com-barra-total { padding-bottom: 110px; }
  #toast { bottom: 24px; }
  .modal-bg { padding: 3vh 16px; }
  .modal { width: 1100px; max-width: 100%; min-height: 0; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lg); }
  .modal.estreito { width: 620px; }
  .modal-cab { padding: 14px 20px; }
  .modal-corpo { padding: 18px 20px; }
  .modal-rodape { padding: 12px 20px; }
  .modal-rodape .btn { flex: none; }
  .folha-bg { align-items: center; }
  .folha { border-radius: 20px; }
}

/* ---------- fotos ---------- */
.foto-vazia { display: flex; align-items: center; justify-content: center; background: var(--surface2); color: var(--muted); }
.foto-vazia .svg { width: 34%; height: 34%; opacity: .45; }

/* ---------- fila de casamento ---------- */
.cas-lista { display: grid; gap: 10px; }
.cas-card { display: grid; gap: 10px; }
.cas-par { display: grid; grid-template-columns: 1fr; gap: 8px; }
.cas-lado { background: var(--surface2); border-radius: 10px; padding: 10px; display: flex; gap: 10px; align-items: flex-start; min-width: 0; }
.cas-lado .txt { min-width: 0; }
.cas-lado small { display: block; color: var(--muted); font-size: 12px; }
.cas-lado b { display: block; font-size: 14px; line-height: 1.3; }
.cas-lado.erp { background: var(--ui-ok-soft); }
.cas-lado.erp.sug { background: var(--ui-warn-soft); }
.cas-lado.vazio-par { background: var(--ui-neutro-soft); color: var(--muted); }
.cas-foto { width: 64px; height: 64px; flex: none; border-radius: 8px; object-fit: contain; background: #fff; }
.cas-seta { text-align: center; font-weight: 800; color: var(--muted); font-size: 13px; }
.cas-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.cas-chips button { border: 1px dashed var(--border); background: none; border-radius: 999px; padding: 6px 10px; font-size: 12px; cursor: pointer; text-align: left; }
.cas-chips button:hover { border-color: var(--accent); }
.cas-acoes { display: flex; gap: 8px; flex-wrap: wrap; }
.cas-acoes .btn { flex: 1; min-width: 110px; }
.busca-erp-item { display: flex; gap: 10px; align-items: center; padding: 10px; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; margin-bottom: 8px; }
.busca-erp-item:hover { border-color: var(--accent); }
@media (min-width: 900px) { .cas-par { grid-template-columns: 1fr 70px 1fr; align-items: stretch; } .cas-seta { align-self: center; } }
/* o cabeçalho é escuro nos 3 temas (--ui-topbar-bg): sempre o logo negativo */
.topo .logo-claro { display: none; } .topo .logo-escuro { display: block; }
@media (min-width: 1024px) { .topo .marca { height: 34px; } }
/* celular: topo enxuto (Configurações e Sair ficam no menu "Mais") e nada passa da largura da tela */
body { overflow-x: clip; }
@media (max-width: 1023px) { #userBox { display: none !important; } }
/* login: um logo só, conforme o tema (o claro no Clean; o negativo no Escuro/Tech) */
.login-card .marca.logo-escuro { display: none; }
[data-theme="dark"] .login-card .marca.logo-claro, [data-theme="tech"] .login-card .marca.logo-claro { display: none; }
[data-theme="dark"] .login-card .marca.logo-escuro, [data-theme="tech"] .login-card .marca.logo-escuro { display: block; }
.busca-erp-item.outra-marca { opacity: .62; }
.busca-erp-item.outra-marca:hover { opacity: 1; }
