:root {
  --bg: #0b1220;
  --panel: #121b2e;
  --panel2: #18233a;
  --line: #24314d;
  --text: #e8eefc;
  --muted: #8b98b5;
  --blue: #3b82f6;
  --teal: #06d6a0;
  --red: #f05d6c;
  --amber: #f5b14c;
  --radius: 12px;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; }
[hidden] { display: none !important; }
a { color: #8fb4ff; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--red); min-height: 1em; }
.pos { color: var(--teal); }
.neg { color: var(--red); }

/* ---------- botões e campos ---------- */
.btn { border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { border-color: #3a4c74; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #2f6fe0; }
.btn.danger { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; font: inherit; width: 100%; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--blue); outline-offset: 1px; }
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 5px; font-weight: 500; }
code, .code { font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; display: block; white-space: pre-wrap; word-break: break-all; }

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: grid; gap: 10px; }
.login-logo { height: 40px; margin-bottom: 6px; }
.login-card h1 { margin: 0; font-size: 20px; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { background: #0e1626; border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; }
.brand img { height: 34px; display: block; margin: 0 6px; }
.side nav { display: grid; gap: 3px; }
.side nav a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 9px; color: var(--muted); text-decoration: none; font-weight: 500; }
.side nav a:hover { background: var(--panel); color: var(--text); }
.side nav a.active { background: var(--blue); color: #fff; }
.side .ic { width: 18px; text-align: center; opacity: .9; }
.logout { margin-top: auto; }
.main { min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 18px 24px 6px; }
.top h1 { margin: 0; font-size: 20px; }
.menu-btn { display: none; }
main { padding: 12px 24px 40px; outline: none; }

/* ---------- blocos ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h2 { margin: 0 0 12px; font-size: 14px; font-weight: 600; }
.panel h3 { margin: 16px 0 8px; font-size: 13px; }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
.filters > div { min-width: 150px; flex: 1 1 150px; max-width: 240px; }
.filters .grow { max-width: none; }
.grid { display: grid; gap: 12px; }
.cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .lbl { color: var(--muted); font-size: 12px; font-weight: 500; }
.card .val { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -.3px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.two { grid-template-columns: 1.4fr 1fr; }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.alert { border: 1px solid #5b4524; background: #2a2114; color: #f8d8a6; padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; }
.alert.bad { border-color: #5b2430; background: #2a141a; color: #ffc2ca; }
.alert.good { border-color: #1e5546; background: #10241f; color: #b9f5df; }

/* listas com barra */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 13px; }
.bar-row .track { grid-column: 1 / -1; height: 6px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.bar-row .fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--teal)); border-radius: 6px; }

/* funil */
.funnel { display: grid; gap: 8px; }
.f-step { display: grid; grid-template-columns: 130px 1fr 110px; align-items: center; gap: 12px; }
.f-step .name { color: var(--muted); font-size: 13px; }
.f-step .shape { height: 34px; display: flex; justify-content: center; }
.f-step .shape div { height: 100%; border-radius: 7px; background: linear-gradient(90deg, #2c6be8, #06d6a0); min-width: 6px; display: grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.f-step .rate { text-align: right; font-size: 12px; color: var(--muted); }
.f-step .rate b { color: var(--text); font-size: 13px; }

/* gráfico */
.chart { width: 100%; height: 220px; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* tabelas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--panel2); color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; position: sticky; top: 0; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: #142036; }
tfoot td { font-weight: 700; background: var(--panel2); }
td .name-btn { background: none; border: 0; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; padding: 0; text-align: left; white-space: normal; max-width: 340px; }
td .name-btn:hover { color: #8fb4ff; text-decoration: underline; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; background: var(--panel2); border: 1px solid var(--line); }
.badge.ok { color: var(--teal); border-color: #1e5546; }
.badge.warn { color: var(--amber); border-color: #5b4524; }
.badge.bad { color: var(--red); border-color: #5b2430; }

/* abas */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 10px 14px; font: inherit; font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--text); border-color: var(--blue); }
.crumbs { margin: -4px 0 12px; font-size: 13px; color: var(--muted); }
.crumbs button { background: none; border: 0; color: #8fb4ff; cursor: pointer; font: inherit; padding: 0; }

/* chave liga/desliga */
.switch { position: relative; width: 38px; height: 22px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #33405e; border-radius: 22px; transition: .15s; cursor: pointer; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 200px; }
.stack { display: grid; gap: 12px; }
.list-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
details summary { cursor: pointer; color: #8fb4ff; margin: 6px 0; }
ol.steps { margin: 6px 0; padding-left: 18px; color: var(--muted); line-height: 1.6; }
ol.steps b { color: var(--text); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1d2a45; border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 50; max-width: calc(100% - 32px); }
.toast.show { opacity: 1; }
.loading { color: var(--muted); padding: 30px 0; text-align: center; }

@media (max-width: 1100px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two, .three { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 240px; z-index: 40; transform: translateX(-100%); transition: .2s; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5); }
  .menu-btn { display: inline-block; }
  .top, main { padding-left: 16px; padding-right: 16px; }
  .f-step { grid-template-columns: 90px 1fr 70px; gap: 8px; }
  .filters > div { max-width: none; }
  .card .val { font-size: 18px; }
}
