/* AUTOFINIX — estilos do MVP (sem build, sem dependências externas). Identidade visual provisória. */
:root {
  --bg: #f5f7f6; --surface: #ffffff; --surface-2: #eef2f0; --border: #dbe2de; --text: #17211c; --muted: #5d6b64;
  --brand: #0f6b4f; --brand-strong: #0a5038; --brand-soft: #e3f2ec;
  --pos: #137a4b; --neg: #b42318; --warn: #a15c07; --warn-soft: #fff4e5; --neg-soft: #fdecea; --info-soft: #e8f0fb; --info: #1d4f91;
  --radius: 10px; --shadow: 0 1px 2px rgba(16, 24, 20, .06), 0 1px 1px rgba(16, 24, 20, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --surface: #161d1a; --surface-2: #1d2622; --border: #2a3530; --text: #e6ece9; --muted: #9aa8a1;
    --brand: #3fb488; --brand-strong: #64c9a1; --brand-soft: #173329;
    --pos: #4cc38a; --neg: #f27a6c; --warn: #f0b35a; --warn-soft: #2c2214; --neg-soft: #2e1714; --info-soft: #14233a; --info: #8db4ea;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--pos); } .neg { color: var(--neg); }

/* Estrutura */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .04em; color: var(--text); margin: 0 6px 16px; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 14px; }
.nav a { display: block; padding: 7px 10px; border-radius: 8px; color: var(--text); margin-bottom: 2px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.nav .group { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 10px 4px; }
.main { padding: 22px 28px 60px; min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.org-switch { display: flex; gap: 8px; align-items: center; }
.menu-toggle, .menu-btn, .btn.menu-btn { display: none; }
.env-banner { background: var(--warn-soft); color: var(--warn); font-size: .8rem; text-align: center; padding: 4px 8px; border-bottom: 1px solid var(--border); }

/* Cartões e grade */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); min-width: 0; }
.card + .card { margin-top: 14px; }
.grid > .card + .card { margin-top: 0; }
.kpi .label { color: var(--muted); font-size: .82rem; }
.kpi .value { font-size: 1.35rem; font-weight: 700; margin-top: 2px; }
.kpi .hint { font-size: .78rem; color: var(--muted); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }

/* Tabelas */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; }
tr:last-child td { border-bottom: 0; }
.empty { color: var(--muted); text-align: center; padding: 22px 8px; }

/* Etiquetas */
.tag { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.tag.ok { background: var(--brand-soft); color: var(--brand-strong); }
.tag.bad { background: var(--neg-soft); color: var(--neg); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.info { background: var(--info-soft); color: var(--info); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 0; }

/* Formulários */
form.inline { display: inline; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; align-items: end; }
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-height: 38px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; margin-right: 6px; }
.check { display: flex; align-items: center; gap: 4px; color: var(--text); font-size: .9rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; border-radius: 8px; padding: 8px 14px; min-height: 38px;
  border: 1px solid var(--brand); background: var(--brand); color: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--brand-strong); text-decoration: none; }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--surface); color: var(--neg); border-color: var(--border); }
.btn.small { padding: 4px 10px; min-height: 30px; font-size: .82rem; }
.btn.link { background: none; border: 0; color: var(--brand); padding: 0; min-height: 0; font-weight: 500; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg a { padding: 6px 12px; color: var(--text); border-right: 1px solid var(--border); }
.seg a:last-child { border-right: 0; }
.seg a.active { background: var(--brand-soft); color: var(--brand-strong); font-weight: 600; }
.error-text { color: var(--neg); font-size: .8rem; margin-top: 3px; }
details summary { cursor: pointer; color: var(--brand); font-weight: 600; }
details[open] summary { margin-bottom: 10px; }

/* Avisos */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; border: 1px solid var(--border); }
.flash.ok { background: var(--brand-soft); color: var(--brand-strong); }
.flash.error { background: var(--neg-soft); color: var(--neg); }
.flash.info { background: var(--info-soft); color: var(--info); }

/* Barras simples (relatórios) */
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr 110px; gap: 10px; align-items: center; font-size: .88rem; }
.bar-track { background: var(--surface-2); border-radius: 6px; height: 12px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--brand); }
.flow-chart { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; align-items: end; height: 180px; padding-top: 10px; border-bottom: 1px solid var(--border); }
.flow-col { display: flex; gap: 3px; align-items: flex-end; justify-content: center; height: 100%; }
.flow-col span { width: 14px; border-radius: 4px 4px 0 0; }
.flow-col .in { background: var(--pos); } .flow-col .out { background: var(--neg); opacity: .8; }
.flow-labels { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; font-size: .75rem; color: var(--muted); text-align: center; margin-top: 4px; }
.legend { display: flex; gap: 14px; font-size: .8rem; color: var(--muted); margin-top: 8px; }

/* Calendário */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal .dow { font-size: .72rem; color: var(--muted); text-transform: uppercase; text-align: center; }
.cal .day { min-height: 92px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 5px 6px; font-size: .78rem; min-width: 0; }
.cal .day.out { background: transparent; border-style: dashed; }
.cal .day.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal .dnum { font-weight: 700; font-size: .8rem; margin-bottom: 3px; }
.cal .item { display: block; border-radius: 5px; padding: 1px 5px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: var(--surface-2); color: var(--text); }
.cal .item.income { border-left: 3px solid var(--pos); }
.cal .item.expense { border-left: 3px solid var(--neg); }
.cal .item.paid { opacity: .55; text-decoration: line-through; }
.cal .item.overdue { background: var(--neg-soft); }

/* Autenticação */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth { width: 100%; max-width: 440px; }
.auth.wide { max-width: 780px; }
.legal h3 { margin-top: 1.1rem; } .legal li { margin-bottom: .3rem; }
.auth .card { padding: 24px; }
.auth .brand { justify-content: center; font-size: 1.15rem; margin-bottom: 18px; }
.stack > * + * { margin-top: 12px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; font-size: .88rem; word-break: break-all; }

@media (max-width: 1000px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 20; transform: translateX(-102%); transition: transform .2s; height: 100vh; box-shadow: 0 0 40px rgba(0,0,0,.25); }
  .menu-toggle:checked ~ .shell .side { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .main { padding: 14px 16px 50px; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .g4.kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: 96px 1fr 88px; }
  .cal { grid-template-columns: 1fr; }
  .cal .dow, .cal .day.out, .cal .day.empty-day { display: none; }
  .cal .day { min-height: 0; }
  .hide-sm { display: none; }
}
