/* Visual do painel: menu lateral escuro com grupos, barra superior clara e
   cartões de borda fina. Claro por padrão; o botão da lua troca para escuro. */
/* ───── paleta (claro) ─────
   Cores tiradas do logo PixelPlay: neon #00ff08, verde #2c8702, verde escuro #0b5707.
   Cada cor tem nome pelo papel; confira o contraste com `node dev/check-colors.js`. */
:root {
  /* superfícies e texto */
  --bg: #ebf5e8;
  --surface: #ffffff;
  --surface-2: #dbefd7;
  --border: rgba(11, 87, 7, .22);
  --border-soft: rgba(11, 87, 7, .11);
  --text: #0c1a0f;
  --muted: #506353;
  /* marca: botão principal · texto sobre ele · texto/ícone verde sobre fundo claro · fundo suave · anel de foco */
  --accent: #2c8702;
  --accent-text: #ffffff;
  --accent-ink: #0b5707;
  --accent-soft: #e0f6da;
  --focus: #2c8702;
  /* menu lateral e tela de entrada (sempre escuros, por causa do logo) */
  --side: #051a04;
  --side-text: #a9beae;
  --side-strong: #ffffff;
  --side-hover: #122a1a;
  --side-on: #00ff08;
  --side-on-text: #07150c;
  /* situações */
  --ok: #006e48;      --ok-bg: #dbf7e8;
  --warn: #8f4e00;    --warn-bg: #ffefb3;
  --bad: #9b0c1d;     --bad-bg: #ffdddd;
  --idle: #374a5d;    --idle-bg: #dfe9f4;
  --danger: #c81a4f;  --danger-text: #ffffff;
  --online: #00aa10;
  /* tons 1 a 6 dos ícones do dashboard (fundo suave + traço); de 1 a 4 também botão cheio + texto sobre ele */
  --t1: #2c8702;  --t1-on: #ffffff;  --t1-bg: #e0f6da;  --t1-ink: #2c8702;
  --t2: #0b5707;  --t2-on: #ffffff;  --t2-bg: #cfedcc;  --t2-ink: #0b5707;
  --t3: #e1ee37;  --t3-on: #2a2100;  --t3-bg: #fff4c9;  --t3-ink: #7d7b00;
  --t4: #07150c;  --t4-on: #00ff08;  --t4-bg: #e4eae6;  --t4-ink: #1f3327;
  --t5-bg: #ffdddd;   --t5-ink: #c81a4f;
  --t6-bg: #d1f3f4;   --t6-ink: #007b80;
}
/* ───── paleta (escuro) ───── */
:root[data-theme="dark"] {
  --bg: #060f09;
  --surface: #0f1c13;
  --surface-2: #1a2a1f;
  --border: rgba(140, 255, 160, .14);
  --border-soft: rgba(140, 255, 160, .09);
  --text: #e3efe5;
  --muted: #a2b6a7;
  --accent: #2c8702;
  --accent-text: #ffffff;
  --accent-ink: #79e475;
  --accent-soft: #153314;
  --focus: #00ff08;
  --side: #030905;
  --side-text: #a3b8a8;
  --side-strong: #ffffff;
  --side-hover: #0f2016;
  --side-on: #00ff08;
  --side-on-text: #030905;
  --ok: #66e8be;      --ok-bg: #0b3223;
  --warn: #eeae33;    --warn-bg: #3a2b07;
  --bad: #ff8484;     --bad-bg: #4c171a;
  --idle: #9eb4ca;    --idle-bg: #242e37;
  --danger: #c81a4f;  --danger-text: #ffffff;
  --online: #00ff08;
  --t1: #2c8702;  --t1-on: #ffffff;  --t1-bg: #153314;  --t1-ink: #79e475;
  --t2: #0b5707;  --t2-on: #ffffff;  --t2-bg: #102e0f;  --t2-ink: #3fbd4c;
  --t3: #e1ee37;  --t3-on: #2a2100;  --t3-bg: #342e0d;  --t3-ink: #e1ee37;
  --t4: #e3efe5;  --t4-on: #07150c;  --t4-bg: #232f25;  --t4-ink: #d6ebdb;
  --t5-bg: #4c171a;   --t5-ink: #ff7085;
  --t6-bg: #073234;   --t6-ink: #4dd4db;
}
/* --chart: preenchimento das barras dos gráficos (conferido com o validador de cores de gráfico nos dois temas). */
:root { --radius: 12px; --shadow: 0 1px 2px rgba(0, 0, 0, .05); --chart: #2c8702; color-scheme: light; }
:root[data-theme="dark"] { --shadow: none; --chart: #45b542; color-scheme: dark; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.ico { width: 18px; height: 18px; flex: none; }

/* ───── estrutura ───── */
.shell { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  border-right: 1px solid var(--side-hover);
}
.brand { height: 57px; display: flex; align-items: center; justify-content: center; flex: none; }
.brand-logo { height: 34px; width: auto; display: block; }
.nav { display: grid; gap: 4px; padding: 26px 12px 20px; }
.nav-item, .nav-group, .nav-sub {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px; min-height: 36px; border-radius: 6px; border: 0; background: none;
  color: inherit; text-decoration: none; text-align: left; cursor: pointer; font-size: 14px;
}
.nav-item:hover, .nav-sub:hover, .nav-group:hover { color: var(--side-strong); background: var(--side-hover); }
.nav-item.on, .nav-sub.on { background: var(--side-on); color: var(--side-on-text); font-weight: 600; }
.side :focus-visible { outline-color: var(--side-on); }
.nav-group { margin-top: 6px; text-transform: uppercase; font-size: 12.5px; letter-spacing: .04em; }
.nav-group .chev { margin-left: auto; width: 15px; height: 15px; transition: transform .15s; }
.nav-group[aria-expanded="false"] .chev { transform: rotate(-90deg); }
.nav-group-body { display: grid; gap: 2px; padding: 4px 0 6px; }
.nav-sub { padding-left: 36px; }
.nav-sub:disabled { opacity: .5; cursor: default; }

.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 57px; flex: none; display: flex; align-items: center; justify-content: flex-end; gap: 6px;
  padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--border-soft);
  position: sticky; top: 0; z-index: 20;
}
.icon-btn.menu-btn { display: none; }
.topbar-brand { display: none; margin-right: auto; }
.topbar-brand img { width: 30px; height: 30px; display: block; }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 999px; border: 0; background: none; cursor: pointer; color: var(--text); }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: .35; cursor: default; background: none; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; flex: none; text-transform: uppercase; }
.avatar.big { width: 58px; height: 58px; font-size: 22px; }
.user-menu { position: relative; }
.user-menu summary { list-style: none; display: flex; align-items: center; gap: 10px; cursor: pointer; padding: 4px 6px 4px 8px; border-radius: 10px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--surface-2); }
.user-meta { display: grid; line-height: 1.2; text-align: left; }
.user-meta b { font-weight: 500; }
.user-meta small { color: var(--muted); font-size: 12px; }
.menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; padding: 6px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, .16); display: grid; gap: 2px; }
.menu button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--surface-2); }

