/* Sistema VetVix — mesma identidade do site: faixa azul-noite, amarelo da marca, Nunito.
   Gráficos: entradas = azul, saídas = laranja (validado para daltonismo e contraste, claro e escuro). */
:root {
  --bg: #F2F5F8; --surface: #FFFFFF; --ink: #1C2B3A; --muted: #56677A; --line: #DCE5EE; --soft: #EBF2F7;
  --night: #12263A; --night-2: #1B3450; --on-night: #EEF4FA; --on-night-muted: #B9CADB;
  --brand: #4A6F87; --on-brand: #FFFFFF; --sun: #E6B440; --sun-soft: #FFF5DC;
  --entra: #2a78d6; --sai: #eb6834; --grade: #E3E8EE; --eixo: #C3CDD8;
  --ok: #1E7A3E; --ok-soft: #DDF3E5; --alerta: #8A5300; --alerta-soft: #FFF1D6; --ruim: #B3261E; --ruim-soft: #FDECEA;
  --f-head: "Nunito", "Segoe UI", system-ui, sans-serif;
  --f-body: "Nunito Sans", "Segoe UI", system-ui, sans-serif;
  --r: 16px;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0E1620; --surface: #17222F; --ink: #E6EDF4; --muted: #A9B9C9; --line: #283748; --soft: #15263A;
  --night: #0A131D; --night-2: #142335; --brand: #8DB5D9; --on-brand: #0E1620; --sun: #E2B84C; --sun-soft: #2A2312;
  --entra: #3987e5; --sai: #d95926; --grade: #223142; --eixo: #33465A;
  --ok: #5FD08A; --ok-soft: #13301F; --alerta: #E8B45C; --alerta-soft: #2E2410; --ruim: #FF8A80; --ruim-soft: #3A1715; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #0E1620; --surface: #17222F; --ink: #E6EDF4; --muted: #A9B9C9; --line: #283748; --soft: #15263A;
  --night: #0A131D; --night-2: #142335; --brand: #8DB5D9; --on-brand: #0E1620; --sun: #E2B84C; --sun-soft: #2A2312;
  --entra: #3987e5; --sai: #d95926; --grade: #223142; --eixo: #33465A;
  --ok: #5FD08A; --ok-soft: #13301F; --alerta: #E8B45C; --alerta-soft: #2E2410; --ruim: #FF8A80; --ruim-soft: #3A1715; color-scheme: dark }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.5; }
h1, h2, h3 { font-family: var(--f-head); line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 900; } h2 { font-size: 1.25rem; font-weight: 900; } h3 { font-size: 1rem; font-weight: 800; }
p { margin: 0; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.pos { color: var(--ok); } .neg { color: var(--ruim); }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; }

/* topo */
.topo { background: var(--night); color: var(--on-night); padding-inline: 16px; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 10; }
.topo-in { max-width: 76rem; margin-inline: auto; display: flex; align-items: center; gap: 8px 18px; flex-wrap: wrap; padding-block: 10px; }
.marca { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--on-night); }
.marca img { height: 34px; width: auto; background: #fff; border-radius: 8px; padding: 3px 6px; }
.marca span { font-family: var(--f-head); font-weight: 900; font-size: 1.05rem; }
.topo nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topo nav a { color: var(--on-night-muted); text-decoration: none; font-family: var(--f-head); font-weight: 800; padding: 7px 12px; border-radius: 10px; }
.topo nav a:hover { color: var(--on-night); }
.topo nav a[aria-current="page"] { background: var(--night-2); color: var(--on-night); }
.conta { display: flex; gap: 12px; align-items: center; color: var(--on-night-muted); font-size: .875rem; margin-left: auto; }
.link { background: none; border: 0; color: var(--on-night); font: inherit; font-weight: 800; cursor: pointer; padding: 6px 4px; }

main { padding-inline: 16px; }
.aba, .carregando { max-width: 76rem; margin-inline: auto; padding-block: 24px 64px; display: grid; gap: 20px; }
.cab { display: flex; justify-content: space-between; align-items: end; gap: 12px; flex-wrap: wrap; }
.cab p { color: var(--muted); }

.cartao { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.grade-2 { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; display: grid; gap: 2px; align-content: start; }
.kpi span { color: var(--muted); font-size: .8125rem; font-weight: 700; }
.kpi b { font-family: var(--f-head); font-size: 1.55rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.kpi small { color: var(--muted); font-size: .8125rem; }
.kpi.atencao { border-color: var(--sun); background: var(--sun-soft); }
.kpi a { font-weight: 800; font-size: .8125rem; }
.previsao { background: var(--night); border: 1px solid var(--line); color: var(--on-night); border-radius: var(--r); padding: 16px 18px; display: flex; gap: 8px 24px; flex-wrap: wrap; align-items: baseline; }
.previsao b { font-family: var(--f-head); font-size: 1.4rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.previsao span { color: var(--on-night-muted); font-size: .875rem; }

/* formulários */
label { font-family: var(--f-head); font-weight: 800; font-size: .875rem; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 2px solid var(--line); border-radius: 10px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus { border-color: var(--brand); outline: none; }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand); }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px 12px; align-items: end; }
.campo { display: grid; gap: 4px; min-width: 0; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.btn { font-family: var(--f-head); font-weight: 800; font-size: .9rem; border: 0; border-radius: 99px; padding: 9px 18px; cursor: pointer; background: var(--soft); color: var(--brand); }
.btn.principal { background: var(--brand); color: var(--on-brand); }
.btn.mini { padding: 5px 12px; font-size: .8125rem; }
.btn:disabled { opacity: .55; cursor: progress; }
.acoes { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.erro { color: var(--ruim); font-weight: 700; }
.ok { color: var(--ok); font-weight: 700; }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.filtros .campo { width: auto; min-width: 150px; }

/* login */
.login { min-height: 70vh; display: grid; place-items: center; padding-block: 40px; }
.form-login { width: min(400px, 100%); }

/* tabelas */
.tabela-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: var(--soft); font-family: var(--f-head); font-weight: 800; font-size: .8125rem; white-space: nowrap; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td.desc { min-width: 220px; }
td.desc small { display: block; color: var(--muted); }
td select { min-width: 190px; padding: 5px 8px; }
tr.anulado td { color: var(--muted); text-decoration: line-through; }
.chip { display: inline-block; font-size: .75rem; font-weight: 800; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.chip.aberta { background: var(--soft); color: var(--brand); }
.chip.vencida { background: var(--ruim-soft); color: var(--ruim); }
.chip.hoje { background: var(--alerta-soft); color: var(--alerta); }
.chip.paga { background: var(--ok-soft); color: var(--ok); }
.chip.manual { background: var(--sun-soft); color: var(--alerta); }
.vazio { color: var(--muted); text-align: center; padding: 24px; }

/* gráficos */
.legenda { display: flex; gap: 16px; flex-wrap: wrap; font-size: .8125rem; color: var(--muted); }
.legenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.grafico { width: 100%; height: auto; display: block; overflow: visible; }
.grafico text { fill: var(--muted); font-family: var(--f-body); font-size: 11px; }
.grafico .gl { stroke: var(--grade); stroke-width: 1; }
.grafico .base { stroke: var(--eixo); stroke-width: 1; }
.grafico .e { fill: var(--entra); } .grafico .s { fill: var(--sai); }
.grafico .alvo { fill: transparent; cursor: default; }
.grafico .alvo:hover + g path, .grafico g.foco path { opacity: 1; }
.grafico g.esmaecido path { opacity: .35; }
.barras-h { display: grid; gap: 8px; }
.barra-h { display: grid; grid-template-columns: minmax(110px, 11rem) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: .875rem; }
.barra-h .trilho { height: 12px; border-radius: 0 4px 4px 0; }
.barra-h .trilho i { display: block; height: 100%; background: var(--sai); border-radius: 0 4px 4px 0; min-width: 2px; }
.barra-h span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dica { position: fixed; z-index: 50; background: var(--night); color: var(--on-night); border-radius: 10px; padding: 8px 12px; font-size: .8125rem; pointer-events: none; box-shadow: 0 10px 24px -10px rgba(0,0,0,.5); font-variant-numeric: tabular-nums; }
.dica b { font-family: var(--f-head); }

/* importar */
.drop { border: 3px dashed var(--line); border-radius: var(--r); padding: 28px 16px; display: grid; gap: 6px; justify-items: center; text-align: center; background: var(--surface); cursor: pointer; }
.drop:hover, .drop.sobre { border-color: var(--brand); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop b { font-family: var(--f-head); font-size: 1.05rem; }
.previa-arq { display: grid; gap: 4px; padding: 12px 14px; border-radius: 12px; background: var(--soft); }

/* regras */
.regras td input, .regras td select { padding: 5px 8px; }
.regras td.mover { white-space: nowrap; }

@media (max-width: 900px) {
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grade-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .cards { grid-template-columns: minmax(0, 1fr); }
  .barra-h { grid-template-columns: minmax(0, 1fr) auto; }
  .barra-h .trilho { grid-column: 1 / -1; grid-row: 2; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* cadastros */
.grade-cad { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.4fr); gap: 16px; align-items: start; }
.lista-cad { display: grid; gap: 6px; max-height: 70vh; overflow-y: auto; }
.item-cad { display: grid; gap: 2px; text-align: left; background: var(--soft); border: 2px solid transparent; border-radius: 12px; padding: 10px 12px; cursor: pointer; font: inherit; color: var(--ink); }
.item-cad:hover, .item-cad:focus-visible { border-color: var(--brand); }
.item-cad .pets { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.form-cad { display: grid; gap: 12px; }
.form-cad.sub { background: var(--soft); border-radius: 12px; padding: 14px; }
.campo.largo { grid-column: 1 / -1; }
.pets-cad { display: grid; gap: 10px; border-top: 1px solid var(--line); padding-top: 14px; }
.pet-cad { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 6px; }
.pet-cad.inativo { opacity: .6; }
.pet-topo { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: start; }
.pet-topo small { display: block; }
.alerta-cad { background: var(--ruim-soft); color: var(--ruim); font-weight: 700; border-radius: 8px; padding: 4px 10px; font-size: .875rem; }
.pesos { font-size: .8125rem; }
.peso-novo { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.peso-novo input { width: 8rem; }
td small.muted { display: block; }
@media (max-width: 900px) { .grade-cad { grid-template-columns: minmax(0, 1fr); } }
