* {
  box-sizing: border-box;
}

:root {
  --bg: #d7e6d7;
  --surface: #ffffff;
  --surface-soft: #f4faf4;
  --line: #e4dfd8;
  --text: #37443d;
  --muted: #68786f;
  --primary: #e99aa0;
  --primary-strong: #dc7f87;
  --mustard: #efd28d;
  --mustard-dark: #75622f;
  --entry: #efd28d;
  --exit: #e99aa0;
  --shadow: 0 12px 28px rgba(74, 69, 66, .10);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #e5f0e4 0%, var(--bg) 58%, #c8d9c8 100%);
  color: var(--text);
}

body:not(.login-body) {
  padding-bottom: 28px;
}

input,
select,
button {
  font: inherit;
}

button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}

button {
  border: 0;
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid rgba(233, 154, 160, .32);
  outline-offset: 2px;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 22px;
  background: linear-gradient(135deg, #e5f0e4, #d3e3d2 74%);
}

.login-card {
  width: min(460px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.login-logo {
  display: block;
  width: min(310px, 100%);
  height: auto;
  margin: 0 auto 20px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 500;
  color: #c96f77;
  text-align: center;
}

.login-card p {
  margin: 0 0 26px;
  color: var(--muted);
  text-align: center;
  font-weight: 400;
}

label {
  display: block;
  margin-bottom: 8px;
  color: #3c3c3c;
  font-size: 14px;
  font-weight: 500;
}

input,
select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .7);
}

input::placeholder {
  color: #8494a5;
}

.login-card button {
  width: 100%;
  min-height: 48px;
  margin-top: 18px;
  border-radius: 8px;
  background: var(--mustard);
  color: #2d2d2d;
  font-weight: 500;
  transition: transform .14s ease, background .14s ease, box-shadow .14s ease;
}

.login-card button:hover {
  background: #e8c676;
  box-shadow: 0 10px 22px rgba(239, 210, 141, .30);
}

.login-card button:active {
  transform: translateY(1px);
}

.alert {
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: 8px;
}

.error {
  border: 1px solid #f1bdc2;
  background: #f4d8dc;
  color: #9b545b;
}

.success {
  border: 1px solid #e8d7a4;
  background: #f3dfad;
  color: #7a6333;
}

.form-links {
  margin-top: 18px;
  text-align: center;
}

.form-links a {
  color: #9b545b;
  font-weight: 500;
  text-decoration: none;
}

.form-links a:hover {
  text-decoration: underline;
}

.approval-link-box {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  padding: 14px;
  border: 1px dashed #e8d7a4;
  border-radius: 8px;
  background: #ffffff;
  text-align: center;
}

.approval-link-box span {
  color: var(--muted);
  font-size: 13px;
}

.approval-link-box a {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--mustard);
  color: var(--text);
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 80px;
  padding: 14px clamp(16px, 3vw, 34px);
  border-bottom: 4px solid var(--primary);
  background: rgba(255, 255, 255, .96);
  color: var(--text);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.brand-logo {
  width: clamp(126px, 18vw, 230px);
  height: auto;
  flex: 0 0 auto;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(23px, 3vw, 34px);
  font-weight: 500;
  color: var(--primary);
}

.topbar span {
  display: inline-flex;
  margin-top: 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
}

#relogio {
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #ead8a7;
  border-radius: 999px;
  background: #f3dfad;
  color: #7a6333;
  box-shadow: 0 8px 18px rgba(239, 210, 141, .20);
  white-space: nowrap;
}

#relogio::before {
  content: "";
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: #e99aa0;
}

.topbar-actions {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.menu-filtros {
  position: relative;
}

.menu-filtros summary {
  width: 44px;
  height: 42px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid #d1d1d1;
  border-radius: 8px;
  background: var(--surface);
  cursor: pointer;
  list-style: none;
}

.menu-filtros summary::-webkit-details-marker {
  display: none;
}

.menu-filtros summary span {
  width: 18px;
  height: 2px;
  display: block;
  margin: 0;
  border-radius: 999px;
  background: var(--muted);
}

.menu-filtros[open] summary {
  background: var(--surface-soft);
}

.menu-filtros .filtros {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 15;
  width: min(360px, calc(100vw - 28px));
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .98);
  box-shadow: var(--shadow);
}

.menu-filtros .filtros button {
  width: 100%;
}

.logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid #d1d1d1;
  border-radius: 8px;
  background: var(--surface);
  color: var(--primary);
  font-weight: 500;
  text-decoration: none;
}

.logout:hover {
  border-color: #bdd0dc;
  background: var(--surface-soft);
}

.modo-box,
.status-line,
.grid-alunos {
  width: min(1180px, calc(100% - 28px));
  margin-inline: auto;
}

.modo-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 18px rgba(27, 43, 58, .07);
}

.modo {
  min-height: 66px;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-size: clamp(18px, 2.2vw, 24px);
  font-weight: 500;
  letter-spacing: 0;
  transition: background .15s ease, color .15s ease, transform .15s ease;
}

.modo:hover {
  background: var(--surface-soft);
}

.modo.active[data-tipo=E] {
  background: var(--entry);
  color: #2d2d2d;
  box-shadow: 0 8px 18px rgba(239, 210, 141, .28);
}

.modo.active[data-tipo=S] {
  background: var(--exit);
  color: #37443d;
  box-shadow: 0 8px 18px rgba(233, 154, 160, .24);
}

.modo:active {
  transform: scale(.99);
}

.filtros {
  display: grid;
  grid-template-columns: minmax(260px, 2fr) minmax(180px, 1fr) auto;
  gap: 10px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
  box-shadow: 0 8px 18px rgba(27, 43, 58, .06);
}

