/* Controle de Importações — barra do app com abas no topo; coluna de conteúdo de até 1280px; tabelas rolam dentro do próprio quadro */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --surface-2: #eceef1;
  --line: #d7dbe1;
  --fg: #1b1f25;
  --muted: #5a626e;
  --accent: #8e2f2c;        /* bordô da VPA */
  --accent-strong: #72231f;
  --accent-soft: #f5e5e4;
  --on-accent: #ffffff;
  --steel: #66778b;         /* "já pago" nos gráficos */
  --ok: #2a774a; --ok-soft: #e1f0e6;
  --warn: #8a5c00; --warn-soft: #fdf1cf;
  --bad: #ad2a20; --bad-soft: #fbe5e2;
  --focus: #2f6fd6;
  --shadow: 0 10px 30px rgb(15 20 30 / .18);
  --font-display: "Bree Serif", Georgia, "Times New Roman", serif;
  --font-ui: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --surface: #191c21; --surface-2: #22262d; --line: #30353e; --fg: #e6e8ec; --muted: #9ca4b0;
    --accent: #e48b85; --accent-strong: #f1a6a1; --accent-soft: #3a2322; --on-accent: #1c0e0d; --steel: #93a5ba;
    --ok: #72c592; --ok-soft: #1b3124; --warn: #e6b851; --warn-soft: #393012; --bad: #f28d84; --bad-soft: #3d1e1b;
    --focus: #7fabff; --shadow: 0 10px 30px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --surface: #191c21; --surface-2: #22262d; --line: #30353e; --fg: #e6e8ec; --muted: #9ca4b0;
  --accent: #e48b85; --accent-strong: #f1a6a1; --accent-soft: #3a2322; --on-accent: #1c0e0d; --steel: #93a5ba;
  --ok: #72c592; --ok-soft: #1b3124; --warn: #e6b851; --warn-soft: #393012; --bad: #f28d84; --bad-soft: #3d1e1b;
  --focus: #7fabff; --shadow: 0 10px 30px rgb(0 0 0 / .5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-ui); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); }
h1, h2, h3 { text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.sem-margem { margin: 0; }
.txt-bad { color: var(--bad); }

/* barra do app */
.appbar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--line); }
.appbar-inner { max-width: 1280px; margin: 0 auto; padding: 10px max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; }
.brand { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-right: auto; }
.brand b { font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; letter-spacing: .01em; }
.brand span { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.bar-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bar-actions .usuario { color: var(--muted); font-size: .84rem; }
.bar-actions a.btn { text-decoration: none; }
nav.tabs { display: flex; gap: 2px; overflow-x: auto; width: 100%; scrollbar-width: none; }
nav.tabs a { padding: 9px 12px 10px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 500; }
nav.tabs a:hover { color: var(--fg); }
nav.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); }

main { max-width: 1280px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right, 0px)) 56px max(16px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 18px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 8px 16px; }
.page-head h1 { font-family: var(--font-display); font-weight: 400; font-size: 1.55rem; margin: 0; }
.page-head p { margin: 2px 0 0; color: var(--muted); max-width: 72ch; }

