@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --surface-2: #f8faf9;
  --border: #e3e8e6;
  --text: #14201b;
  --muted: #64726c;
  --brand: #0b7a5a;
  --brand-2: #0e9a72;
  --brand-soft: #e3f4ee;
  --danger: #c2372f;
  --danger-soft: #fbeceb;
  --warn: #a86200;
  --warn-soft: #fff3df;
  --neutral-soft: #eef0ef;
  --on-text: #ffffff;
  --input-bg: #ffffff;
  --input-border: #e3e8e6;
  --side: #0f1c17;
  --side-text: #b9c9c2;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 32, 27, .05), 0 4px 16px rgba(16, 32, 27, .05);
  color-scheme: light;
}

/* Tema escuro: ativado pelo /assets/theme.js (escolha do usuário ou do sistema) */
:root[data-theme="dark"] {
  --bg: #0c1411;
  --surface: #131d19;
  --surface-2: #19251f;
  --border: #25332d;
  --text: #e4ede9;
  --muted: #92a39b;
  --brand: #14a376;
  --brand-2: #19b986;
  --brand-soft: #12302a;
  --danger: #f2786e;
  --danger-soft: #3a1d1b;
  --warn: #f0b252;
  --warn-soft: #33270f;
  --neutral-soft: #222e29;
  --on-text: #0c1411;
  --input-bg: #0d1613;
  --input-border: #34463e;
  --side: #08100d;
  --side-text: #a6b8b0;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  color-scheme: dark;
}
:root[data-theme="dark"] .side { border-right: 1px solid var(--border); }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }

