:root {
  --bg: #090a10;
  --bg2: #0e1019;
  --card: #151824;
  --card2: #1a1d2c;
  --line: #24283a;
  --line2: #34394e;
  --text: #e8edf9;
  --muted: #8a97b8;
  --dim: #5d6a8c;
  --blue: #2f6bff;
  --blue2: #5b8cff;
  --brand2: #7c3aed;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #f59e0b;
  --purple: #a855f7;
  --cyan: #06b6d4;
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--blue2); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 236px; flex-shrink: 0; background: var(--bg2); border-right: 1px solid var(--line); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 22px 20px 18px; font-weight: 700; font-size: 18px; letter-spacing: -.3px; }
.brand-logo { width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, var(--blue), var(--brand2)); display: grid; place-items: center; }
.nav { padding: 6px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label { color: var(--dim); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; color: var(--muted); padding: 9px 11px; border-radius: 9px; font-weight: 500; transition: .15s; }
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.active { background: color-mix(in srgb, var(--blue) 14%, transparent); color: #fff; }
.nav a.active svg { color: var(--blue2); }
.nav svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--card2); border: 1px solid var(--line2); display: grid; place-items: center; font-weight: 600; color: var(--blue2); flex-shrink: 0; }
.sidebar-foot .who { flex: 1; min-width: 0; }
.sidebar-foot .who b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-foot .who span { color: var(--dim); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(9, 10, 16, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); padding: 14px 28px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar h1 { font-size: 20px; margin: 0; font-weight: 700; letter-spacing: -.3px; flex: 1; min-width: 160px; }
.content { padding: 24px 28px 60px; }
.btn.menu-btn { display: none; }

/* ---------- controles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 10px; border: 1px solid var(--line2); background: var(--card); color: var(--text); font-weight: 500; cursor: pointer; white-space: nowrap; transition: .15s; }
.btn:hover { border-color: var(--blue); }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: color-mix(in srgb, var(--blue) 85%, #000); }
.btn.danger { color: #fca5a5; }
.btn.danger:hover { border-color: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 8px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--card); }
.btn:disabled { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.input, select.input, textarea.input { background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 12px; outline: none; width: 100%; transition: .15s; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 18%, transparent); }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a97b8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 32px; cursor: pointer; }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { color: var(--muted); font-size: 13px; font-weight: 500; }
.field small { color: var(--dim); font-size: 12px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 6px 11px; border-radius: 7px; cursor: pointer; font-weight: 500; font-size: 13px; }
.seg button.on { background: var(--card2); color: #fff; box-shadow: 0 1px 0 var(--line2); }
.date-pop { position: relative; }
.date-btn { min-width: 200px; justify-content: space-between; }
.pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--card); border: 1px solid var(--line2); border-radius: 12px; padding: 8px; z-index: 50; min-width: 260px; box-shadow: 0 20px 50px rgba(0,0,0,.5); display: none; }
.pop.open { display: block; }
.pop button.opt { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: 8px; cursor: pointer; color: var(--text); }
.pop button.opt:hover, .pop button.opt.on { background: var(--card2); }
.pop .custom { border-top: 1px solid var(--line); margin-top: 6px; padding: 10px 4px 4px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pop .custom .btn { grid-column: span 2; }
.switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--line2); border-radius: 20px; cursor: pointer; transition: .2s; }
.switch span::before { content: ''; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--blue); }
.switch input:checked + span::before { transform: translateX(16px); }
.switch input:disabled + span { opacity: .5; cursor: wait; }
.check { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h3 .sub { color: var(--dim); font-weight: 400; font-size: 13px; margin-left: auto; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { position: relative; overflow: hidden; }
.kpi .label { color: var(--muted); font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 8px; letter-spacing: -.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .hint { color: var(--dim); font-size: 12px; margin-top: 4px; }
.kpi .ico { position: absolute; right: 16px; top: 16px; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; }
.kpi .ico svg { width: 18px; height: 18px; }
.kpi.big .value { font-size: 30px; }
.kpi.hl { background: linear-gradient(140deg, color-mix(in srgb, var(--blue) 25%, var(--card)) 0%, var(--card) 70%); border-color: color-mix(in srgb, var(--blue) 40%, var(--line)); }
.pos { color: var(--green) !important; }
.neg { color: var(--red) !important; }
.warn { color: var(--yellow) !important; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.mini-kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.mini-kpis .kpi { padding: 14px 16px; }
.mini-kpis .kpi .value { font-size: 18px; margin-top: 4px; }
.charts { grid-template-columns: 2fr 1fr; }
.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section { margin-top: 14px; }

/* listas */
.bar-list { display: flex; flex-direction: column; gap: 12px; }
.bar-item .top { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; margin-bottom: 6px; }
.bar-item .top span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-item .bar { height: 6px; background: var(--bg2); border-radius: 6px; overflow: hidden; }
.bar-item .bar i { display: block; height: 100%; background: var(--blue); border-radius: 6px; }
.method { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.method:last-child { border-bottom: 0; }
.method .dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.method .name { flex: 1; }
.method .name small { display: block; color: var(--dim); font-size: 12px; }
.method .val { text-align: right; font-weight: 600; }
.method .val small { display: block; color: var(--dim); font-weight: 400; font-size: 12px; }
.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel .step { display: grid; grid-template-columns: 130px 1fr 70px; align-items: center; gap: 10px; font-size: 13px; }
.funnel .step .bar { height: 26px; background: var(--bg2); border-radius: 7px; overflow: hidden; }
.funnel .step .bar i { display: flex; align-items: center; height: 100%; padding-left: 8px; font-weight: 600; font-size: 12px; background: linear-gradient(90deg, var(--blue), #6d4bff); border-radius: 7px; min-width: 2px; white-space: nowrap; }
.funnel .rate { color: var(--muted); text-align: right; }

/* ---------- graficos ---------- */
.chart { width: 100%; height: 260px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart text { fill: var(--dim); font-size: 11px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tooltip { position: fixed; pointer-events: none; z-index: 100; background: #0a1022; border: 1px solid var(--line2); border-radius: 10px; padding: 9px 12px; font-size: 12px; display: none; box-shadow: 0 10px 30px rgba(0,0,0,.5); min-width: 150px; }
.tooltip b { display: block; margin-bottom: 4px; }
.tooltip div { display: flex; justify-content: space-between; gap: 14px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-wrap svg { width: 140px; height: 140px; flex-shrink: 0; }

/* ---------- tabelas ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); max-height: calc(100vh - 250px); }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13px; }
th, td { padding: 11px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th { position: sticky; top: 0; background: var(--card2); color: var(--muted); font-weight: 600; font-size: 12px; z-index: 2; cursor: pointer; user-select: none; }
th:hover { color: var(--text); }
th.sorted { color: var(--blue2); }
th.nosort { cursor: default; }
td.l, th.l { text-align: left; }
tbody tr:hover td { background: color-mix(in srgb, var(--blue) 5%, transparent); }
tbody tr.sel td { background: color-mix(in srgb, var(--blue) 9%, transparent); }
tfoot td { position: sticky; bottom: 0; background: var(--card2); font-weight: 700; border-top: 1px solid var(--line2); border-bottom: 0; }
.sticky-col { position: sticky; left: 0; z-index: 1; background: var(--card); }
th.sticky-col { z-index: 3; background: var(--card2); }
tfoot td.sticky-col { background: var(--card2); z-index: 3; }
tbody tr:hover td.sticky-col { background: #121c34; }
tbody tr.sel td.sticky-col { background: #13203f; }
.name-cell { display: flex; align-items: center; gap: 10px; max-width: 380px; }
.name-cell .nm { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.name-cell .nm b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; }
.name-cell .nm small { color: var(--dim); display: block; overflow: hidden; text-overflow: ellipsis; font-size: 11px; }
.budget { cursor: pointer; border-bottom: 1px dashed var(--line2); }
.budget:hover { color: var(--blue2); border-color: var(--blue2); }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; background: var(--card2); color: var(--muted); }
.badge.approved { background: rgba(34, 197, 94, .12); color: #4ade80; }
.badge.pending { background: rgba(245, 158, 11, .12); color: #fbbf24; }
.badge.refunded, .badge.chargeback { background: rgba(168, 85, 247, .12); color: #c084fc; }
.badge.refused { background: rgba(239, 68, 68, .12); color: #f87171; }
.badge.active { background: rgba(34, 197, 94, .12); color: #4ade80; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; color: var(--muted); padding: 11px 16px; cursor: pointer; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.tabs button.on { color: #fff; border-color: var(--blue); }
.tabs .count { background: var(--blue); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; color: var(--muted); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; color: var(--dim); margin-bottom: 10px; }
.empty h4 { color: var(--text); margin: 0 0 6px; font-size: 16px; }

/* ---------- integracoes ---------- */
.code { background: var(--bg); border: 1px solid var(--line2); border-radius: 10px; padding: 12px 14px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; word-break: break-all; white-space: pre-wrap; color: #b9c7ea; position: relative; }
.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row .code { flex: 1; }
.list-item { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { min-width: 0; }
.list-item .grow b { display: block; }
.list-item .grow small { color: var(--dim); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.plat-logo { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; color: #fff; flex-shrink: 0; font-size: 15px; }
.steps { margin: 0; padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 8px; }
.steps b { color: var(--text); }
.alert { padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--blue) 10%, transparent); border: 1px solid color-mix(in srgb, var(--blue) 30%, transparent); color: color-mix(in srgb, var(--blue) 30%, #fff); font-size: 13px; }
.alert.warn { background: rgba(245, 158, 11, .08); border-color: rgba(245, 158, 11, .3); color: #fcd9a0; }

/* ---------- modal / toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 0, 0, .6); display: grid; place-items: center; z-index: 200; padding: 16px; animation: fade .15s; }
.modal { background: var(--card); border: 1px solid var(--line2); border-radius: 16px; width: 100%; max-width: 460px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.6); max-height: 90vh; overflow: auto; }
.modal h2 { margin: 0 0 16px; font-size: 18px; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#toasts { position: fixed; bottom: 20px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--card2); border: 1px solid var(--line2); border-left: 3px solid var(--blue); padding: 12px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 360px; animation: fade .2s; }
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } }
.spin { width: 16px; height: 16px; border: 2px solid var(--line2); border-top-color: var(--blue2); border-radius: 50%; animation: rot .7s linear infinite; display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }
.loading { display: grid; place-items: center; padding: 80px; }

/* ---------- login ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side { background: radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--blue) 45%, var(--bg)) 0%, color-mix(in srgb, var(--blue) 10%, var(--bg)) 50%, var(--bg) 100%); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { font-size: 36px; line-height: 1.15; letter-spacing: -1px; margin: 0 0 14px; max-width: 460px; }
.auth-side p { color: #aab8dc; max-width: 440px; font-size: 15px; }
.auth-feats { display: grid; gap: 12px; margin-top: 28px; }
.auth-feats div { display: flex; gap: 10px; align-items: center; color: #cdd8f5; }
.auth-feats svg { width: 18px; height: 18px; color: var(--green); flex-shrink: 0; }
.auth-form { display: grid; place-items: center; padding: 32px 16px; }
.auth-form form { width: 100%; max-width: 380px; }
.auth-form h1 { font-size: 26px; margin: 0 0 6px; letter-spacing: -.5px; }

/* ---------- responsivo ---------- */
@media (max-width: 1200px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mini-kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .charts, .three { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; z-index: 100; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.5); }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px 16px 50px; }
  .two { grid-template-columns: 1fr; }
  .auth { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .table-wrap { max-height: none; }
}
@media (max-width: 560px) {
  .kpis, .mini-kpis { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 19px; }
  .kpi.big .value { font-size: 22px; }
  .kpi .ico { display: none; }
  .date-btn { min-width: 0; }
  .funnel .step { grid-template-columns: 90px 1fr 50px; }
}
