/* =========================================================
   Radar Studio — páginas internas (conta, admin, termos, privacidade)
   Mesma identidade da landing (vinho, osso, grão estático), sem as animações pesadas.
   ========================================================= */
:root {
  --ink: #0b0708;
  --night: #140a0c;
  --card: #1d0f12;
  --card-2: #26141a;
  --wine: #50212a;
  --wine-2: #6a2b37;
  --bone: #f3ece6;
  --bone-2: rgba(243, 236, 230, 0.74);
  --bone-3: rgba(243, 236, 230, 0.52);
  --line: rgba(243, 236, 230, 0.14);
  --line-2: rgba(243, 236, 230, 0.22);
  --ember: #ff6a3d;
  --ok: #6fd39b;
  --warn: #ffc26a;
  --bad: #ff7d7d;
  --f-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --f-serif: "Instrument Serif", "Times New Roman", serif;
  --f-mono: "Geist Mono", ui-monospace, "Cascadia Mono", monospace;
  --radius: 22px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ink); color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  background:
    radial-gradient(1100px 560px at 85% -12%, rgba(106, 43, 55, 0.42), transparent 62%),
    radial-gradient(760px 520px at -12% 112%, rgba(80, 33, 42, 0.28), transparent 62%),
    var(--ink);
  color: var(--bone); font-family: var(--f-display); font-size: 16px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
/* grão estático, como na landing (textura gerada aqui mesmo, sem arquivo externo) */
body::before {
  content: ""; position: fixed; inset: 0; z-index: 0; pointer-events: none; opacity: 0.06;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main, .foot { position: relative; z-index: 1; }
main { flex: 1 0 auto; }
a { color: var(--bone); text-underline-offset: 3px; text-decoration-color: rgba(243, 236, 230, 0.4); }
a:hover { color: #fff; text-decoration-color: currentColor; }
h1, h2, h3, h4, p { margin: 0; }
p, li { text-wrap: pretty; }
/* e-mail ou código comprido quebra a linha em vez de sair do cartão */
.card p, .dialog__body, #app > p { overflow-wrap: anywhere; }
b, strong { font-weight: 700; color: var(--bone); }
:focus-visible { outline: 2px solid var(--bone); outline-offset: 3px; border-radius: 8px; }
[hidden] { display: none !important; }
::selection { background: var(--wine); color: var(--bone); }

/* ---------- topo ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px clamp(16px, 4vw, 48px); min-height: 64px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 7, 8, 0.8); backdrop-filter: blur(12px) saturate(1.2); -webkit-backdrop-filter: blur(12px) saturate(1.2);
}
.top__brand {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0;
  font-weight: 700; font-stretch: 115%; letter-spacing: -0.02em; font-size: 15px;
  text-decoration: none; white-space: nowrap;
}
.top__brand img { width: 26px; height: 26px; flex: none; }
.top__nav { display: flex; align-items: center; gap: 4px; font-family: var(--f-mono); font-size: 13px; letter-spacing: 0.03em; }
.top__nav a, .top__nav .linkbtn {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: 999px;
  color: var(--bone-2); text-decoration: none; white-space: nowrap; transition: color 0.2s, background-color 0.2s;
}
.top__nav a:hover, .top__nav .linkbtn:hover { color: var(--bone); background: rgba(243, 236, 230, 0.07); }
.top__nav .linkbtn { font-family: var(--f-mono); font-size: 13px; border: 1px solid var(--line); margin-left: 4px; }

/* ---------- moldura ---------- */
.wrap { width: min(1080px, 100% - 32px); margin: 0 auto; padding: clamp(28px, 5vh, 52px) 0 clamp(56px, 9vh, 96px); }
.wrap--narrow { width: min(480px, 100%); margin-inline: auto; }
.wrap--doc { width: min(760px, 100% - 32px); }

/* login, cadastro, confirmações e avisos: um cartão central */
#app > .wrap--narrow {
  position: relative; margin-top: clamp(4px, 3vh, 32px);
  padding: clamp(24px, 4.5vw, 38px);
  border-radius: 28px; border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(40, 21, 27, 0.94), rgba(20, 10, 12, 0.94));
  box-shadow: 0 50px 120px -50px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 176, 154, 0.1);
}
#app > .wrap--narrow::before {
  content: ""; position: absolute; left: 28px; right: 28px; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 106, 61, 0.7), transparent);
}
#app > .wrap--narrow > .title:first-child { margin-top: 0; }
#app > .wrap--narrow > .btn { margin-top: 20px; }