.filtros button {
  min-width: 124px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 8px;
  background: var(--mustard);
  color: #2d2d2d;
  font-weight: 500;
}

.filtros button:hover {
  background: #e8c676;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 66px;
  margin-top: 14px;
  padding: 0 4px;
  color: var(--muted);
  font-size: clamp(17px, 2.2vw, 24px);
}

#status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  width: min(760px, 100%);
  padding: 10px 18px;
  border: 1px solid #ead8a7;
  border-radius: 999px;
  background: #f3dfad;
  color: #6f5830;
  box-shadow: 0 12px 24px rgba(239, 210, 141, .22);
  text-align: center;
  font-weight: 500;
}

.grid-alunos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 16px;
  padding-top: 6px;
}

.aluno-card {
  position: relative;
  min-height: 238px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 14px 12px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: 0 8px 18px rgba(27, 43, 58, .07);
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.aluno-card:hover {
  border-color: #e7c879;
  box-shadow: 0 16px 28px rgba(27, 43, 58, .12);
  transform: translateY(-2px);
}

.aluno-card.menino {
  border-color: #c9dced;
  background: #eaf4fb;
}

.aluno-card.menina {
  border-color: #efd0db;
  background: #fbedf2;
}

.aluno-card:active {
  transform: translateY(0) scale(.99);
}

.aluno-card:disabled {
  cursor: wait;
  opacity: .76;
}

.aluno-card.enviado-entrada {
  border-color: rgba(239, 210, 141, .88);
  background: #fff7d6;
}

.aluno-card.enviado-saida {
  border-color: rgba(233, 154, 160, .72);
  background: #f4d8dc;
}

.foto-wrap {
  width: 100%;
}

.foto,
.sem-foto {
  width: 118px;
  height: 118px;
  margin: 0 auto 14px;
  border-radius: 50%;
}

.foto {
  display: block;
  object-fit: cover;
  border: 5px solid #f7f4ee;
  background: #edf6ed;
}

.sem-foto {
  display: grid;
  place-items: center;
  border: 5px solid #f7f4ee;
  background: linear-gradient(145deg, #e5f0e4, #ffffff);
  color: #c96f77;
  font-size: 44px;
  font-weight: 500;
}

.nome {
  min-height: 44px;
  margin-bottom: 9px;
  color: #2d2d2d;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.2;
}

.turma {
  display: inline-flex;
  align-self: center;
  max-width: 100%;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: #e9dfd3;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.card-status {
  min-height: 18px;
  margin-top: auto;
  padding-top: 10px;
  color: #c96f77;
  font-size: 12px;
  font-weight: 500;
}

.empty-state {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
  justify-items: center;
  padding: 34px 18px;
  border: 1px dashed #d7cec4;
  border-radius: 8px;
  background: rgba(255, 255, 255, .78);
  color: var(--muted);
  text-align: center;
}

.empty-state strong {
  color: #c96f77;
  font-size: 18px;
}

.lista-marcados {
  width: min(1180px, calc(100% - 28px));
  margin: 18px auto 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .88);
  box-shadow: 0 8px 18px rgba(74, 69, 66, .07);
  overflow: hidden;
}

.lista-marcados summary {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  color: var(--muted);
  cursor: pointer;
  list-style: none;
}

.lista-marcados summary::-webkit-details-marker {
  display: none;
}

.lista-marcados summary span,
.lista-marcados summary strong {
  font-weight: 500;
}

.lista-marcados summary strong {
  min-width: 34px;
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--mustard);
  color: var(--text);
}

.marcados-vazia {
  padding: 0 16px 16px;
  color: var(--muted);
  font-size: 14px;
}

.marcados-lista {
  display: grid;
  gap: 8px;
  padding: 0 12px 12px;
}

.marcado-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f4faf4;
  color: var(--text);
}

.marcado-item > div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.marcado-item span {
  font-weight: 500;
}

.marcado-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  text-align: left;
}

.corrigir-marcacao {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ead8a7;
  border-radius: 50%;
  background: #f3dfad;
  color: var(--mustard-dark);
  font-size: 24px;
  line-height: 1;
}

.corrigir-marcacao:hover {
  background: var(--mustard);
}

.corrigir-marcacao:active {
  transform: scale(.96);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(520px, 92vw);
  padding: 14px 18px;
  border-radius: 8px;
  background: #37443d;
  color: #fff;
  box-shadow: 0 18px 34px rgba(11, 23, 34, .26);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity .18s ease, transform .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 760px) {
  body:not(.login-body) {
    padding-bottom: 18px;
  }

  .topbar {
    min-height: 76px;
    padding: 12px 14px;
  }

  .brand {
    gap: 10px;
  }

  .brand-logo {
    width: 118px;
  }

  .modo-box,
  .status-line,
  .grid-alunos,
  .lista-marcados {
    width: calc(100% - 18px);
  }

  .modo-box {
    margin-top: 10px;
  }

  .modo {
    min-height: 58px;
  }

  .grid-alunos {
    grid-template-columns: repeat(auto-fill, minmax(145px, 1fr));
    gap: 10px;
  }

  .aluno-card {
    min-height: 222px;
    padding: 12px 10px;
  }

  .foto,
  .sem-foto {
    width: 98px;
    height: 98px;
  }

  .login-card {
    padding: 26px;
  }

  .marcado-item {
    align-items: center;
  }
}

@media (max-width: 390px) {
  .topbar h1 {
    font-size: 19px;
  }

  .topbar span {
    font-size: 12px;
  }

  .brand-logo {
    width: 96px;
  }

  .logout {
    min-width: 66px;
    padding-inline: 12px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .menu-filtros summary {
    width: 42px;
  }

  .grid-alunos {
    grid-template-columns: 1fr 1fr;
  }
}
