:root {
  --wine: #5b2118;
  --wine-dark: #34150f;
  --terracotta: #a64b35;
  --cream: #f6f0e6;
  --paper: #fffdf8;
  --ink: #2c2521;
  --muted: #746b65;
  --line: #e7ddd0;
  --green: #2f7d58;
  --red: #b5463c;
  --shadow: 0 18px 50px rgba(70, 34, 23, 0.1);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--cream);
}
[hidden] {
  display: none !important;
}
.auth-view {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(
      circle at 80% 0%,
      rgba(255, 255, 255, 0.13),
      transparent 30%
    ),
    linear-gradient(135deg, var(--wine-dark), var(--wine));
}
.auth-card {
  width: min(440px, 100%);
  padding: 32px;
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 30px 90px rgba(30, 12, 8, 0.32);
}
.auth-brand {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  color: var(--wine-dark);
}
.auth-brand-logo {
  width: 72px;
  height: 72px;
  flex: 0 0 72px;
  display: block;
  object-fit: contain;
  padding: 10px;
  border-radius: 16px;
  background: linear-gradient(145deg, var(--wine-dark), var(--wine));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 10px 24px rgba(52, 21, 15, 0.22);
}
.auth-brand small,
.auth-brand strong {
  display: block;
}
.auth-brand small {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.auth-brand strong {
  color: var(--wine-dark);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.auth-copy {
  margin: 28px 0 20px;
}
.auth-copy h1 {
  margin: 0 0 7px;
  color: var(--wine-dark);
  font:
    700 30px Georgia,
    serif;
}
.auth-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}
.auth-form {
  padding: 0;
  display: grid;
  gap: 15px;
  overflow: visible;
}
.auth-form .btn {
  width: 100%;
  margin-top: 3px;
}
.auth-message {
  min-height: 20px;
  margin: 0;
  text-align: center;
  color: var(--red);
  font-size: 13px;
}
.auth-message.success {
  color: var(--green);
}
.auth-links {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 6px;
}
.auth-links button {
  border: 0;
  padding: 6px 0;
  color: var(--wine);
  background: transparent;
  font-size: 13px;
  font-weight: 700;
}
.account-bar {
  position: absolute;
  top: 30px;
  right: clamp(20px, 5vw, 72px);
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 13px;
}
.btn-account {
  min-height: 38px;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.1);
}
.loading-state {
  text-align: center;
  padding: 18px;
  color: var(--muted);
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
.topbar {
  min-height: 180px;
  padding: 32px clamp(20px, 5vw, 72px) 64px;
  color: white;
  background:
    radial-gradient(
      circle at 80% 0%,
      rgba(255, 255, 255, 0.12),
      transparent 28%
    ),
    linear-gradient(135deg, var(--wine-dark), var(--wine));
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.auth-brand > div {
  min-width: 0;
}

.auth-brand small {
  max-width: none;
  white-space: nowrap;
  font-size: 9px;
}

.auth-brand strong {
  display: block;
  color: var(--wine-dark);
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 58px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 6px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.08);
}
.brand-mark img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.brand small {
  display: block;
  opacity: 0.72;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 10px;
}
.brand strong {
  font:
    700 23px Georgia,
    serif;
  letter-spacing: 0.02em;
}
.top-copy {
  margin-top: 28px;
}
.top-copy h1 {
  margin: 0 0 7px;
  font:
    700 clamp(28px, 4vw, 44px) Georgia,
    serif;
}
.top-copy p {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
}
.app {
  width: min(1180px, calc(100% - 32px));
  margin: -38px auto 48px;
  position: relative;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 18px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.stat strong {
  display: block;
  margin-top: 7px;
  font-size: 30px;
  color: var(--wine-dark);
}
.panel {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.toolbar {
  padding: 22px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.class-filter {
  height: 46px;
  min-width: 190px;
  padding: 0 36px 0 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: white;
  outline: none;
}
.class-filter:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(166, 75, 53, 0.1);
}
.search {
  flex: 1;
  max-width: 500px;
  position: relative;
}
.search input {
  width: 100%;
  height: 46px;
  padding: 0 16px 0 43px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  outline: none;
}
.search input:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(166, 75, 53, 0.12);
}
.search::before {
  content: "⌕";
  position: absolute;
  left: 16px;
  top: 8px;
  font-size: 25px;
  color: var(--muted);
}
.btn {
  border: 0;
  border-radius: 12px;
  min-height: 46px;
  padding: 0 18px;
  font-weight: 750;
  transition: 0.18s ease;
}
.btn:hover {
  transform: translateY(-1px);
}
.btn-primary {
  color: #fff;
  background: var(--wine);
  box-shadow: 0 8px 18px rgba(91, 33, 24, 0.22);
}
.btn-light {
  background: #f2eae0;
  color: var(--wine);
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}
th {
  padding: 14px 20px;
  color: var(--muted);
  font-size: 11px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: #faf6f0;
}
td {
  padding: 17px 20px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
}
.couple strong {
  display: block;
  font-size: 15px;
}
.couple small {
  color: var(--muted);
}
.class-name {
  display: inline-flex;
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--wine);
  background: #f2e7dc;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 750;
}
.pill::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}
.paid {
  color: var(--green);
  background: #e6f4ec;
}
.pending {
  color: var(--red);
  background: #fbeae7;
}
.payments {
  display: flex;
  gap: 7px;
}
.person-payment {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin: 5px 0;
}
.person-payment-name {
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 750;
  color: var(--muted);
}
.month {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: white;
  font-size: 12px;
  font-weight: 800;
}
.month.on {
  color: white;
  background: var(--green);
  border-color: var(--green);
}
.count {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}
.actions {
  display: flex;
  gap: 6px;
}
.icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--wine);
}
.icon-btn:hover {
  background: #f7eee6;
}
.empty {
  text-align: center;
  padding: 60px 20px !important;
  color: var(--muted);
}
.empty b {
  display: block;
  color: var(--ink);
  margin-bottom: 5px;
}
dialog {
  width: min(560px, calc(100% - 28px));
  border: 0;
  border-radius: 22px;
  padding: 0;
  box-shadow: 0 30px 90px rgba(30, 12, 8, 0.3);
}
dialog::backdrop {
  background: rgba(35, 19, 15, 0.62);
  backdrop-filter: blur(4px);
}
.modal-head {
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.modal-head h2 {
  margin: 0 0 4px;
  font:
    700 26px Georgia,
    serif;
  color: var(--wine-dark);
}
.modal-head p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.close {
  border: 0;
  background: transparent;
  font-size: 24px;
  color: var(--muted);
}
form {
  padding: 24px 26px 26px;
}
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  margin-bottom: 7px;
}
.field input,
.field select {
  width: 100%;
  height: 45px;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0 13px;
  outline: none;
  background: white;
}
.field input:focus,
.field select:focus {
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(166, 75, 53, 0.1);
}
.wide {
  grid-column: 1/-1;
}
.checks {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.check {
  flex: 1;
  min-width: 110px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #faf7f2;
}
.check input {
  accent-color: var(--green);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}
.class-list {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  max-height: 220px;
  overflow: auto;
}
.class-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf7f2;
}
.class-item strong {
  display: block;
  font-size: 14px;
}
.class-item small {
  color: var(--muted);
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 13px 17px;
  border-radius: 12px;
  background: var(--wine-dark);
  color: white;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: 0.25s;
}
.toast.show {
  opacity: 1;
  transform: translateY(0);
}
@media (max-width: 760px) {
  .stats {
    grid-template-columns: 1fr 1fr;
  }
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }
  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .class-filter {
    min-width: 0;
    width: 100%;
  }
  .search {
    max-width: none;
  }
  .grid {
    grid-template-columns: 1fr;
  }
  .wide {
    grid-column: auto;
  }
  .topbar {
    padding-bottom: 60px;
  }
  .stat strong {
    font-size: 25px;
  }
}
/* Adaptação para celulares */
@media (max-width: 768px) {
  .auth-card {
    padding: 24px 20px;
  }
  .auth-copy h1 {
    font-size: 26px;
  }
  .account-bar {
    position: static;
    margin-top: 18px;
    justify-content: space-between;
  }
  body {
    overflow-x: hidden;
  }

  .topbar {
    min-height: 160px;
    padding: 24px 18px 55px;
  }

  .brand-mark {
    width: 50px;
    height: 45px;
    padding: 5px;
    border-radius: 13px;
  }

  .brand strong {
    font-size: 20px;
  }

  .top-copy {
    margin-top: 22px;
  }

  .top-copy h1 {
    font-size: 29px;
  }

  .top-copy p {
    font-size: 14px;
    line-height: 1.5;
  }

  .app {
    width: calc(100% - 24px);
    margin-top: -35px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .stat {
    padding: 15px;
    border-radius: 15px;
  }

  .stat span {
    font-size: 10px;
  }

  .stat strong {
    font-size: 25px;
  }

  .toolbar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 15px;
  }

  .search {
    width: 100%;
    max-width: none;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 1fr;
    width: 100%;
  }

  .class-filter,
  .toolbar-actions .btn {
    width: 100%;
  }

  /* Permite movimentar a tabela para os lados */
  .table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  table {
    min-width: 850px;
  }

  td,
  th {
    padding: 13px 12px;
  }

  .person-payment {
    grid-template-columns: 110px auto;
  }

  .month {
    width: 40px;
    height: 40px;
  }

  dialog {
    width: calc(100% - 20px);
    max-height: 92vh;
    overflow-y: auto;
    border-radius: 17px;
  }

  .modal-head {
    padding: 20px 18px 15px;
  }

  .modal-head h2 {
    font-size: 23px;
  }

  form {
    padding: 20px 18px;
  }

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

  .wide {
    grid-column: auto;
  }

  .checks {
    display: grid;
    grid-template-columns: 1fr;
  }

  .check {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-actions .btn {
    width: 100%;
  }

  .toast {
    right: 12px;
    left: 12px;
    bottom: 12px;
    text-align: center;
  }
}

/* Celulares muito pequenos */
@media (max-width: 380px) {
  .stats {
    grid-template-columns: 1fr;
  }

  .top-copy h1 {
    font-size: 25px;
  }
}

/* Rolagem dentro das janelas de cadastro */
dialog[open] {
  display: flex;
  flex-direction: column;
  max-height: 90vh;
  max-height: 90dvh;
  overflow: hidden;
}

dialog .modal-head {
  flex-shrink: 0;
}

dialog form {
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Ajuste para celulares */
@media (max-width: 768px) {
  dialog {
    width: calc(100% - 20px);
    max-height: 92vh;
    max-height: 92dvh;
    margin: auto;
  }

  dialog form {
    padding-bottom: 30px;
  }

  .modal-actions {
    position: sticky;
    bottom: -30px;
    padding: 15px 0;
    background: var(--paper);
    border-top: 1px solid var(--line);
  }
}

#person2Payments {
  display: block !important;
}