/* estado de carregamento inicial */
.loading { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 42vh; color: var(--bone-3); font-family: var(--f-mono); font-size: 13px; letter-spacing: 0.04em; text-align: center; }
.loading .spinner { width: 28px; height: 28px; }

/* ---------- tipografia ---------- */
.eyebrow { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--bone-2); }
.title { display: block; font-size: clamp(32px, 4.8vw, 52px); font-weight: 800; font-stretch: 110%; letter-spacing: -0.035em; line-height: 1.02; margin: 10px 0 12px; text-wrap: balance; }
.title em { font-family: var(--f-serif); font-style: italic; font-weight: 400; font-stretch: 100%; letter-spacing: -0.01em; }
.muted { color: var(--bone-2); }
.small { font-size: 13px; line-height: 1.55; }
.mono { font-family: var(--f-mono); }

/* ---------- cartões e grade ---------- */
.grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 400px), 1fr)); margin-top: 28px; align-items: start; }
.card {
  position: relative; min-width: 0;
  display: flex; flex-direction: column; gap: 16px;
  padding: clamp(20px, 2.6vw, 28px); border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(38, 20, 26, 0.92), rgba(26, 13, 16, 0.92));
  box-shadow: 0 30px 80px -50px rgba(0, 0, 0, 0.9);
}
.card--wide { grid-column: 1 / -1; }
.card h2 { font-size: 21px; font-weight: 800; font-stretch: 106%; letter-spacing: -0.02em; line-height: 1.2; }
.card h3 { margin-top: 6px; font-family: var(--f-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.12em; text-transform: uppercase; color: var(--bone-3); }
/* cabeçalho de cada cartão: título (e selo) com uma linha embaixo */
.card > h2:first-child, .card > .row--between:first-child { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.card > .btn { align-self: flex-start; }
.card ol, .card ul { display: grid; gap: 6px; }
.card ol li::marker { color: var(--ember); font-family: var(--f-mono); }
/* ações destrutivas ficam separadas, no fim da linha */
.card .row > .btn--danger:last-child { margin-left: auto; }

/* pares rótulo/valor */
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px 18px; margin: 0; font-size: 15px; }
.kv dt { align-self: center; color: var(--bone-3); font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (min-width: 640px) {
  /* nos cartões largos, os pares viram uma faixa de números fácil de ler */
  .card--wide > .kv {
    grid-auto-flow: column; grid-template-rows: auto auto; grid-template-columns: none; grid-auto-columns: minmax(0, 1fr);
    gap: 6px 0; padding: 16px 0; border: 1px solid var(--line); border-radius: 16px; background: rgba(11, 7, 8, 0.35);
  }
  .card--wide > .kv dt, .card--wide > .kv dd { padding: 0 18px; border-left: 1px solid var(--line); }
  .card--wide > .kv dt:first-of-type, .card--wide > .kv dd:first-of-type { border-left: 0; }
  .card--wide > .kv dt { align-self: end; }
  .card--wide > .kv dd { font-size: 17px; font-weight: 700; line-height: 1.3; }
  #afiliados > .kv dd { font-size: clamp(20px, 2.2vw, 26px); font-weight: 800; font-stretch: 108%; letter-spacing: -0.02em; }
}

/* selos de status */
.badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 4px 11px; border-radius: 999px;
  font-family: var(--f-mono); font-size: 12px; letter-spacing: 0.03em; white-space: nowrap;
  color: var(--bone-2); border: 1px solid var(--line); background: rgba(243, 236, 230, 0.04);
}
.badge--ok, .badge--warn, .badge--bad { font-weight: 500; }
.badge--ok::before, .badge--warn::before, .badge--bad::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge--ok { color: var(--ok); border-color: rgba(111, 211, 155, 0.4); background: rgba(111, 211, 155, 0.08); }
.badge--warn { color: var(--warn); border-color: rgba(255, 194, 106, 0.4); background: rgba(255, 194, 106, 0.08); }
.badge--bad { color: var(--bad); border-color: rgba(255, 125, 125, 0.4); background: rgba(255, 125, 125, 0.08); }

/* avisos */
.notice {
  display: block; padding: 12px 14px 12px 16px; border-radius: 14px;
  border: 1px solid var(--line); border-left: 3px solid var(--bone-3);
  background: rgba(243, 236, 230, 0.04); font-size: 14px; line-height: 1.55; color: var(--bone-2);
}
.notice a, .notice .linkbtn { color: var(--bone); font-weight: 700; }
.notice--warn { border-color: rgba(255, 194, 106, 0.32); border-left-color: var(--warn); background: rgba(255, 194, 106, 0.07); color: #ffe3b8; }
.notice--ok { border-color: rgba(111, 211, 155, 0.32); border-left-color: var(--ok); background: rgba(111, 211, 155, 0.07); color: #c9f2da; }
/* erro ao carregar os afiliados: o cartão só tem o título e a mensagem */
#afiliados > h2:first-child + p.muted:last-child {
  padding: 12px 14px 12px 16px; border-radius: 14px;
  border: 1px solid rgba(255, 125, 125, 0.32); border-left: 3px solid var(--bad);
  background: rgba(255, 125, 125, 0.07); color: #ffd3d3; font-size: 14px;
}

/* carregando dentro de um cartão (ex.: afiliados): vira um bloco que pulsa */
.card > .spinner {
  width: 100%; height: 132px; border: 0; border-radius: 16px; animation: shimmer 1.4s ease-in-out infinite;
  background: linear-gradient(100deg, rgba(243, 236, 230, 0.04) 30%, rgba(243, 236, 230, 0.1) 50%, rgba(243, 236, 230, 0.04) 70%) 0 0 / 220% 100%;
}
#panel > .spinner { margin: 40px auto; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- planos ---------- */
.plans { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 230px), 1fr)); }
.plan { position: relative; display: block; cursor: pointer; }
.plan input { position: absolute; opacity: 0; pointer-events: none; }
.plan__box {
  position: relative; height: 100%;
  display: grid; gap: 4px; align-content: start;
  padding: 18px 18px 18px 52px; border-radius: 18px;
  border: 1px solid var(--line-2); background: rgba(11, 7, 8, 0.35);
  transition: border-color 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.plan__box::before {
  content: ""; position: absolute; left: 18px; top: 21px; width: 20px; height: 20px; border-radius: 50%;
  border: 1.5px solid var(--bone-3); transition: border-color 0.2s, background 0.2s;
}
.plan:hover .plan__box { border-color: rgba(243, 236, 230, 0.34); }
.plan input:checked + .plan__box {
  border-color: var(--ember);
  background: linear-gradient(160deg, rgba(255, 106, 61, 0.13), rgba(11, 7, 8, 0.35) 70%);
  box-shadow: inset 0 0 0 1px rgba(255, 106, 61, 0.5);
}
.plan input:checked + .plan__box::before { border-color: var(--ember); background: radial-gradient(circle, var(--ember) 0 42%, transparent 47%); }
.plan input:focus-visible + .plan__box { outline: 2px solid var(--bone); outline-offset: 2px; }
.plan__name { font-weight: 800; font-size: 16px; letter-spacing: -0.01em; }
.plan__price { font-size: 30px; font-weight: 900; font-stretch: 110%; letter-spacing: -0.03em; line-height: 1.15; }
.plan__price small { font-family: var(--f-serif); font-style: italic; font-size: 17px; font-weight: 400; color: var(--bone-2); letter-spacing: 0; }
.plan__old { color: var(--bone-3); text-decoration: line-through; text-decoration-color: var(--ember); font-family: var(--f-mono); font-size: 12px; }

.segmented { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: 999px; padding: 4px; gap: 4px; background: rgba(11, 7, 8, 0.35); width: fit-content; max-width: 100%; }
.segmented label { position: relative; cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: flex; align-items: center; min-height: 36px; padding: 0 18px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--bone-2); transition: background-color 0.2s, color 0.2s; }
.segmented label:hover span { color: var(--bone); }
.segmented input:checked + span { background: var(--bone); color: #1a0d10; }
.segmented input:focus-visible + span { outline: 2px solid var(--bone); outline-offset: 2px; }

/* ---------- formulários ---------- */
form { display: grid; gap: 16px; }
.field { display: grid; gap: 7px; font-size: 14px; min-width: 0; }
.field > span { color: var(--bone-2); font-weight: 500; }
/* :where mantém a especificidade baixa, para .copy input e afins continuarem valendo */
input:where(:not([type=checkbox], [type=radio], [type=hidden])), select {
  width: 100%; min-width: 0; min-height: 46px; font: inherit; font-size: 16px; color: var(--bone);
  background: rgba(0, 0, 0, 0.38); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input[type=number] { appearance: textfield; -moz-appearance: textfield; font-variant-numeric: tabular-nums; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=date]::-webkit-calendar-picker-indicator { cursor: pointer; opacity: 0.75; }
input[type=search]::-webkit-search-cancel-button { cursor: pointer; }
input::placeholder { color: rgba(243, 236, 230, 0.36); }
input:hover, select:hover { border-color: rgba(243, 236, 230, 0.32); }
input:focus, select:focus { outline: none; border-color: rgba(255, 106, 61, 0.75); box-shadow: 0 0 0 3px rgba(255, 106, 61, 0.18); }
input[readonly] { color: var(--bone-2); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 40px; cursor: pointer;
  background: rgba(0, 0, 0, 0.38) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23f3ece6' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") right 14px center / 12px 8px no-repeat;
}
select option { background: var(--card); color: var(--bone); }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: var(--bone-2); cursor: pointer; }
.check input { margin-top: 2px; accent-color: var(--ember); width: 18px; height: 18px; flex: none; cursor: pointer; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }

/* ---------- botões ---------- */
.btn {
  --spin: #1a0d10;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px; border: 0; border-radius: 999px;
  font: inherit; font-weight: 700; font-size: 15px; letter-spacing: -0.005em; line-height: 1.2; text-align: center;
  color: #1a0d10; background: var(--bone); cursor: pointer; text-decoration: none;
  transition: transform 0.15s var(--ease), background-color 0.2s, border-color 0.2s, color 0.2s, opacity 0.2s;
}
.btn:hover { background: #fff; color: #1a0d10; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn--ember { background: var(--ember); color: #1a0d10; box-shadow: 0 14px 34px -16px rgba(255, 106, 61, 0.8); }
.btn--ember:hover { background: #ff8460; }
.btn--ghost { --spin: var(--bone); background: rgba(243, 236, 230, 0.03); color: var(--bone); border: 1px solid var(--line-2); }
.btn--ghost:hover { background: rgba(243, 236, 230, 0.09); color: var(--bone); border-color: rgba(243, 236, 230, 0.36); }
.btn--danger { --spin: var(--bad); background: transparent; color: var(--bad); border: 1px solid rgba(255, 125, 125, 0.45); }
.btn--danger:hover { background: rgba(255, 125, 125, 0.1); color: #ffa3a3; }
.btn--sm { min-height: 36px; padding: 0 15px; font-size: 13px; }
.btn--block { width: 100%; }
/* ação em andamento: o texto some e aparece um indicador girando */
.btn[aria-busy=true] { color: transparent !important; cursor: progress; opacity: 0.9; }
.btn[aria-busy=true]::after {
  content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -9px 0 0 -9px;
  border-radius: 50%; border: 2px solid var(--spin); border-right-color: transparent; animation: spin 0.7s linear infinite;
}
.linkbtn { background: none; border: 0; color: var(--bone-2); font: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(243, 236, 230, 0.4); cursor: pointer; padding: 0; }
.linkbtn:hover { color: var(--bone); text-decoration-color: currentColor; }
.linkbtn[aria-busy=true] { opacity: 0.5; cursor: progress; }

/* link de afiliado com o botão de copiar colado */
.copy { display: flex; align-items: center; gap: 6px; padding: 5px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(0, 0, 0, 0.38); }
.copy input { min-height: 36px; border: 0; background: transparent; padding: 0 12px; font-family: var(--f-mono); font-size: 14px; text-overflow: ellipsis; }
.copy input:focus { box-shadow: none; }
.copy .btn { flex: none; }
.copy:focus-within { border-color: rgba(255, 106, 61, 0.6); }

.progress { height: 10px; background: rgba(243, 236, 230, 0.08); border-radius: 99px; overflow: hidden; box-shadow: inset 0 0 0 1px var(--line); }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--wine-2), var(--ember)); border-radius: 99px; }

/* ---------- tabelas ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: rgba(11, 7, 8, 0.32); -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
#app .table-wrap table { min-width: 560px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--bone-3); font-weight: 500; font-family: var(--f-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; background: rgba(243, 236, 230, 0.03); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(243, 236, 230, 0.025); }
td .row { gap: 6px; }
/* lista vazia ("Nada por aqui ainda.", "Nenhum saque.") */
tbody td[colspan] { padding: 30px 16px; text-align: center; color: var(--bone-3); }

/* abas do admin */
.tabs {
  display: flex; gap: 4px; width: fit-content; max-width: 100%; overflow-x: auto;
  margin: 32px 0 0; padding: 4px; border: 1px solid var(--line-2); border-radius: 999px; background: rgba(11, 7, 8, 0.4);
}
.tabs button {
  flex: none; min-height: 38px; padding: 0 18px; border: 0; border-radius: 999px; background: none;
  color: var(--bone-2); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background-color 0.2s, color 0.2s;
}
.tabs button:hover { color: var(--bone); }
.tabs button[aria-selected=true] { background: var(--bone); color: #1a0d10; }

/* ---------- painel admin ---------- */
/* mesma margem do topo da página, para tudo alinhar pela esquerda */
.wrap--admin { width: min(1560px, 100% - 2 * clamp(16px, 4vw, 48px)); }
.admin-head .title { margin-bottom: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.nowrap { white-space: nowrap; }
#panel { margin-top: 20px; }

/* resumo: um painel só, com a receita em destaque */
.stats {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-top: 24px; overflow: hidden;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--line);
  box-shadow: 0 30px 80px -50px rgba(0, 0, 0, 0.9);
}
.stat { container-type: inline-size; display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: clamp(16px, 1.7vw, 24px); background: #1b0e11; }
.stat--hero { grid-column: span 2; background: linear-gradient(120deg, #3a1a22, #1f1014 72%); }
.stat__label { color: var(--bone-2); font-size: 13px; font-weight: 500; line-height: 1.3; }
.stat__value {
  font-size: 26px; font-size: clamp(19px, 12cqi, 34px); font-weight: 900; font-stretch: 108%; line-height: 1.1;
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.stat--hero .stat__value { font-size: 40px; font-size: clamp(30px, 10.5cqi, 60px); letter-spacing: -0.04em; }
.stat__note { margin-top: auto; color: var(--bone-3); font-size: 13px; line-height: 1.4; }

/* filtros acima das listas */
.toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; margin-bottom: 14px; }
.toolbar .field { flex: 0 1 340px; }
.toolbar__count { padding-bottom: 12px; color: var(--bone-3); font-size: 13px; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--bone-2);
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; transition: background-color 0.2s, color 0.2s, border-color 0.2s;
}
.chip:hover { color: var(--bone); border-color: var(--line-2); }
.chip b { color: var(--bone-3); font-family: var(--f-mono); font-size: 12px; font-weight: 500; }
.chip[aria-pressed=true] { background: var(--bone); border-color: var(--bone); color: #1a0d10; }
.chip[aria-pressed=true] b { color: inherit; }
.stage-select { display: none; margin-bottom: 12px; }

/* formulários do painel: os campos se acomodam em quantas colunas couberem */
.form-grid { grid-template-columns: repeat(auto-fit, minmax(min(100%, 190px), 1fr)); gap: 14px; align-items: end; }
.form-grid .btn { width: 100%; }
.card-note { color: var(--bone-2); font-size: 14px; max-width: 76ch; }

/* lotes de saque */
.batch { margin-bottom: 16px; }
.batch__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.pick { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--bone-2); cursor: pointer; }
.pick input {
  appearance: none; -webkit-appearance: none; display: grid; place-items: center; flex: none;
  width: 20px; height: 20px; margin: 0; border: 1.5px solid var(--bone-3); border-radius: 6px;
  background: rgba(0, 0, 0, 0.38); cursor: pointer; transition: background-color 0.15s, border-color 0.15s;
}
.pick input:hover { border-color: var(--bone); }
.pick input:checked { border-color: var(--ember); background: var(--ember); }
.pick input:checked::after { content: ""; width: 10px; height: 5px; margin-top: -2px; border: solid #1a0d10; border-width: 0 0 2px 2px; transform: rotate(-45deg); }
.batch__foot .linkbtn, .data-table .linkbtn { font-size: 13px; }
.code-display { padding: 14px; border: 1px dashed var(--line-2); border-radius: 12px; background: rgba(0, 0, 0, 0.3); font-family: var(--f-mono); font-size: clamp(16px, 4.6vw, 20px); letter-spacing: 0.04em; text-align: center; overflow-wrap: anywhere; }

/* tabelas do painel */
.data-wrap { position: relative; overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; background: rgba(11, 7, 8, 0.32); -webkit-overflow-scrolling: touch; }
.data-table th, .data-table td { padding: 13px 10px; }
.data-table th:first-child, .data-table td:first-child { padding-left: 16px; }
.data-table th:last-child, .data-table td:last-child { padding-right: 16px; }
.data-table td { overflow-wrap: anywhere; }
.data-table--wide { min-width: 1240px; }
.td-main { min-width: 200px; }
.td-aff { min-width: 190px; }
.td-aff b { display: block; white-space: nowrap; }
.cell-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; color: var(--bone); font-weight: 600; }
.cell-sub { display: block; color: var(--bone-3); font-size: 13px; line-height: 1.45; }
.cell-sub b { color: var(--bone-2); font-weight: 600; }
.cell-mono { font-family: var(--f-mono); font-size: 13px; }
.actions { display: flex; justify-content: flex-end; gap: 6px; }
.actions .btn { white-space: nowrap; }
@media (min-width: 900px) {
  .pick span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  /* com todas as colunas, o nome do cliente fica fixo ao rolar para o lado */
  .data-table--wide th:first-child, .data-table--wide td:first-child { position: sticky; left: 0; z-index: 1; background: #150a0d; box-shadow: 1px 0 0 var(--line); }
  .data-table--wide tbody tr:hover td:first-child { background: #1c1013; }
}
@media (max-width: 1199px) {
  /* saques e acessos cabem sem rolar: os botões descem e a primeira coluna encolhe */
  .data-table:not(.data-table--wide) .actions { flex-wrap: wrap; justify-content: flex-start; }
  .data-table:not(.data-table--wide) .td-main { min-width: 170px; }
}
@media (max-width: 1099px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 899px) {
  /* no celular e tablet, cada linha vira um bloco com todas as colunas rotuladas */
  .data-wrap { overflow: visible; border: 0; border-radius: 0; background: none; }
  .data-table, .data-table tbody, .data-table--wide { display: block; min-width: 0; width: 100%; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .data-table tbody { display: grid; gap: 10px; }
  .data-table tbody tr {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; padding: 16px;
    border: 1px solid var(--line); border-radius: 16px; background: rgba(11, 7, 8, 0.42);
  }
  .data-table td, .data-table td:first-child, .data-table td:last-child { display: block; min-width: 0; padding: 0; border: 0; }
  .data-table td:empty { display: none; }
  .data-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 3px; color: var(--bone-3); font-size: 12px; font-weight: 500; }
  .data-table tbody tr:hover td { background: none; }
  .data-table tbody td[colspan] { padding: 14px 0; }
  .data-table .td-full { grid-column: 1 / -1; }
  .data-table .td-main { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .data-table td.td-main::before { display: none; }
  .data-table .nowrap, .data-table .badge { white-space: normal; }
  .actions { flex-wrap: wrap; justify-content: flex-start; }
  .actions .btn { flex: 1 1 auto; }
}
@media (max-width: 720px) {
  .chips { display: none; }
  .stage-select { display: grid; }
  .toolbar .field { flex: 1 1 100%; }
  .toolbar__count { padding-bottom: 0; }
}
@media (max-width: 560px) {
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; border-radius: 20px; overflow: visible; }
  .tabs button { min-width: 0; min-height: 42px; padding: 6px 8px; border-radius: 15px; font-size: 13px; line-height: 1.2; white-space: normal; }
  .stat { padding: 14px; }
  .stat__label, .stat__note { font-size: 12px; }
  .batch__foot .btn { width: 100%; }
}

/* ---------- diálogo e aviso flutuante ---------- */
.dialog {
  border: 1px solid var(--line-2); border-radius: 24px; padding: clamp(20px, 4vw, 28px);
  width: min(500px, calc(100% - 32px)); max-height: calc(100dvh - 32px);
  background: linear-gradient(180deg, #2a161c, #1a0d10); color: var(--bone);
  box-shadow: 0 50px 140px -30px rgba(0, 0, 0, 0.95);
}
.dialog[open] { animation: dlg-in 0.28s var(--ease); }
.dialog::backdrop { background: rgba(5, 3, 4, 0.72); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.dialog h2 { font-size: 22px; font-weight: 800; font-stretch: 106%; letter-spacing: -0.02em; line-height: 1.2; }
.dialog__body { color: var(--bone-2); font-size: 15px; display: grid; gap: 10px; }
.dialog__body ol, .dialog__body ul { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.dialog .row--end { margin-top: 4px; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(14px) scale(0.98); } }
.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 50;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  max-width: min(520px, calc(100% - 32px)); padding: 13px 18px 13px 16px;
  border: 1px solid var(--line-2); border-left: 3px solid var(--ok); border-radius: 14px;
  background: #24131a; color: var(--bone); font-size: 14px; line-height: 1.45;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.85);
  transition: opacity 0.25s, transform 0.25s var(--ease);
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.toast--error { border-color: rgba(255, 125, 125, 0.45); border-left-color: var(--bad); color: #ffd3d3; }

/* ---------- documentos legais ---------- */
.doc { padding-top: clamp(32px, 6vh, 64px); }
.doc h1 { font-size: clamp(36px, 5.4vw, 60px); font-weight: 800; font-stretch: 110%; letter-spacing: -0.04em; line-height: 1; margin: 12px 0 14px; text-wrap: balance; }
.doc .updated { display: inline-flex; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-family: var(--f-mono); font-size: 12px; color: var(--bone-3); }
.doc h2 { font-size: clamp(20px, 2.2vw, 25px); font-weight: 800; font-stretch: 106%; letter-spacing: -0.02em; line-height: 1.2; margin: 44px 0 12px; padding-top: 24px; border-top: 1px solid var(--line); scroll-margin-top: 88px; }
.doc h3 { font-size: 16px; margin: 20px 0 6px; }
.doc p, .doc li { color: var(--bone-2); margin: 0 0 10px; line-height: 1.7; }
.doc ul, .doc ol { padding-left: 22px; margin: 0 0 12px; }
.doc li { padding-left: 4px; }
.doc li::marker { color: var(--ember); }
.doc .table-wrap { margin: 14px 0 18px; }
.doc table { margin: 0; }
.doc td { color: var(--bone-2); line-height: 1.5; }
.doc td:first-child { color: var(--bone); }
@media (max-width: 640px) {
  /* no celular, cada linha da tabela vira um bloco com o rótulo de cada coluna */
  .doc table, .doc tbody, .doc tr, .doc td { display: block; width: 100%; }
  .doc thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .doc tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .doc tbody tr:last-child { border-bottom: 0; }
  .doc td { padding: 3px 0; border: 0; }
  .doc td[data-label]::before { content: attr(data-label); display: block; margin-top: 6px; font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--bone-3); }
  .doc td:first-child::before { margin-top: 0; }
  .doc td:first-child { font-weight: 700; }
  .doc tbody tr:hover td { background: none; }
}

/* ---------- rodapé ---------- */
.foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  padding: 22px clamp(16px, 4vw, 48px) calc(22px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); background: rgba(11, 7, 8, 0.6); color: var(--bone-3); font-size: 13px;
}
.foot span { min-width: 0; overflow-wrap: anywhere; }
.foot nav { display: flex; flex-wrap: wrap; gap: 6px 18px; }
.foot a { color: var(--bone-2); }
.foot a[href^="tel:"] { white-space: nowrap; }

.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--bone); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  .top { padding-block: 10px; }
  .top__brand { font-size: 14px; gap: 8px; }
  .top__nav { gap: 2px; font-size: 12px; }
  .top__nav a, .top__nav .linkbtn { padding: 0 9px; }
  .card > .btn, .card > div > .btn--ember { align-self: stretch; width: 100%; }
  .card .row > .btn--danger:last-child { margin-left: 0; }
  .dialog .row--end { flex-direction: column-reverse; align-items: stretch; }
  .dialog .row--end .btn { width: 100%; }
  .copy { border-radius: 16px; }
  /* tabela que rola para o lado: sombras nas bordas mostram que há mais colunas */
  #app .table-wrap {
    background:
      linear-gradient(90deg, #1f1014 30%, rgba(31, 16, 20, 0)) left center / 32px 100% no-repeat local,
      linear-gradient(270deg, #1f1014 30%, rgba(31, 16, 20, 0)) right center / 32px 100% no-repeat local,
      radial-gradient(farthest-side at 0 50%, rgba(243, 236, 230, 0.16), transparent) left center / 12px 100% no-repeat scroll,
      radial-gradient(farthest-side at 100% 50%, rgba(243, 236, 230, 0.16), transparent) right center / 12px 100% no-repeat scroll,
      #1f1014;
  }
  #app .table-wrap th { background: transparent; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; }
  .spinner, .btn[aria-busy=true]::after { animation-duration: 1.6s !important; animation-iteration-count: infinite !important; }
}
