/* MAV SOLAR — tema escuro (padrão) e claro. Paleta: navy + âmbar solar. */
:root {
  color-scheme: dark;
  --bg: #070d1f; --bg2: #0b1430; --panel: #0f1a3a; --panel2: #15224a; --line: #1e2d5c; --line2: #2b3d73;
  --text: #eef2ff; --muted: #9aa8cf; --dim: #6b7aa6;
  --sol: #f5a524; --sol2: #ffd166; --sol-soft: rgba(245,165,36,.14);
  --accent: #3987e5; --accent-soft: rgba(57,135,229,.16);
  --ok: #22c55e; --ok-soft: rgba(34,197,94,.14); --warn: #eab308; --warn-soft: rgba(234,179,8,.14);
  --risk: #ef4444; --risk-soft: rgba(239,68,68,.14);
  --sem: #e66767; --com: #3987e5; --eco: #22c55e; --eq: #8391b8;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --r: 14px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f5fb; --bg2: #e9edf7; --panel: #ffffff; --panel2: #f1f4fb; --line: #e2e7f2; --line2: #cfd7ea;
  --text: #0f172a; --muted: #55607d; --dim: #8892ad;
  --sol: #d98a00; --sol2: #b26b00; --sol-soft: rgba(245,165,36,.16);
  --accent: #2a78d6; --accent-soft: rgba(42,120,214,.12);
  --ok: #16a34a; --ok-soft: rgba(22,163,74,.12); --warn: #b98900; --warn-soft: rgba(234,179,8,.16);
  --risk: #dc2626; --risk-soft: rgba(220,38,38,.10);
  --sem: #e34948; --com: #2a78d6; --eco: #16a34a; --eq: #94a3b8;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;
  --shadow: 0 8px 24px rgba(15,23,42,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, sans-serif; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; overflow-x: hidden; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; font-weight: 800; } h2 { font-size: 16px; font-weight: 700; } h3 { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--muted); } .dim { color: var(--dim); } .small { font-size: 12px; } .num { font-variant-numeric: tabular-nums; }
.ok { color: var(--ok); } .risk { color: var(--risk); } .warn { color: var(--warn); } .solc { color: var(--sol); }

/* ---------- shell */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; background: linear-gradient(180deg, var(--bg2), var(--bg)); border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo { width: 38px; height: 38px; border-radius: 11px; background: radial-gradient(circle at 35% 35%, var(--sol2), var(--sol)); display: grid; place-items: center; box-shadow: 0 0 24px rgba(245,165,36,.45); }
.brand .logo svg { color: #241500; }
.brand b { display: block; font-size: 16px; font-weight: 800; letter-spacing: .02em; }
.brand small { color: var(--muted); font-size: 11px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; font-weight: 600; transition: .15s; }
.nav a:hover { background: var(--panel); color: var(--text); }
.nav a.on { background: var(--sol-soft); color: var(--sol); box-shadow: inset 3px 0 0 var(--sol); }
.side .rodape { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.user { display: flex; align-items: center; gap: 9px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--panel2); display: grid; place-items: center; font-weight: 700; font-size: 12px; color: var(--sol); }
main { padding: 26px 30px 90px; min-width: 0; max-width: 1560px; width: 100%; margin: 0 auto; }
.topo { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 20px; }
.topo .acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.bnav { display: none; }

/* ---------- componentes */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.card > header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0,1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-21 { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 15px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel2); color: var(--text); font: 600 13.5px Inter, sans-serif; cursor: pointer; transition: .15s; white-space: nowrap; text-decoration: none; }
.btn:hover { border-color: var(--sol); transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.pri { background: linear-gradient(135deg, var(--sol2), var(--sol)); color: #241500; border-color: transparent; box-shadow: 0 6px 18px rgba(245,165,36,.3); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--panel2); }
.btn.danger { background: var(--risk-soft); color: var(--risk); border-color: transparent; }
.btn.okb { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.btn.icon { padding: 0; width: 40px; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 12.5px; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--bg2); color: var(--text); font: 14px Inter, sans-serif; outline: none; transition: .15s; }
input:focus, select:focus, textarea:focus { border-color: var(--sol); box-shadow: 0 0 0 3px var(--sol-soft); }
label.f { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); min-width: 0; }
label.f small { font-weight: 400; color: var(--dim); }
.form { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
.form .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { width: 18px; min-height: 18px; accent-color: var(--sol); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 99px; font-size: 11.5px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.pill.paga { background: var(--ok-soft); color: var(--ok); } .pill.aberta { background: var(--accent-soft); color: var(--accent); }
.pill.vencida { background: var(--risk-soft); color: var(--risk); } .pill.cancelada { background: var(--panel2); color: var(--dim); }
.pill.neutra { background: var(--panel2); color: var(--muted); } .pill.solp { background: var(--sol-soft); color: var(--sol); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line2); background: transparent; color: var(--muted); font: 600 12.5px Inter; cursor: pointer; min-height: 34px; }
.chip.on { background: var(--sol-soft); border-color: var(--sol); color: var(--sol); }

/* KPIs */
.kpi { position: relative; overflow: hidden; cursor: default; transition: .2s; }
.kpi.click { cursor: pointer; } .kpi.click:hover { transform: translateY(-2px); border-color: var(--line2); }
.kpi .rot { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; display: flex; align-items: center; gap: 7px; }
.kpi .val { font-size: 27px; font-weight: 800; margin: 8px 0 4px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); }
.kpi::after { content: ""; position: absolute; inset: auto -30px -40px auto; width: 120px; height: 120px; border-radius: 50%; background: var(--glow, var(--sol-soft)); filter: blur(10px); opacity: .7; }
.kpi .ico { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--glow, var(--sol-soft)); color: var(--c, var(--sol)); }
.delta { font-weight: 700; } .delta.up { color: var(--ok); } .delta.down { color: var(--risk); }

