/* ==========================================================================
   Coord. Patrimônio – Colégio Vita
   Índice: 1 Tema · 2 Base · 3 Cabeçalho e navegação · 4 Cartões e formulários
           5 Listas e tabelas · 6 Gráficos · 7 Telas específicas · 8 Impressão
   ========================================================================== */

/* ---------- 1. Tema (claro, escuro automático e escuro manual) ---------- */
:root {
  --bg: #f3eefa; --card: #fff; --ink: #22123a; --mute: #6c5a86; --line: #ddd0ee;
  --pri: #5B2D8E; --lime: #8DC63F; --acc: #5B2D8E; --hl: #e6f5c8; --on: #5B2D8E; --onink: #fff;
  --grid: rgba(91, 45, 142, .07);
  /* Paleta dos gráficos */
  --c1: #5B2D8E; --c2: #6aa626; --c3: #2e86ab; --c4: #e0a21b; --c5: #c0392b; --c6: #1abc9c; --c7: #e67e22; --c8: #7f8c8d;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #140826; --card: #211038; --ink: #f2ebfc; --mute: #a893c6; --line: #3a2461; --acc: #8DC63F; --hl: #2c4312;
    --on: #8DC63F; --onink: #1a0a2e; --grid: rgba(141, 198, 63, .07);
    --c1: #b08ce6; --c2: #8DC63F; --c3: #5dade2; --c4: #f4c542; --c5: #ec7063; --c6: #48c9b0; --c7: #eb984e; --c8: #aab7b8;
  }
}
:root[data-theme="dark"] {
  --bg: #140826; --card: #211038; --ink: #f2ebfc; --mute: #a893c6; --line: #3a2461; --acc: #8DC63F; --hl: #2c4312;
  --on: #8DC63F; --onink: #1a0a2e; --grid: rgba(141, 198, 63, .07);
  --c1: #b08ce6; --c2: #8DC63F; --c3: #5dade2; --c4: #f4c542; --c5: #ec7063; --c6: #48c9b0; --c7: #eb984e; --c8: #aab7b8;
}

/* ---------- 2. Base ---------- */
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; color: var(--ink);
  background: var(--bg) linear-gradient(var(--grid) 1px, transparent 1px) 0 0/28px 28px, linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0/28px 28px;
  font: 15px/1.4 "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 760px; margin: 0 auto; padding: 16px 14px 40px; }
h2 { margin: 0 0 12px; font-size: 18px; font-weight: 700; color: var(--acc); }
h3 { margin: 14px 0 8px; font-size: 14px; color: var(--mute); text-transform: uppercase; letter-spacing: .06em; }
.muted { color: var(--mute); }
.small { font-size: 12px; margin: 4px 0 0; }
.r { text-align: right; }
.lnk { color: var(--acc); font-weight: 600; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }

