/* Identidade Twol: só preto, grafite, prata e branco. Escuro = painel técnico; claro = cartões brancos arredondados. */
:root {
  --bg: #0B0B0C; --side: transparent; --main: #0E0E0F; --main-line: #1F1F21; --main-pad: 24px;
  --card: #141415; --card-top: #19191A; --card-2: #1A1A1A; --line: #2D2D2D;
  --fg: #F2F2F0; --muted: #8A8A8A;
  --hi: #F2F2F0; --hi-fg: #0B0B0C;
  --feat: #141415; --feat-top: #222223; --feat-fg: #F2F2F0; --feat-muted: #8A8A8A;
  --bar: #4A4A4C; --bar-hi: #F2F2F0;
  --bad: #F0686B; --ok: #5CCB8F;
  --overlay: rgba(0,0,0,.6);
  --nav-bg: #161617; --nav-pill: #2D2D2D; --nav-fg: #F2F2F0; --nav-muted: #8A8A8A;
  --r: 12px; --r-ctl: 8px;
  --f-display: "Michroma", "Eurostile", Arial, sans-serif;
  --f-text: "Inter", "Segoe UI", system-ui, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #E4E4E1; --side: #FFFFFF; --main: transparent; --main-line: transparent; --main-pad: 4px;
  --card: #FFFFFF; --card-top: #FFFFFF; --card-2: #F0F0EE; --line: #E0E0DC;
  --fg: #1A1A1A; --muted: #6B6B6B;
  --hi: #1A1A1A; --hi-fg: #F2F2F0;
  --feat: #1A1A1A; --feat-top: #2D2D2D; --feat-fg: #F2F2F0; --feat-muted: #A3A3A3;
  --bar: #2D2D2D; --bar-hi: #8A8A8A;
  --bad: #C23A3E; --ok: #2E8A57;
  --overlay: rgba(20,20,20,.35);
  --nav-bg: #0B0B0C; --nav-pill: #2D2D2D; --nav-fg: #F2F2F0; --nav-muted: #9A9A9A;
  --r: 22px; --r-ctl: 999px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--fg); font: 14px/1.45 var(--f-text);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.bad { color: var(--bad); }
.ok { color: var(--ok); }
.logo { color: var(--fg); width: 56px; height: auto; display: block; }

/* Botões e campos */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); padding: 8px 14px;
  border-radius: var(--r-ctl); font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--card-2); }
.btn.primary { background: var(--hi); color: var(--hi-fg); border-color: var(--hi); }
.btn.primary:hover { opacity: .88; }
.btn.block { width: 100%; }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.switch { display: flex; align-items: center; background: none; border: 0; padding: 6px; color: var(--muted); }
.switch:hover { color: var(--fg); }
.switch i { position: relative; flex: none; width: 40px; height: 22px; border-radius: 999px; background: var(--line); transition: background .2s; }
.switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .2s; }
.switch[aria-checked="true"] i { background: var(--fg); }
.switch[aria-checked="true"] i::after { transform: translateX(18px); background: var(--bg); }
@media (prefers-reduced-motion: reduce) { .switch i, .switch i::after { transition: none; } }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; color: var(--muted); }
.field input, .field select, .field textarea, .tool, .org {
  width: 100%; border: 1px solid var(--line); background: var(--card-2); border-radius: min(var(--r-ctl), 12px);
  padding: 9px 12px; min-width: 0;
}
.field textarea { min-height: 90px; resize: vertical; }
.field.erro input, .field.erro select { border-color: var(--bad); }
.tool { width: auto; background: var(--card); padding: 8px 12px; }
.inline { display: flex; gap: 8px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--fg); }
.check input { accent-color: var(--fg); width: 16px; height: 16px; }
.err { color: var(--bad); font-size: 13px; margin: 0; }

/* Login */
.login { min-height: calc(100vh - 32px); display: grid; place-items: center; }
.login-card {
  width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px;
  background: linear-gradient(180deg, var(--card-top), var(--card)); border: 1px solid var(--line); border-radius: calc(var(--r) + 4px); padding: 32px 28px;
}
.login-card .logo { width: 72px; margin: 0 auto 8px; }

/* Estrutura: barra de cima (logo · menu em pílula · tema/sair) e o conteúdo embaixo */
.app { max-width: 1320px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.tb-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.tb-left .logo { width: 48px; }
.tb-left .logo.logo-org { width: 104px; }
.org { width: auto; }
.tb-right { display: flex; justify-content: flex-end; align-items: center; gap: 6px; }
.tb-right .logo-twol { width: 40px; margin-left: 10px; }

.pillnav { display: flex; align-items: center; gap: 6px; background: var(--nav-bg); border-radius: 999px; padding: 6px; }
.pillnav nav { display: flex; align-items: center; gap: 2px; }
.pillnav a {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 11px; border-radius: 999px;
  color: var(--nav-muted); text-decoration: none; white-space: nowrap; transition: background .2s, color .2s;
}
.pillnav a:hover { color: var(--nav-fg); }
.pillnav a span { display: none; font-size: 13px; font-weight: 500; }
.pillnav a[aria-current="page"] { background: var(--nav-pill); color: var(--nav-fg); padding: 0 16px 0 12px; }
.pillnav a[aria-current="page"] span { display: inline; }
.pillnav svg, .icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.pillnav a[aria-current="page"] svg { fill: currentColor; fill-opacity: .18; }
.pn-add { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--nav-fg); color: var(--nav-bg); display: grid; place-items: center; margin-left: 4px; }
.pn-add svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.pn-add:hover { opacity: .85; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: none; color: var(--muted); display: grid; place-items: center; }
.icon-btn:hover { color: var(--fg); background: var(--card-2); }

