/* MT5 Painel: mesmo sistema visual do relatório do Marcio_Robô. */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11,11,11,0.10);
  --good: #0ca30c;
  --good-text: #006300;
  --bad: #d03b3b;
  --warn: #b77900;
  --line: #2a78d6;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --hover: rgba(11,11,11,0.05);
  --shadow: 0 6px 24px rgba(0,0,0,0.10);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232322;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255,255,255,0.10);
    --good-text: #0ca30c;
    --warn: #e0a100;
    --line: #3987e5;
    --accent: #3987e5;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --hover: rgba(255,255,255,0.06);
    --shadow: 0 6px 24px rgba(0,0,0,0.5);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232322;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255,255,255,0.10);
  --good-text: #0ca30c;
  --warn: #e0a100;
  --line: #3987e5;
  --accent: #3987e5;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
  --hover: rgba(255,255,255,0.06);
  --shadow: 0 6px 24px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; overflow-x: hidden; background: var(--page); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
[hidden] { display: none !important; }

/* ---------- topo ---------- */
.topo { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.topo .in { max-width: 1400px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.marca { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; color: var(--ink); display: flex; align-items: center; gap: 8px; }
.marca:hover { text-decoration: none; }
.marca .logo { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: grid; place-items: center; }
.menu { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; align-items: center; }
.menu a, .menu button { font: inherit; color: var(--ink-2); background: none; border: 0; padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.menu a:hover, .menu button:hover { background: var(--hover); text-decoration: none; color: var(--ink); }
.menu a.ativo { color: var(--ink); background: var(--hover); font-weight: 600; }
.menu .quem { color: var(--muted); font-size: 12px; padding: 0 8px; }

.wrap { max-width: 1400px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -0.01em; }
.sub { color: var(--ink-2); margin: 0 0 16px; }

/* ---------- botões e campos ---------- */
.btn { font: inherit; font-weight: 600; color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 14px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.prim { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.btn.prim:hover { filter: brightness(1.08); }
.btn.perigo { color: var(--bad); }
.btn.peq { padding: 4px 10px; font-size: 12px; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, .btn:focus-visible, .ms-botao:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label.campo { display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
label.campo input, label.campo select { font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }

/* ---------- filtros ---------- */
.filtros { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 16px;
  display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.filtros .grupo { display: grid; gap: 4px; }
.filtros .grupo > span { font-size: 12px; color: var(--ink-2); }
.presets { display: flex; flex-wrap: wrap; gap: 4px; }
.presets button { font: inherit; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px solid transparent;
  border-radius: 999px; padding: 5px 10px; cursor: pointer; }
.presets button:hover { color: var(--ink); }
.presets button.on { background: var(--accent); color: var(--accent-ink); }
.datas { display: flex; gap: 6px; align-items: center; }
.datas input { width: 140px; }
.limpar { margin-left: auto; }

/* seleção múltipla */
.ms { position: relative; }
.ms-botao { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 7px 28px 7px 10px; min-width: 130px; max-width: 220px; text-align: left; cursor: pointer; position: relative;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ms-botao::after { content: ""; position: absolute; right: 10px; top: 50%; width: 6px; height: 6px; margin-top: -5px;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); }
.ms-botao.tem { border-color: var(--accent); }
.ms-lista { position: absolute; z-index: 30; top: calc(100% + 4px); left: 0; min-width: 100%; width: max-content; max-width: 320px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.ms-lista input[type=search] { width: 100%; margin-bottom: 6px; }
.ms-itens { max-height: 280px; overflow: auto; }
.ms-itens label { display: flex; gap: 8px; align-items: center; padding: 5px 8px; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.ms-itens label:hover { background: var(--hover); }
.ms-itens .n { color: var(--muted); font-size: 12px; margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }
.ms-acoes { display: flex; gap: 6px; justify-content: space-between; border-top: 1px solid var(--grid); margin-top: 6px; padding-top: 6px; }

/* ---------- contas (status) ---------- */
.contas { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 16px; }
.conta { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.conta .t { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.conta .nome { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conta .linhas { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin-top: 8px; font-size: 12px; color: var(--ink-2); }
.conta .linhas b { text-align: right; color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.selo { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.selo.real { background: color-mix(in srgb, var(--good) 15%, transparent); color: var(--good-text); }
.selo.demo { background: color-mix(in srgb, var(--s4) 18%, transparent); color: var(--warn); }
.aviso { color: var(--warn); }
.erro-txt { color: var(--bad); }
.conta .erro-txt { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- KPIs, cards e gráficos (do relatório) ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; }
.tile .k { color: var(--ink-2); font-size: 12px; }
.tile .v { font-size: 24px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .d { color: var(--muted); font-size: 12px; margin-top: 2px; }
.pos { color: var(--good-text); }
.neg { color: var(--bad); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; margin-bottom: 16px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px; min-width: 0; margin-bottom: 16px; }
.grid2 .card { margin-bottom: 0; }
.card h2 { font-size: 15px; margin: 0 0 2px; }
.card .nota { color: var(--muted); font-size: 12px; margin: 0 0 10px; }
td .nota, h2 .nota { margin: 0; }
.card .cab { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.chart { position: relative; width: 100%; }
.rolagem { overflow-x: auto; overflow-y: hidden; }
svg { display: block; overflow: visible; }
svg text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tip { position: fixed; pointer-events: none; z-index: 50; background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12); display: none; white-space: nowrap; }
.tip b { font-weight: 600; }
.bar-hit { fill: transparent; }
.bar-hit:hover { fill: var(--hover); }
.donut-wrap { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; }
.legend { flex: 1; min-width: 200px; display: grid; gap: 6px; }
.legend .it { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; font-size: 13px; }
.legend .it > span:nth-child(2) { overflow-wrap: anywhere; }
.legend .sw { width: 12px; height: 12px; border-radius: 3px; }
.legend .n { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.legend .r { font-variant-numeric: tabular-nums; text-align: right; min-width: 92px; }
.vazio { color: var(--muted); text-align: center; padding: 48px 16px; }

/* ---------- tabelas ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--ink-2); font-weight: 600; position: sticky; top: 0; background: var(--surface); z-index: 1; }
th:first-child, td:first-child { text-align: left; }
td.t, th.t { text-align: left; }
.scroll { max-height: 520px; overflow: auto; }
tr.mes { cursor: pointer; font-weight: 600; }
tr.mes:hover td { background: var(--hover); }
tr.mes td:first-child::before { content: "▸"; display: inline-block; width: 14px; color: var(--muted); transition: transform .15s; }
tr.mes.aberto td:first-child::before { transform: rotate(90deg); }
tr.dia td { color: var(--ink-2); font-size: 12px; }
tr.dia td:first-child { padding-left: 26px; }
tr.clic { cursor: pointer; }
tr.clic:hover td { background: var(--hover); }
tr.total td { font-weight: 700; border-top: 2px solid var(--axis); }

/* ---------- formulários (login, conta, admin) ---------- */
.centro { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.caixa { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px 24px; box-shadow: var(--shadow); }
.caixa h1 { margin-bottom: 4px; }
.caixa form { display: grid; gap: 14px; margin-top: 18px; }
.caixa .rodape { margin-top: 16px; font-size: 13px; text-align: center; color: var(--ink-2); }
.msg { border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.msg.erro { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.msg.ok { background: color-mix(in srgb, var(--good) 12%, transparent); color: var(--good-text); }
.form-card { max-width: 480px; }
.form-card form { display: grid; gap: 14px; }

.abas { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.abas button { font: inherit; color: var(--ink-2); background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px; cursor: pointer; margin-bottom: -1px; }
.abas button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { font-size: 11px; background: var(--surface-2); border-radius: 999px; padding: 2px 8px; color: var(--ink-2); }
.acoes { display: flex; gap: 6px; justify-content: flex-end; }

dialog { border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--ink); padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,0.4); }
dialog form { display: grid; gap: 14px; padding: 22px; }
dialog h2 { margin: 0; font-size: 17px; }
.lista-checks { display: grid; gap: 4px; max-height: 220px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.linha-botoes { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.link-copia { display: flex; gap: 6px; }
.link-copia input { flex: 1; font-size: 12px; }

.carregando { position: fixed; top: 0; left: 0; height: 2px; background: var(--accent); z-index: 100; width: 0; transition: width .3s; }

.abre-filtros { display: none; }

@media (max-width: 640px) {
  body { font-size: 14px; }
  .wrap { padding: 14px 12px 40px; }
  .topo .in { padding: 8px 12px; gap: 6px; }
  .menu { margin-left: 0; width: 100%; gap: 2px; overflow-x: auto; flex-wrap: nowrap; }
  .menu a, .menu button { padding: 6px 8px; white-space: nowrap; }
  .menu .quem { display: none; }
  h1 { font-size: 20px; }

  /* filtros recolhíveis */
  .abre-filtros { display: flex; width: 100%; justify-content: space-between; align-items: center; margin-bottom: 12px; }
  .filtros { display: none; padding: 10px; }
  .filtros.aberto { display: grid; grid-template-columns: 1fr 1fr; }
  .filtros .grupo { min-width: 0; }
  .filtros .grupo:first-child, .filtros .grupo:nth-child(2), .filtros .limpar { grid-column: 1 / -1; }
  .filtros select, .ms-botao { width: 100%; max-width: none; min-width: 0; }
  .datas input { width: auto; flex: 1; min-width: 0; }
  .limpar { margin-left: 0; }
  /* lista de seleção vira uma gaveta embaixo da tela */
  .ms-lista { position: fixed; left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; min-width: 0; max-width: none; max-height: 70vh; display: flex; flex-direction: column; }
  .ms-lista[hidden] { display: none; }
  .ms-itens { max-height: none; flex: 1; }
  .ms-itens label { padding: 9px 8px; }

  .contas { grid-template-columns: 1fr; gap: 8px; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 8px; }
  .tile { padding: 10px 12px; }
  .tile .v { font-size: 18px; }
  .grid2 { grid-template-columns: 1fr; gap: 12px; margin-bottom: 12px; }
  .card { padding: 12px; margin-bottom: 12px; }
  .scroll { max-height: 420px; }
  th, td { padding: 6px; }
  .legend { min-width: 0; }
  .legend .r { min-width: 0; }
  .legend .it { grid-template-columns: 12px minmax(0, 1fr) auto; }
  .legend .it .n { grid-column: 2; grid-row: 2; font-size: 11px; }
  .legend .it .r { grid-column: 3; grid-row: 1 / span 2; }
  .donut-wrap { justify-content: center; }
  .caixa { padding: 22px 18px; }
  .abas { overflow-x: auto; }
  .linha-botoes .btn { flex: 1; }
}
