/* Painel Futelupa: cards de resumo, tabela compacta com links em ícones, números com intensidade de cor
   e linha que expande com os detalhes. Tema claro e escuro; a escolha fica guardada no navegador. */
:root {
  --bg: #F7F8FA; --surface: #FFFFFF; --surface-2: #F0F2F5; --line: #E3E6EB; --fg: #1A1F29; --muted: #69707D; --faint: #B9BEC7;
  --accent: #2F5BEA; --accent-soft: #E6ECFD; --on-accent: #FFFFFF;
  --ok: #1F8A4C; --ok-soft: #E3F4EA; --warn: #A15C00; --warn-soft: #FCF0DC; --neutral-soft: #ECEEF2;
  --ig: #C1357A; --tt: #3B4252; --heat: 47 91 234;
  --font-ui: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-num: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0F1115; --surface: #161A21; --surface-2: #1D222B; --line: #2A303B; --fg: #E7EAF0; --muted: #8D95A3; --faint: #464D5A;
  --accent: #7C9BFF; --accent-soft: #1F2A4A; --on-accent: #0F1115;
  --ok: #4CC782; --ok-soft: #173325; --warn: #F0B04F; --warn-soft: #3A2C14; --neutral-soft: #262B35;
  --ig: #F06BA8; --tt: #C9CED8; --heat: 124 155 255; color-scheme: dark; } }
:root[data-theme="dark"] {
  --bg: #0F1115; --surface: #161A21; --surface-2: #1D222B; --line: #2A303B; --fg: #E7EAF0; --muted: #8D95A3; --faint: #464D5A;
  --accent: #7C9BFF; --accent-soft: #1F2A4A; --on-accent: #0F1115;
  --ok: #4CC782; --ok-soft: #173325; --warn: #F0B04F; --warn-soft: #3A2C14; --neutral-soft: #262B35;
  --ig: #F06BA8; --tt: #C9CED8; --heat: 124 155 255; color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { background: var(--bg); }
body { margin: 0; color: var(--fg); font-family: var(--font-ui); font-size: 14px; line-height: 1.45; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.wrap { max-width: 1240px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.wait { color: var(--muted); font-size: 12px; }
.ig-t { color: var(--ig); } .tt-t { color: var(--tt); }

.top { position: sticky; top: 0; z-index: 6; background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.top .wrap { display: flex; align-items: center; gap: 12px; padding-block: 10px; }
.top h1 { margin: 0 auto 0 0; font-size: 17px; font-weight: 600; }
.coletor { font-size: 12px; color: var(--muted); }
.coletor.alerta { color: var(--warn); }
.btn-sec { border: 1px solid var(--line); background: none; border-radius: 8px; padding: 6px 12px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.btn-sec svg { width: 15px; height: 15px; }
.btn { border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); border-radius: 6px; padding: 7px 14px; cursor: pointer; font-weight: 600; }
.btn[disabled] { opacity: .6; cursor: progress; }

/* Login */
.login { max-width: 340px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 24px; display: grid; gap: 8px; }
.login h2 { margin: 0 0 8px; font-size: 18px; }
.login label { font-size: 12px; color: var(--muted); }
.login input { border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 8px 10px; }
.login .btn { margin-top: 8px; }
.erro { color: var(--warn); font-size: 13px; margin: 0; min-height: 1em; }

main#painel { padding-block: 20px 56px; display: grid; gap: 20px; }

/* Cards do resumo */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; display: grid; gap: 10px; align-content: start; min-width: 0; }
.kpi > span { color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }
.kpi > b { font-family: var(--font-num); font-size: 30px; font-weight: 500; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi .split { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; }
.kpi .split div { display: grid; gap: 1px; min-width: 0; }
.kpi .split small { font-size: 11px; font-weight: 600; letter-spacing: .04em; }
.kpi .split em { font-style: normal; font-family: var(--font-num); font-size: 15px; font-variant-numeric: tabular-nums; }
.kpi .note { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); padding-top: 10px; font-size: 12px; color: var(--muted); }
.kpi .note b { font-family: var(--font-num); font-weight: 500; font-size: 15px; color: var(--warn); background: var(--warn-soft); border-radius: 5px; padding: 0 7px; }
.kpi .note.zero b { color: var(--ok); background: var(--ok-soft); }
.kpi .gain { color: var(--ok); font-size: 11px; font-family: var(--font-num); }

/* Ferramentas */
.tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tools .sp { flex: 1; }
.tools .div { width: 1px; height: 22px; background: var(--line); }
.tools input { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 7px 12px; min-width: 0; width: 240px; max-width: 100%; }
.f { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; color: var(--muted); }
.f[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--fg); }
.count { color: var(--muted); font-size: 12px; }

/* Tabela */
.scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; min-width: 960px; font-size: 13px; }
th { text-align: left; font-weight: 500; white-space: nowrap; background: var(--surface-2); color: var(--muted); font-size: 12px; height: 36px; padding: 0 12px; border-bottom: 1px solid var(--line); }
th button { all: unset; cursor: pointer; }
th button:focus-visible { outline: 2px solid var(--accent); }
td { padding: 0 12px; height: 46px; border-bottom: 1px solid var(--line); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.num { font-family: var(--font-num); white-space: nowrap; }
td.heat { background: rgb(var(--heat) / var(--h, 0)); }
tr.row { cursor: pointer; }
tr.row:hover td:not(.heat) { background: var(--surface-2); }
tr.row[aria-expanded="true"] td { border-bottom-color: transparent; }
tr.row[aria-expanded="true"] td:not(.heat) { background: var(--surface-2); }
.car { display: inline-block; width: 12px; color: var(--muted); transition: transform .15s; }
tr.row[aria-expanded="true"] .car { transform: rotate(90deg); color: var(--accent); }
.id { font-family: var(--font-num); color: var(--muted); white-space: nowrap; }
.t { font-weight: 500; max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; font-weight: 500; white-space: nowrap; }
.pill.prod { background: var(--warn-soft); color: var(--warn); }
.pill.fin { background: var(--ok-soft); color: var(--ok); }
.pill.pub { background: var(--accent-soft); color: var(--accent); }
.pill.sem { background: var(--neutral-soft); color: var(--muted); }
tfoot td { font-size: 12px; color: var(--muted); height: 36px; border-bottom: 0; }

/* Ícones de links */
.links { display: flex; gap: 6px; }
.ico { width: 30px; height: 30px; border-radius: 7px; border: 1px solid var(--line); display: grid; place-items: center; color: var(--fg); text-decoration: none; flex: none; }
.ico svg { width: 16px; height: 16px; }
a.ico:hover { border-color: var(--accent); color: var(--accent); }
.ico.off { color: var(--faint); border-color: color-mix(in srgb, var(--line) 60%, transparent); cursor: default; }

/* Detalhe expandido */
tr.det-row > td { background: var(--surface-2); padding: 4px 16px 20px 36px; height: auto; border-bottom: 1px solid var(--line); }
.det { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 28px; }
.det > div { display: grid; gap: 10px; align-content: start; min-width: 0; }
.det h3 { margin: 6px 0 0; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.det dl { display: grid; grid-template-columns: repeat(4, auto); justify-content: start; gap: 4px 18px; margin: 0; font-size: 12px; }
.det dt { color: var(--muted); } .det dd { margin: 0; }
.det svg.chart { width: 100%; height: auto; display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 3px; margin-right: 6px; vertical-align: middle; }
.mt { width: 100%; min-width: 0; font-size: 13px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; border-collapse: separate; border-spacing: 0; overflow: hidden; }
.mt th { background: none; height: 30px; }
.mt th, .mt td { padding: 4px 12px; height: 30px; border-bottom: 1px solid var(--line); }
.mt tr:last-child td { border-bottom: 0; }
.mt td { text-align: right; font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.mt td:first-child { text-align: left; font-family: var(--font-ui); color: var(--muted); }
.cap { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; white-space: pre-line; font-size: 13px; }
.acoes { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.vincular { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.vincular select { border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 6px 8px; max-width: 100%; }

/* Celular */
.mlist { display: none; gap: 8px; }
.mi { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mi-h { display: grid; gap: 6px; padding: 12px; cursor: pointer; width: 100%; border: 0; background: none; text-align: left; }
.mi .r { display: flex; justify-content: space-between; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.mi b { font-size: 14px; font-weight: 600; line-height: 1.3; }
.mi .nums { display: flex; gap: 6px; flex-wrap: wrap; font-family: var(--font-num); font-size: 12px; }
.mi .nums span { padding: 2px 6px; border-radius: 4px; background: rgb(var(--heat) / var(--h, 0)); }
.mi .links { padding: 0 12px 12px; }
.mi .det { grid-template-columns: 1fr; gap: 14px; padding: 0 12px 14px; }

@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .scroll { display: none; } .mlist { display: grid; }
  .tools input { width: 100%; } .tools .div, .tools .sp { display: none; }
  .det dl { grid-template-columns: auto 1fr; }
  .coletor { display: none; }
}
@media (max-width: 520px) { .kpi { padding: 12px; } .kpi > b { font-size: 24px; } .kpi .split em { font-size: 13px; white-space: nowrap; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