.main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.top h1 { margin: 0; font: 18px/1.2 var(--f-display); letter-spacing: .04em; }
.top-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* Cartões */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px 20px; min-width: 0; }
.card h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card .sub { color: var(--muted); margin: 2px 0 0; font-size: 13px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .value { font-size: 28px; font-weight: 600; letter-spacing: -.01em; line-height: 1.1; }
.kpi .foot { color: var(--muted); font-size: 13px; }
.kpi.feat { background: var(--feat); color: var(--feat-fg); border-color: var(--feat); }
.kpi.feat .label, .kpi.feat .foot { color: var(--feat-muted); }
.empty { color: var(--muted); padding: 20px 4px; text-align: center; margin: 0; }

/* Funil de conversão */
.fun { display: flex; flex-direction: column; gap: 4px; }
.fun-row { display: grid; grid-template-columns: 130px minmax(0, 1fr) 44px; gap: 10px; align-items: center; font-size: 13px; }
.fun-row .trilho { height: 22px; background: var(--card-2); border-radius: 6px; overflow: hidden; }
.fun-row .trilho i { display: block; height: 100%; background: var(--bar); border-radius: 6px; }
.fun-row:last-child .trilho i { background: var(--bar-hi); }
.fun-pass { font-size: 12px; color: var(--muted); padding-left: 140px; }
.fun-pass.pior { color: var(--bad); font-weight: 600; }

/* Barras horizontais (motivos) */
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 130px minmax(0, 1fr) 40px; gap: 10px; align-items: center; font-size: 13px; }
.hbar .trilho { height: 10px; background: var(--card-2); border-radius: 5px; overflow: hidden; }
.hbar .trilho i { display: block; height: 100%; background: var(--fg); border-radius: 5px; }

/* Tabelas */
.table-wrap { overflow-x: auto; margin: 0 -20px -18px; }
table { width: 100%; border-collapse: collapse; }
.wide { min-width: 820px; }
th { text-align: left; font-weight: 500; color: var(--muted); font-size: 13px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--card-2); white-space: nowrap; }
td { padding: 11px 20px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.r { text-align: right; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover td { background: var(--card-2); }
td .sub2 { color: var(--muted); font-size: 12px; }

/* Etapa: a forma do ponto mostra o estado */
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 2px 9px; font-size: 12px; white-space: nowrap; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; }
.chip.meio::before { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.chip.cheio::before { background: currentColor; }
.chip.pago { color: var(--ok); border-color: currentColor; }
.chip.pago::before { background: currentColor; }
.chip.perdido { color: var(--muted); }
.chip.perdido::before { border-style: dotted; }

/* Quadro do funil */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.col { background: var(--card-2); border: 1px solid var(--line); border-radius: var(--r); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-height: 240px; }
.col-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; font-size: 13px; }
.col-head small { color: var(--muted); font-weight: 400; }
.bcard { text-align: left; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: calc(var(--r) * .7); padding: 11px 12px; display: flex; flex-direction: column; gap: 4px; }
.bcard:hover { border-color: var(--muted); }
.bcard .nome { font-weight: 600; }
.bcard .meta { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }

/* Investimento */
.verba-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; align-items: end; }

/* Gaveta */
.overlay { position: fixed; inset: 0; background: var(--overlay); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); z-index: 21;
  background: var(--card); border-left: 1px solid var(--line); display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) 0;
}
.drawer header { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.drawer header h2 { margin: 0; font: 14px var(--f-display); letter-spacing: .06em; }
.drawer .body { overflow-y: auto; padding: 18px 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-content: start; flex: 1; }
.drawer .full { grid-column: 1 / -1; }
.drawer footer { display: flex; gap: 8px; justify-content: space-between; padding: 14px 22px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.drawer footer div { display: flex; gap: 8px; }
.x { background: none; border: 0; color: var(--muted); font-size: 22px; line-height: 1; padding: 4px 8px; }
.hist { list-style: none; margin: 6px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 16px; font-size: 13px; }
.hist li { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed var(--line); padding: 4px 0; }
.hist-title { font-size: 12px; color: var(--muted); }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 30; bottom: max(20px, env(safe-area-inset-bottom));
  background: var(--hi); color: var(--hi-fg); padding: 10px 16px; border-radius: var(--r-ctl); font-weight: 500; max-width: calc(100% - 32px);
}

@media (max-width: 1100px) { .grid4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 960px) { .grid2 { grid-template-columns: minmax(0, 1fr); } }
/* Celular: o menu vira barra fixa embaixo, como app */
@media (max-width: 760px) {
  body { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .topbar { grid-template-columns: 1fr auto; }
  .pillnav { position: fixed; z-index: 15; left: 50%; transform: translateX(-50%); bottom: max(14px, env(safe-area-inset-bottom)); box-shadow: 0 6px 24px rgba(0,0,0,.3); }
}
@media (max-width: 520px) {
  .grid4 { grid-template-columns: minmax(0, 1fr); }
  .drawer .body { grid-template-columns: minmax(0, 1fr); }
  .fun-row, .hbar { grid-template-columns: 100px minmax(0, 1fr) 40px; }
  .fun-pass { padding-left: 110px; }
  .hist { grid-template-columns: minmax(0, 1fr); }
}
