/* Sistema Financeiro — CSS próprio, sem framework, sem build step.
   Hospedagem compartilhada não tem Node. Tudo aqui é servido como está. */

:root {
  --bg:        #f1f5f9;
  --surface:   #ffffff;
  --border:    #e2e8f0;
  --text:      #0f172a;
  --muted:     #64748b;
  --primary:   #2563eb;
  --primary-d: #1d4ed8;

  /* Valor negativo é vermelho, positivo é verde. Sem exceção, sem sutileza. */
  --verde:     #16a34a;
  --vermelho:  #dc2626;
  --amarelo:   #ca8a04;

  --pf:        #0ea5e9;
  --pj:        #8b5cf6;

  --r: 10px;
  --sombra: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ─────────────────────────────────────────── */
.topo {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topo-in {
  max-width: 1240px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 20px; height: 56px;
}
.marca { font-weight: 700; font-size: 16px; color: var(--text); white-space: nowrap; }
.marca:hover { text-decoration: none; }

nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
nav a {
  padding: 7px 12px; border-radius: 7px; color: var(--muted);
  font-weight: 500; white-space: nowrap; font-size: 14px;
}
nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
nav a.on { background: var(--primary); color: #fff; }

/* Seletor PF | PJ | Consolidado — fixo no topo, visível em toda tela */
.escopo { display: flex; background: var(--bg); border-radius: 8px; padding: 3px; }
.escopo a {
  padding: 5px 11px; border-radius: 6px; font-size: 13px; font-weight: 600;
  color: var(--muted);
}
.escopo a:hover { text-decoration: none; color: var(--text); }
.escopo a.on { background: var(--surface); color: var(--text); box-shadow: var(--sombra); }

main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 60px; }

h1 { font-size: 22px; margin-bottom: 4px; }
h2 { font-size: 16px; margin-bottom: 12px; }
.sub { color: var(--muted); font-size: 14px; margin-bottom: 20px; }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 18px; box-shadow: var(--sombra);
}
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.g21 { grid-template-columns: 2fr 1fr; }

.kpi .rot { font-size: 12px; color: var(--muted); text-transform: uppercase;
            letter-spacing: .04em; font-weight: 600; }
.kpi .val { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; }
.kpi .pe  { font-size: 12px; color: var(--muted); margin-top: 2px; }

.verde    { color: var(--verde); }
.vermelho { color: var(--vermelho); }
.amarelo  { color: var(--amarelo); }

/* ── Alertas ────────────────────────────────────────── */
.alerta {
  padding: 12px 16px; border-radius: var(--r); margin-bottom: 12px;
  display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500;
}
.alerta-erro  { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }
.alerta-ok    { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.alerta-aviso { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }

/* ── Tabela ─────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 9px 10px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
  border-bottom: 1px solid var(--border);
}
td { padding: 11px 10px; border-bottom: 1px solid #f1f5f9; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Semáforo — a informação mais importante da tela de contas a pagar.
   Tem que ser lida em meio segundo. */
.sem { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 7px; }
.sem-VERMELHO { background: var(--vermelho); }
.sem-AMARELO  { background: var(--amarelo); }
.sem-VERDE    { background: var(--verde); }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.tag-PF { background: #e0f2fe; color: #0369a1; }
.tag-PJ { background: #ede9fe; color: #6d28d9; }
.tag-PAGO      { background: #dcfce7; color: #166534; }
.tag-PENDENTE  { background: #fef3c7; color: #92400e; }
.tag-ATRASADO  { background: #fee2e2; color: #991b1b; }
.tag-PREVISTO  { background: #f1f5f9; color: #475569; }
.tag-CANCELADO { background: #f1f5f9; color: #94a3b8; }

/* ── Form ───────────────────────────────────────────── */
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: #334155; }
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; font: inherit; font-size: 14px; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.campo { margin-bottom: 14px; }
.linha { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600;
  font-size: 14px; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); text-decoration: none; }
.btn-p { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-p:hover { background: var(--primary-d); }
.btn-v { background: var(--verde); color: #fff; border-color: var(--verde); }
.btn-r { background: var(--vermelho); color: #fff; border-color: var(--vermelho); }
.btn-s { padding: 5px 10px; font-size: 12px; }

/* ── Barra de progresso (orçamento) ─────────────────── */
.barra { height: 7px; background: var(--bg); border-radius: 4px; overflow: hidden; margin-top: 6px; }
.barra span { display: block; height: 100%; border-radius: 4px; background: var(--verde); transition: width .3s; }
.barra span.q  { background: var(--amarelo); }
.barra span.e  { background: var(--vermelho); }

/* ── Vazio ──────────────────────────────────────────── */
.vazio { text-align: center; padding: 44px 20px; color: var(--muted); }
.vazio .ic { font-size: 34px; margin-bottom: 8px; }

.chart { position: relative; height: 240px; }

.flex  { display: flex; align-items: center; gap: 10px; }
.entre { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt    { margin-top: 20px; }
.muted { color: var(--muted); }
.pequeno { font-size: 12px; }
.mono  { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

/* ── Mobile — cenário real, não bônus ────────────────
   Você vai abrir isto no celular depois de receber o Telegram. */
@media (max-width: 900px) {
  .g4, .g3, .g2, .g21 { grid-template-columns: 1fr; }
  .topo-in { height: auto; padding: 10px 12px; flex-wrap: wrap; }
  nav { order: 3; width: 100%; }
  main { padding: 16px 12px 60px; }

  /* Tabela larga vira card empilhado */
  table, thead, tbody, th, td, tr { display: block; }
  thead { display: none; }
  tbody tr {
    border: 1px solid var(--border); border-radius: var(--r);
    margin-bottom: 10px; padding: 10px; background: var(--surface);
  }
  td { border: 0; padding: 5px 0; display: flex; justify-content: space-between; gap: 10px; }
  td::before {
    content: attr(data-r); font-size: 11px; color: var(--muted);
    text-transform: uppercase; font-weight: 600; flex-shrink: 0;
  }
  .num { text-align: right; }
}
