/* ==========================================================================
   Controle Financeiro — sistema visual
   Tokens por papel (light/dark), componentes e layout.
   ========================================================================== */

:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --bg: #f5f5f3;
  --surface: #ffffff;
  --surface-2: #fafaf8;
  --surface-3: #f1f0ec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7a7873;
  --line: #e6e5df;
  --line-strong: #d3d2ca;
  --ring: rgba(42, 120, 214, .35);

  --accent: #1c5cab;
  --accent-hover: #184f95;
  --accent-ink: #ffffff;
  --accent-soft: #eaf1fb;

  /* séries categóricas (ordem fixa) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --s1-track: #cde2fb;

  /* status (sempre com ícone + texto) */
  --good: #0ca30c;      --good-ink: #006300;  --good-soft: #e7f5e7;
  --warn: #fab219;      --warn-ink: #7a5200;  --warn-soft: #fff5dc;
  --serious: #ec835a;   --serious-ink: #9a3d17;
  --crit: #d03b3b;      --crit-ink: #b42323;  --crit-soft: #fdecec;
  --info-soft: #eaf1fb; --info-ink: #1c5cab;

  --grid: #ebeae4;
  --axis: #c3c2b7;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(11, 11, 11, .04), 0 1px 1px rgba(11, 11, 11, .03);
  --shadow-2: 0 10px 30px rgba(11, 11, 11, .10), 0 2px 6px rgba(11, 11, 11, .06);
  --sidebar-w: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #1f1f1d; --surface-3: #262624;
    --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8f8d86; --line: #2c2c2a; --line-strong: #3a3a37;
    --ring: rgba(57, 135, 229, .45);
    --accent: #3987e5; --accent-hover: #5598e7; --accent-ink: #0b0b0b; --accent-soft: #16263b;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
    --s1-track: #1a3352;
    --good-ink: #3cc13c; --good-soft: #142614;
    --warn-ink: #fab219; --warn-soft: #2b2310;
    --serious-ink: #ec835a;
    --crit: #e05252; --crit-ink: #f07b7b; --crit-soft: #2f1616;
    --info-soft: #16263b; --info-ink: #86b6ef;
    --grid: #2a2a28; --axis: #383835;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-2: 0 12px 32px rgba(0, 0, 0, .55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d; --surface: #1a1a19; --surface-2: #1f1f1d; --surface-3: #262624;
  --ink: #f0efec; --ink-2: #c3c2b7; --muted: #8f8d86; --line: #2c2c2a; --line-strong: #3a3a37;
  --ring: rgba(57, 135, 229, .45);
  --accent: #3987e5; --accent-hover: #5598e7; --accent-ink: #0b0b0b; --accent-soft: #16263b;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
  --s5: #d55181; --s6: #0ca30c; --s7: #9085e9; --s8: #e66767;
  --s1-track: #1a3352;
  --good-ink: #3cc13c; --good-soft: #142614;
  --warn-ink: #fab219; --warn-soft: #2b2310;
  --serious-ink: #ec835a;
  --crit: #e05252; --crit-ink: #f07b7b; --crit-soft: #2f1616;
  --info-soft: #16263b; --info-ink: #86b6ef;
  --grid: #2a2a28; --axis: #383835;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-2: 0 12px 32px rgba(0, 0, 0, .55);
}