.main { padding: 22px 22px 48px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 18px; font-weight: 650; }
.page-head p { color: var(--muted); margin-top: 2px; font-size: 13px; }

/* ───── peças ───── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card.pad { padding: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-head p { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.card-tools { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-bottom: 10px; }
.card-tools input { max-width: 220px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { background: var(--surface-2); border-radius: 999px; padding: 3px 11px; font-size: 13px; white-space: nowrap; }
.chip.warn { background: var(--warn-bg); color: var(--warn); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 13px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--text);
}
.btn .ico { width: 15px; height: 15px; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover, .btn[class*="fill-"]:hover { filter: brightness(1.08); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: var(--danger-text); }
.btn.fill-1 { background: var(--t1); border-color: var(--t1); color: var(--t1-on); }
.btn.fill-2 { background: var(--t2); border-color: var(--t2); color: var(--t2-on); }
.btn.fill-3 { background: var(--t3); border-color: var(--t3); color: var(--t3-on); }
.btn.fill-4 { background: var(--t4); border-color: var(--t4); color: var(--t4-on); }
.btn.small { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--accent-ink); padding: 0 6px; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.ghost.bad { color: var(--bad); }
.btn.ghost.bad:hover { background: var(--bad-bg); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

input[type=text], input[type=password], input[type=number], input[type=search], input[type=date], select, textarea {
  height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); width: 100%;
}
textarea { height: auto; padding: 8px 10px; resize: vertical; min-height: 64px; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
input[type=search] { background: var(--surface-2); border-color: transparent; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); }

.toolbar { display: flex; gap: 10px; padding: 14px 16px 12px; flex-wrap: wrap; align-items: center; }
.toolbar .grow { flex: 1 1 220px; max-width: 320px; }
.toolbar select { width: auto; min-width: 170px; }

.table-wrap { overflow-x: auto; padding: 0 16px 6px; }
.card > div > .table-wrap:first-child, .card > .table-wrap:first-child { padding-top: 16px; }
.toolbar + div > .table-wrap:first-child { padding-top: 0; }
.card.pad .table-wrap { padding: 0; }
table { border-collapse: separate; border-spacing: 0; width: 100%; }
th, td { text-align: left; padding: 11px 12px; vertical-align: middle; white-space: nowrap; }
th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); text-transform: uppercase; letter-spacing: .02em; }
th:first-child { border-radius: 8px 0 0 8px; }
th:last-child { border-radius: 0 8px 8px 0; }
td { border-bottom: 1px solid var(--border-soft); }
tbody tr:last-child td { border-bottom: 0; }
td.wrap { white-space: normal; min-width: 150px; max-width: 280px; }
td.right, th.right { text-align: right; }
/* Título de coluna comprido: quebra em duas linhas quando a tabela aperta, em vez de criar rolagem lateral. */
th.two-line { white-space: normal; min-width: 104px; line-height: 1.25; }
td.actions { text-align: right; }
/* Ações da linha: lado a lado em tela larga; em grade compacta nas demais, para a linha não estourar. */
.row-actions { display: inline-grid; grid-auto-flow: column; gap: 2px; }
/* As ações ficam presas à direita: em tela estreita a tabela rola por baixo delas. */
td.actions, table:has(td.actions) th:last-child { position: sticky; right: 0; }
td.actions { background: var(--surface); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty.small { padding: 26px 12px; }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty .btn { margin-top: 10px; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 16px 14px; color: var(--muted); font-size: 13px; }
.pager { display: flex; gap: 6px; }

.badge { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 500; background: var(--idle-bg); color: var(--idle); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.user-cell { display: flex; align-items: center; gap: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); flex: none; }
.dot.on { background: var(--online); box-shadow: 0 0 0 3px color-mix(in srgb, var(--online) 22%, transparent); }
.sub { display: block; color: var(--muted); font-size: 12px; }
.sub.alert { color: var(--bad); font-weight: 500; }

/* ───── dashboard ───── */
/* Colunas fixas por largura, para os blocos nunca sobrarem sozinhos numa linha (6 → 3 → 2; 4 → 2). */
.stats { --cols: 4; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.stats.six { --cols: 6; }
.stats.three { --cols: 3; }
.stat { display: flex; align-items: center; gap: 12px; padding: 12px 14px; min-height: 76px; }
.stat-ico { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--t1-bg); color: var(--t1-ink); }
.stat-ico.t2 { background: var(--t2-bg); color: var(--t2-ink); }
.stat-ico.t3 { background: var(--t3-bg); color: var(--t3-ink); }
.stat-ico.t4 { background: var(--t4-bg); color: var(--t4-ink); }
.stat-ico.t5 { background: var(--t5-bg); color: var(--t5-ink); }
.stat-ico.t6 { background: var(--t6-bg); color: var(--t6-ink); }
.stat > div { min-width: 0; }
button.stat { width: 100%; text-align: left; cursor: pointer; }
button.stat:hover { border-color: var(--accent); }
.stat.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.stats .wide { grid-column: 1 / -1; }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { font-size: 22px; font-weight: 650; line-height: 1.2; }

.dash-row { display: grid; grid-template-columns: minmax(320px, 480px) 1fr; gap: 12px; align-items: start; margin-bottom: 20px; }
.profile { padding: 18px; }
.profile-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.profile-id { display: grid; line-height: 1.3; }
.profile-id b { font-size: 16px; font-weight: 600; }
.profile-actions { flex: 1 1 230px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.profile-actions .btn { height: 30px; font-size: 12px; font-weight: 600; padding: 0 10px; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border-soft); margin-bottom: 4px; flex-wrap: wrap; }
.tab { border: 0; background: none; padding: 8px 10px; margin-bottom: -1px; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }
.tab.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 500; }
.tab-count { background: var(--surface-2); border-radius: 999px; padding: 0 7px; font-size: 11.5px; }
.exp-row { display: flex; align-items: center; gap: 14px; padding: 10px 2px; border-bottom: 1px solid var(--border-soft); }
.exp-row:last-child { border-bottom: 0; }
.exp-row > :first-child { flex: 1; min-width: 0; }
.exp-row .when { text-align: right; }
.exp-actions { display: flex; align-items: center; gap: 4px; }

