/* Presença escolar — tema claro: branco, preto e cinzas */

:root {
  --black: #0a0a0a;
  --gray-950: #171717;
  --gray-900: #262626;
  --gray-800: #404040;
  --gray-600: #525252;
  --gray-500: #737373;
  --gray-400: #a3a3a3;
  --gray-300: #d4d4d4;
  --gray-200: #e5e5e5;
  --gray-100: #f5f5f5;
  --white: #ffffff;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--gray-900);
  background: var(--gray-100);
  min-height: 100vh;
}

/* Shell + sidebar */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 268px;
  flex-shrink: 0;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  padding: 1.5rem 1.25rem;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-brand {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.sidebar-brand__mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--black) 0%, var(--gray-800) 100%);
  flex-shrink: 0;
}

.sidebar-brand__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--black);
  line-height: 1.25;
}

.sidebar-brand__tag {
  margin: 0.25rem 0 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-nav__link {
  display: block;
  padding: 0.65rem 0.875rem;
  border-radius: var(--radius-sm);
  color: var(--gray-600);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}

.sidebar-nav__link:hover {
  background: var(--gray-100);
  color: var(--black);
}

.sidebar-nav__link.is-active {
  background: var(--black);
  color: var(--white);
}

/* Main */
.content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.content-inner {
  flex: 1;
  padding: 1.5rem clamp(1rem, 3vw, 2rem) 2.5rem;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.75rem;
  padding: 1rem 1.25rem;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.topbar-user {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.topbar-user__label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-500);
}

.topbar-user__name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--black);
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--black);
}

.filters-inline {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Cards + KPI */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.card h3 {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
}

/* Texto padrão em cards (status, descrições) */
.card p {
  margin: 0 0 0.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.45;
  color: var(--gray-800);
  letter-spacing: normal;
}

.card p:last-child {
  margin-bottom: 0;
}

/* Números de destaque só nos KPIs do dashboard */
.cards-grid .card p {
  margin: 0;
  font-size: 1.875rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--black);
}

/* Tables */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9375rem;
}

.table thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  background: var(--gray-100);
  border-bottom: 1px solid var(--gray-200);
}

.table tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--gray-200);
  color: var(--gray-900);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--gray-100);
}

.thumb-student {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1rem;
  cursor: pointer;
  background: var(--white);
  color: var(--gray-900);
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

.btn-primary {
  background: var(--black);
  color: var(--white);
  border-color: var(--black);
}

.btn-primary:hover {
  background: var(--gray-900);
  border-color: var(--gray-900);
}

.btn-danger {
  background: var(--gray-900);
  color: var(--white);
  border-color: var(--gray-900);
}

.btn-danger:hover {
  background: var(--black);
  border-color: var(--black);
}

.btn-ghost {
  background: transparent;
  border-color: var(--gray-300);
  color: var(--gray-800);
}

.btn-ghost:hover {
  background: var(--gray-100);
  border-color: var(--gray-400);
}

/* Form controls */
label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="file"],
select,
textarea {
  width: 100%;
  max-width: 100%;
  background: var(--white);
  border: 1px solid var(--gray-300);
  color: var(--gray-900);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.9375rem;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--black);
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.08);
}

input::placeholder {
  color: var(--gray-400);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.25rem;
  align-items: center;
}

/* Camera */
.camera-grid {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 1.25rem;
  align-items: start;
}

.video-wrapper {
  position: relative;
  margin-top: 0.75rem;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--black);
  border: 1px solid var(--gray-200);
}

#cameraVideo,
#cameraMjpeg,
#cameraEmbed,
#overlayCanvas {
  width: 100%;
  max-height: 480px;
  display: block;
}

#cameraEmbed {
  height: 480px;
  border: 0;
  background: var(--black);
}

#cameraMjpeg {
  object-fit: contain;
  vertical-align: top;
}

#overlayCanvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#buscaAluno {
  margin-bottom: 0.75rem;
}

.reconhecimento-status {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gray-800);
  margin: 0 0 0.5rem;
}

.camera-options {
  margin-bottom: 0.75rem;
}

.webcam-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) auto;
  gap: 0.75rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--gray-600);
  cursor: pointer;
  line-height: 1.35;
}

.checkbox-label input {
  width: auto;
  margin-top: 0.15rem;
}

.hint-fila {
  font-size: 0.8125rem;
  color: var(--gray-600);
  margin: 0 0 0.75rem;
  line-height: 1.4;
}

.fila {
  display: grid;
  gap: 0.75rem;
  max-height: min(72vh, 640px);
  overflow-y: auto;
  padding-right: 4px;
}

.fila::-webkit-scrollbar {
  width: 6px;
}

.fila::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 3px;
}

.item-fila {
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 1rem;
  display: grid;
  gap: 0.65rem;
}

.thumb-face {
  width: 112px;
  height: 112px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
}

.thumb-face--history {
  width: 56px;
  height: 56px;
}

.capturas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}

.captura-card {
  margin-bottom: 0;
}

.captura-card__img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  margin-bottom: 0.75rem;
}

.item-fila small {
  color: var(--gray-500);
  font-size: 0.8125rem;
}

.confirmacao-status {
  display: block;
  font-weight: 600;
  color: var(--gray-800);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Login */
.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(180deg, var(--white) 0%, var(--gray-100) 100%),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 10px,
      rgba(0, 0, 0, 0.02) 10px,
      rgba(0, 0, 0, 0.02) 11px
    );
}