/* ---------- 3. Cabeçalho e navegação ---------- */
.hero { background: linear-gradient(135deg, #3b1a63, #5B2D8E); color: #fff; padding: 18px 16px 14px; }
.hero > div { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 14px; }
.hero h1 { margin: 0; font-size: 24px; font-weight: 700; }
.hero p { margin: 2px 0 0; color: #d9c8f2; font-size: 13px; }
.hero b { color: var(--lime); }
nav { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--card); border-bottom: 2px solid var(--lime); }
nav div { max-width: 760px; margin: 0 auto; display: flex; overflow-x: auto; scrollbar-width: none; }
nav div::-webkit-scrollbar { display: none; }
nav button {
  all: unset; box-sizing: border-box; flex: 1 0 76px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 2px; font-size: 11px; font-weight: 600; color: var(--mute); cursor: pointer; min-height: 54px; text-align: center;
}
nav button[aria-current=true] { color: var(--acc); box-shadow: inset 0 -3px 0 var(--lime); }
nav button:focus-visible { outline: 3px solid var(--lime); outline-offset: -3px; }
nav svg { width: 22px; height: 22px; }

/* ---------- 4. Cartões, botões e formulários ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: 0 0 0 1px rgba(141, 198, 63, .08); }
.card.flush { padding: 0; overflow: hidden; }
.card.latest { border-color: var(--lime); }
label, .q { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 5px; color: var(--mute); }
input, select { width: 100%; font: inherit; color: var(--ink); background: var(--bg); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 46px; }
textarea { width: 100%; min-height: 80px; font: 12px ui-monospace, monospace; background: var(--bg); color: var(--ink); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px; margin-top: 8px; }
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.g2 > div { min-width: 0; }
.row-add { display: flex; gap: 8px; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip, .sp { font: inherit; font-weight: 600; min-height: 44px; padding: 8px 13px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; }
.chip[aria-pressed=true] { background: var(--on); border-color: var(--on); color: var(--onink); }
.btn { display: inline-flex; align-items: center; justify-content: center; font: inherit; font-weight: 700; min-height: 48px; padding: 10px 18px; border-radius: 10px; border: 0; background: var(--lime); color: #1d0b33; cursor: pointer; width: 100%; margin-top: 14px; text-decoration: none; }
.btn.s { width: auto; min-height: 40px; margin: 0; padding: 6px 14px; }
.btn.ghost { background: var(--bg); color: var(--ink); border: 1.5px solid var(--line); }
.btn.dark { background: var(--pri); color: #fff; }
.btn.file { cursor: pointer; margin-top: 0; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-row .btn.s { flex: 1 1 auto; }
.x { all: unset; cursor: pointer; color: var(--mute); padding: 8px; font-size: 18px; }
.x:focus-visible { outline: 3px solid var(--lime); }
.back { all: unset; cursor: pointer; color: var(--acc); font-weight: 700; padding: 8px 0; display: inline-block; }
.back:focus-visible { outline: 3px solid var(--lime); }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--lime); color: #1d0b33; font-weight: 700; padding: 10px 18px; border-radius: 10px; display: none; z-index: 9; max-width: 90vw; text-align: center; }
details { margin-top: 8px; }
summary { cursor: pointer; color: var(--mute); }

/* ---------- 5. Listas, indicadores e tabelas ---------- */
.it { border-top: 1px solid var(--line); padding: 11px 0; display: flex; gap: 10px; justify-content: space-between; align-items: flex-start; }
.it:first-of-type { border-top: 0; }
.it b { font-weight: 700; }
.it small { display: block; color: var(--mute); }
.v { font-family: ui-monospace, Menlo, monospace; font-weight: 700; white-space: nowrap; }
.tag { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 6px; padding: 2px 7px; background: var(--on); color: var(--onink); margin-right: 4px; }
.tag.s0 { background: #c0392b; color: #fff; }
.tag.s1 { background: #f0b429; color: #1d0b33; }
.tag.s2 { background: var(--lime); color: #1d0b33; }
.btn-tag { border: 0; cursor: pointer; font: inherit; font-size: 11px; font-weight: 700; }
.best { background: var(--hl); border-radius: 8px; padding: 8px; border: 1.5px solid var(--lime); }
.qr { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px; border-radius: 8px; margin-top: 6px; border: 1.5px solid transparent; }
.qr.total { border-top: 2px solid var(--line); border-radius: 0; margin-top: 10px; }
.kp { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.kp.one { grid-template-columns: 1fr; margin-top: 10px; }
.kp div { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px; text-align: center; min-width: 0; }
.kp b { display: block; font-size: 17px; font-family: ui-monospace, Menlo, monospace; color: var(--acc); overflow-wrap: anywhere; }
.kp small { color: var(--mute); font-size: 11px; }
.bar { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; align-items: center; margin: 7px 0; font-size: 13px; }
.bar i { display: block; height: 14px; border-radius: 7px; background: linear-gradient(90deg, var(--pri), var(--lime)); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; }
.sp { text-align: left; min-height: 56px; }
.sp small { display: block; color: var(--mute); font-weight: 400; }
.sp.has { border-color: var(--lime); }
.tw { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 13px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); }
th { color: var(--mute); font-size: 11px; text-transform: uppercase; }
table.pt { min-width: 760px; }
.pt th { background: var(--lime); color: #1d0b33; text-align: center; font-weight: 700; border: 1px solid #1d0b33; padding: 8px 6px; }
.pt td { text-align: center; border: 1px solid var(--line); padding: 8px 6px; font-size: 13px; }
.best-cell { color: var(--acc); }
.ptt { text-align: center; font-weight: 700; font-size: 20px; padding: 14px 10px; text-transform: uppercase; }
.ptb { background: var(--pri); color: #fff; text-align: center; font-weight: 700; padding: 6px; letter-spacing: .04em; }
.ptf { display: flex; justify-content: space-between; padding: 10px 14px; color: var(--mute); font-weight: 600; }
.dt-in { width: 150px; }

/* ---------- 6. Gráficos ---------- */
.chart { width: 100%; height: auto; display: block; margin: 8px 0; overflow: visible; }
.chart .gl { stroke: var(--line); stroke-width: 1; }
.chart .ax { fill: var(--mute); font-size: 9px; }
.chart .vl { fill: var(--ink); font-size: 9px; font-weight: 700; }
.chart .band { fill: var(--lime); opacity: .2; }
.lg { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--mute); margin: 4px 0 8px; }
.lg i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; flex: none; }
.donut { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 8px 0; }
.donut svg { width: 140px; height: 140px; flex: none; }
.donut .dc { fill: var(--ink); font-size: 15px; font-weight: 700; }
.donut .ax { font-size: 9px; }
.lg.list { flex-direction: column; flex: 1; min-width: 180px; list-style: none; padding: 0; margin: 0; gap: 6px; }
.lg.list li { display: flex; align-items: center; gap: 6px; }
.lg.list b { margin-left: auto; color: var(--ink); font-weight: 600; text-align: right; }

/* ---------- 7. Telas específicas ---------- */
/* Gráficos: acontecimentos do dia */
.day-nav { display: flex; gap: 8px; align-items: center; }
.day-nav input { flex: 1; }
.timeline { margin-top: 8px; }
.tl { display: grid; grid-template-columns: 48px 24px 1fr; gap: 6px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.tl .tm { color: var(--mute); font-family: ui-monospace, Menlo, monospace; font-size: 12px; padding-top: 2px; }
/* Livros: transferência de aluno */
.move { background: var(--bg); border: 1.5px dashed var(--lime); border-radius: 10px; padding: 10px; margin: 0 0 8px; }
/* Piscina */
.fixed { font-weight: 700; font-size: 18px; color: var(--acc); }
.warn { color: #c0392b; font-size: 12px; font-weight: 600; margin: 6px 0 0; min-height: 0; }
.warn:empty { display: none; }
.prod { margin-bottom: 10px; }
.prod .chip.main { width: 100%; text-align: left; font-weight: 700; min-height: 52px; }
.qty { margin: 10px 0 4px; }
.qty .q { margin: 0 0 8px; }
.foto-btn { display: flex; align-items: center; justify-content: center; min-height: 52px; border-radius: 12px; border: 1.5px dashed var(--acc); color: var(--acc); font-weight: 700; cursor: pointer; }
#pi_prev { display: block; width: 100%; max-height: 260px; object-fit: cover; border-radius: 12px; margin-top: 10px; }
.rm, .reset { all: unset; display: block; margin: 8px auto 0; color: var(--mute); text-decoration: underline; cursor: pointer; padding: 10px; }
.rm:focus-visible, .reset:focus-visible { outline: 3px solid var(--lime); }
pre { white-space: pre-wrap; word-wrap: break-word; font-family: inherit; font-size: 15px; line-height: 1.5; background: var(--bg); border: 1.5px dashed var(--line); border-radius: 12px; padding: 14px; margin: 0 0 12px; }
.act { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.act .btn { margin-top: 0; color: #fff; }
.act .wide { grid-column: 1 / -1; }
.b1 { background: #1c9d57; }
.b2 { background: #07687a; }

@media (max-width: 380px) {
  .g2 { grid-template-columns: 1fr; }
  .kp b { font-size: 15px; }
}

/* ---------- 8. Impressão ---------- */
@media print {
  :root { --bg: #fff; --card: #fff; --ink: #000; --mute: #333; --line: #999; --acc: #5B2D8E; --hl: #e6f5c8; }
  body.printing { background: #fff !important; }
  body.printing input[type=date] { border: 0; background: none; padding: 0; min-height: 0; }
  body.printing .hero, body.printing nav, body.printing .noprint, body.printing .toast, body.printing .back, body.printing .x, body.printing .btn { display: none !important; }
  body.printing main > *:not(.pa) { display: none !important; }
  body.printing main { max-width: none; padding: 0; }
  body.printing .pa { display: block; margin: 0; }
  body.printing section.pa { border: 0; box-shadow: none; padding: 0; }
  body.printing .pa::before { content: "Colégio Vita – Coord. Patrimônio · " attr(data-d); display: block; font-weight: 700; color: #5B2D8E; margin-bottom: 10px; }
  body.printing * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.printing .tw { overflow: visible; }
  body.printing table.pt { min-width: 0; width: 100%; font-size: 10px; }
  body.printing tr { break-inside: avoid; }
  body.printing thead { display: table-header-group; }
}

/* ---------- 9. Nuvem (faixa de status, login e conta) ---------- */
.syncbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 6px 14px; font-size: 12px; background: var(--card); border-bottom: 1px solid var(--line); color: var(--mute); }
.syncbar[hidden] { display: none; }
.syncbar button { all: unset; cursor: pointer; color: var(--acc); font-weight: 700; padding: 6px 4px; }
.syncbar button:focus-visible { outline: 3px solid var(--lime); }
.syncbar.s-erro, .syncbar.s-offline { color: #b9770e; }
.syncbar.s-erro { color: #c0392b; }
.syncbar.s-ok { color: var(--mute); }
.overlay { position: fixed; inset: 0; z-index: 20; overflow: auto; padding: calc(24px + env(safe-area-inset-top, 0px)) 16px 24px; background: var(--bg); }
.overlay[hidden] { display: none; }
.auth-card { max-width: 420px; margin: 8vh auto 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
@media print { .syncbar, .overlay { display: none !important; } }

/* ---------- 10. Estoque, auditório e selos ---------- */
nav button { position: relative; }
.nb { position: absolute; top: 4px; right: calc(50% - 22px); min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #c0392b; color: #fff; font: 700 10px/16px "Space Grotesk", sans-serif; font-style: normal; text-align: center; }
.cal { margin: 10px 0; }
.cal-h, .cal-b { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-h span { text-align: center; font-size: 11px; font-weight: 700; color: var(--mute); padding: 2px 0; }
.cal-d { position: relative; font: inherit; font-weight: 600; min-height: 44px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer; padding: 4px 0 10px; }
.cal-d.today { border-color: var(--acc); }
.cal-d.sel { background: var(--on); border-color: var(--on); color: var(--onink); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin: 0 1px; }
.dot.ok { background: var(--c2); }
.dot.wait { background: var(--c4); }
.cal-d .dot { position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%); }
.cal-d .dot + .dot { transform: translateX(2px); }
.qr-box { max-width: 280px; margin: 10px auto; background: #fff; padding: 8px; border-radius: 12px; border: 1px solid var(--line); }
.qr-box svg { display: block; width: 100%; height: auto; }
.it .btn.s { margin: 2px 0; }
@media print { body.printing .qr-box { max-width: 420px; border: 0; } }