.banner { padding: 12px 14px; border-radius: var(--radius); background: var(--warn-bg); color: var(--warn); margin-bottom: 16px; font-weight: 500; }
.banner.bad { background: var(--bad-bg); color: var(--bad); }
.cost-input { width: 84px !important; }
.name-input { min-width: 150px; }
.delta-pos { color: var(--ok); font-weight: 600; }
.delta-neg { color: var(--bad); font-weight: 600; }

/* ───── financeiro ───── */
.head-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.month-nav { display: inline-flex; align-items: center; gap: 2px; }
.month-nav b { min-width: 128px; text-align: center; font-weight: 600; }
.ico.left { transform: rotate(90deg); }
.ico.right { transform: rotate(-90deg); }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
/* Legenda de cada fileira de cartões: o mês (com as setas) e "Agora". */
.stats-caption { display: flex; align-items: center; min-height: 36px; margin-bottom: 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.stats-caption .month-nav { margin-left: -8px; color: var(--text); }
.stats.money { margin-bottom: 14px; }
.card-tabs { padding: 8px 16px 0; margin-bottom: 0; }
.badge.tag { gap: 5px; }
.badge.tag .ico { width: 13px; height: 13px; }
.note { color: var(--muted); font-size: 12.5px; margin-top: 10px; }
.note:empty { display: none; }
/* Trecho que recebe o foco só para o teclado não voltar ao topo da página depois de um redesenho. */
[tabindex="-1"]:focus { outline: none; }
/* Escolha entre duas opções dentro de um diálogo (para quem é a fatura, tipo de cobrança). */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; padding: 3px; background: var(--surface-2); border-radius: 9px; }
.seg button { min-height: 30px; padding: 4px 6px; line-height: 1.2; border: 0; border-radius: 7px; background: none; cursor: pointer; font-size: 13px; color: var(--muted); }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
.suggest { display: grid; gap: 2px; margin-top: 4px; padding: 4px; max-height: 196px; overflow-y: auto; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.suggest button { display: flex; align-items: baseline; gap: 10px; padding: 6px 8px; border: 0; border-radius: 6px; background: none; text-align: left; cursor: pointer; font-size: 13px; }
.suggest button:hover, .suggest button:focus-visible { background: var(--surface-2); }
/* A frase que diz o que vai acontecer ao salvar a fatura. */
.summary { padding: 10px 12px; border-radius: 9px; background: var(--surface-2); font-size: 13px; }
/* Bloco "Cobrança" dos diálogos que entregam plano ou créditos. */
.charge { display: grid; gap: 14px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
/* Aviso de fatura pendente esperando o pagamento, com a escolha de quem está lançando. */
.banner.guard { display: grid; gap: 10px; font-weight: 400; }
.banner-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.amount { font-size: 28px; font-weight: 700; line-height: 1.15; }
.detail { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; margin: 14px 0 0; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.price-row { display: grid; grid-template-columns: 1fr 120px; gap: 10px; align-items: center; }
.price-row + .price-row { margin-top: 8px; }
.price-row input { text-align: right; }

/* ───── analytics ───── */
.section { margin-bottom: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; align-items: start; }
.hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 18px 40px; padding: 20px; margin-bottom: 12px; }
.hero-value { font-size: 48px; font-weight: 700; line-height: 1.08; letter-spacing: -.01em; margin: 2px 0 4px; }
.hero-side { display: grid; gap: 9px; min-width: min(300px, 100%); }
.kv { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.delta { font-weight: 600; }
.delta.up { color: var(--ok); }
.delta.down { color: var(--bad); }
.rank-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 8px 0; }
.rank-name { min-width: 0; overflow-wrap: anywhere; }
.rank-track { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--t1-bg); overflow: hidden; }
.rank-fill { display: block; height: 100%; border-radius: 999px; background: var(--chart); }
/* Gráfico: marcas finas, grade discreta; o texto usa as cores de texto, nunca a cor da série. */
.chart { position: relative; min-height: 230px; }
.chart svg { display: block; }
.chart .grid { stroke: var(--border-soft); stroke-width: 1; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .value { fill: var(--text); font-size: 11.5px; font-weight: 600; }
.chart .bar { fill: var(--chart); transition: opacity .12s; }
.chart .hit { fill: transparent; }
.chart .col { outline: none; }
.chart svg:has(.col:hover) .bar, .chart svg:has(.col:focus-visible) .bar { opacity: .45; }
.chart svg .col:hover .bar, .chart svg .col:focus-visible .bar { opacity: 1; }
.chart .col:focus-visible .hit { stroke: var(--focus); stroke-width: 2; }
.chart-tip { position: absolute; transform: translate(-50%, -100%); pointer-events: none; white-space: nowrap; z-index: 2; padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 20px rgba(0, 0, 0, .18); font-size: 12.5px; color: var(--muted); }
.chart-tip b { display: block; color: var(--text); font-size: 14px; }
.chart-table { margin-top: 8px; }
.chart-table summary { cursor: pointer; color: var(--muted); font-size: 12.5px; width: fit-content; }
.chart-table .table-wrap { margin-top: 8px; }

/* ───── login ───── */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 24px; background: var(--side); }
.auth-logo { width: 148px; height: auto; display: block; }
.auth-card { width: 100%; max-width: 380px; padding: 28px; }
.auth-card h1 { font-size: 20px; }
.auth-card > p { color: var(--muted); margin: 4px 0 20px; }

/* ───── formulários e diálogos ───── */
.form { display: grid; gap: 14px; }
.field label, .field-label { display: block; font-weight: 500; margin-bottom: 5px; font-size: 13px; }
.field-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-row > .field { min-width: 0; }
.form .banner { margin-bottom: 0; }
.field .hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
/* pre-line: o erro pode ganhar uma segunda linha (ex.: como o cliente ficou no CMS). */
.form-error { color: var(--bad); background: var(--bad-bg); padding: 9px 11px; border-radius: 8px; font-weight: 500; white-space: pre-line; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
dialog { border: 1px solid var(--border); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(440px, calc(100vw - 32px)); box-shadow: 0 24px 60px rgba(0, 0, 0, .28); }
dialog.wide { width: min(720px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(10, 13, 20, .5); }
.dlg-head { padding: 18px 20px 0; }
.dlg-head h2 { font-size: 17px; font-weight: 650; }
.dlg-head p { color: var(--muted); margin-top: 4px; }
.dlg-body { padding: 16px 20px 20px; }
.dlg-body .table-wrap { padding: 0; }
.access { background: var(--surface-2); border-radius: 10px; padding: 12px 14px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
.access dt { color: var(--muted); }
.access dd { margin: 0; font-weight: 600; }
/* Mensagem pronta (a que vai para o cliente, ou o exemplo de um layout): só leitura, texto como foi escrito. */
textarea.msg { display: block; width: 100%; background: var(--surface-2); border-color: transparent; resize: none; white-space: pre-wrap; overflow-wrap: anywhere; }
textarea.layout-text { display: block; width: 100%; }
.field .hint.bad { color: var(--bad); font-weight: 500; }
.offscreen { position: fixed; top: 0; left: 0; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; opacity: 0; }
.grid-2.layouts, .grid-2.layout-edit { margin-bottom: 0; }
.grid-2.layouts { gap: 20px; }
.layout-block { display: grid; gap: 8px; min-width: 0; }
.layout-block h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.layout-tools { display: grid; gap: 8px; margin-top: 12px; }
.layout-tools .note { margin-top: 0; }
.scroll-y { max-height: 52vh; overflow-y: auto; }

#toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 50; }
.toast { background: var(--side); color: var(--side-strong); border: 1px solid var(--side-hover); padding: 10px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: 360px; font-weight: 500; }
:root[data-theme="dark"] .toast { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.toast.bad, :root[data-theme="dark"] .toast.bad { background: var(--danger); color: var(--danger-text); border-color: transparent; }

@media (max-width: 1480px) {
  .stats.six { --cols: 3; }
  .row-actions { grid-auto-flow: row; grid-template-columns: repeat(2, auto); }
  .row-actions:has(> :nth-child(5)) { grid-template-columns: repeat(3, auto); }
  /* Faturas: "Confirmar pagamento" e "Detalhes" ficam um sobre o outro, e as sete colunas cabem sem rolar de lado. */
  table.stack .row-actions { grid-template-columns: auto; justify-items: end; }
}
@media (max-width: 1000px) {
  .dash-row { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .stats, .stats.three { --cols: 2; }
  .stats.six { --cols: 3; }
  /* Cartões de dinheiro: três lado a lado não cabem ao lado do menu. O primeiro ocupa a linha, os outros dois dividem a de baixo; sem ícone, o valor cabe inteiro. */
  .stats.three.money > :first-child { grid-column: 1 / -1; }
  .stats.money .stat-ico { display: none; }
  .stats.money .stat-value { font-size: clamp(16px, 4.6vw, 22px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Lista do Financeiro em tela estreita: as sete colunas não cabem ao lado do menu, então cada fatura vira um bloco (quem · valor / o quê · situação / data · método / ações). */
  table.stack, table.stack tbody { display: block; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  table.stack tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td { display: block; position: static; padding: 0; border: 0; white-space: normal; }
  table.stack td:nth-child(3) { order: 1; }
  table.stack td:nth-child(5) { order: 2; font-weight: 600; }
  table.stack td:nth-child(2) { order: 3; }
  table.stack td:nth-child(4) { order: 4; text-align: right; }
  table.stack td:nth-child(1) { order: 5; color: var(--muted); font-size: 12px; }
  table.stack td:nth-child(6) { order: 6; text-align: right; font-size: 12px; }
  table.stack td:nth-child(7) { order: 7; grid-column: 1 / -1; }
  table.stack .row-actions { grid-template-columns: repeat(2, auto); justify-items: normal; }
  /* Recargas compradas (revenda): créditos · valor / data · situação / método. */
  table.stack.bought td:nth-child(2) { order: 1; }
  table.stack.bought td:nth-child(4) { order: 2; font-weight: 600; }
  table.stack.bought td:nth-child(1) { order: 3; }
  table.stack.bought td:nth-child(3) { order: 4; text-align: right; }
  table.stack.bought td:nth-child(5) { order: 5; grid-column: 1 / -1; font-weight: 400; font-size: 12px; color: var(--muted); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 256px; z-index: 40; transform: translateX(-100%); transition: transform .18s ease-out; }
  .shell.nav-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .45); }
  .icon-btn.menu-btn { display: grid; }
  .topbar-brand { display: block; }
  .topbar { padding: 0 12px; }
  .main { padding: 16px 12px 40px; }
  .user-meta { display: none; }
  .stats, .stats.six, .stats.three { --cols: 2; }
  .hide-sm { display: none; }
  /* No celular os pares de campos ficam um embaixo do outro: o nome do plano não cabe em meia largura. */
  .field-row { grid-template-columns: minmax(0, 1fr); }
  .hero-value { font-size: 38px; }
  .page-head { align-items: flex-start; }
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(6px); opacity: 0; } }
}