/* --- Base ---------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.ink-2 { color: var(--ink-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--good-ink); }
.neg { color: var(--crit-ink); }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* --- Layout -------------------------------------------------------------- */
.app {
  display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh;
  /* pinta a coluna da barra lateral até o fim de páginas longas */
  background: linear-gradient(to right, var(--surface) calc(var(--sidebar-w) - 1px), var(--line) calc(var(--sidebar-w) - 1px), var(--line) var(--sidebar-w), transparent var(--sidebar-w));
}
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--ink); color: var(--surface);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; letter-spacing: -.02em;
}
.brand-name { font-weight: 650; font-size: 14px; line-height: 1.2; }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.nav-section { margin-top: 14px; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 10px 6px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav a.ativo { background: var(--accent-soft); color: var(--accent); }
.nav a.ativo .icon { stroke: var(--accent); }
.nav .badge { margin-left: auto; }
.sidebar-foot { margin-top: auto; padding-top: 16px; font-size: 11.5px; color: var(--muted); padding-left: 10px; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px; padding: 12px 28px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; max-width: 1440px; width: 100%; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }

/* --- Cards --------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-1); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 0; }
.card-head .hint { color: var(--muted); font-size: 12px; }
.card-body { padding: 16px 18px 18px; }
.card-body.flush { padding: 8px 0 0; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* --- KPI / stat tiles ------------------------------------------------------ */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.kpi { padding: 16px 18px; }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--ink-2); font-size: 13px; font-weight: 500; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -.02em; margin-top: 6px; white-space: nowrap; }
.kpi-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; color: var(--muted); font-size: 12.5px; }
.kpi-bar { height: 4px; border-radius: 99px; background: var(--surface-3); margin-top: 12px; overflow: hidden; }
.kpi-bar > span { display: block; height: 100%; border-radius: 99px; background: var(--s1); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; font-size: 12px; }
.delta.bom { color: var(--good-ink); }
.delta.ruim { color: var(--crit-ink); }
.delta.neutro { color: var(--muted); }

.hero { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hero-value { font-size: 48px; font-weight: 650; letter-spacing: -.03em; line-height: 1.05; }

/* --- Buttons ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 550; font-size: 13.5px;
  cursor: pointer; white-space: nowrap; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink); }
.btn-danger { color: var(--crit-ink); border-color: color-mix(in srgb, var(--crit) 40%, var(--line)); }
.btn-danger:hover { background: var(--crit-soft); }
.btn-danger-solid { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 8px; }
.btn-icon { width: 36px; padding: 0; }
.btn-sm.btn-icon { width: 30px; }
.btn[disabled] { opacity: .5; pointer-events: none; }
kbd {
  font: 11px/1 var(--font); padding: 2px 5px; border-radius: 4px; border: 1px solid currentColor;
  opacity: .6; margin-left: 4px;
}

/* --- Badges -------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px;
  font-size: 11.5px; font-weight: 600; line-height: 18px; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
}
.badge .icon { width: 12px; height: 12px; }
.badge-ok { background: var(--good-soft); color: var(--good-ink); }
.badge-atencao { background: var(--warn-soft); color: var(--warn-ink); }
.badge-critico { background: var(--crit-soft); color: var(--crit-ink); }
.badge-info { background: var(--info-soft); color: var(--info-ink); }
.badge-count { background: var(--crit); color: #fff; min-width: 18px; justify-content: center; padding: 0 5px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.avatar {
  width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center;
  font-size: 10px; font-weight: 700; color: #fff; flex: none;
}

/* --- Tables -------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 10px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface);
  position: sticky; top: 0;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: var(--surface-2); }
.table tr:last-child td { border-bottom: none; }
.table .num, .table th.num { text-align: right; }
.table tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); border-bottom: none; background: var(--surface-2); }
.table .col-check { width: 36px; padding-right: 0; }
.table .col-acoes { width: 1%; white-space: nowrap; text-align: right; }
.table .desc { font-weight: 550; color: var(--ink); }
.table .sub-desc { color: var(--muted); font-size: 12px; }
.table tr.linha-pago td .desc { color: var(--ink-2); }
.table tr.sub td:first-child { padding-left: 32px; }
.table tr.grupo td { background: var(--surface-2); font-weight: 600; }
.table-compact td, .table-compact th { padding: 7px 10px; }
.cat-dot { display: inline-flex; align-items: center; gap: 8px; }
.cat-dot::before { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--c, var(--muted)); flex: none; }

/* botão de status pago/pendente na tabela */
.status-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px 0 7px;
  border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface);
  font: inherit; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.status-btn .icon { width: 14px; height: 14px; }
.status-btn.pago { background: var(--good-soft); border-color: transparent; color: var(--good-ink); }
.status-btn.atrasado { background: var(--crit-soft); border-color: transparent; color: var(--crit-ink); }
.status-btn:hover { border-color: var(--ink-2); }
.status-btn[disabled] { cursor: default; }
.status-btn[disabled]:hover { border-color: transparent; }