.login-card {
  width: min(420px, 100%);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 16px;
  padding: 2rem 2rem 1.75rem;
  box-shadow: var(--shadow-lg);
}

.login-card__brand {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(145deg, var(--black) 0%, var(--gray-800) 100%);
  margin-bottom: 1.25rem;
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.375rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--black);
}

.login-card__lead {
  margin: 0 0 1.5rem;
  font-size: 0.9375rem;
  color: var(--gray-600);
}

.login-card form {
  display: grid;
  gap: 1rem;
}

.login-card .btn-primary {
  width: 100%;
  padding: 0.75rem 1rem;
  margin-top: 0.25rem;
}

.login-card small {
  display: block;
  margin-top: 1.25rem;
  font-size: 0.75rem;
  color: var(--gray-500);
  line-height: 1.4;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  border: 1px solid var(--gray-300);
  background: var(--gray-100);
  color: var(--gray-900);
}

.alert-danger {
  border-color: var(--gray-800);
  background: var(--gray-200);
  color: var(--black);
}

.flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-size: 0.9375rem;
  border: 1px solid var(--gray-300);
  background: var(--white);
  color: var(--gray-900);
}

.flash--info {
  border-color: var(--gray-400);
}

.card__title {
  margin: 0 0 1rem;
  font-size: 1.0625rem;
  font-weight: 600;
  color: var(--black);
}

.alunos-camera {
  grid-column: 1 / -1;
  padding: 1rem;
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--gray-100);
}

.alunos-camera__hint {
  margin: 0 0 0.75rem;
  font-size: 0.875rem;
  color: var(--gray-600);
}

.alunos-camera__video {
  display: block;
  width: 100%;
  max-width: 360px;
  max-height: 270px;
  border-radius: var(--radius-sm);
  background: var(--gray-900);
  object-fit: cover;
}

.alunos-camera__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.alunos-camera__status {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--gray-600);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.table__actions {
  white-space: nowrap;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
  align-items: center;
}

.table__actions .form-inline {
  margin: 0;
  display: inline;
}

.btn--sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8125rem;
}

/* Responsive */
@media (max-width: 960px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 1rem 1.25rem;
    gap: 1rem;
  }

  .sidebar-brand {
    padding-bottom: 0;
    border-bottom: none;
    flex: 1;
    min-width: 200px;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    width: 100%;
  }

  .sidebar-nav__link {
    flex: 1 1 auto;
    min-width: calc(50% - 4px);
    text-align: center;
  }

  .camera-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .cards-grid {
    grid-template-columns: 1fr 1fr;
  }

  .page-header h2 {
    font-size: 1.25rem;
  }
}

/* ---- Face Scan ---- */
.face-scan {
  grid-column: 1 / -1;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 1rem;
  background: var(--gray-100);
}

.face-scan h4 {
  margin: 0 0 0.25rem;
  font-size: 1rem;
}

.face-scan__hint {
  color: var(--gray-500);
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.face-scan__preview {
  position: relative;
  max-width: 480px;
  margin: 0 auto 0.75rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--gray-900);
}

.face-scan__video,
.face-scan__overlay {
  width: 100%;
  display: block;
}

.face-scan__overlay {
  position: absolute;
  top: 0; left: 0;
}

.face-scan__guide {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 0.5rem 1rem;
  background: rgba(0, 0, 0, 0.7);
  color: var(--white);
  font-size: 0.95rem;
  text-align: center;
  transition: opacity 0.3s;
}

.face-scan__progress {
  max-width: 480px;
  margin: 0 auto 0.5rem;
}

.face-scan__bar {
  height: 8px;
  background: var(--gray-300);
  border-radius: 4px;
  overflow: hidden;
  font-size: 0;
  position: relative;
}

.face-scan__bar span {
  font-size: 0.75rem;
  color: var(--gray-500);
  position: absolute;
  right: 4px;
  top: -18px;
  z-index: 1;
}

.face-scan__bar-fill {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--black);
  border-radius: 4px;
  transition: width 0.3s;
}

.face-scan__actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 0.75rem;
}

.face-scan__grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  min-height: 72px;
}

.face-scan__thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 2px solid var(--gray-300);
}

.face-scan__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.face-scan__thumb--recent {
  border-color: var(--black);
}

.face-scan__remove {
  position: absolute;
  top: 2px; right: 2px;
  width: 20px; height: 20px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: var(--white);
  font-size: 14px;
  line-height: 20px;
  text-align: center;
  cursor: pointer;
}

.face-scan__remove:hover {
  background: #c00;
}

.face-scan__status {
  color: var(--gray-500);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
  text-align: center;
}

/* Consentimento LGPD */
.consent-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.consent-overlay[hidden] {
  display: none;
}

.consent-modal {
  background: var(--white);
  border-radius: 12px;
  padding: 2rem;
  max-width: 480px;
  width: 90%;
  text-align: center;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
}

.consent-modal h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 1rem;
  color: var(--black);
}

.consent-modal p {
  color: var(--gray-600);
  font-size: 0.9rem;
  line-height: 1.5;
  margin: 0 0 0.75rem;
}

.consent-modal .btn {
  margin-top: 0.75rem;
  padding: 0.625rem 2rem;
  font-size: 1rem;
}
