/* EscolaOn — protótipo da vitrine. Tokens copiados de templates/base.html. */
:root {
  --blue-primary: #2563eb; --blue-dark: #0f2d6b; --blue-700: #1d4ed8;
  --blue-50: #eff6ff; --blue-100: #dbeafe; --blue-200: #bfdbfe;
  --bg: #f1f5f9; --white: #ffffff;
  --gray-50: #f9fafb; --gray-100: #f3f4f6; --gray-200: #e5e7eb; --gray-300: #d1d5db;
  --gray-400: #9ca3af; --gray-500: #6b7280; --gray-600: #4b5563; --gray-700: #374151; --gray-800: #1f2937;
  --green-100: #dcfce7; --green-700: #15803d; --red-100: #fee2e2; --red-700: #b91c1c;
  --yellow-100: #fef9c3; --yellow-700: #a16207; --teal-100: #ccfbf1; --teal-700: #0f766e;
  --sidebar-w: 224px;
  --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-xl: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05); --shadow-md: 0 2px 8px rgba(0,0,0,.08); --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Inter', system-ui, sans-serif; font-size: 14px; background: var(--bg); color: var(--gray-800); -webkit-font-smoothing: antialiased; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--blue-primary); text-decoration: none; }
svg { flex-shrink: 0; }

