/* ============================================================
   styles.css — Distribuidora de Areia
   Interface profissional, tema claro/escuro, referência "pátio".
   ============================================================ */

/* ---------- Tema: tokens de cor ---------- */
:root,
:root[data-theme="light"] {
  --bg: #e6e0d2;
  --bg-2: #dad2c1;
  --surface: #ffffff;
  --surface-2: #f3efe5;
  --surface-3: #e9e2d3;
  --border: #cdc2ac;
  --border-strong: #b3a78f;
  --text: #211f1a;
  --text-muted: #6f6a5d;
  --text-faint: #9a9384;
  --accent: #b06f2c;
  --accent-hover: #985e22;
  --accent-soft: #f1e6d3;
  --on-accent: #ffffff;
  --ok: #2e8b57;        --ok-soft: #e3f1e8;
  --bad: #bf4630;       --bad-soft: #f8e5df;
  --warn: #a9802a;      --warn-soft: #f4ead2;
  --topbar-1: #262219;
  --topbar-2: #1c1913;
  --topbar-text: #f2eee4;
  --topbar-muted: #b3aa95;
  --topbar-line: rgba(255,255,255,.10);
  --shadow-sm: 0 1px 3px rgba(40,33,22,.11), 0 1px 2px rgba(40,33,22,.07);
  --shadow-md: 0 8px 22px rgba(40,33,22,.13);
  --shadow-lg: 0 18px 44px rgba(40,33,22,.22);
  --ring: rgba(176,111,44,.32);
  --radius: 12px;
  --radius-sm: 8px;
}

:root[data-theme="dark"] {
  --bg: #141210;
  --bg-2: #100f0c;
  --surface: #201d18;
  --surface-2: #1a1813;
  --surface-3: #272219;
  --border: #332e26;
  --border-strong: #463f33;
  --text: #efe9dc;
  --text-muted: #a79e8c;
  --text-faint: #7c7565;
  --accent: #d28a3e;
  --accent-hover: #e09a4f;
  --accent-soft: #2c2316;
  --on-accent: #1a1510;
  --ok: #54b07f;        --ok-soft: #1b2a20;
  --bad: #d76a52;       --bad-soft: #2f1d18;
  --warn: #cfa24c;      --warn-soft: #2b2415;
  --topbar-1: #16140f;
  --topbar-2: #0e0d0a;
  --topbar-text: #efe9dc;
  --topbar-muted: #9a9180;
  --topbar-line: rgba(255,255,255,.07);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.40);
  --shadow-md: 0 6px 18px rgba(0,0,0,.48);
  --shadow-lg: 0 18px 44px rgba(0,0,0,.62);
  --ring: rgba(210,138,62,.40);
}

/* ---------- Base ---------- */
* { box-sizing: border-box; margin: 0; padding: 0; }

html { color-scheme: light dark; }

body {
  font-family: 'Segoe UI', Inter, system-ui, -apple-system, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
  transition: background .25s ease, color .25s ease;
}

h1, h2, h3 { line-height: 1.25; letter-spacing: -0.01em; }

::selection { background: var(--accent-soft); }

/* ---------- Barra de rolagem (laranja, discreta) ---------- */
/* Firefox (scrollbar-color é herdada: vale para a página e para as listas internas) */
:root { scrollbar-color: var(--accent) transparent; scrollbar-width: thin; }
/* Chrome / Edge / Safari */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 999px;
  border: 2px solid transparent;   /* margem transparente: deixa o "pegador" mais fino e solto */
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-hover);
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-corner { background: transparent; }

.ic {
  width: 1.15em; height: 1.15em;
  flex: none; vertical-align: -0.18em;
  pointer-events: none;
}

/* ---------- Barra superior ---------- */
.topo {
  background: linear-gradient(180deg, var(--topbar-1), var(--topbar-2));
  color: var(--topbar-text);
  border-bottom: 1px solid var(--topbar-line);
  box-shadow: var(--shadow-md);
  position: sticky; top: 0; z-index: 50;
}
.topo-conteudo {
  max-width: 1180px; margin: 0 auto; padding: 13px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.marca { display: flex; align-items: center; gap: 14px; min-width: 0; }
.marca-icone {
  color: var(--on-accent);
  background: linear-gradient(150deg, var(--accent-hover), var(--accent));
  width: 46px; height: 46px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 11px;
  box-shadow: 0 4px 10px rgba(0,0,0,.28), inset 0 1px 0 rgba(255,255,255,.22);
}
.marca-icone svg { width: 28px; height: 28px; }
.marca-texto { min-width: 0; }
.marca-texto h1 { font-size: 18px; font-weight: 650; color: var(--topbar-text); white-space: nowrap; }
.marca-texto p { font-size: 12.5px; color: var(--topbar-muted); margin-top: 1px; white-space: nowrap; }

.area-usuario { display: flex; align-items: center; gap: 10px; }
.usuario-chip {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; font-weight: 550; color: var(--topbar-text);
  background: rgba(255,255,255,.07);
  border: 1px solid var(--topbar-line);
  padding: 7px 13px; border-radius: 999px; white-space: nowrap;
}
.usuario-chip .ic { color: var(--accent); }

.icon-btn {
  width: 38px; height: 38px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,.07);
  border: 1px solid var(--topbar-line);
  color: var(--topbar-text);
  border-radius: 10px; cursor: pointer;
  transition: background .15s, transform .08s;
}
.icon-btn:hover { background: rgba(255,255,255,.16); }
.icon-btn:active { transform: scale(.95); }
.icon-btn .ic { width: 19px; height: 19px; }