/* blocos */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel > h2, .panel-head h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.12rem; margin: 0; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 18px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 170px), 1fr)); gap: 12px; }
.kpis.duas { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .lab { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .val { font-size: 1.32rem; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi .sub { font-size: .8rem; color: var(--muted); }
.kpi.hot { border-color: var(--accent); }
.kpi.hot .val { color: var(--accent); }

/* tabelas */
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .86rem; }
th { background: var(--surface-2); text-align: left; font-weight: 600; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; white-space: nowrap; }
td { padding: 8px 10px; border-top: 1px solid var(--line); vertical-align: top; }
td.wrap { min-width: 170px; max-width: 360px; }
td.desp { min-width: 150px; max-width: 210px; }
td.obs { min-width: 240px; max-width: 420px; color: var(--muted); font-size: .8rem; }
td.mega { min-width: 110px; white-space: nowrap; }
td .hint { font-weight: 400; }
.venc-atraso { color: var(--bad); font-weight: 600; }
tr.total td { font-weight: 600; background: var(--surface-2); }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tr.flag td.money-k, tr.flag td.money-g { background: var(--warn-soft); }
.code { font-family: var(--font-display); font-size: 1rem; white-space: nowrap; }
.code.grande { font-size: 1.2rem; }
.code-sm { font-family: ui-monospace, Consolas, monospace; font-size: .8rem; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* marcadores */
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.pill.Pago { background: var(--ok-soft); color: var(--ok); }
.pill.Vencido { background: var(--bad-soft); color: var(--bad); }
.pill.A-pagar { background: var(--accent-soft); color: var(--accent); }
.pill.Parcial, .pill.est { background: var(--warn-soft); color: var(--warn); }
.pill.Sem-pagamento, .pill.neutro { background: var(--surface-2); color: var(--muted); }
.pill.andamento { background: var(--accent-soft); color: var(--accent); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.busca { min-width: min(100%, 280px); }
.meter { width: 70px; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 6px; }
.meter i { display: block; height: 100%; background: var(--steel); }

/* botões e formulários */
.btn { display: inline-block; border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: var(--radius); padding: 7px 13px; cursor: pointer; font-weight: 500; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.small { padding: 3px 9px; font-size: .8rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.linkbtn { border: none; background: none; color: var(--accent); padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 12px 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field.span-2 { grid-column: span 2; }
.field.fim { justify-content: flex-end; }
.field label { font-size: .78rem; color: var(--muted); font-weight: 500; }
.field label .req { color: var(--accent); }
.field label.check, label.check { display: inline-flex; gap: 8px; align-items: center; color: var(--fg); font-size: .86rem; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 9px; min-width: 0; width: 100%; }
input:disabled, select:disabled, textarea:disabled { opacity: .6; }
textarea { min-height: 70px; resize: vertical; }
input[type="checkbox"] { width: auto; }
.hint { font-size: .76rem; color: var(--muted); }
.err { color: var(--bad); font-size: .82rem; min-height: 1em; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin: 0; min-width: 0; }
legend { padding: 0 6px; font-family: var(--font-display); font-size: 1rem; }
.novo { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.novo form { display: flex; flex-direction: column; gap: 14px; }
.preview { position: sticky; top: 96px; }
.preview h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.12rem; margin: 0; }
@media (max-width: 900px) { .novo { grid-template-columns: minmax(0, 1fr); } .preview { position: static; } }
@media (max-width: 520px) { .field.span-2 { grid-column: auto; } }

/* ficha do processo */
.ficha-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.ficha-head h1 { font-family: var(--font-display); font-weight: 400; font-size: 1.6rem; margin: 0; }
.ficha-head .titulo { font-size: 1.05rem; color: var(--muted); }
.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr)); gap: 0 28px; margin: 0; }
.dl.uma-coluna { grid-template-columns: minmax(0, 1fr); }
.dl > div { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.dl dt { color: var(--muted); font-size: .8rem; }
.dl dd { margin: 0; overflow-wrap: anywhere; }
.dl .destaque dd { font-weight: 600; }
@media (max-width: 520px) { .dl > div { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
ul.notas { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
ul.notas li { max-width: 110ch; }
.est-box { background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; font-size: .86rem; }

/* gráficos */
svg.chart { width: 100%; height: auto; display: block; }
.chart .bar-apagar { fill: var(--accent); }
.chart .bar-vencido { fill: var(--bad); }
.chart .bar-pago { fill: var(--steel); }
.chart .axis-line { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 3 4; }
.chart text { fill: var(--muted); font-family: var(--font-ui); font-size: 11px; }
.chart .bar-val { fill: var(--fg); font-weight: 600; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.legend i.leg-vencido { background: var(--bad); }
.legend i.leg-apagar { background: var(--accent); }
.legend i.leg-pago { background: var(--steel); }

/* janela de edição e avisos */
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgb(10 12 16 / .5); display: flex; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 24px 16px; }
.modal { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); width: min(780px, 100%); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal h2 { font-family: var(--font-display); font-weight: 400; font-size: 1.2rem; margin: 0; }
.modal-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; }
.modal-foot .right { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
#toast { position: fixed; left: 50%; bottom: max(18px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60; background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-weight: 500; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.notice { border: 1px solid var(--line); border-left: 4px solid var(--warn); background: var(--warn-soft); color: var(--fg); padding: 10px 12px; border-radius: var(--radius); }
.loading { padding: 48px 16px; text-align: center; color: var(--muted); }
@media (prefers-reduced-motion: no-preference) { .kpi, .panel { transition: border-color .15s; } }

/* login e erro */
.entrar-fundo { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.entrar-cartao { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); width: min(400px, 100%); padding: 24px; display: flex; flex-direction: column; gap: 14px; }
.entrar-cartao form { display: flex; flex-direction: column; gap: 12px; }
.entrar-cartao h1 { font-family: var(--font-display); font-weight: 400; font-size: 1.4rem; margin: 0; }

/* erro do circuito do Blazor */
#blazor-error-ui { display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70; background: var(--warn-soft); color: var(--fg); padding: 10px 16px; border-top: 1px solid var(--line); }
#blazor-error-ui .reload { margin-left: 8px; }
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 16px; top: 8px; }