/* hero sem × com */
.hero { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 14px; align-items: stretch; }
.hero .bx { border-radius: var(--r); padding: 16px 18px; border: 1px solid var(--line); background: var(--panel); position: relative; overflow: hidden; }
.hero .bx::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.hero .bx .rot { font-size: 11.5px; font-weight: 800; color: var(--c); text-transform: uppercase; letter-spacing: .06em; }
.hero .bx .val { font-size: 30px; font-weight: 800; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.hero .op { display: grid; place-items: center; font-size: 22px; font-weight: 800; color: var(--dim); }

/* tabela */
.tabela { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim); font-weight: 700; padding: 10px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }
tr.click { cursor: pointer; transition: .12s; } tr.click:hover td { background: var(--panel2); }
th.ord { cursor: pointer; } th[data-dir=asc]::after { content: " ▲"; } th[data-dir=desc]::after { content: " ▼"; }

/* alertas / insights */
.lista { display: flex; flex-direction: column; gap: 8px; }
.alerta { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 10px; background: var(--panel2); border-left: 3px solid var(--c, var(--accent)); font-size: 13px; cursor: pointer; transition: .15s; }
.alerta:hover { transform: translateX(3px); }
.alerta.risco { --c: var(--risk); } .alerta.atencao { --c: var(--warn); } .alerta.info { --c: var(--accent); }
.alerta svg { color: var(--c); flex: none; margin-top: 1px; }
.insight { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.insight:last-child { border: 0; }
.insight svg { color: var(--sol); flex: none; margin-top: 2px; }

/* gráficos */
.chart { width: 100%; position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart svg text { fill: var(--dim); font: 11px Inter, sans-serif; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .hit:hover { fill: var(--text); opacity: .06; }
.legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tip { position: fixed; z-index: 100; pointer-events: none; background: var(--panel); border: 1px solid var(--line2); color: var(--text); padding: 9px 11px; border-radius: 10px; font-size: 12.5px; box-shadow: var(--shadow); display: none; max-width: 280px; }
.tip b { display: block; margin-bottom: 3px; }
.tip .l { display: flex; justify-content: space-between; gap: 14px; } .tip .l i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.rbar { display: grid; grid-template-columns: minmax(90px, 200px) 1fr auto; gap: 10px; align-items: center; font-size: 12.5px; padding: 5px 0; cursor: pointer; border-radius: 8px; }
.rbar:hover { background: var(--panel2); }
.rbar .track { height: 10px; border-radius: 99px; background: var(--panel2); overflow: hidden; display: flex; gap: 2px; }
.rbar .track i { display: block; height: 100%; border-radius: 4px; transition: width .8s cubic-bezier(.2,.8,.2,1); }
.rbar .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* passos (memória de cálculo) */
.passos { display: flex; flex-direction: column; }
.passo { display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 9px 10px; border-bottom: 1px solid var(--line); }
.passo .f { grid-column: 1; font-size: 11.5px; color: var(--dim); }
.passo .v { grid-row: 1; grid-column: 2; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.passo.sem { background: var(--risk-soft); border-radius: 8px; font-weight: 800; } .passo.sem .v { color: var(--sem); }
.passo.com { background: var(--accent-soft); border-radius: 8px; font-weight: 800; } .passo.com .v { color: var(--com); }
.passo.eco { background: var(--ok-soft); border-radius: 8px; font-weight: 800; } .passo.eco .v { color: var(--eco); }

/* importação */
.drop { border: 2px dashed var(--line2); border-radius: 18px; padding: 38px 20px; text-align: center; background: radial-gradient(ellipse at top, var(--sol-soft), transparent 70%); transition: .2s; cursor: pointer; }
.drop.over { border-color: var(--sol); transform: scale(1.01); background: var(--sol-soft); }
.drop .big { width: 64px; height: 64px; border-radius: 18px; background: var(--sol-soft); color: var(--sol); display: grid; place-items: center; margin: 0 auto 12px; }
.prev { border: 1px solid var(--line); border-radius: var(--r); padding: 14px; background: var(--panel); display: grid; gap: 12px; animation: sobe .35s ease both; }
@keyframes sobe { from { opacity: 0; transform: translateY(8px); } }
.mini { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.mini > div { background: var(--panel2); border-radius: 10px; padding: 8px 10px; }
.mini small { display: block; color: var(--dim); font-size: 11px; } .mini b { font-variant-numeric: tabular-nums; }

/* modal / toast */
.modal-bg { position: fixed; inset: 0; background: rgba(3,7,18,.6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; padding: 16px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--panel); border: 1px solid var(--line2); border-radius: 18px; width: min(560px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: var(--shadow); animation: sobe .2s; }
.modal.wide { width: min(980px, 100%); }
.modal header, .modal footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px; }
.modal header { border-bottom: 1px solid var(--line); } .modal footer { border-top: 1px solid var(--line); justify-content: flex-end; flex-wrap: wrap; }
.modal .body { padding: 18px; overflow: auto; }
.toast-box { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--panel); border: 1px solid var(--line2); border-left: 4px solid var(--ok); padding: 11px 15px; border-radius: 10px; box-shadow: var(--shadow); animation: sobe .2s; max-width: 360px; }
.toast.err { border-left-color: var(--risk); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(ellipse at 20% 10%, rgba(245,165,36,.18), transparent 50%), radial-gradient(ellipse at 90% 90%, rgba(57,135,229,.18), transparent 50%), var(--bg); }
.login .card { width: min(400px, 100%); padding: 30px; }
.vazio { text-align: center; padding: 40px 16px; color: var(--muted); }
.vazio .big { width: 70px; height: 70px; border-radius: 20px; background: var(--sol-soft); color: var(--sol); display: grid; place-items: center; margin: 0 auto 14px; }
.sk { background: linear-gradient(90deg, var(--panel) 25%, var(--panel2) 50%, var(--panel) 75%); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r); min-height: 110px; }
@keyframes sk { to { background-position: -200% 0; } }
.slider { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; }
input[type=range] { padding: 0; min-height: 28px; accent-color: var(--sol); background: transparent; border: 0; box-shadow: none; }
.sol-anim { animation: gira 24s linear infinite; transform-origin: center; } @keyframes gira { to { transform: rotate(360deg); } }
.sep { height: 1px; background: var(--line); margin: 14px 0; }

/* ---------- responsivo */
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g-21 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { display: none; }
  main { padding: 16px 16px 92px; }
  .bnav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 40; background: var(--bg2); border-top: 1px solid var(--line); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; }
  .bnav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 10.5px; color: var(--muted); text-decoration: none; padding: 4px 6px; min-width: 52px; border-radius: 10px; font-weight: 600; }
  .bnav a.on { color: var(--sol); background: var(--sol-soft); }
  .g2, .g3 { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; } .hero .op { display: none; }
  .mtop { display: flex !important; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi .val { font-size: 20px; } .card { padding: 14px; }
  h1 { font-size: 19px; }
  .rbar { grid-template-columns: minmax(70px, 110px) 1fr auto; }
  .hide-sm { display: none; }
}
.mtop { display: none; align-items: center; justify-content: space-between; margin: -4px 0 14px; }
.mtop-wrap { display: none; }
@media (max-width: 900px) { .mtop-wrap { display: block; } }
tr.grupo td { background: var(--panel2); border-bottom: 1px solid var(--line2); padding-top: 9px; padding-bottom: 9px; }

/* ====== responsividade completa ====== */
/* monitores grandes: mais respiro e conteúdo centralizado */
@media (min-width: 1800px) { main { max-width: 1760px; padding: 32px 40px 90px; } html, body { font-size: 15px; } .kpi .val { font-size: 30px; } }
@media (min-width: 2400px) { main { max-width: 2100px; } html, body { font-size: 16px; } }
/* notebook 900–1180: KPIs em 2 colunas, menu lateral mais estreito */
@media (min-width: 901px) and (max-width: 1180px) { .app { grid-template-columns: 210px 1fr; } main { padding: 22px 22px 80px; } .hero .bx .val { font-size: 24px; } }
/* tablet */
@media (min-width: 601px) and (max-width: 900px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0,1fr)); } }
/* celular e tablet: tabelas viram cartões */
@media (max-width: 900px) {
  .tabela { overflow: visible; }
  .tabela table, .tabela tbody, .tabela tr, .tabela td { display: block; width: 100%; }
  .tabela thead { display: none; }
  .tabela tbody tr:not(.grupo) { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; padding: 12px; margin: 0 0 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
  .tabela tbody tr:not(.grupo) td { border: 0; padding: 0; text-align: left !important; min-width: 0; }
  .tabela td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--dim); margin-bottom: 2px; }
  .tabela td.m-titulo { grid-column: 1 / -1; font-size: 15px; }
  .tabela td.m-acoes { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 6px; border-top: 1px solid var(--line) !important; padding-top: 8px !important; }
  .tabela td.m-acoes .btn.icon { width: 44px; min-height: 40px; }
  .tabela td.m-chk { grid-column: auto; align-self: center; }
  .tabela td.m-chk input { width: 22px; min-height: 22px; }
  .tabela tr.grupo { display: flex; flex-wrap: wrap; gap: 4px 14px; padding: 10px 12px; margin: 6px 0 8px; border-radius: 10px; background: var(--panel2); }
  .tabela tr.grupo td { border: 0; padding: 0; background: transparent; width: auto; }
  .tabela tr.grupo td:empty { display: none; }
  .card:has(> .tabela) { padding: 8px !important; background: transparent; border-color: transparent; box-shadow: none; }
  tr.click:hover td { background: transparent; }
  /* janelas como painel inferior */
  .modal-bg { padding: 0; align-items: end; }
  .modal, .modal.wide { width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; }
  .modal footer { position: sticky; bottom: 0; background: var(--panel); }
  .modal footer .btn { flex: 1 1 auto; }
  .toast-box { left: 12px; right: 12px; bottom: 84px; } .toast { max-width: none; }
  .tip { max-width: calc(100vw - 24px); }
}
@media (hover: none) { .btn:hover { transform: none; } .kpi.click:hover { transform: none; } }
@media (min-width: 601px) and (max-width: 900px) { .tabela tbody tr:not(.grupo) { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* janela como painel inferior só no celular; no tablet volta a ser centralizada */
@media (min-width: 701px) and (max-width: 900px) { .modal-bg { padding: 16px; align-items: center; } .modal, .modal.wide { border-radius: 18px; width: min(980px, 100%); } .modal footer .btn { flex: 0 0 auto; } }
/* notebook (901–1280): menu lateral só com ícones e tabelas compactas para caber sem rolagem */
@media (min-width: 901px) and (max-width: 1280px) {
  .app { grid-template-columns: 72px 1fr; }
  .side { padding: 14px 10px; align-items: center; }
  .side .brand { padding: 4px 0 14px; } .side .brand > div:not(.logo) { display: none; }
  .nav a { justify-content: center; padding: 11px; } .nav a span { display: none; }
  .nav a.on { box-shadow: inset 0 -3px 0 var(--sol); }
  .side .rodape { align-items: center; padding: 10px 0 0; } .side .user > div:not(.avatar) { display: none; }
  .side .rodape > div:last-child { flex-direction: column; } .side .rodape .btn { padding: 0; width: 40px; font-size: 0; gap: 0; }
  .tabela table { font-size: 12.5px; } .tabela th, .tabela td { padding: 9px 6px; } .tabela th { font-size: 10px; letter-spacing: .03em; }
  .tabela .btn.icon.sm { width: 32px; }
}
@media (min-width: 901px) and (max-width: 1280px) {
  .tabela td:last-child { white-space: normal !important; width: 76px; } .tabela td:last-child .btn.icon.sm { width: 30px; min-height: 30px; }
  .tabela th { white-space: normal; }
}
.passo.pagar { background: var(--sol-soft); border-radius: 8px; font-weight: 800; border: 1px solid var(--sol); } .passo.pagar .v { color: var(--sol); font-size: 15px; }
.alerta.risco b { color: var(--risk); }

/* ====== sincronização / offline ====== */
.sync { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line2); background: var(--panel2); color: var(--muted); font: 600 12px Inter, sans-serif; padding: 6px 10px; border-radius: 99px; cursor: pointer; min-height: 30px; white-space: nowrap; }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.sync.pend i { background: var(--accent); animation: pulso 1s infinite alternate; } .sync.pend { color: var(--accent); }
.sync.off i { background: var(--warn); } .sync.off { color: var(--warn); border-color: var(--warn); }
.sync.erro i { background: var(--risk); } .sync.erro { color: var(--risk); border-color: var(--risk); }
@keyframes pulso { to { opacity: .35; } }
.side .rodape .sync { align-self: flex-start; }
.faixa-off { display: none; align-items: flex-start; gap: 10px; margin: 14px 30px 0; padding: 12px 16px; border-radius: 12px; background: var(--warn-soft); border: 1px solid var(--warn); color: var(--text); font-size: 13.5px; }
.faixa-off svg { color: var(--warn); flex: none; margin-top: 1px; }
@media (max-width: 900px) { .faixa-off { margin: 10px 16px 0; } .mtop .sync span { display: none; } .mtop .sync { padding: 6px; min-height: 34px; min-width: 34px; justify-content: center; } }
@media (min-width: 901px) and (max-width: 1280px) { .side .rodape .sync span { display: none; } .side .rodape .sync { padding: 6px; align-self: center; } }

/* =====================================================================
   REFINO DE ALTO NÍVEL — CELULAR E TABLET (≤ 900 px)
   Princípios: denso sem apertar, ação principal sempre à mão, nada de rolagem lateral da página,
   toque ≥ 44 px, texto ≥ 16 px em campos (iOS não dá zoom), barras de filtros/ações roláveis.
   ===================================================================== */
@media (max-width: 900px) {
  main { padding: 12px 14px calc(88px + env(safe-area-inset-bottom)); }
  .grid { gap: 12px; }
  .card { padding: 14px; border-radius: 14px; }
  .card > header { margin-bottom: 10px; gap: 8px; }
  h1 { font-size: 21px; line-height: 1.2; } h2 { font-size: 15px; }
  /* cabeçalho da página: título + barra de ações numa faixa rolável */
  .topo { gap: 10px; margin-bottom: 14px; align-items: stretch; flex-direction: column; }
  .topo > div:first-child .muted { font-size: 13px; }
  .topo .acoes, .chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; gap: 8px; padding: 2px 2px 4px; margin: -2px -2px 0;
    scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; mask-image: linear-gradient(90deg, #000 88%, transparent); }
  .topo .acoes::-webkit-scrollbar, .chips::-webkit-scrollbar { display: none; }
  .topo .acoes > *, .chips > * { flex: none; scroll-snap-align: start; }
  .topo .acoes > select, .topo .acoes > input { width: auto !important; min-width: 190px; max-width: 260px; }
  .topo .acoes .btn { padding: 0 13px; }
  /* "sem solar → com solar = economia": vira um cartão compacto de 3 linhas */
  .hero { grid-template-columns: 1fr; gap: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
  .hero .op { display: none; }
  .hero .bx { border: 0; border-radius: 0; background: transparent; padding: 11px 14px 11px 18px; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; column-gap: 12px; }
  .hero .bx + .bx { border-top: 1px solid var(--line); }
  .hero .bx .rot { font-size: 10.5px; letter-spacing: .05em; }
  .hero .bx .val { grid-column: 2; grid-row: 1 / span 2; font-size: 20px !important; margin: 0; text-align: right; }
  .hero .bx .small { font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* indicadores */
  .kpi { padding: 12px 13px; }
  .kpi::after { display: none; }
  .kpi .rot { font-size: 10.5px; gap: 6px; letter-spacing: .04em; line-height: 1.25; }
  .kpi .ico { width: 24px; height: 24px; border-radius: 7px; flex: none; } .kpi .ico svg { width: 14px; height: 14px; }
  .kpi .val { font-size: 20px; margin: 6px 0 2px; }
  .kpi .sub { font-size: 11.5px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  /* listas, alertas, passos */
  .alerta { padding: 10px 12px; font-size: 13px; }
  .insight { font-size: 13px; padding: 8px 0; }
  .passo { padding: 8px 10px; } .passo .f { font-size: 11px; }
  .mini { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .rbar { grid-template-columns: minmax(80px, 34%) 1fr auto; font-size: 12px; }
  .legenda { font-size: 11.5px; gap: 4px 12px; }
  /* formulários: 16 px (iOS não aproxima a tela), 2 colunas quando cabe */
  input, select, textarea { font-size: 16px; min-height: 44px; }
  label.f { font-size: 12px; }
  .form { gap: 10px 12px; }
  .drop { padding: 22px 14px; } .drop h2 { font-size: 16px; } .drop .big { width: 52px; height: 52px; }
  /* janelas (folha inferior no celular) */
  .modal header { padding: 12px 16px; } .modal header h2 { font-size: 16px; }
  .modal .body { padding: 14px 16px; }
  .modal footer { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); }
  .modal footer > * { width: 100%; margin: 0 !important; justify-content: center; }
  .modal footer > .btn.pri, .modal footer > .btn.okb { grid-column: 1 / -1; order: -1; min-height: 46px; }
  .modal footer > span.small { grid-column: 1 / -1; text-align: center; }
  /* navegação inferior */
  .bnav { padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 30px rgba(0,0,0,.25); backdrop-filter: blur(10px); background: color-mix(in srgb, var(--bg2) 92%, transparent); }
  .bnav a { flex: 1; min-width: 0; padding: 6px 2px; font-size: 10.5px; }
  .bnav a svg { width: 21px; height: 21px; }
  .mtop .brand .logo { width: 34px; height: 34px; }
  .mtop .btn.icon { width: 40px; min-height: 40px; }
}
@media (max-width: 600px) {
  .form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form > .full, .form > .sep, .form > .check { grid-column: 1 / -1; }
  .modal-bg { align-items: end; }
  .modal, .modal.wide { max-height: 92vh; }
  .modal::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--line2); margin: 8px auto 0; }
  .g4 { gap: 10px; }
}
@media (max-width: 360px) {
  .kpi .val { font-size: 17px; } .hero .bx .val { font-size: 17px !important; }
  .bnav a { font-size: 9.5px; }
  .form { grid-template-columns: 1fr; }
}
/* tablet (601–900): aproveita a largura */
@media (min-width: 601px) and (max-width: 900px) {
  main { padding: 18px 22px calc(92px + env(safe-area-inset-bottom)); }
  .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
  .hero { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero .bx { display: block; padding: 14px 16px 14px 20px; }
  .hero .bx + .bx { border-top: 0; border-left: 1px solid var(--line); }
  .hero .bx .val { text-align: left; margin: 4px 0 2px; font-size: 22px !important; }
  .kpi .val { font-size: 19px; }
  .topo { flex-direction: row; align-items: flex-end; flex-wrap: wrap; }
  .topo .acoes { width: auto; flex: 1 1 100%; }
  .bnav { justify-content: center; gap: 8px; } .bnav a { flex: 0 1 120px; font-size: 11.5px; }
  .modal footer { grid-template-columns: repeat(3, 1fr); }
}
/* celular deitado / telas baixas */
@media (max-height: 500px) and (max-width: 900px) {
  .modal, .modal.wide { max-height: 96vh; }
  .bnav a span, .bnav a { font-size: 0; } .bnav a svg { width: 22px; height: 22px; }
}
/* toque: alvos maiores, sem efeitos de hover que "grudam" */
@media (pointer: coarse) {
  .btn { min-height: 44px; } .btn.sm { min-height: 38px; } .btn.sm.icon { width: 40px; }
  .chip { min-height: 40px; padding: 8px 14px; }
  .aba, .alerta, tr.click { -webkit-tap-highlight-color: transparent; }
}

/* listas no celular/tablet: busca em largura total, cartão de cobrança mais enxuto */
@media (max-width: 900px) {
  input.busca { flex: 1 1 100% !important; width: 100% !important; max-width: none !important; min-width: 0 !important; }
  .topo .acoes:has(> input.busca) { flex-wrap: wrap; overflow: visible; mask-image: none; }
  .tabela tbody tr:not(.grupo) { position: relative; }
  .tabela tbody tr:not(.grupo) td.m-chk { position: absolute; top: 10px; right: 10px; width: auto; }
  .tabela tbody tr:not(.grupo):has(td.m-chk) td.m-titulo { padding-right: 36px; }
  .tabela td.m-titulo { order: -1; }
  .tabela td.m-comp { display: none; }
  .tabela tr.grupo { gap: 8px 16px; }
  .tabela tr.grupo td[colspan] { flex: 1 1 100%; }
  .tabela tr.grupo td[data-label]::before { font-size: 9.5px; margin-bottom: 0; }
}
@media (max-width: 900px) {
  .tabela td.m-titulo::before { display: none !important; }
  .tabela tr.grupo { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tabela tr.grupo td { text-align: left !important; }
  .tabela tr.grupo td[colspan] { grid-column: 1 / -1; }
  .tabela tr.grupo td:not([data-label]):not([colspan="2"]) { display: none; }
  .tabela td.m-acoes { padding-top: 6px !important; margin-bottom: -6px; }
}
@media (min-width: 601px) and (max-width: 900px) { .tabela tr.grupo { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
/* janela no celular/tablet: 2 ações principais lado a lado + secundárias compactas (antes ocupavam meia tela) */
@media (max-width: 900px) {
  .modal footer { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
  .modal footer > * { grid-column: span 2; min-height: 38px !important; padding: 4px 6px !important; font-size: 12.5px; line-height: 1.15; white-space: normal; text-align: center; gap: 5px; }
  .modal footer > * svg { width: 15px; height: 15px; flex: none; }
  .modal footer > .btn.pri, .modal footer > .btn.okb { grid-column: span 3; min-height: 46px !important; font-size: 14px; }
  .modal footer > .btn.okb { order: -2; }
  .modal footer:not(:has(> .okb)):has(> :nth-child(3)) > .btn.pri, .modal footer:not(:has(> .pri)):has(> :nth-child(3)) > .btn.okb { grid-column: 1 / -1; }
  .modal footer > :first-child:nth-last-child(2) { grid-column: span 3; } .modal footer > :first-child:nth-last-child(2) ~ * { grid-column: span 3; }
  .modal footer > :first-child:last-child { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  .form > .m-full { grid-column: 1 / -1; }
  .form > label.f { justify-content: flex-end; }  /* rótulo de 2 linhas não desalinha o campo vizinho */
  .form > label.f > select { width: 100%; }
}
@media (max-width: 900px) {
  .tabela td.m-livre { grid-column: auto; }
  .tabela tbody tr:has(> td.m-livre) td.m-titulo { grid-column: 1; }
  .tabela tbody tr:has(> td.m-livre) td.m-livre { align-self: center; justify-self: end; }
}
@media (min-width: 601px) and (max-width: 900px) {
  .tabela td.m-acoes { grid-column: auto / span 2; border-top: 0 !important; padding-top: 0 !important; margin: 0; align-self: end; }
  .tabela tbody tr:has(> td.m-livre) { grid-template-columns: 1fr auto auto; }
}
@media (min-width: 601px) and (max-width: 900px) { .modal footer > * { font-size: 13.5px; min-height: 42px !important; } }
/* celular deitado: rodapé da janela numa linha só (sobra altura para o conteúdo) */
@media (max-height: 500px) and (max-width: 950px) {
  .modal footer { display: flex !important; flex-wrap: nowrap; gap: 6px; padding: 8px 12px; }
  .modal footer > * { flex: 1 1 0; width: auto !important; min-width: 0; min-height: 38px !important; padding: 2px 6px !important; font-size: 12px !important; line-height: 1.1; }
  .modal footer > * svg { display: none; }
  .modal footer > .btn.pri, .modal footer > .btn.okb { flex-grow: 1.4; min-height: 38px !important; }
  .modal footer > span.small { display: none; }
  .modal::before { display: none; }
  .modal header { padding: 8px 16px; }
}
/* negociação */
.pill.negociada { background: color-mix(in srgb, #8b5cf6 18%, transparent); color: #a78bfa; }
:root[data-theme="light"] .pill.negociada { color: #6d28d9; }