/* --- Forms --------------------------------------------------------------- */
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 14px 16px; }
.field { grid-column: span 6; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field.span-12 { grid-column: span 12; } .field.span-8 { grid-column: span 8; } .field.span-4 { grid-column: span 4; }
.field.span-3 { grid-column: span 3; } .field.span-6 { grid-column: span 6; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12px; color: var(--muted); }
.field .errorlist, .errorlist { list-style: none; margin: 0; padding: 0; color: var(--crit-ink); font-size: 12.5px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--crit); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=month],
input[type=search], select, textarea {
  width: 100%; height: 38px; padding: 0 11px; border-radius: 9px; border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 14px;
  transition: border-color .12s, box-shadow .12s;
}
textarea { height: auto; padding: 9px 11px; resize: vertical; }
select { padding-right: 30px; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 16px, calc(100% - 10px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
input[type=file] { font: inherit; font-size: 13px; color: var(--ink-2); max-width: 100%; }
input[type=file]::file-selector-button {
  font: inherit; font-weight: 550; margin-right: 10px; height: 32px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer;
}
.anexos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.anexo { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface-2); display: flex; flex-direction: column; }
.anexo .thumb { height: 110px; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); }
.anexo .thumb img { width: 100%; height: 100%; object-fit: cover; }
.anexo .info { padding: 8px 10px; font-size: 12px; display: flex; align-items: center; gap: 6px; }
.anexo .info a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); }
.meta-card .valor-grande { font-size: 24px; font-weight: 650; letter-spacing: -.02em; }
.progress-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-top: 6px; }
input[type=color] { width: 56px; height: 38px; padding: 3px; border-radius: 9px; border: 1px solid var(--line-strong); background: var(--surface); }
input[data-money] { font-variant-numeric: tabular-nums; font-weight: 600; }
.input-money { position: relative; }
.input-money::before { content: "R$"; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; pointer-events: none; }
.input-money input { padding-left: 34px; }
.input-lg input[data-money] { height: 48px; font-size: 22px; }
.input-lg.input-money::before { font-size: 15px; }
.check { display: flex; align-items: flex-start; gap: 9px; cursor: pointer; font-weight: 500; color: var(--ink); font-size: 13.5px; }
.check input { width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; padding-top: 6px; }
.form-section { grid-column: span 12; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 6px; border-top: 1px solid var(--line); margin-top: 4px; }
.form-card { max-width: 760px; }

/* segmented control (tipo de lançamento) */
.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 10px; background: var(--surface-3); width: 100%; }
.seg label { flex: 1; position: relative; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 34px; border-radius: 8px;
  font-weight: 600; font-size: 13px; color: var(--ink-2); cursor: pointer; user-select: none;
}
.seg input:checked + span { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg .dot { width: 7px; height: 7px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input, .filters select { height: 34px; font-size: 13px; width: auto; min-width: 150px; }
.filters input[type=search] { min-width: 220px; }

/* --- Month nav ------------------------------------------------------------ */
.month-nav { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 2px; }
.month-nav a { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--ink-2); }
.month-nav a:hover { background: var(--surface-3); text-decoration: none; }
.month-nav .label { min-width: 150px; text-align: center; font-weight: 600; font-size: 13.5px; padding: 0 6px; }
.month-nav .hoje { width: auto; padding: 0 10px; font-size: 12px; font-weight: 600; }

/* --- Meters (orçamento, limites) -------------------------------------------- */
.meter-list { display: flex; flex-direction: column; gap: 14px; }
.meter-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: baseline; }
.meter-row .nome { font-weight: 550; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meter-row .valor { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; white-space: nowrap; }
.meter-row .meter { grid-column: 1 / -1; }
.meter-row .meta { grid-column: 1 / -1; display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); }
.meter { position: relative; height: 8px; border-radius: 99px; background: var(--s1-track); overflow: hidden; }
.meter > span { position: absolute; inset: 0 auto 0 0; border-radius: 99px; background: var(--s1); }
.meter.atencao > span { background: var(--warn); }
.meter.critico > span { background: var(--crit); }
.meter.neutro { background: var(--surface-3); }
.meter.neutro > span { background: var(--s1); }
.meter-thin { height: 6px; }