/* ---------- Estrutura ---------- */
body { display: flex; flex-direction: column; height: 100vh; }
.demo-bar { flex-shrink: 0; background: #0b1f4d; color: rgba(255,255,255,.8); font-size: 12px; line-height: 1.45; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 7px 16px; }
.demo-bar .txt-pc { max-width: 860px; }
.demo-bar .txt-cel { display: none; }
.demo-bar strong { color: #fff; font-weight: 600; }
.demo-bar button { flex-shrink: 0; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); color: #fff; border-radius: var(--radius-sm); padding: 3px 9px; font-size: 11px; cursor: pointer; white-space: nowrap; }
.demo-bar button:hover { background: rgba(255,255,255,.22); }
.shell { display: flex; flex: 1; min-height: 0; }
.sidebar { width: var(--sidebar-w); background: var(--blue-dark); display: flex; flex-direction: column; flex-shrink: 0; }
.brand { display: flex; align-items: center; gap: 9px; padding: 18px 16px 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand-icon { width: 30px; height: 30px; background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.2); border-radius: 6px; display: grid; place-items: center; }
.brand-text { font-weight: 700; color: #fff; letter-spacing: .5px; }
.escola-nome { padding: 10px 16px; font-size: 11px; color: rgba(255,255,255,.55); border-bottom: 1px solid rgba(255,255,255,.07); }
.escola-nome b { display: block; color: #fff; font-size: 12px; font-weight: 600; margin-top: 2px; }
.nav { flex: 1; overflow-y: auto; padding: 6px 8px; }
.nav-group { font-size: 10px; font-weight: 600; letter-spacing: .8px; text-transform: uppercase; color: rgba(255,255,255,.35); padding: 14px 8px 6px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: var(--radius-md); color: rgba(255,255,255,.65); font-size: 13px; cursor: pointer; transition: background .13s, color .13s; }
.nav-item svg { width: 16px; height: 16px; }
.nav-item:hover { background: rgba(255,255,255,.08); color: rgba(255,255,255,.95); }
.nav-item.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; }
.nav-badge { margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; line-height: 18px; text-align: center; }
.nav-item.lock { color: rgba(255,255,255,.42); font-size: 12px; padding: 6px 8px 6px 10px; gap: 7px; white-space: nowrap; letter-spacing: -.1px; }
.nav-item.lock:hover { color: rgba(255,255,255,.8); }
.nav-item.lock .cad { margin-left: auto; width: 13px; height: 13px; opacity: .7; }
.modal .aviso-txt { color: var(--gray-600); font-size: 13.5px; line-height: 1.55; margin-top: 10px; }
.modal .aviso-cad { width: 40px; height: 40px; border-radius: 50%; background: var(--blue-50); color: var(--blue-primary); display: grid; place-items: center; margin: 0 auto 12px; }
.modal .aviso-rod { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--gray-100); font-size: 12.5px; color: var(--blue-dark); font-weight: 600; }
.side-user { display: flex; align-items: center; gap: 9px; padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--blue-primary); border: 2px solid rgba(255,255,255,.2); display: grid; place-items: center; font-size: 11px; font-weight: 700; color: #fff; }
.side-user .n { font-size: 12px; font-weight: 600; color: #fff; }
.side-user .r { font-size: 10px; color: rgba(255,255,255,.45); }

.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 52px; background: var(--white); border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; gap: 10px; padding: 0 20px; box-shadow: var(--shadow-sm); flex-shrink: 0; }
.topbar h1 { font-size: 15px; font-weight: 600; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.chip-year { background: var(--blue-50); color: var(--blue-primary); font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; border: 1px solid var(--blue-200); }
.menu-btn { display: none; background: var(--gray-100); border: 0; border-radius: var(--radius-md); width: 34px; height: 34px; place-items: center; cursor: pointer; color: var(--gray-600); }
.main { flex: 1; overflow-y: auto; padding: 20px; }
.main-inner { max-width: 1180px; margin: 0 auto; }

/* ---------- Componentes ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head h2 { font-size: 20px; font-weight: 700; color: var(--gray-800); }
.page-head p { color: var(--gray-500); font-size: 13px; margin-top: 2px; }
.card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--gray-100); }
.card-h h3 { font-size: 14px; font-weight: 600; }
.card-b { padding: 16px; }
.grid { display: grid; gap: 14px; }
.kpis { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.kpi { padding: 16px; }
.kpi .l { font-size: 12px; color: var(--gray-500); font-weight: 500; }
.kpi .v { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.3px; }
.kpi .s { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.kpi .v.red { color: var(--red-700); }
.kpi .v.green { color: var(--green-700); }
.two { grid-template-columns: 1.3fr 1fr; }

.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: var(--radius-md); border: 1px solid var(--gray-300); background: var(--white); color: var(--gray-700); font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; transition: background .13s, border-color .13s; }
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--blue-primary); border-color: var(--blue-primary); color: #fff; }
.btn-primary:hover { background: var(--blue-700); border-color: var(--blue-700); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .4px; }
.field select, .field input { height: 34px; border: 1px solid var(--gray-300); border-radius: var(--radius-md); padding: 0 10px; background: var(--white); min-width: 150px; }
.field select:focus, .field input:focus { outline: 2px solid var(--blue-200); border-color: var(--blue-primary); }

.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { text-align: left; font-size: 11px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .4px; padding: 10px 12px; background: var(--gray-50); border-bottom: 1px solid var(--gray-200); white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: center; }
.tbl .money { text-align: right; white-space: nowrap; }
.muted { color: var(--gray-500); }
.small { font-size: 12px; }

.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; white-space: nowrap; }
.b-green { background: var(--green-100); color: var(--green-700); }
.b-red { background: var(--red-100); color: var(--red-700); }
.b-yellow { background: var(--yellow-100); color: var(--yellow-700); }
.b-blue { background: var(--blue-100); color: var(--blue-700); }
.b-gray { background: var(--gray-100); color: var(--gray-600); }

.nota-input { width: 64px; height: 32px; text-align: center; border: 1px solid var(--gray-300); border-radius: var(--radius-md); font-weight: 600; background: var(--white); }
.nota-input:focus { outline: 2px solid var(--blue-200); border-color: var(--blue-primary); }
.nota-input.vazia { background: var(--yellow-100); border-color: #fde68a; }
.nota-input.baixa { color: var(--red-700); }
.nota-input.salvo { border-color: var(--green-700); box-shadow: 0 0 0 2px var(--green-100); }
.nota-input.erro { border-color: var(--red-700); box-shadow: 0 0 0 2px var(--red-100); }
.n-baixa { color: var(--red-700); font-weight: 600; }

.bar { height: 8px; background: var(--gray-100); border-radius: 4px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--blue-primary); border-radius: 4px; }
.bar.ok > span { background: var(--green-700); }
.prog-row { display: grid; grid-template-columns: 90px 1fr 46px; gap: 10px; align-items: center; padding: 7px 0; font-size: 13px; }

.atalhos { grid-template-columns: repeat(2, 1fr); }
.atalho { display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); color: var(--gray-700); font-weight: 500; cursor: pointer; background: var(--white); transition: border-color .13s, background .13s; }
.atalho:hover { border-color: var(--blue-200); background: var(--blue-50); }
.atalho .ic { width: 32px; height: 32px; border-radius: 8px; background: var(--blue-50); color: var(--blue-primary); display: grid; place-items: center; }
.atalho .ic svg { width: 17px; height: 17px; }

.turma-cards { grid-template-columns: repeat(3, 1fr); }
.turma-card { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.turma-card h4 { font-size: 16px; font-weight: 700; }

.doc-tipos { grid-template-columns: repeat(4, 1fr); margin-bottom: 14px; }
.doc-tipo { padding: 14px; cursor: pointer; border: 2px solid var(--gray-200); transition: border-color .13s; display: flex; gap: 10px; align-items: flex-start; }
.doc-tipo:hover { border-color: var(--blue-200); }
.doc-tipo.on { border-color: var(--blue-primary); background: var(--blue-50); }
.doc-tipo .t { font-weight: 600; font-size: 13px; }
.doc-tipo .d { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.doc-tipo svg { width: 20px; height: 20px; color: var(--blue-primary); margin-top: 1px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--gray-800); color: #fff; padding: 10px 16px; border-radius: var(--radius-lg); font-size: 13px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 60; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: var(--white); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); width: 100%; max-width: 380px; padding: 22px; text-align: center; }
.modal h3 { font-size: 16px; }
.modal .qr { width: 180px; height: 180px; margin: 16px auto; display: block; }
.modal .copia { font-family: ui-monospace, monospace; font-size: 11px; background: var(--gray-50); border: 1px dashed var(--gray-300); border-radius: var(--radius-md); padding: 8px; word-break: break-all; color: var(--gray-600); text-align: left; }
.modal .acoes { display: flex; gap: 8px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

/* ---------- Folha A4 (boletim, documentos) ---------- */
.folha-wrap { background: var(--gray-200); border-radius: var(--radius-xl); padding: 24px; overflow-x: auto; }
.folha { background: #fff; width: 210mm; min-height: 297mm; margin: 0 auto; padding: 16mm 16mm 18mm; box-shadow: var(--shadow-md); color: #111; font-size: 11.5pt; line-height: 1.5; }
.f-cab { display: flex; align-items: center; gap: 14px; border-bottom: 2px solid var(--blue-dark); padding-bottom: 10px; margin-bottom: 18px; }
.f-brasao { width: 54px; height: 54px; border-radius: 50%; background: var(--blue-dark); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.f-cab .e { font-size: 14pt; font-weight: 700; color: var(--blue-dark); }
.f-cab .x { font-size: 9pt; color: #444; line-height: 1.4; }
.f-titulo { text-align: center; font-size: 13pt; font-weight: 700; letter-spacing: .5px; margin: 6px 0 16px; text-transform: uppercase; }
.f-dados { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px 16px; font-size: 10pt; border: 1px solid #ccc; border-radius: 4px; padding: 8px 10px; margin-bottom: 14px; }
.f-dados b { font-weight: 600; }
.folha table { width: 100%; border-collapse: collapse; font-size: 10pt; }
.folha th, .folha td { border: 1px solid #999; padding: 5px 6px; }
.folha th { background: #eef2f8; font-weight: 600; }
.folha td.c, .folha th.c { text-align: center; }
.folha p { text-align: justify; margin-bottom: 10px; }
.folha h5 { font-size: 10.5pt; margin: 12px 0 4px; }
.f-local { text-align: right; margin: 26px 0 50px; }
.f-ass { display: flex; justify-content: space-around; gap: 30px; margin-top: 40px; }
.f-ass div { flex: 1; text-align: center; border-top: 1px solid #333; padding-top: 4px; font-size: 10pt; }
.f-rodape { margin-top: 24px; font-size: 8.5pt; color: #666; text-align: center; border-top: 1px solid #ddd; padding-top: 6px; }

/* ---------- Celular ---------- */
@media (max-width: 860px) {
  .demo-bar { justify-content: space-between; padding: 6px 12px; }
  .demo-bar .txt-pc { display: none; }
  .demo-bar .txt-cel { display: inline; }
  .sidebar { position: fixed; top: var(--bar-h, 36px); bottom: 0; left: 0; z-index: 40; transform: translateX(-100%); transition: transform .22s; }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.nav-open .scrim { position: fixed; inset: var(--bar-h, 36px) 0 0; background: rgba(15,23,42,.4); z-index: 30; }
  .menu-btn { display: grid; }
  .topbar { padding: 0 12px; }
  .main { padding: 14px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .two, .turma-cards { grid-template-columns: 1fr; }
  .doc-tipos { grid-template-columns: repeat(2, 1fr); }
  .kpi .v { font-size: 20px; }
  .folha-wrap { padding: 10px; }
  .esconde-cel { display: none; }
}
@media (max-width: 420px) {
  .field select, .field input { min-width: 0; width: 100%; }
  .filters .field { flex: 1 1 140px; }
}

/* ---------- Impressão: só a folha ---------- */
@media print {
  @page { size: A4; margin: 0; }
  body { background: #fff; display: block; height: auto; }
  .demo-bar, .sidebar, .topbar, .page-head, .filters, .doc-tipos, .no-print, .toast { display: none !important; }
  .shell, .content, .main { display: block; height: auto; overflow: visible; padding: 0; }
  .folha-wrap { background: none; padding: 0; border-radius: 0; }
  .folha { box-shadow: none; margin: 0; }
}
