:root {
  color-scheme: dark;
  --bg: #0a0f1f;
  --glow: radial-gradient(1100px 520px at 85% -120px, #17306b 0%, transparent 60%);
  --surface: #131b33;
  --surface2: #19243f;
  --field: var(--field);
  --line: #26335a;
  --line-strong: #3a4c82;
  --hair: rgba(255, 255, 255, .07);
  --ink: #e9eefb;
  --muted: #9aa7c7;
  --ph: #6d7a9d;
  --top-bg: rgba(10, 15, 31, .88);
  --nav-bg: rgba(12, 18, 38, .96);
  --fin-bg: linear-gradient(160deg, #162a5a 0%, #101a38 70%);
  --fin-line: #2a3d78;
  --chart-bg: rgba(8, 12, 28, .55);
  --chart-line: rgba(255, 255, 255, .08);
  --grid: rgba(255, 255, 255, .12);
  --tag-bg: rgba(168, 85, 247, .2);
  --tag-ink: #e9d5ff;
  --note-bg: rgba(47, 123, 255, .1);
  --note-line: rgba(47, 123, 255, .35);
  --note-ink: #c6dafc;
  --toast-bg: #e9eefb;
  --toast-ink: #0a0f1f;
  --primary: #2f7bff;
  --primary2: #1b4fd8;
  --wa: #16a34a;
  --paid: #4ade80;
  --paid-bg: rgba(34, 197, 94, .16);
  --today: #fbbf24;
  --today-bg: rgba(245, 179, 1, .16);
  --soon: #7db2ff;
  --soon-bg: rgba(47, 123, 255, .18);
  --late: #fb7185;
  --late-bg: rgba(244, 63, 94, .17);
  --radius: 16px;
  --nav-h: 64px;
  --font: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2f9;
  --glow: radial-gradient(1100px 520px at 85% -120px, #cfe0ff 0%, transparent 60%);
  --surface: #ffffff;
  --surface2: #eef2fa;
  --field: #ffffff;
  --line: #d3dbed;
  --line-strong: #aebbd9;
  --hair: rgba(16, 26, 51, .08);
  --ink: #101a33;
  --muted: #55627f;
  --ph: #8792ad;
  --top-bg: rgba(255, 255, 255, .9);
  --nav-bg: rgba(255, 255, 255, .97);
  --fin-bg: linear-gradient(160deg, #e6efff 0%, #ffffff 75%);
  --fin-line: #c3d3f3;
  --chart-bg: #f7faff;
  --chart-line: #d9e3f7;
  --grid: rgba(16, 26, 51, .14);
  --tag-bg: rgba(124, 58, 237, .12);
  --tag-ink: #6d28d9;
  --note-bg: rgba(37, 99, 235, .08);
  --note-line: rgba(37, 99, 235, .3);
  --note-ink: #1e3a8a;
  --toast-bg: #101a33;
  --toast-ink: #ffffff;
  --primary: #2563eb;
  --primary2: #1d4ed8;
  --wa: #15803d;
  --paid: #15803d;
  --paid-bg: rgba(22, 163, 74, .14);
  --today: #92590a;
  --today-bg: rgba(245, 179, 1, .22);
  --soon: #1d4ed8;
  --soon-bg: rgba(37, 99, 235, .12);
  --late: #be123c;
  --late-bg: rgba(225, 29, 72, .12);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    color-scheme: light;
    --bg: #eef2f9;
    --glow: radial-gradient(1100px 520px at 85% -120px, #cfe0ff 0%, transparent 60%);
    --surface: #ffffff;
    --surface2: #eef2fa;
    --field: #ffffff;
    --line: #d3dbed;
    --line-strong: #aebbd9;
    --hair: rgba(16, 26, 51, .08);
    --ink: #101a33;
    --muted: #55627f;
    --ph: #8792ad;
    --top-bg: rgba(255, 255, 255, .9);
    --nav-bg: rgba(255, 255, 255, .97);
    --fin-bg: linear-gradient(160deg, #e6efff 0%, #ffffff 75%);
    --fin-line: #c3d3f3;
    --chart-bg: #f7faff;
    --chart-line: #d9e3f7;
    --grid: rgba(16, 26, 51, .14);
    --tag-bg: rgba(124, 58, 237, .12);
    --tag-ink: #6d28d9;
    --note-bg: rgba(37, 99, 235, .08);
    --note-line: rgba(37, 99, 235, .3);
    --note-ink: #1e3a8a;
    --toast-bg: #101a33;
    --toast-ink: #ffffff;
    --primary: #2563eb;
    --primary2: #1d4ed8;
    --wa: #15803d;
    --paid: #15803d;
    --paid-bg: rgba(22, 163, 74, .14);
    --today: #92590a;
    --today-bg: rgba(245, 179, 1, .22);
    --soon: #1d4ed8;
    --soon-bg: rgba(37, 99, 235, .12);
    --late: #be123c;
    --late-bg: rgba(225, 29, 72, .12);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  background: var(--glow), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
body.noscroll { overflow: hidden; }
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px 20px; color: var(--muted); text-align: center; }
.muted { color: var(--muted); }
:focus-visible { outline: 3px solid #7db2ff; outline-offset: 2px; }

/* ---------- Estrutura ---------- */
.shell { min-height: 100vh; padding-bottom: calc(var(--nav-h) + 96px + env(safe-area-inset-bottom, 0px)); }
.top {
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--line);
  isolation: isolate;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.top::before { /* o desfoque fica num elemento à parte para não prender o menu fixo de baixo */
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--top-bg); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand img { height: 34px; width: auto; display: block; }
.brand span { line-height: 1.1; }
.brand small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.page-title { font-size: 24px; font-weight: 700; margin-bottom: 14px; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.head-row .page-title { margin: 0; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: var(--nav-bg); border-top: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--nav-h); color: var(--muted); text-decoration: none; font-size: 11.5px; font-weight: 600;
}
.nav a svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.on { color: var(--ink); }
.nav a.on svg { stroke: var(--primary); stroke-width: 2.4; }

/* ---------- Botões ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface2); font-weight: 600; cursor: pointer; text-decoration: none; color: var(--ink);
}
.btn:hover { border-color: var(--line-strong); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: linear-gradient(135deg, var(--primary), var(--primary2)); color: #fff; border-color: transparent; }
.btn.wa { background: var(--wa); color: #fff; border-color: transparent; }
.btn.danger { color: var(--late); border-color: rgba(251, 113, 133, .4); background: transparent; }
.btn.danger.solid { background: #e11d48; color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.disabled { opacity: .4; pointer-events: none; }
.link { background: none; border: 0; padding: 0; color: var(--soon); font-weight: 600; text-decoration: underline; cursor: pointer; }

.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px)); z-index: 25;
  box-shadow: 0 8px 24px rgba(27, 79, 216, .45); min-height: 52px; padding: 0 20px; border-radius: 26px;
}

/* ---------- Formulários ---------- */
label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 12px; }
label.check { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 500; }
label.check input { flex: none; width: 22px; height: 22px; min-height: 0; margin: 0; accent-color: var(--primary); }
input, select, textarea {
  display: block; width: 100%; margin-top: 5px; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: var(--field); font-size: 16px; color: var(--ink); font-weight: 400;
}
input::placeholder, textarea::placeholder { color: var(--ph); }
textarea { resize: vertical; line-height: 1.45; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 13px; color: var(--muted); margin: -4px 0 12px; }
.hint.warn { color: var(--late); }
.form-msg { min-height: 20px; color: var(--late); font-size: 14px; margin-bottom: 8px; }
.form-msg.ok { color: var(--paid); }
.actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 6px; }
.actions .btn { flex: 1; }
details.more { border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; margin-bottom: 12px; background: var(--hair); }
details.more summary { cursor: pointer; padding: 12px 0; font-weight: 600; font-size: 14px; color: var(--muted); }
details.more[open] summary { margin-bottom: 4px; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 390px; background: var(--surface); padding: 28px 22px; border-radius: 20px; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .4); }
.login-card img { display: block; height: 130px; width: auto; max-width: 100%; margin: 0 auto 14px; background: #fff; border-radius: 14px; padding: 8px 14px; }
.login-card h1 { font-size: 22px; margin-bottom: 6px; text-align: center; }
.login-card p { margin-bottom: 20px; text-align: center; }
.login-card .btn + .btn { margin-top: 10px; }

/* ---------- Painel ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar select { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 10px; }
.tile {
  display: block; text-align: left; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; cursor: default; color: var(--ink);
}
button.tile { cursor: pointer; }
button.tile:hover { border-color: var(--line-strong); }
.tile .n { display: block; font-size: 28px; font-weight: 700; line-height: 1.1; }
.tile .t { display: block; margin-top: 4px; font-size: 14px; color: var(--muted); font-weight: 500; }
.tile.wide { grid-column: 1 / -1; }
.tile.late { border-left: 5px solid #f43f5e; }
.tile.today { border-left: 5px solid #f5b301; }
.tile.soon { border-left: 5px solid #2f7bff; }
.tile .n.money { font-size: 24px; }
.section-title { font-size: 17px; font-weight: 700; margin: 24px 0 10px; display: flex; justify-content: space-between; align-items: baseline; }
.section-title .link { font-size: 14px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h3 { font-size: 16px; margin-bottom: 8px; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); }

.todo { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 10px 14px; margin-bottom: 8px; border-left: 5px solid #f43f5e; }
.todo.today { border-left-color: #f5b301; }
.todo .who { flex: 1; min-width: 0; }
.todo .who strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.todo .who small { color: var(--muted); font-size: 13px; }

/* ---------- Financeiro ---------- */
.fin { background: var(--fin-bg); border: 1px solid var(--fin-line); border-radius: 20px; padding: 16px; margin: 18px 0 10px; }
.fin h2 { font-size: 19px; }
.fin .sub { color: var(--muted); font-size: 14px; margin: 2px 0 12px; }
.fin-tools { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.fin-tools select { width: auto; min-height: 40px; margin: 0; padding: 6px 10px; font-size: 14px; }
.fin-cards { display: grid; grid-template-columns: 1fr; gap: 10px; margin-bottom: 14px; }
.fcard { color: #fff; border-radius: 14px; padding: 12px 14px; border: 1px solid rgba(255, 255, 255, .12); }
.fcard .l { display: block; font-size: 11.5px; letter-spacing: .08em; font-weight: 700; text-transform: uppercase; opacity: .85; }
.fcard .v { display: block; font-size: 25px; font-weight: 700; margin-top: 2px; }
.fcard.in { background: linear-gradient(135deg, #1e56c9, #17357d); }
.fcard.out { background: linear-gradient(135deg, #b4234a, #6e1630); }
.fcard.profit { background: linear-gradient(135deg, #168a4a, #0f5430); }
.fcard.profit.neg { background: linear-gradient(135deg, #8a5a16, #54380f); }
.chart { background: var(--chart-bg); border: 1px solid var(--chart-line); border-radius: 14px; padding: 10px 8px 6px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--grid); stroke-dasharray: 3 4; }
.chart .axis { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .bar-in { fill: #3b82f6; }
.chart .bar-out { fill: #f43f5e; }
.chart .line { fill: none; stroke: #34d399; stroke-width: 2; stroke-linejoin: round; }
.chart .dot { fill: var(--bg); stroke: #34d399; stroke-width: 2; }
.legend { display: flex; gap: 14px; justify-content: center; font-size: 12.5px; color: var(--muted); padding: 6px 0 4px; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hide-money .m { filter: blur(9px); user-select: none; }
.cat { display: inline-block; padding: 2px 9px; border-radius: 99px; background: var(--surface2); border: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.month-h { font-size: 14px; font-weight: 700; color: var(--muted); margin: 16px 0 8px; text-transform: capitalize; display: flex; justify-content: space-between; }

/* ---------- Chips de status ---------- */
.chip { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.chip.paid { background: var(--paid-bg); color: var(--paid); }
.chip.today { background: var(--today-bg); color: var(--today); }
.chip.soon { background: var(--soon-bg); color: var(--soon); }
.chip.late { background: var(--late-bg); color: var(--late); }

/* ---------- Lista de clientes ---------- */
.filters { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.filters .search { grid-column: 1 / -1; }
.filters input, .filters select { margin: 0; }
.count { color: var(--muted); font-size: 14px; margin-bottom: 8px; }

.crow {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  grid-template-areas: "name name status" "server plan value" "due due phone" "actions actions actions";
  gap: 4px 10px; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 12px 12px 16px; margin-bottom: 10px; position: relative; overflow: hidden;
}
.crow::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: #64748b; }
.crow.s-paid::before { background: #22c55e; }
.crow.s-today::before { background: #f5b301; }
.crow.s-soon::before { background: #2f7bff; }
.crow.s-late::before { background: #f43f5e; }
.chead { display: none; }
.c-name { grid-area: name; min-width: 0; }
.c-name .name { background: none; border: 0; padding: 0; font-weight: 700; font-size: 17px; text-align: left; cursor: pointer; color: var(--ink); }
.c-name .note { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.c-status { grid-area: status; justify-self: end; }
.c-server { grid-area: server; color: var(--muted); font-size: 14px; }
.c-plan { grid-area: plan; color: var(--muted); font-size: 14px; }
.c-value { grid-area: value; font-weight: 700; justify-self: end; }
.c-due { grid-area: due; font-size: 14px; }
.c-due small { display: block; color: var(--muted); font-size: 12px; }
.c-phone { grid-area: phone; color: var(--muted); font-size: 14px; justify-self: end; }
.c-actions { grid-area: actions; display: grid; grid-template-columns: 1.55fr 1fr 1fr 1fr; gap: 6px; margin-top: 8px; }
.c-actions .btn { padding: 0 6px; white-space: nowrap; }
.c-server, .c-plan { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lbl { color: var(--muted); }

/* ---------- Histórico ---------- */
.hrow { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.hrow .amt { font-weight: 700; text-align: right; grid-row: span 2; align-self: center; }
.hrow small { color: var(--muted); }
.hrow .name { background: none; border: 0; padding: 0; font-weight: 700; text-align: left; cursor: pointer; font-size: 16px; color: var(--ink); }
.hline { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); gap: 10px; }
.hline:last-child { border-bottom: 0; }
.hline small { color: var(--muted); display: block; }

/* ---------- Ajustes ---------- */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(78px, 1fr); grid-template-columns: none; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 14px; gap: 4px; }
.seg button { min-height: 40px; padding: 0 2px; border: 0; background: transparent; border-radius: 9px; font-weight: 600; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--surface2); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.item { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item .grow { flex: 1; min-width: 0; }
.item small { color: var(--muted); display: block; }
.addrow { display: flex; gap: 8px; margin-top: 10px; }
.addrow input { margin: 0; }
.msg-tools { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px; }
.msg-tools .btn.on { outline: 2px solid var(--primary); }
.panel { background: var(--field); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; max-height: 270px; overflow-y: auto; }
.tagrow { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--hair); }
.tagrow:last-child { border-bottom: 0; }
.tagrow button { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13.5px; font-weight: 600; background: var(--tag-bg); color: var(--tag-ink); border: 0; border-radius: 8px; padding: 6px 9px; cursor: pointer; white-space: nowrap; }
.tagrow span { color: var(--muted); font-size: 14px; }
.emojis { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.emojis button { font-size: 24px; background: var(--surface2); border: 1px solid var(--line); border-radius: 10px; min-height: 46px; cursor: pointer; }
.note-box { background: var(--note-bg); border: 1px solid var(--note-line); border-radius: 12px; padding: 10px 12px; font-size: 13.5px; color: var(--note-ink); margin-bottom: 12px; }

/* ---------- Janela (modal) ---------- */
.overlay { position: fixed; inset: 0; background: rgba(3, 6, 16, .7); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--line); border-radius: 20px 20px 0 0; padding: 0 18px calc(18px + env(safe-area-inset-bottom, 0px));
}
.sheet-h { position: sticky; top: 0; background: var(--surface); display: flex; justify-content: space-between; align-items: center; padding: 16px 0 10px; z-index: 1; }
.sheet-h h2 { font-size: 19px; }
.x { background: var(--surface2); border: 0; width: 38px; height: 38px; border-radius: 50%; font-size: 16px; cursor: pointer; color: var(--ink); }
.sum { background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }

#toasts { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 78px + env(safe-area-inset-bottom, 0px)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--toast-bg); color: var(--toast-ink); padding: 11px 16px; border-radius: 12px; font-size: 15px; font-weight: 500; max-width: 460px; box-shadow: 0 4px 16px rgba(0, 0, 0, .4); }
.toast.err { background: #e11d48; color: #fff; }

.errbox { max-width: 520px; margin: 40px auto; padding: 20px; background: var(--surface); border: 1px solid rgba(251, 113, 133, .5); border-radius: var(--radius); }
.errbox h2 { font-size: 18px; margin-bottom: 8px; }
.errbox p { margin-bottom: 10px; }
.errbox code { display: block; background: var(--field); padding: 8px 10px; border-radius: 8px; font-size: 13px; word-break: break-word; margin-bottom: 12px; }

@media (prefers-reduced-motion: no-preference) {
  .sheet { animation: up .18s ease-out; }
  @keyframes up { from { transform: translateY(24px); opacity: .6; } to { transform: none; opacity: 1; } }
}

/* ---------- Computador / tela grande ---------- */
@media (min-width: 760px) {
  .shell { padding-bottom: 40px; }
  .top { padding-right: 24px; padding-left: 24px; justify-content: flex-start; gap: 28px; }
  .nav { position: static; background: transparent; border: 0; display: flex; gap: 4px; padding: 0; margin-left: auto; backdrop-filter: none; }
  .nav a { flex-direction: row; min-height: 40px; padding: 0 14px; color: var(--muted); border-radius: 10px; font-size: 15px; gap: 8px; }
  .nav a.on { color: var(--ink); background: rgba(47, 123, 255, .18); }
  .nav a svg { width: 20px; height: 20px; }
  .fab { bottom: 24px; right: 24px; }
  #toasts { bottom: 24px; }
  .overlay { align-items: center; }
  .sheet { border-radius: 20px; }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .tile.wide { grid-column: span 2; }
  .fin-cards { grid-template-columns: repeat(3, 1fr); }
  .filters { grid-template-columns: 2fr 1fr 1fr 1fr; }
  .filters .search { grid-column: auto; }
}

/* ---------- Tabela completa (telas largas) ---------- */
@media (min-width: 1280px) {
  main { max-width: 1320px; }
  .crow, .chead {
    grid-template-columns: minmax(130px, 1.3fr) 128px 84px 88px 84px 104px 124px 400px;
    grid-template-areas: none;
    gap: 8px;
  }
  .chead { display: grid; padding: 0 13px 8px 17px; color: var(--muted); font-size: 13px; font-weight: 600; }
  .crow { padding: 10px 12px 10px 16px; }
  .c-name, .c-phone, .c-server, .c-plan, .c-value, .c-due, .c-status, .c-actions { grid-area: auto; justify-self: start; }
  .c-value { white-space: nowrap; }
  .c-phone { font-size: 14px; white-space: nowrap; }
  .c-actions { display: flex; margin: 0; gap: 6px; }
  .c-actions .btn { padding: 0 10px; }
  .c-due .lbl { display: none; }
}

/* ---------- Saídas (despesas) ---------- */
.exp { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; }
.exp .amt { font-weight: 700; text-align: right; }
.exp small { color: var(--muted); }
.exp .acts { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* ---------- Botão de tema ---------- */
.theme-btn { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface2); color: var(--ink); display: inline-grid; place-items: center; cursor: pointer; flex: none; }
.theme-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn .sun { display: none; }
:root[data-theme="light"] .theme-btn .moon { display: none; }
:root[data-theme="light"] .theme-btn .sun { display: inline; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-btn .moon { display: none; }
  :root:not([data-theme]) .theme-btn .sun { display: inline; }
}
@media (min-width: 760px) { .top .theme-btn { margin-left: 4px; } }

.chip.muted { background: var(--surface2); color: var(--muted); }
@media (min-width: 760px) { .seg button { font-size: 14px; } }

.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

/* regras de envio por servidor */
.rule { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin: 10px 0; background: var(--surface2); }
.rule.off { opacity: .65; }
.rule-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.rule-h strong { display: block; } .rule-h small { color: var(--muted); }
.rule-g { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.rule-g > div { border: 1px dashed var(--line); border-radius: 10px; padding: 8px 10px; }
.rule-g .wide { grid-column: 1 / -1; }
.rule-g small { display: block; color: var(--muted); font-size: 12px; } .rule-g b { font-size: 15px; }
.rule .actions { margin-top: 8px; justify-content: flex-start; }
.lbl { font-size: 13px; font-weight: 600; color: var(--muted); margin: 4px 0 6px; }
.wk { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 12px; }
.pill { position: relative; display: block; }
.pill input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pill span { display: block; text-align: center; padding: 10px 0; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; background: var(--surface2); }
.pill input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }
.pill input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
/* contadores do envio */
.cnt3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.cnt3 > div { border: 2px solid var(--line); border-radius: 14px; padding: 10px 6px; text-align: center; }
.cnt3 b { display: block; font-size: 26px; line-height: 1.1; } .cnt3 small { color: var(--muted); font-size: 12px; }
.cnt3 .c-ok { border-color: var(--paid); } .cnt3 .c-q { border-color: var(--soon); } .cnt3 .c-bad { border-color: var(--late); }

ol.steps-list { margin: 0; padding-left: 20px; color: var(--muted); } ol.steps-list li { margin: 6px 0; } ol.steps-list strong { color: var(--text, inherit); }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .9em; background: var(--surface2, rgba(127,127,127,.15)); border-radius: 6px; padding: 1px 6px; }

/* diagnóstico do envio */
.diag-i { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 8px 0; background: var(--surface2, transparent); }
.diag-i span { flex: none; font-size: 18px; line-height: 1.4; } .diag-i p { margin: 0; font-size: 15px; line-height: 1.45; }
.diag-i.bad { border-color: rgba(251,113,133,.6); } .diag-i.warn { border-color: rgba(245,179,1,.6); } .diag-i.ok { border-color: rgba(34,197,94,.5); }

/* revisão dos cadastros */
.card.rv { border-left: 4px solid var(--soon); } .card.rv.bad { border-left-color: var(--late); }
.rv-h { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.rv-i { margin: 4px 0; font-size: 15px; color: var(--muted); } .rv-i span { margin-right: 4px; }
.alert-card { display: block; width: 100%; text-align: left; border: 1px solid rgba(251,113,133,.55); background: rgba(251,113,133,.1); color: inherit; border-radius: 14px; padding: 12px 14px; margin: 0 0 12px; cursor: pointer; font: inherit; }
.alert-card small { display: block; color: var(--muted); margin-top: 2px; }
.seg { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.seg button { white-space: nowrap; }

/* ===== Gestor para venda: revenda, créditos, APIs e WhatsApp ===== */
.nav { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); }
.nav a span { font-size: 11px; }
.bal { text-align: left; }
.bal-n { font-size: 40px; font-weight: 700; line-height: 1.1; }
.bal-l { color: var(--muted); font-size: 14px; }
.uhead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.urow .who { min-width: 0; flex: 1 1 180px; }
.urow .who strong, .lrow strong { display: block; overflow-wrap: anywhere; }
.urow .who small, .lrow small { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.uact { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.lrow { padding: 12px 14px; }
.apis { display: grid; grid-template-columns: 1fr; gap: 12px; }
.api-card { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; margin: 0; }
.api-card .flag { font-size: 64px; line-height: 1.1; }
.api-card small { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.qr-area { display: flex; justify-content: center; margin: 14px 0; min-height: 120px; align-items: center; }
.qr { width: 260px; max-width: 100%; height: auto; background: #fff; padding: 10px; border-radius: 12px; border: 1px solid var(--line); }
.qr-steps { margin: 0 0 0 20px; color: var(--muted); font-size: 14px; display: grid; gap: 4px; }
@media (min-width: 640px) { .apis { grid-template-columns: repeat(3, 1fr); } }
