:root {
  --bg: #eef3f9;
  --surface: #ffffff;
  --surface-2: #e8eef7;
  --line: #cfdae8;
  --ink: #071d3a;
  --muted: #536883;
  --brand: #123f6f;
  --brand-2: #0a3159;
  --ok: #087f5b;
  --bad: #b42318;
  --shadow: 0 14px 30px rgba(7, 29, 58, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 15px;
}
body.viewer-open {
  overflow: hidden;
}
a { color: var(--brand); font-weight: 700; text-decoration: none; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 68px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .95);
  backdrop-filter: blur(10px);
}
.menu-toggle {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  display: grid;
  place-content: center;
  gap: 4px;
  cursor: pointer;
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: #fff;
}
.home-link {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--surface);
}
.home-link svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--brand);
  stroke-width: 2;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}
.brand small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}
.userbar {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: min(330px, 88vw);
  transform: translateX(-105%);
  transition: transform .2s ease;
  background: var(--surface);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}
body.menu-open .sidebar { transform: translateX(0); }
.backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(7, 29, 58, .35);
}
body.menu-open .backdrop { display: block; }
.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.side-head button {
  border: 0;
  background: var(--surface-2);
  color: var(--ink);
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 22px;
  cursor: pointer;
}
.sidebar nav {
  display: grid;
  gap: 6px;
}
.sidebar nav a {
  padding: 12px 14px;
  border-radius: 8px;
  color: var(--ink);
}
.sidebar nav a:hover { background: var(--surface-2); }
.page {
  max-width: 1480px;
  margin: 0 auto;
  padding: 26px;
}
.hero {
  background: linear-gradient(135deg, var(--brand), #08274a);
  color: #fff;
  padding: 30px;
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin-bottom: 22px;
}
.hero h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.1;
}
.hero p {
  margin: 10px 0 0;
  color: #e9f2ff;
}
.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.grid {
  display: grid;
  gap: 14px;
  margin-bottom: 18px;
}
.grid-5 { grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }
.mt { margin-top: 18px; }
.wide { grid-column: 1 / -1; }
.kpi,
.card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.kpi {
  padding: 16px;
  border-top: 5px solid #1e73af;
  min-width: 0;
}
.kpi small,
.mini-kpi small,
.info small {
  display: block;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .02em;
}
.kpi strong {
  display: block;
  margin: 8px 0 4px;
  font-size: clamp(24px, 2.2vw, 34px);
  line-height: 1;
  overflow-wrap: anywhere;
}
.kpi span { color: var(--muted); font-size: 13px; }
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 18px;
}
input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
}
.toolbar input { max-width: 680px; }
.button,
button.button {
  border: 0;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
}
.button.secondary { background: var(--surface-2); color: var(--ink); }
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  background: #eaf2fb;
  border: 1px solid var(--line);
  color: var(--brand-2);
  font-size: 12px;
  font-weight: 800;
}
.school-grid,
.card-grid,
.chart-grid {
  display: grid;
  gap: 14px;
}
.school-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.photo-school-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card-grid { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.chart-grid { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); margin-bottom: 18px; }
.card {
  padding: 18px;
  min-width: 0;
}
.card h2 {
  margin: 0 0 14px;
  font-size: 22px;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.exp-card {
  padding: 0;
  overflow: hidden;
}
.exp-card > summary,
.block > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  cursor: pointer;
  padding: 16px 20px;
  font-weight: 900;
}
.school-card[open] {
  grid-column: 1 / -1;
}
.school-card-summary {
  display: block !important;
  position: relative;
  padding: 18px 22px 0 !important;
}
.school-card-summary::before {
  display: none !important;
}
.school-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.school-vcard {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 12px;
}
.school-title h2,
.school-vcard h2 {
  margin: 0;
  color: var(--brand-2);
  font-size: 20px;
  line-height: 1.15;
}
.school-title p,
.school-vcard p {
  margin: 5px 0 0;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.35;
}
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.pill-warn {
  background: #fff2df;
  border-color: #f0c58a;
  color: #a34a00;
}
.school-card-button {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--brand-2);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 900;
}
.school-card-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(135px, 1fr));
  gap: 8px;
  margin-top: 14px;
}
.school-card-metrics div {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px 12px;
}
.school-card-metrics small {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .02em;
  margin-bottom: 5px;
}
.school-card-metrics strong {
  display: block;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}