/* ---------- Botões e campos ---------- */
.btn {
  appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 9px 14px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.lg { padding: 13px 20px; font-size: 15px; width: 100%; justify-content: center; }

label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 13px; }
input, select, textarea {
  width: 100%; font: inherit; color: inherit; background: var(--input-bg);
  border: 1px solid var(--input-border); border-radius: 9px; padding: 10px 12px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.field + .field { margin-top: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid2 > .field { margin-top: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- Cartões ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card h2 { margin-bottom: 12px; }
.alert { border-radius: 10px; padding: 11px 14px; font-size: 13px; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.err { background: var(--danger-soft); color: var(--danger); }
.alert.ok { background: var(--brand-soft); color: var(--brand); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.badge.paid, .badge.confirmed, .badge.success { background: var(--brand-soft); color: var(--brand); }
.badge.pending, .badge.processing, .badge.sent { background: var(--warn-soft); color: var(--warn); }
.badge.expired, .badge.failed, .badge.refunded { background: var(--neutral-soft); color: var(--muted); }
.badge.failed { background: var(--danger-soft); color: var(--danger); }

/* ---------- Layout do painel ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-text); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 700; font-size: 17px; padding: 4px 8px 22px; }
.logo-mark { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #19c08e, #0b7a5a); display: grid; place-items: center; }
.nav a {
  display: flex; align-items: center; gap: 10px; color: var(--side-text); text-decoration: none;
  padding: 9px 10px; border-radius: 8px; font-weight: 500; margin-bottom: 2px;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(25, 192, 142, .14); color: #fff; }
.nav svg { width: 18px; height: 18px; flex: none; }
.side-foot { margin-top: auto; font-size: 12px; padding: 8px; }
.side-foot button { background: none; border: 0; color: var(--side-text); padding: 0; cursor: pointer; font: inherit; text-decoration: underline; }

.main { padding: 26px 30px 60px; max-width: 1180px; width: 100%; min-width: 0; /* deixa só as tabelas rolarem, não a página */ }
.main section, .main .card { min-width: 0; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.mobile-top { display: none; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi .label { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.kpi .value { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.split { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; margin-bottom: 16px; }

/* Filtro de período */
.range { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.range .chip { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 6px 12px; cursor: pointer; font: inherit; font-weight: 500; font-size: 13px; color: var(--text); }
.range .chip.active { background: var(--text); color: var(--on-text); border-color: var(--text); }
.range input[type=date] { width: auto; padding: 6px 10px; border-radius: 99px; }

/* Gráfico */
.chart { width: 100%; height: 240px; display: block; }
.chart .bar { fill: var(--brand); }
.chart .bar:hover { fill: var(--brand-2); }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .gl { stroke: var(--border); }

/* Tabelas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { text-align: center; color: var(--muted); padding: 32px 12px; }

.list-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }

/* Saldo */
.balance-hero { background: linear-gradient(135deg, #0f1c17, #0b3d2e); color: #fff; border: 0; }
.balance-hero .muted { color: #9fb8ae; }
.balance-hero .big { font-size: 40px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 20, 16, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--surface); border-radius: 14px; width: min(560px, 100%); max-height: 92vh; overflow: auto; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin-bottom: 14px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--on-text); padding: 10px 16px; border-radius: 10px; z-index: 99; font-weight: 500; box-shadow: var(--shadow); }
.toast.err { background: var(--danger); }

.copybox { display: flex; gap: 8px; }
.copybox input { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- Páginas públicas (login, checkout, entrega) ---------- */
.public { min-height: 100vh; display: grid; place-items: start center; padding: 32px 16px; }
.public-card { width: min(460px, 100%); }
.co-product { display: flex; gap: 14px; align-items: center; margin-bottom: 16px; }
.co-product img { width: 64px; height: 64px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border); }
.co-price { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.qr { display: grid; place-items: center; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin: 14px 0; }
.qr img { width: 230px; height: 230px; image-rendering: pixelated; }
.qr-mock { width: 230px; height: 230px; display: grid; place-items: center; text-align: center; color: var(--muted); background: repeating-linear-gradient(45deg, #f2f4f3 0 10px, #fff 10px 20px); border-radius: 8px; font-weight: 600; padding: 20px; }
.steps { padding-left: 18px; color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.wait { display: flex; gap: 10px; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; margin-top: 12px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); animation: pulse 1.2s infinite; }
@keyframes pulse { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.secure { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }
.success-icon { width: 58px; height: 58px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; margin: 0 auto 12px; }
.delivery-text { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; word-break: break-word; }

/* Abertura de conta */
.public-card.wide { width: min(640px, 100%); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg label { position: relative; margin: 0; display: flex; flex-direction: column; gap: 2px; border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; cursor: pointer; font-weight: 600; font-size: 14px; }
.seg label span { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.seg input { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.seg label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.seg label:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--brand-soft); }
.form-section { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--border); }
.form-section > h2 { margin-bottom: 12px; }
.grid3 { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.grid3 > .field { margin-top: 0; }
.grid2 + .grid2, .grid2 + .grid3, .grid3 + .grid2, .grid3 + .grid3, .field + .grid2, .grid2 + .field, .grid3 + .field, .field + .grid3 { margin-top: 12px; }
.field-err { color: var(--danger); font-size: 12px; margin-top: 4px; }
.ok-hint { color: var(--brand); }
.err-hint { color: var(--danger); }
.field.invalid input, .field.invalid select { border-color: var(--danger); }
.check-block { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; margin: 0; }
.check-block input { width: auto; margin-top: 3px; }
.radios { display: flex; gap: 18px; }
.radios label { display: flex; gap: 6px; align-items: center; font-weight: 400; margin: 0; }
.radios input { width: auto; }
.badge.em_analise { background: var(--warn-soft); color: var(--warn); }
.badge.aprovada { background: var(--brand-soft); color: var(--brand); }
.badge.recusada { background: var(--danger-soft); color: var(--danger); }

@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 250px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .mobile-top { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: var(--side); color: #fff; font-weight: 700; position: sticky; top: 0; z-index: 30; }
  .mobile-top button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; padding: 0 4px; }
  .main { padding: 18px 16px 60px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kpi .value { font-size: 20px; }
  .balance-hero .big { font-size: 32px; }
}

/* Planos de taxa (cadastro e configurações) */
.plan-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.plan-card { position: relative; display: flex; flex-direction: column; gap: 4px; margin: 0; border: 1px solid var(--border); border-radius: 12px; padding: 14px; cursor: pointer; font-weight: 400; background: var(--surface); }
.plan-card input { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.plan-card:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 0 0 1px var(--brand); }
.plan-card:has(input:focus-visible) { box-shadow: 0 0 0 3px var(--brand-soft); }
.plan-card .plan-name { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.plan-card .plan-price { font-size: 13px; font-weight: 600; color: var(--brand); }
.plan-card .plan-best { font-size: 12px; color: var(--muted); }
.plan-card table { margin-top: 8px; font-size: 12px; }
.plan-card td { padding: 3px 0; border: 0; }
.plan-card .tag { font-size: 10.5px; font-weight: 700; background: var(--brand); color: #fff; border-radius: 99px; padding: 1px 7px; }
.plan-sim { margin-top: 14px; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 10px; }
.sim-result { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; font-size: 13px; }
.sim-result div { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.sim-result b { display: block; font-size: 15px; }
.sim-result .best { outline: 2px solid var(--brand); }
.fee-switch { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--brand-soft); }
.fee-switch-info { display: flex; flex-direction: column; gap: 2px; flex: 1 1 220px; min-width: 0; }
.fee-switch-info b { font-size: 15px; }
#plansEditor.locked input { opacity: .6; }
.plan-margin { margin-top: 10px; font-size: 12.5px; }
.plan-margin table { width: 100%; }
.plan-margin td, .plan-margin th { padding: 5px 8px; }
.loss { color: var(--danger); font-weight: 600; }

/* Primeiros passos */
.onboarding { margin-bottom: 16px; border-color: var(--brand); }
.onboarding .progress { height: 6px; border-radius: 99px; background: var(--neutral-soft); overflow: hidden; margin: 10px 0 14px; }
.onboarding .progress span { display: block; height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.ob-step { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.ob-step .ck { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; flex: none; color: #fff; font-size: 13px; font-weight: 700; }
.ob-step.done .ck { background: var(--brand); border-color: var(--brand); }
.ob-step.done .ob-title { text-decoration: line-through; color: var(--muted); }
.ob-step .ob-title { font-weight: 600; }
.ob-step .ob-text { font-size: 12.5px; color: var(--muted); }
.ob-step .btn { margin-left: auto; flex: none; }

/* Histórico do pedido */
.timeline { list-style: none; margin: 8px 0 0; padding: 0 0 0 4px; }
.timeline li { position: relative; padding: 0 0 12px 20px; font-size: 13px; }
.timeline li::before { content: ''; position: absolute; left: 0; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--border); }
.timeline li::after { content: ''; position: absolute; left: 4px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li.ok::before { background: var(--brand); }
.timeline li.warn::before { background: var(--warn); }
.timeline li.err::before { background: var(--danger); }
.timeline time { display: block; font-size: 11.5px; color: var(--muted); }
.badge.canceled { background: var(--neutral-soft); color: var(--muted); }
.amount-in { color: var(--brand); font-weight: 600; }
.amount-out { color: var(--danger); font-weight: 600; }
.share-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.share-row .btn { flex: 1; justify-content: center; }
.qr-small { display: grid; place-items: center; background: #fff; border-radius: 12px; padding: 10px; margin: 12px auto; width: 200px; }
.qr-small img { width: 180px; height: 180px; image-rendering: pixelated; }

/* Editor de taxa (percentual com mín./máx. ou valor fixo) */
.fee-editor { margin-top: 12px; }
.fee-editor .seg { max-width: 460px; margin-bottom: 12px; }
.fee-editor .seg label { padding: 9px 12px; }
.fee-editor .preview { font-size: 12.5px; color: var(--muted); margin-top: 8px; }

/* Verificação em duas etapas */
.tfa-icon { width: 36px; height: 36px; border-radius: 10px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; flex: none; }
.channel-btn { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 12px 14px; font: inherit; font-weight: 600; cursor: pointer; }
.channel-btn:hover { border-color: var(--brand); background: var(--brand-soft); }
.channel-btn:disabled { opacity: .6; cursor: wait; }
.channel-btn svg { width: 20px; height: 20px; color: var(--brand); flex: none; }
.code-input { font-size: 26px; letter-spacing: 10px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 600; }
.link-btn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; font-size: 13px; cursor: pointer; text-decoration: underline; }
.link-btn:disabled { color: var(--muted); cursor: default; text-decoration: none; }

/* Termos e Privacidade */
.legal { line-height: 1.65; padding: 28px; }
.legal h2 { margin: 22px 0 6px; }
.legal p, .legal ul { margin: 8px 0; }
.legal ul { padding-left: 20px; }
.legal li + li { margin-top: 4px; }

/* Painel por papel: administrador da plataforma x vendedor */
body:not(.role-admin) [data-only="admin"], body:not(.role-seller) [data-only="seller"] { display: none !important; }
.nav-count { margin-left: auto; background: #19c08e; color: #06231a; font-size: 11px; font-weight: 700; border-radius: 99px; padding: 1px 7px; }
.badge.solicitado, .badge.suspensa { background: var(--warn-soft); color: var(--warn); }
.badge.pago { background: var(--brand-soft); color: var(--brand); }
.badge.aberta { background: var(--danger-soft); color: var(--danger); }
.badge.respondida { background: var(--warn-soft); color: var(--warn); }
.badge.procedente { background: var(--neutral-soft); color: var(--muted); }
.badge.improcedente { background: var(--brand-soft); color: var(--brand); }
.badge.cancelada { background: var(--neutral-soft); color: var(--muted); }
.late { color: var(--danger); font-weight: 600; }
.file-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.file-list a { display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 9px; padding: 8px 10px; text-decoration: none; color: var(--text); background: var(--surface-2); font-size: 13px; }
.file-list a span { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.file-list img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; flex: none; }
.file-list .ext { width: 40px; height: 40px; border-radius: 6px; display: grid; place-items: center; background: var(--neutral-soft); color: var(--muted); font-size: 10px; font-weight: 700; flex: none; text-transform: uppercase; }
.response-box { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; font-size: 13px; margin-top: 8px; }
.badge.recusado { background: var(--danger-soft); color: var(--danger); }
.docs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 8px; }
.docs a { display: block; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; text-decoration: none; color: var(--text); font-size: 12px; background: var(--surface-2); }
.docs img { width: 100%; height: 90px; object-fit: cover; display: block; }
.docs .pdf { height: 90px; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.docs span { display: block; padding: 6px 8px; }

/* Seletor de tema (claro / escuro / sistema) */
.theme-picker { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); }
.theme-picker button { appearance: none; border: 0; background: none; color: var(--muted); font: inherit; font-size: 12.5px; font-weight: 500; padding: 5px 10px; border-radius: 99px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.theme-picker button:hover { color: var(--text); }
.theme-picker button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.theme-picker svg { width: 14px; height: 14px; flex: none; }
.side .theme-picker { display: flex; border-color: rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .04); margin-bottom: 12px; }
/* No menu lateral os três botões dividem a largura igualmente e mostram só o texto (com ícone não cabem) */
.side .theme-picker button { flex: 1 1 0; min-width: 0; justify-content: center; text-decoration: none; color: var(--side-text); padding: 5px 2px; font-size: 12px; white-space: nowrap; }
.side .theme-picker svg { display: none; }
.side .theme-picker button:hover { color: #fff; }
.side .theme-picker button[aria-pressed="true"] { background: rgba(255, 255, 255, .12); color: #fff; box-shadow: none; }
.theme-foot { display: flex; justify-content: center; margin-top: 16px; }

/* Botão de instalar o app */
.install-btn { margin-top: 18px; display: flex; align-items: center; gap: 10px; width: 100%; background: rgba(25, 192, 142, .14); color: #fff; border: 1px dashed rgba(25, 192, 142, .5); border-radius: 10px; padding: 10px; font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.install-btn:hover { background: rgba(25, 192, 142, .24); }
@media (display-mode: standalone) { .install-btn { display: none !important; } .mobile-top { padding-top: max(12px, env(safe-area-inset-top)); } }

.rank-inline { display: none; }

/* Seletor de período: atalhos + datas */
.range .chips, .range .dates { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ============================================================
   Celular — fica no fim do arquivo para valer sobre todas as regras acima
   ============================================================ */
@media (max-width: 760px) {
  /* Campos com 16px: o iPhone não dá zoom ao tocar */
  input, select, textarea { font-size: 16px; }
  .code-input { font-size: 26px; }

  /* Grades viram uma coluna (inclusive as com colunas definidas no HTML) */
  .grid2, .grid3, .kpis.grid-fixed { grid-template-columns: 1fr !important; }
  .grid3 > *, .grid2 > * { grid-column: auto !important; }
  .kpis { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
  .kpi { padding: 14px; }
  .kpi .value { font-size: 19px; overflow-wrap: anywhere; }
  .split { gap: 12px; }
  .card { padding: 15px; }

  /* Cabeçalho das páginas */
  .page-head { flex-direction: column; align-items: stretch; gap: 10px; margin-bottom: 14px; }
  .page-head h1 { font-size: 20px; }
  .page-head .spacer { display: none; }
  .page-head > .btn { justify-content: center; }

  /* Período: atalhos numa faixa que desliza para o lado; datas lado a lado */
  .range { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; width: 100%; }
  .range .chips { min-width: 0; flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px; scrollbar-width: none; }
  .range .chips::-webkit-scrollbar { display: none; }
  .range .chip { flex: none; }
  .range .dates { flex-wrap: nowrap; width: 100%; }
  .range .dates input[type=date] { flex: 1 1 0; width: 0; min-width: 0; padding: 8px 10px; }
  .chart { height: 190px; }

  /* Tabelas viram cartões: cada valor com o nome da coluna em cima */
  .table-wrap { overflow: visible; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tr { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; padding: 13px 0; border-bottom: 1px solid var(--border); }
  .table-wrap tr:last-child { border-bottom: 0; }
  .table-wrap td { border: 0; padding: 0; text-align: left !important; white-space: normal !important; max-width: none !important; min-width: 0; overflow-wrap: anywhere; }
  .table-wrap td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); font-weight: 500; margin-bottom: 1px; }
  .table-wrap td.wide, .table-wrap td.empty, .table-wrap td[colspan] { grid-column: 1 / -1; order: -1; }
  .table-wrap td.actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; }
  .table-wrap td.actions .btn { flex: 1; justify-content: center; }
  .table-wrap td.rank { display: none; }
  .plan-cards, .sim-result { grid-template-columns: 1fr; }
  .ob-step { flex-wrap: wrap; }
  .ob-step .btn { margin-left: 36px; }
  .rank-inline { display: inline; color: var(--brand); }
  tr.click:hover td { background: none; }
  tr.click:active { background: var(--surface-2); }

  /* Botões pequenos com área de toque maior */
  .btn.sm { padding: 8px 12px; font-size: 13px; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1 1 auto; justify-content: center; }
  .modal-actions .spacer { display: none; }

  /* Janelas sobem de baixo, ocupando a largura toda */
  .modal-bg { place-items: end center; padding: 0; }
  .modal { width: 100%; max-height: 92vh; border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }

  .toast { left: 16px; right: 16px; transform: none; bottom: calc(16px + env(safe-area-inset-bottom)); text-align: center; }
  .alert { font-size: 12.5px; }
  .seg { grid-template-columns: 1fr; }
  .fee-editor .seg { grid-template-columns: 1fr 1fr; }
  .copybox { flex-direction: column; }
  .docs { grid-template-columns: repeat(2, 1fr); }
  .legal { padding: 18px; }
  .public { padding: 20px 16px; }
  .balance-hero .row .btn { flex: 1; justify-content: center; }
  .side { width: 270px; padding-top: max(20px, env(safe-area-inset-top)); overflow-y: auto; }
  .side.open { box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
}