.btn-sair {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent; color: var(--topbar-muted);
  border: 1px solid var(--topbar-line);
  padding: 7px 14px; border-radius: 10px;
  font-size: 13.5px; font-weight: 550; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s;
}
.btn-sair:hover { color: var(--topbar-text); background: rgba(255,255,255,.08); }
.btn-sair .ic { width: 17px; height: 17px; }

/* ---------- Abas (navegação) ---------- */
.abas {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 72px; z-index: 40;
}
.abas:empty { display: none; }
.abas {
  max-width: 1180px; margin: 0 auto;
  display: flex; gap: 2px; padding: 0 16px;
  overflow-x: auto; scrollbar-width: thin;
  min-width: 0;   /* flex item do body: permite encolher e rolar as abas por dentro (sem estourar a página) */
}
.aba {
  border: none; background: transparent;
  color: var(--text-muted);
  padding: 15px 16px 13px;
  font-size: 14.5px; font-weight: 550; cursor: pointer;
  white-space: nowrap;
  border-bottom: 2.5px solid transparent;
  transition: color .15s, border-color .15s;
}
.aba:hover { color: var(--text); }
.aba.ativa { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Conteúdo ---------- */
#conteudo { max-width: 1180px; margin: 0 auto; width: 100%; padding: 24px; flex: 1; min-width: 0; }
.layout { display: grid; grid-template-columns: 340px 1fr; gap: 22px; align-items: start; }

/* ---------- Painéis ---------- */
.painel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.painel-cabecalho {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.painel-cabecalho h2 { font-size: 16px; font-weight: 650; display: flex; align-items: center; gap: 9px; }
.contagem {
  background: var(--surface-3); color: var(--text-muted);
  font-size: 12.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px;
}
.painel-largo { max-width: 880px; margin: 0 auto; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 9px 15px; font-size: 14px; font-weight: 600; cursor: pointer;
  font-family: inherit;
  transition: background .15s, transform .08s, box-shadow .15s, border-color .15s;
}
.btn:active { transform: translateY(1px); }
.btn .ic { width: 16px; height: 16px; }
.btn-add { background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 8px rgba(176,111,44,.30); }
.btn-add:hover { background: var(--accent-hover); }
.btn-perigo { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn-perigo:hover { background: var(--bad); color: #fff; border-color: var(--bad); }

/* ---------- Busca ---------- */
.busca {
  width: calc(100% - 36px); margin: 14px 18px 6px;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface-2) no-repeat 12px center; color: var(--text);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a9080' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-size: 16px;
}
.busca:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* ---------- Lista (mestre) ---------- */
.lista { list-style: none; max-height: 62vh; overflow-y: auto; padding: 8px; }
.lista-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  cursor: pointer; border: 1px solid transparent;
  border-left: 3px solid transparent;
  transition: background .12s, border-color .12s;
}
.lista-item:hover { background: var(--surface-2); }
.lista-item.ativo { background: var(--accent-soft); border-left-color: var(--accent); }
.item-nome { font-weight: 600; font-size: 14.5px; }
.item-sub { font-size: 12.5px; color: var(--text-muted); }
.lista-vazia { color: var(--text-muted); text-align: center; padding: 26px 14px; font-size: 14px; }

/* ---------- Detalhe ---------- */
.detalhe-painel { padding: 22px; min-height: 340px; }
.vazio {
  display: flex; align-items: center; justify-content: center; min-height: 280px;
  color: var(--text-muted); text-align: center; line-height: 1.7; padding: 20px;
}
.detalhe-cabecalho { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.input-nome {
  flex: 1; min-width: 0; font-size: 20px; font-weight: 650; color: var(--text);
  border: none; border-bottom: 2px solid var(--border); padding: 6px 2px; background: transparent;
}
.input-nome:focus { outline: none; border-bottom-color: var(--accent); }

.campo { margin-bottom: 16px; }
.campo > label {
  display: block; font-size: 12px; font-weight: 650; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
}
.campo input:not([type="checkbox"]):not([type="radio"]),
.select, input[type="month"], input[type="date"] {
  width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 14px; background: var(--surface-2); color: var(--text); font-family: inherit;
}
.campo input:focus, .select:focus, input[type="month"]:focus, input[type="date"]:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring);
}
.select { cursor: pointer; }
input::placeholder { color: var(--text-faint); }

/* Campo de moeda */
.input-moeda {
  display: flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 12px; background: var(--surface-2); max-width: 220px;
}
.input-moeda > span { color: var(--text-muted); font-weight: 600; font-size: 13px; }
.input-moeda input { border: none; background: transparent; padding: 10px 4px; font-size: 15px; font-weight: 600; width: 100%; color: var(--text); }
.input-moeda input:focus { outline: none; }
.input-moeda.desabilitado { opacity: .45; }
.input-moeda:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

.destaque-frete {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.destaque-frete > label { color: var(--accent); }
.destaque-frete .input-moeda { background: var(--surface); max-width: 240px; }
.destaque-frete .input-moeda input { font-size: 18px; }

/* ---------- Seções com título + ícone ---------- */
.acesso-secao, .frete-clientes-secao {
  margin-top: 22px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius); padding: 16px;
}
.acesso-secao h3, .frete-clientes-secao h3 {
  font-size: 15px; color: var(--text); margin-bottom: 4px;
  display: flex; align-items: center; gap: 8px;
}
.acesso-secao h3 .ic, .frete-clientes-secao h3 .ic { color: var(--accent); }
.acesso-dica { font-size: 12.5px; color: var(--text-muted); margin-bottom: 12px; }
.acesso-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.acesso-grid .campo { margin-bottom: 0; }
.acesso-grid input { background: var(--surface); }

/* Frete por cliente */
.frete-clientes-lista { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.frete-cliente-linha {
  display: grid; grid-template-columns: minmax(110px, 1fr) 132px 130px 130px; align-items: end; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px;
}
.fc-nome { font-size: 14px; font-weight: 600; min-width: 0; align-self: center; }
.fc-tipo { padding: 8px 9px; font-size: 13px; align-self: end; }
.fc-valor { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.fc-valor > label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.frete-cliente-linha .input-moeda { background: var(--surface-2); }
.frete-cliente-linha .input-moeda input { width: 100%; }

/* ---------- Produtos (preço duplo) ---------- */
.produtos-secao { margin-top: 24px; }
.produtos-cabecalho {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin-bottom: 10px; padding-bottom: 9px; border-bottom: 1.5px solid var(--border);
}
.produtos-cabecalho h3 { font-size: 15px; }
.legenda { font-size: 12px; color: var(--text-muted); font-weight: 600; text-align: right; }
.produtos-tabela { display: flex; flex-direction: column; gap: 6px; }
.produto-linha {
  display: grid; grid-template-columns: 46px 1fr auto; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid transparent; transition: border-color .12s, background .12s;
}
.produto-linha.on { background: var(--surface-3); border-color: var(--border); }
.produto-nome { font-size: 14px; font-weight: 550; }
.produto-linha:not(.on) .produto-nome { color: var(--text-muted); }
.precos-duplos { display: flex; gap: 10px; }
.preco-campo { display: flex; flex-direction: column; gap: 3px; }
.preco-campo > label { font-size: 10.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.precos-duplos .input-moeda { max-width: 132px; padding: 0 8px; }
.precos-duplos .input-moeda input { width: 84px; padding: 7px 2px; font-size: 14px; }

/* ---------- Interruptor ---------- */
.switch { position: relative; display: inline-block; width: 40px; height: 23px; cursor: pointer; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .15s; }
.slider::before {
  content: ""; position: absolute; height: 17px; width: 17px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(17px); }

/* ---------- Formulário de viagem ---------- */
.form-viagem { padding: 18px; }
.unidade-toggle { display: flex; gap: 10px; }
.radio-pill {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); cursor: pointer; font-size: 14px; font-weight: 600; color: var(--text-muted);
  transition: all .12s;
}
.radio-pill:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.radio-pill input { accent-color: var(--accent); }
#vBtnCriar, .login-btn { width: 100%; justify-content: center; padding: 12px; font-size: 15px; margin-top: 4px; }

/* ---------- Cartões de viagem ---------- */
.viagens-lista { padding: 16px; display: flex; flex-direction: column; gap: 12px; max-height: 72vh; overflow-y: auto; }
.viagem-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); padding: 15px; }
.viagem-topo { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-bottom: 10px; }
.viagem-produto { font-weight: 650; font-size: 15.5px; }

.badge { font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 6px; white-space: nowrap; border: 1px solid transparent; }
.badge.metros { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.badge.toneladas { background: var(--surface-3); color: var(--text-muted); border-color: var(--border-strong); }

.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; padding: 4px 11px; border-radius: 999px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.status.concluida { background: var(--ok-soft); color: var(--ok); }
.status.concluida .status-dot { background: var(--ok); }
.status.nao-concluida { background: var(--bad-soft); color: var(--bad); }
.status.nao-concluida .status-dot { background: var(--bad); }
.status.pendente { background: var(--warn-soft); color: var(--warn); }
.status.pendente .status-dot { background: var(--warn); }

.viagem-linhas { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.viagem-linhas .rotulo {
  display: inline-block; min-width: 152px; font-size: 11px; font-weight: 700;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em;
}
.viagem-excluir { margin-top: 12px; padding: 6px 12px; font-size: 13px; }
.trip-lock { margin-top: 8px; font-size: 13px; color: var(--ok); font-weight: 600; }
.aviso-dia { margin: 0 18px 8px; font-size: 13px; color: var(--text-muted); }

/* Campos editáveis da viagem */
.viagem-edit {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  margin: 10px 0; padding: 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.ve-campo { display: flex; flex-direction: column; gap: 4px; }
.ve-campo > label { font-size: 10.5px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.ve-campo select, .ve-campo input { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 14px; color: var(--text); width: 100%; font-family: inherit; }
.ve-campo select:focus, .ve-campo input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.ve-campo select:disabled, .ve-campo input:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Comprovação (número da nota + fotos) ---------- */
.imagens-bloco {
  margin-top: 12px; display: flex; flex-direction: column; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px;
}
.nota-campo { display: flex; flex-direction: column; gap: 4px; max-width: 320px; }
.nota-campo label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.nota-input {
  padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600;
}
.nota-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.nota-input[readonly] { background: var(--surface-2); color: var(--text-muted); }
.foto-grupos { display: flex; flex-wrap: wrap; gap: 18px; }
.foto-grupo { display: flex; flex-direction: column; gap: 6px; }
.foto-grupo-rot { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.thumb-wrap { position: relative; }
.thumb { width: 64px; height: 64px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: zoom-in; background: var(--surface-3); }
.thumb-remover {
  position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid var(--surface); background: var(--bad); color: #fff; font-size: 13px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sem-img { font-size: 13px; color: var(--text-faint); font-style: italic; }
.btn-anexar {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  background: var(--surface-3); color: var(--text); font-size: 13px; font-weight: 600; border: 1px solid var(--border-strong);
  transition: background .15s;
}
.btn-anexar:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.btn-anexar .ic { width: 16px; height: 16px; }

/* Visualizador de imagem */
.lightbox { position: fixed; inset: 0; z-index: 1000; background: rgba(12,9,5,.86); display: flex; align-items: center; justify-content: center; cursor: zoom-out; padding: 24px; }
.lightbox img { max-width: 92vw; max-height: 88vh; border-radius: 10px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.lightbox-fechar { position: absolute; top: 16px; right: 24px; color: #fff; font-size: 38px; line-height: 1; cursor: pointer; }

/* ---------- Relatório ---------- */
.rel-painel { padding-bottom: 8px; }
.rel-filtros { display: flex; flex-wrap: wrap; gap: 14px; padding: 16px 18px; border-bottom: 1px solid var(--border); align-items: flex-end; }
.rel-filtros .campo { margin-bottom: 0; min-width: 180px; }

.rel-resumo { display: flex; flex-wrap: wrap; gap: 10px; padding: 16px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.rmetric {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 14px; min-width: 112px; display: flex; flex-direction: column; gap: 2px;
  box-shadow: var(--shadow-sm); transition: transform .12s, box-shadow .12s;
}
.rmetric:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.rmetric span { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }
.rmetric strong { font-size: 17px; font-weight: 700; }
.rmetric strong.ok { color: var(--ok); }
.rmetric strong.bad { color: var(--bad); }
.rmetric.destaque { background: linear-gradient(150deg, var(--accent-hover), var(--accent)); border-color: transparent; }
.rmetric.destaque span { color: rgba(255,255,255,.85); }
.rmetric.destaque strong { color: #fff; }
.rmetric.pend strong { color: var(--warn); }

.rel-corpo { padding: 16px 18px; display: flex; flex-direction: column; gap: 14px; }
.rel-grupo { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rel-grupo-cabecalho {
  display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: space-between; align-items: baseline;
  padding: 12px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.rel-grupo-cabecalho h3 { font-size: 15.5px; }
.rel-subtotal { font-size: 13px; color: var(--text-muted); }
.rel-subtotal strong { color: var(--text); }
.rel-grupo .viagem-card { border: none; border-bottom: 1px solid var(--border); border-radius: 0; background: var(--surface); }
.rel-grupo .viagem-card:last-child { border-bottom: none; }
.rel-card { background: var(--surface); }
.rel-data { font-size: 12px; color: var(--text-faint); margin-left: auto; }

.rel-valores { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.vl { flex: 1; min-width: 92px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 11px; display: flex; flex-direction: column; gap: 2px; }
.vl span { font-size: 10.5px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
.vl strong { font-size: 15px; font-weight: 700; }
.rel-acoes { margin-top: 12px; }
.rel-status-label { font-size: 13px; font-weight: 600; color: var(--text-muted); display: inline-flex; align-items: center; gap: 8px; }
.rel-status-label select { padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 13px; color: var(--text); cursor: pointer; font-family: inherit; }

/* ---------- Login (com foto do pátio) ---------- */
.login-wrap {
  max-width: 940px; margin: 28px auto; width: 100%;
  display: grid; grid-template-columns: 1.05fr .95fr;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-lg);
}
.login-visual {
  position: relative; min-height: 440px;
  background: url("patio.png") center/cover no-repeat, var(--surface-3);
  display: flex; align-items: flex-end;
}
.login-visual-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(20,15,8,.30) 0%, rgba(20,15,8,.55) 55%, rgba(20,15,8,.86) 100%);
}
.login-visual-conteudo { position: relative; padding: 32px; color: #fff; }
.login-visual-conteudo .marca-icone.grande {
  width: 60px; height: 60px; border-radius: 14px;
  background: rgba(255,255,255,.14); color: #fff; backdrop-filter: blur(2px);
  border: 1px solid rgba(255,255,255,.22); box-shadow: 0 6px 20px rgba(0,0,0,.35);
  margin-bottom: 16px;
}
.login-visual-conteudo .marca-icone.grande svg { width: 36px; height: 36px; }
.login-visual-conteudo h2 { font-size: 24px; font-weight: 700; }
.login-visual-conteudo p { font-size: 14px; color: rgba(255,255,255,.85); margin-top: 6px; max-width: 320px; }

.login-card { padding: 38px 34px; display: flex; flex-direction: column; }
.login-card h2 { font-size: 22px; font-weight: 700; }
.login-sub { color: var(--text-muted); font-size: 14px; margin-bottom: 22px; }
.login-card > label {
  font-size: 12px; font-weight: 650; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em; margin: 14px 0 6px;
}
.login-card input {
  width: 100%; padding: 11px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 15px; background: var(--surface-2); color: var(--text);
}
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.login-erro { color: var(--bad); font-size: 13px; font-weight: 600; min-height: 18px; margin-top: 12px; }

/* ---------- Rodapé ---------- */
.rodape { text-align: center; padding: 20px; color: var(--text-faint); font-size: 12.5px; }

/* ---------- Relatório financeiro (planilha) ---------- */
.fin-secao-titulo {
  font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--text-muted); margin: 4px 2px 2px;
}
.rel-corpo > .fin-secao-titulo:not(:first-child) { margin-top: 14px; }

.tabela-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.tabela { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); min-width: 540px; }
.tabela thead th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--text-muted); background: var(--surface-2); padding: 11px 14px;
  border-bottom: 1px solid var(--border-strong); white-space: nowrap; position: sticky; top: 0;
}
.tabela tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tabela tbody tr:last-child td { border-bottom: none; }
.tabela tbody tr:nth-child(even) td { background: var(--surface-2); }
.tabela tbody tr:hover td { background: var(--accent-soft); }
.tabela .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tabela .td-vazio { text-align: center; color: var(--text-muted); padding: 22px; }
.tabela tfoot .tabela-total td {
  padding: 12px 14px; font-weight: 700; background: var(--surface-3);
  border-top: 2px solid var(--border-strong); color: var(--text);
}

/* Situação (pago / em aberto) */
.sit-select {
  padding: 6px 10px; border-radius: 999px; border: 1px solid transparent;
  font-size: 12.5px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.sit-select.sit-pago { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.sit-select.sit-aberto { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 38%, transparent); }
.sit-select option { color: var(--text); background: var(--surface); }

.obs-input {
  width: 100%; min-width: 160px; padding: 7px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text); font-size: 13px; font-family: inherit;
}
.obs-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }

/* Cabeçalho da entidade específica */
.fin-entidade-cabecalho {
  display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center;
  padding: 16px 18px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px;
}
.fin-ent-info h3 { font-size: 18px; color: var(--text); }
.fin-ent-meta { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
.fin-kpis { display: flex; gap: 10px; flex-wrap: wrap; }
.fin-kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 16px; min-width: 120px; box-shadow: var(--shadow-sm);
}
.fin-kpi span { display: block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); }
.fin-kpi strong { font-size: 18px; color: var(--accent); }

.fin-pagamento {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 14px; margin-bottom: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.fin-pg-rot { font-size: 13px; font-weight: 650; color: var(--text-muted); }
.fin-pagamento .obs-input { flex: 1; }

/* ---------- Saldo + ajustes (substitui o "pago / em aberto") ---------- */
.fin-ajustes {
  margin-bottom: 12px; padding: 14px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius);
}
.fin-ajustes-topo {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 6px 16px; margin-bottom: 12px;
}
.fin-saldo-box { display: flex; align-items: baseline; gap: 9px; }
.fin-saldo-box span { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.fin-saldo-box strong { font-size: 22px; font-weight: 750; color: var(--ok); font-variant-numeric: tabular-nums; }
.fin-saldo-box.neg strong { color: var(--bad); }
.fin-saldo-detalhe { font-size: 12.5px; color: var(--text-muted); }
.fin-saldo-detalhe b { color: var(--text); }

.ajustes-lista { list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 0 0 12px; padding: 0; }
.ajuste-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.ajuste-item .aj-desc { flex: 1; min-width: 0; font-size: 13.5px; word-break: break-word; }
.ajuste-item .aj-valor { font-weight: 700; font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ajuste-item.pos .aj-valor { color: var(--ok); }
.ajuste-item.neg .aj-valor { color: var(--bad); }
.aj-remover {
  flex: none; width: 24px; height: 24px; border-radius: 6px; cursor: pointer; line-height: 1;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted); font-size: 17px;
  display: flex; align-items: center; justify-content: center; transition: background .12s, color .12s, border-color .12s;
}
.aj-remover:hover { background: var(--bad); border-color: var(--bad); color: #fff; }
.ajuste-vazio { list-style: none; font-size: 13px; color: var(--text-faint); font-style: italic; padding: 4px 2px; }

.ajuste-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.ajuste-form .ajuste-desc {
  flex: 1; min-width: 160px; padding: 9px 11px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font-size: 14px; font-family: inherit;
}
.ajuste-form .ajuste-desc:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.ajuste-form .ajuste-moeda { background: var(--surface); max-width: 150px; }
.ajuste-form .btn { padding: 9px 14px; }

/* Saldo negativo (tabela geral e KPI da entidade) */
.tabela td.saldo { font-weight: 700; }
.tabela td.saldo-neg, .fin-kpi strong.saldo-neg, .rmetric strong.saldo-neg { color: var(--bad); }

/* ---------- Sub-abas do detalhe (Cadastro / Histórico de preços) ---------- */
.sub-abas {
  display: flex; gap: 6px; margin-bottom: 18px;
  border-bottom: 1.5px solid var(--border); padding-bottom: 0;
}
.sub-aba {
  border: none; background: transparent; cursor: pointer;
  color: var(--text-muted); font-size: 14px; font-weight: 600; font-family: inherit;
  padding: 9px 14px; border-bottom: 2.5px solid transparent;
  display: inline-flex; align-items: center; gap: 7px;
  transition: color .15s, border-color .15s;
}
.sub-aba:hover { color: var(--text); }
.sub-aba.ativa { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Histórico de preços (pontos de mudança por dia) ---------- */
.historico-secao { display: flex; flex-direction: column; gap: 12px; }
.hist-filtros { display: flex; flex-wrap: wrap; gap: 12px; }
.hist-filtros .campo { flex: 1; min-width: 170px; margin-bottom: 0; }
.hist-atual-valor {
  display: block; padding: 10px 12px; font-size: 14px; font-weight: 600;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.pontos-lista { list-style: none; display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; }
.ponto-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.ponto-dia { font-weight: 700; font-size: 13.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.ponto-valores { flex: 1; font-size: 13.5px; color: var(--text-muted); }
.ponto-valores .sep { color: var(--text-faint); margin: 0 4px; }
.ponto-form {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
}
.ponto-form .campo { flex: 1; min-width: 140px; margin-bottom: 0; }
.ponto-form .input-moeda { max-width: 100%; background: var(--surface); }
.ponto-form .btn { flex: none; }
.hist-msg { font-size: 13px; font-weight: 650; color: var(--ok); }
.rota-forn-campo { max-width: 340px; }

/* ---------- Viagens totais: adicionar retroativa + cartões recolhíveis ---------- */
.vt-add-form { padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.form-viagem-linha { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 12px 0 0; }
.form-viagem-linha .campo { margin-bottom: 0; }
.form-viagem-linha .login-erro { grid-column: 1 / -1; min-height: 0; margin: 0; }
.form-viagem-linha .btn { grid-column: 1 / -1; justify-content: center; }

.vc-toggle {
  width: 100%; border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-size: inherit; color: inherit; text-align: left;
  padding: 2px 0;
}
.vc-toggle:hover .viagem-produto { color: var(--accent); }
.vc-seta { display: inline-flex; color: var(--text-muted); transition: transform .15s; }
.vc-seta .ic { width: 17px; height: 17px; }
.vc-seta.aberta { transform: rotate(180deg); }
.vc-cliente { font-size: 13px; color: var(--text-muted); font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viagem-card.fechada .vc-corpo { display: none; }
.viagem-card.fechada .viagem-topo { margin-bottom: 0; }
.vc-corpo { margin-top: 8px; }

/* Endereço do cliente no cartão do motorista */
.viagem-endereco { font-size: 13px; color: var(--text-muted); margin: -4px 0 10px; }

/* ---------- Seletor de data próprio (Dia / Mês / Ano, sem calendário) ---------- */
.data-select { display: flex; gap: 6px; }
.data-select .ds-dia { flex: 0 0 64px; padding-left: 8px; padding-right: 6px; }
.data-select .ds-mes { flex: 0 0 64px; padding-left: 8px; padding-right: 6px; }
.data-select .ds-ano { flex: 0 0 82px; padding-left: 8px; padding-right: 6px; }
.rel-filtros .campo-data { min-width: 224px; }

/* Filtro por motorista na aba Viagens */
.vg-filtro { margin: 12px 16px 0; }

/* ---------- Histórico de preços: tabela igual ao Cadastro, por dia ---------- */
.hist-dia-linha { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.hist-dia-linha .campo { margin-bottom: 0; }
.hist-chips label {
  display: block; font-size: 12px; font-weight: 650; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px;
}
.hist-chips-lista { display: flex; flex-wrap: wrap; gap: 6px; }
.hist-chip {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-muted);
  font-size: 12.5px; font-weight: 650; font-family: inherit; padding: 6px 11px;
  border-radius: 999px; cursor: pointer; transition: all .12s;
}
.hist-chip:hover { border-color: var(--accent); color: var(--accent); }
.hist-chip.ativa { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.hist-flag { color: var(--border-strong); font-size: 12px; flex: none; }
.hist-flag.tem { color: var(--accent); }
.hist-sem-x { width: 24px; flex: none; }
.hist-linha { grid-template-columns: 16px 1fr auto 28px; }
.hrota-linha { grid-template-columns: 16px minmax(100px, 1fr) 170px 130px 130px 28px; }
.hist-rotas h3 { margin-bottom: 10px; }

@media (max-width: 820px) {
  .hist-linha { grid-template-columns: 16px 1fr 28px; row-gap: 10px; }
  .hist-linha .precos-duplos { grid-column: 1 / -1; }
  .hrota-linha { grid-template-columns: 16px 1fr 28px; row-gap: 8px; }
  .hrota-linha .fc-tipo, .hrota-linha .fc-valor { grid-column: 1 / -1; }
}

/* ---------- Linha do tempo (log de preços) ---------- */
.linha-tempo { margin-top: 6px; }
.lt-produto { margin-top: 12px; }
.lt-produto h4 { font-size: 13.5px; margin-bottom: 6px; }
.lt-produto ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.lt-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 13px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 7px 11px;
}
.lt-faixa { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lt-tipo {
  margin-left: auto; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; color: var(--text-faint); white-space: nowrap;
}
.lt-tipo.lt-dia { color: var(--accent); }
.lt-item .aj-remover { margin-left: 6px; }
.lt-item .sep { color: var(--text-faint); margin: 0 3px; }

/* ---------- Cartão de viagem compacto (Viagens totais) ---------- */
.viagem-card.compacta { padding: 11px 13px; }
.compacta .viagem-topo { gap: 7px; margin-bottom: 8px; }
.compacta .viagem-produto { font-size: 14px; }
.compacta .badge, .compacta .status { font-size: 10.5px; padding: 2px 8px; }
.compacta .rel-data { font-size: 11px; }
.compacta .viagem-edit { gap: 7px; padding: 9px; margin: 8px 0; }
.compacta .ve-campo { gap: 3px; }
.compacta .ve-campo > label { font-size: 9.5px; }
.compacta .ve-campo select, .compacta .ve-campo input { padding: 6px 8px; font-size: 13px; }
.rel-valores-linha {
  font-size: 13px; color: var(--text-muted); padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.rel-valores-linha b { color: var(--text); font-weight: 700; }
.rel-valores-linha .sep { color: var(--text-faint); margin: 0 4px; }
.rel-valores-linha .lucro b { color: var(--accent); }
.rel-rodape {
  display: flex; flex-direction: column; align-items: stretch;
  gap: 9px; margin-top: 9px;
}
.compacta .imagens-bloco { margin-top: 0; gap: 9px; padding: 10px; }
.compacta .thumb { width: 48px; height: 48px; }
.compacta .thumb { width: 44px; height: 44px; }
.compacta .btn-anexar { padding: 6px 10px; font-size: 12px; }
.compacta .rel-status-label { font-size: 12.5px; }
.compacta .rel-status-label select { padding: 5px 9px; font-size: 12.5px; }

.rel-filtros .vt-acoes { min-width: auto; }
#vtExportar { white-space: nowrap; }

/* Log */
.log-data { white-space: nowrap; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* ---------- Responsivo ---------- */

/* No celular os campos vão a 16px: evita o "zoom" automático do iOS ao focar. */
@media (max-width: 820px) {
  .login-card input,
  .campo input:not([type="checkbox"]):not([type="radio"]),
  .select, input[type="month"], input[type="date"],
  .nota-input, .ve-campo select, .ve-campo input,
  .compacta .ve-campo select, .compacta .ve-campo input,
  .obs-input, .busca, .input-moeda input,
  .rel-status-label select, .compacta .rel-status-label select,
  .sit-select, .fc-tipo, .ajuste-form .ajuste-desc {
    font-size: 16px;
  }
  .form-viagem-linha { grid-template-columns: 1fr; }
  .hist-filtros .campo, .ponto-form .campo { min-width: 100%; }
  .ponto-form .btn { width: 100%; justify-content: center; }
}

/* Tablets e telas médias */
@media (max-width: 820px) {
  .topo-conteudo { padding: 12px 16px; }
  .marca-texto p { display: none; }
  .usuario-chip span:not(.ic) { display: none; }
  .usuario-chip { padding: 8px; }
  .btn-sair span { display: none; }
  .btn-sair { padding: 8px; }
  /* margin:0 (sem auto): margens automáticas num flex item do body desativam o stretch e fazem
     a barra de abas encolher para o tamanho do conteúdo, estourando a página. Com margin:0 ela
     ocupa a largura da tela e as abas rolam por dentro (overflow-x). */
  .abas { top: 70px; margin: 0; }
  #conteudo { padding: 16px; }
  .layout { grid-template-columns: 1fr; }
  .lista { max-height: 40vh; }
  .login-wrap { grid-template-columns: 1fr; margin: 16px 0; }   /* sem margem lateral: width:100% + margem dos lados estouraria a tela */
  .login-visual { min-height: 170px; }
  .login-card { padding: 26px 22px; }
  .produto-linha { grid-template-columns: 40px 1fr; row-gap: 10px; }
  .produto-linha .precos-duplos { grid-column: 1 / -1; }
  .precos-duplos { width: 100%; }
  .precos-duplos .preco-campo { flex: 1; }
  .precos-duplos .input-moeda { max-width: 100%; }
  .precos-duplos .input-moeda input { width: 100%; }
  .acesso-grid { grid-template-columns: 1fr; }
  .frete-cliente-linha { grid-template-columns: 1fr 1fr; }
  .frete-cliente-linha .fc-nome, .frete-cliente-linha .fc-tipo { grid-column: 1 / -1; }
  .viagem-edit { grid-template-columns: 1fr 1fr; }
  .rel-filtros .campo { min-width: 140px; flex: 1; }
  .viagem-linhas .rotulo { min-width: 0; display: block; margin-bottom: 2px; }
}

/* Celulares */
@media (max-width: 560px) {
  /* Cabeçalho mais enxuto; as abas continuam roláveis na horizontal */
  .marca { gap: 10px; }
  .marca-icone { width: 40px; height: 40px; border-radius: 10px; }
  .marca-icone svg { width: 24px; height: 24px; }
  .marca-texto h1 { font-size: 16px; white-space: normal; }
  .area-usuario { gap: 7px; }
  .abas { top: 64px; padding: 0 8px; }
  .aba { padding: 13px 12px 11px; font-size: 14px; }

  #conteudo { padding: 12px; }
  .painel-cabecalho { padding: 14px; }
  .form-viagem { padding: 14px; }

  /* Rolagem natural da página (sem "scroll dentro de scroll") nas listas de viagem */
  .viagens-lista { max-height: none; padding: 12px; }

  /* Grades de campos viram coluna única */
  .viagem-edit { grid-template-columns: 1fr; }
  .frete-cliente-linha { grid-template-columns: 1fr; }
  .frete-cliente-linha .fc-nome,
  .frete-cliente-linha .fc-tipo,
  .frete-cliente-linha .fc-valor { grid-column: auto; }
  .input-moeda, .destaque-frete .input-moeda { max-width: 100%; }

  /* Botões de ação dentro de cartões: largura total e mais altos (fáceis de tocar) */
  .btn { padding: 11px 16px; }
  .viagem-excluir, .rel-rodape .btn-perigo { width: 100%; justify-content: center; }

  /* Filtros: 2 por linha; "Gerar Excel" ocupa a linha inteira */
  .rel-filtros { gap: 10px; padding: 14px; }
  .rel-filtros .campo { min-width: 0; flex: 1 1 calc(50% - 5px); }
  .rel-filtros .vt-acoes { flex-basis: 100%; }
  .rel-filtros .vt-acoes .btn { width: 100%; justify-content: center; }

  /* Resumo do relatório: 2 cartões por linha, preenchendo a largura */
  .rel-resumo { padding: 14px; gap: 8px; }
  .rmetric { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .rel-corpo { padding: 14px; }
  .rel-grupo-cabecalho { padding: 11px 14px; }

  /* Financeiro: KPIs e pagamento ocupam a largura */
  .fin-entidade-cabecalho { gap: 10px; padding: 14px; }
  .fin-kpis { width: 100%; }
  .fin-kpi { flex: 1; min-width: 0; padding: 8px 12px; }
  .fin-pagamento .obs-input { flex-basis: 100%; }

  /* Comprovação: grupos de foto empilhados */
  .foto-grupos { gap: 12px; }
  .nota-campo { max-width: 100%; }

  /* Ajustes de saldo: formulário em coluna; os 2 botões dividem a linha */
  .fin-saldo-box strong { font-size: 20px; }
  .ajuste-form .ajuste-desc { flex-basis: 100%; min-width: 0; }
  .ajuste-form .ajuste-moeda { flex-basis: 100%; max-width: 100%; }
  .ajuste-form .btn { flex: 1; justify-content: center; }

  /* Visualizador de imagem aproveita a tela */
  .lightbox { padding: 12px; }
  .lightbox img { max-width: 96vw; max-height: 85vh; }
  .lightbox-fechar { top: 8px; right: 14px; }
}

/* Telas bem pequenas (≈ até 380px) */
@media (max-width: 380px) {
  .marca-texto h1 { font-size: 15px; }
  .rmetric { flex-basis: 100%; }            /* um cartão por linha */
  .rel-filtros .campo { flex-basis: 100%; } /* um filtro por linha */
}