.school-card-contact {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(140px, .8fr) minmax(220px, 1.4fr) minmax(90px, .5fr);
  gap: 14px;
  margin-top: 12px;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
}
.school-card-contact span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.school-card-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px -22px 0;
  padding: 13px 22px;
  border-top: 1px solid var(--line);
  background: linear-gradient(90deg, #fff, #f6f9fd);
}
.summary-action {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--brand-2);
  font-size: 16px;
  font-weight: 900;
}
.summary-action::before {
  content: ">";
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
}
.school-card[open] .summary-action::before {
  content: "v";
}
.summary-counts {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}
.school-visit-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.school-visit-card div {
  min-height: 62px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px;
}
.school-visit-card small {
  display: block;
  color: var(--muted);
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 800;
  margin-bottom: 5px;
}
.school-visit-card strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}
.exp-card > summary::-webkit-details-marker,
.block > summary::-webkit-details-marker { display: none; }
.exp-card > summary::before,
.block > summary::before {
  content: ">";
  display: inline-grid;
  place-items: center;
  flex: 0 0 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  margin-right: 8px;
}
.block > summary::before {
  margin-right: 0;
}
.exp-card[open] > summary::before,
.block[open] > summary::before { content: "v"; }
.exp-card > summary > span:first-child,
.block > summary > span:first-child { flex: 1; }
.summary-meta {
  margin-left: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}