/* barras ranqueadas (gastos por categoria) */
.rank-list { display: flex; flex-direction: column; gap: 11px; }
.rank { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.rank .nome { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .nome a { color: inherit; }
.rank .barra { height: 18px; position: relative; }
.rank .barra > span { position: absolute; left: 0; top: 0; bottom: 0; background: var(--s1); border-radius: 0 4px 4px 0; min-width: 2px; }
.rank .barra .orc { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-2); border-radius: 1px; }
.rank .valor { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; min-width: 96px; }
.rank .valor small { display: block; font-weight: 500; color: var(--muted); }

/* barra segmentada (perfil de gastos) */
.segbar { display: flex; height: 28px; gap: 2px; border-radius: 6px; overflow: hidden; }
.segbar > span { display: flex; align-items: center; padding: 0 8px; color: #fff; font-size: 12px; font-weight: 650; min-width: 0; white-space: nowrap; overflow: hidden; }
.segbar > span:first-child { border-radius: 4px 0 0 4px; }
.segbar > span:last-child { border-radius: 0 4px 4px 0; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 12.5px; color: var(--ink-2); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }

/* --- Alerts -------------------------------------------------------------- */
.alert-list { display: flex; flex-direction: column; }
.alert-item { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--line); align-items: start; }
.alert-item:first-child { border-top: none; }
.alert-icon { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.alert-icon .icon { width: 16px; height: 16px; }
.alert-item.critico .alert-icon { background: var(--crit-soft); color: var(--crit-ink); }
.alert-item.atencao .alert-icon { background: var(--warn-soft); color: var(--warn-ink); }
.alert-item.info .alert-icon { background: var(--info-soft); color: var(--info-ink); }
.alert-item.ok .alert-icon { background: var(--good-soft); color: var(--good-ink); }
.alert-title { font-weight: 600; }
.alert-text { color: var(--ink-2); font-size: 12.5px; margin-top: 1px; }
.alert-item .btn { margin-top: 1px; }

.banner { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); margin-bottom: 16px; }
.banner.info { background: var(--info-soft); border-color: transparent; color: var(--info-ink); }
.banner.info .btn { margin-left: auto; }
.banner .txt { color: var(--ink); }

/* mensagens (toasts do servidor) */
.messages { position: fixed; right: 20px; bottom: 20px; z-index: 80; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 32px)); }
.toast {
  display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 10px;
  background: var(--ink); color: var(--surface); box-shadow: var(--shadow-2); font-size: 13.5px;
  animation: toast-in .2s ease-out;
}
.toast .icon { margin-top: 1px; }
.toast.success .icon { color: #5fd35f; }
.toast.danger .icon, .toast.error .icon { color: #ff8a8a; }
.toast.warning .icon { color: var(--warn); }
.toast button { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 0; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* --- Dropdown (details) --------------------------------------------------- */
.dropdown { position: relative; }
.dropdown > summary { list-style: none; cursor: pointer; }
.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50; min-width: 240px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-2);
  padding: 6px; overflow: hidden;
}
.dropdown-menu.wide { width: min(420px, calc(100vw - 32px)); padding: 0; }
.dropdown-menu a, .dropdown-menu button.item {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 8px;
  color: var(--ink); background: none; border: 0; font: inherit; text-align: left; cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button.item:hover { background: var(--surface-3); text-decoration: none; }
.dropdown-menu .sep { height: 1px; background: var(--line); margin: 6px 0; }
.dropdown-head { padding: 12px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.dropdown-scroll { max-height: 420px; overflow-y: auto; }
.user-btn { display: flex; align-items: center; gap: 8px; padding: 4px 8px 4px 4px; border-radius: 99px; border: 1px solid var(--line-strong); background: var(--surface); }
.user-btn .avatar { width: 28px; height: 28px; font-size: 11px; }
.user-btn .nome { font-weight: 600; font-size: 13px; }
.bell { position: relative; }
.bell .badge-count { position: absolute; top: -4px; right: -4px; font-size: 10.5px; line-height: 16px; height: 16px; }

/* --- Modal --------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 70; background: rgba(11, 11, 11, .45);
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 16px; overflow-y: auto;
  animation: fade .15s ease-out;
}
.modal { width: min(640px, 100%); background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-2); border: 1px solid var(--line); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 18px 20px 20px; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* --- Empty state / misc --------------------------------------------------- */
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty .icon { width: 32px; height: 32px; margin-bottom: 8px; stroke-width: 1.4; }
.empty h3 { color: var(--ink); margin-bottom: 4px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 12px; color: var(--ink-2); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.ativo { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .badge { margin-left: 6px; }
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-top: 1px solid var(--line); }
.list-item:first-child { border-top: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .titulo { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { font-size: 12px; color: var(--muted); }
.date-box { width: 42px; text-align: center; border-radius: 8px; border: 1px solid var(--line); padding: 3px 0; flex: none; }
.date-box .d { font-weight: 700; font-size: 15px; line-height: 1.1; }
.date-box .m { font-size: 10.5px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.date-box.atrasado { border-color: color-mix(in srgb, var(--crit) 45%, transparent); background: var(--crit-soft); }
.date-box.atrasado .d, .date-box.atrasado .m { color: var(--crit-ink); }

.card-visual {
  border-radius: 14px; padding: 16px; color: #fff; min-height: 120px; display: flex; flex-direction: column; justify-content: space-between;
  background: linear-gradient(135deg, var(--cc, #0b0b0b), color-mix(in srgb, var(--cc, #0b0b0b) 70%, #000));
}
.card-visual .nome { font-weight: 650; font-size: 15px; }
.card-visual .numero { font-variant-numeric: tabular-nums; letter-spacing: .12em; opacity: .85; font-size: 13px; }
.card-visual .row-between { color: rgba(255, 255, 255, .85); font-size: 12px; }

.chart-box { position: relative; height: 260px; }
.card-fill { display: flex; flex-direction: column; }
.card-fill > .card-body { flex: 1; display: flex; flex-direction: column; }
.card-fill .chart-box { flex: 1; height: auto; min-height: 260px; }
.chart-box.sm { height: 200px; }
details.table-toggle summary { cursor: pointer; color: var(--accent); font-size: 12.5px; font-weight: 550; padding: 0 18px 14px; list-style: none; }
details.table-toggle summary::-webkit-details-marker { display: none; }

.bulk-bar {
  position: sticky; bottom: 16px; z-index: 15; margin: 12px auto 0; width: fit-content;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 12px;
  background: var(--ink); color: var(--surface); box-shadow: var(--shadow-2);
}
.bulk-bar .btn { height: 30px; }

.totais-bar { display: flex; gap: 24px; flex-wrap: wrap; padding: 14px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.totais-bar .t { display: flex; flex-direction: column; }
.totais-bar .t span:first-child { font-size: 12px; color: var(--muted); }
.totais-bar .t span:last-child { font-weight: 650; font-variant-numeric: tabular-nums; }

.fab { display: none; }

/* --- Login --------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-side { background: var(--ink); color: var(--surface); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h2 { font-size: 30px; line-height: 1.2; letter-spacing: -.02em; max-width: 440px; font-weight: 600; }
.auth-side p { color: color-mix(in srgb, var(--surface) 70%, transparent); max-width: 420px; font-size: 15px; }
.auth-side .feat { display: flex; gap: 10px; align-items: center; margin-top: 12px; color: color-mix(in srgb, var(--surface) 85%, transparent); }
.auth-main { display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: min(380px, 100%); }
.auth-card h1 { font-size: 24px; margin-bottom: 6px; }

/* --- Responsivo ---------------------------------------------------------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); background: none; }
  .sidebar {
    position: fixed; z-index: 60; left: 0; top: 0; width: 272px; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow-2);
  }
  body.sidebar-aberta .sidebar { transform: none; }
  body.sidebar-aberta::after { content: ""; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 96px; }
  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-side { display: none; }
  .fab {
    display: grid; place-items: center; position: fixed; right: 16px; bottom: 16px; z-index: 40;
    width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); border: 0;
    box-shadow: var(--shadow-2); cursor: pointer;
  }
  .topbar .btn-novo-texto { display: none; }
  .user-btn .nome { display: none; }
  .hide-mobile { display: none !important; }
}
@media (max-width: 640px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .field, .field.span-3, .field.span-4, .field.span-8 { grid-column: span 12; }
  .rank { grid-template-columns: minmax(0, 1fr) auto; }
  .rank .barra { grid-column: 1 / -1; grid-row: 2; height: 10px; }
  .month-nav .label { min-width: 110px; }
  .hero-value { font-size: 40px; }
  .filters input, .filters select, .filters input[type=search] { min-width: 0; flex: 1 1 140px; }
  .page-head h1 { font-size: 20px; }
}

@media print {
  .sidebar, .topbar, .fab, .page-actions, .bulk-bar, .messages { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; break-inside: avoid; }
}