.exp-body { padding: 0 20px 20px; }
.mini-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.mini-kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdff;
}
.mini-kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  overflow-wrap: anywhere;
}
.block {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 10px 0;
  background: #fbfdff;
}
.block > summary { padding: 12px 14px; }
.block-body { padding: 0 14px 14px; }
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.info {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
  min-height: 70px;
}
.info.wide { grid-column: 1 / -1; }
.photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.photo-thumb,
.photo-school-cover {
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.photo-thumb {
  aspect-ratio: 1;
  color: var(--brand-2);
  font-weight: 900;
  cursor: pointer;
}
.photo-thumb img,
.photo-school-cover img,
.photo-card img,
.photo-card video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.photo-sync-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin: -4px 0 18px;
}
.photo-sync-form .form-message {
  color: var(--muted);
  font-weight: 800;
}
.photo-date-group {
  margin-top: 18px;
}
.photo-date-group + .photo-date-group {
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.photo-date-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.photo-date-head h3 {
  margin: 0;
  color: var(--brand-2);
  font-size: 18px;
}
.photo-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.photo-card.is-cover {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(18, 63, 111, .12), var(--shadow);
}
.photo-preview,
.photo-thumb {
  border: 1px solid var(--line);
  padding: 0;
  background: var(--surface-2);
  font: inherit;
}
.photo-preview {
  position: relative;
  display: block;
  width: 100%;
  cursor: zoom-in;
}
.photo-card img,
.photo-card video {
  aspect-ratio: 4 / 3;
  background: var(--surface-2);
}
.photo-play {
  position: absolute;
  left: 10px;
  bottom: 10px;
  border-radius: 999px;
  background: rgba(7, 29, 58, .86);
  color: #fff;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
}
.photo-meta {
  display: grid;
  gap: 4px;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}
.photo-meta strong {
  color: var(--ink);
  overflow-wrap: anywhere;
}
.cover-badge {
  width: fit-content;
  border-radius: 999px;
  background: #e6f6ef;
  border: 1px solid #b9e4cf;
  color: var(--ok);
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}
.cover-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.cover-form .button {
  padding: 9px 12px;
  font-size: 12px;
}
.photo-school-cover {
  aspect-ratio: 16 / 9;
  margin-bottom: 12px;
}
.photo-school-card h2 {
  margin-bottom: 10px;
  color: var(--brand-2);
  font-size: 18px;
  line-height: 1.15;
}
.photo-school-card .section-head {
  align-items: flex-start;
}
.photo-school-card .mini-kpis {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.photo-school-cover:empty::before {
  content: "Sem miniatura";
  color: var(--muted);
  font-weight: 800;
}
.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: rgba(4, 14, 28, .94);
  color: #fff;
}
.photo-viewer[hidden] {
  display: none;
}
.photo-viewer-header,
.photo-viewer-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
}
.photo-viewer-header {
  border-bottom: 1px solid rgba(255, 255, 255, .15);
}
.photo-viewer-title {
  min-width: 0;
  flex: 1;
}
.photo-viewer-title strong,
.photo-viewer-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.photo-viewer-title span {
  margin-top: 3px;
  color: #bfd0e4;
  font-size: 12px;
}
.viewer-button {
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px;
  background: rgba(255, 255, 255, .11);
  color: #fff;
  min-width: 42px;
  min-height: 38px;
  padding: 8px 12px;
  font-weight: 900;
  cursor: pointer;
}
.viewer-button:hover {
  background: rgba(255, 255, 255, .18);
}
.photo-viewer-stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
}
.photo-viewer-media {
  max-width: 100%;
  max-height: 100%;
  transform-origin: center;
  transition: transform .12s ease;
}
.photo-viewer-media img,
.photo-viewer-media video {
  display: block;
  max-width: 96vw;
  max-height: calc(100vh - 150px);
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.photo-viewer-footer {
  justify-content: center;
  border-top: 1px solid rgba(255, 255, 255, .15);
}
.photo-viewer-count {
  min-width: 90px;
  text-align: center;
  color: #d8e6f6;
  font-weight: 900;
}
.table-wrap { width: 100%; overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}
.table th {
  background: var(--surface-2);
  color: var(--brand-2);
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
}
.table th,
.table td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  vertical-align: top;
}
.bars {
  display: grid;
  gap: 9px;
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(120px, 230px) 1fr auto;
  gap: 10px;
  align-items: center;
}
.bar-label {
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-track {
  height: 14px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), #1e73af);
}
.bar-value {
  font-weight: 800;
  color: var(--brand-2);
  font-size: 12px;
}
.empty,
.flash {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 16px;
}
.muted { color: var(--muted); }
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.page:has(.login-page) {
  max-width: none;
  padding: 0;
}
.login-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-card h1 { margin-top: 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}
.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
}
.form-grid .actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.compact-form {
  margin-top: 12px;
}
.inline-action-form {
  margin: 12px 0 0;
}
.note-list {
  display: grid;
  gap: 12px;
}
.note-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
}
.note-item header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.note-item small {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin-top: 4px;
}
.note-item p {
  margin: 10px 0 0;
  line-height: 1.45;
}
.raw-note {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}
.form-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
}
.password-wrap {
  display: flex;
  gap: 8px;
}
.password-wrap input {
  min-width: 0;
  flex: 1;
}
.password-wrap button,
.link-button {
  border: 0;
  background: transparent;
  color: var(--brand);
  font-weight: 800;
  cursor: pointer;
}
.password-wrap button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface-2);
}
.status-on { color: var(--ok); font-weight: 900; }
.status-off { color: var(--bad); font-weight: 900; }
.form-message { font-weight: 800; color: var(--ok); }
.is-hidden { display: none !important; }
@media (max-width: 1100px) {
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .photo-school-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .photo-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .photo-school-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .page { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .userbar span { display: none; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar input { max-width: none; }
  .chart-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
  .school-grid { grid-template-columns: 1fr; }
  .photo-grid { grid-template-columns: 1fr; }
  .photo-school-grid { grid-template-columns: 1fr; }
  .school-visit-card { grid-template-columns: 1fr; }
  .school-card-top,
  .school-card-action {
    align-items: stretch;
    flex-direction: column;
  }
  .school-card-button {
    width: fit-content;
  }
  .school-card-metrics,
  .school-card-contact {
    grid-template-columns: 1fr;
  }
  .school-card-contact span {
    white-space: normal;
  }
  .bar-row { grid-template-columns: 1fr; gap: 5px; }
  .summary-meta { justify-content: flex-start; width: 100%; }
  .exp-card > summary { flex-wrap: wrap; }
}
