:root {
  /* Cores oficiais — Manual de Identidade Visual Santa Maria */
  --navy: #34343f;        /* Preto Chumbo */
  --navy-dark: #24242c;   /* Preto Chumbo, sombreado */
  --gold: #31b454;        /* Verde Folha de Bananeira (mantém o nome da variável --gold por compatibilidade com os templates) */
  --gold-dark: #279143;
  --bg: #f4f4f4;          /* aprox. Cinza Platina, mais clara p/ leitura em tela */
  --card-bg: #ffffff;
  --text: #24242c;
  --text-muted: #6b6b76;
  --border: #e3e3e3;      /* Cinza Platina */
  --green: #31b454;
  --green-bg: #e8f7ec;
  --red: #c0392b;
  --red-bg: #fdecea;
  --amber: #b3790c;
  --amber-bg: #fdf3dc;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
}

.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.topbar .brand .mark {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  font-weight: 900;
}

.topbar .brand .mark-logo {
  height: 28px;
  width: auto;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 0.92rem;
}

.topbar nav a {
  text-decoration: none;
  color: #cfd8e6;
  padding: 6px 4px;
  border-bottom: 2px solid transparent;
}

.topbar nav a:hover, .topbar nav a.active {
  color: #fff;
  border-bottom-color: var(--gold);
}

.topbar .user {
  font-size: 0.85rem;
  color: #cfd8e6;
  display: flex;
  align-items: center;
  gap: 10px;
}

.logout-form { margin: 0; }
.logout-form .btn { width: auto; }

.topbar .badge-pend {
  background: var(--gold);
  color: var(--navy);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.75rem;
  font-weight: 700;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

.container.narrow {
  max-width: 480px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--text-muted);
  margin: 0 0 24px;
  font-size: 0.95rem;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 20px;
}

.card h2 {
  font-size: 1.05rem;
  margin: 0 0 14px;
}

.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--navy) 0%, var(--navy-dark) 55%, #17171d 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

.login-card .mark {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--navy);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  font-size: 1.2rem;
  margin: 0 auto 14px;
}

.login-logo {
  display: block;
  height: 64px;
  width: auto;
  margin: 0 auto 18px;
}

.login-card h1 {
  text-align: center;
  font-size: 1.3rem;
  margin: 0 0 4px;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 24px;
}

.login-card .demo-hint {
  margin-top: 20px;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: #f8fafc;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  line-height: 1.5;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin: 14px 0 6px;
}

input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.94rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

textarea { resize: vertical; min-height: 70px; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(11,37,69,0.12);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 0.92rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary { background: var(--navy); color: #fff; width: 100%; margin-top: 18px; }
.btn-primary:hover { background: var(--navy-dark); }

.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-dark); }

.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--navy); }

.btn-danger { background: var(--red-bg); color: var(--red); border-color: #f3c9c4; }
.btn-danger:hover { background: #fbdbd7; }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }

.flash {
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.88rem;
}
.flash-error { background: var(--red-bg); color: var(--red); }
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-info { background: #eaf1fb; color: var(--navy); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
}
.pill-cadastrado { background: var(--amber-bg); color: var(--amber); }
.pill-agenda_liberada { background: #e9ecff; color: #4338ca; }
.pill-agendado { background: var(--green-bg); color: var(--green); }
.pill-realizado { background: #e5e7eb; color: #374151; }
.pill-recusado, .pill-cancelado { background: var(--red-bg); color: var(--red); }

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters select { width: auto; }
.filters input[type="text"] { flex: 1; min-width: 200px; }

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

.detail-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.92rem; }
.detail-row:last-child { border-bottom: none; }
.detail-row .k { color: var(--text-muted); }
.detail-row .v { font-weight: 600; text-align: right; }

.slot-list { display: flex; flex-direction: column; gap: 8px; }
.slot-option {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Calendário da agenda */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.cal-title {
  margin: 0;
  font-size: 1rem;
  text-transform: capitalize;
}

table.calendar {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 4px;
}

table.calendar th {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-bottom: 6px;
  text-align: center;
  border: none;
}

.cal-day {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0;
  text-align: center;
  vertical-align: top;
  height: 52px;
  position: relative;
}

.cal-day a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-decoration: none;
  color: var(--text);
  gap: 2px;
}

.cal-num { font-size: 0.85rem; font-weight: 600; }

.cal-fora-mes { opacity: 0.35; }
.cal-fora-mes .cal-num { font-weight: 400; }

.cal-hoje { border-color: var(--navy); }
.cal-hoje .cal-num { color: var(--navy); }

.cal-selecionado { background: var(--green-bg); border-color: var(--green); }

.cal-dot {
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 999px;
  padding: 0 6px;
  line-height: 1.4;
  min-width: 16px;
}

.cal-dot-verde { background: var(--green-bg); color: var(--green); }
.cal-dot-cinza { background: #ececec; color: #7a7a7a; }

.horarios-padrao {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 4px;
}

.horario-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.horario-chip:has(input:checked) {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--gold-dark);
}

.comprovante-shell {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  justify-content: center;
  padding: 40px 16px;
}

.comprovante-card {
  background: #fff;
  border-radius: 16px;
  max-width: 420px;
  width: 100%;
  padding: 32px 28px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  text-align: center;
  height: fit-content;
}

.comprovante-logo {
  display: block;
  height: 40px;
  width: auto;
  margin: 0 auto 20px;
}

.comprovante-card .check {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--green-bg);
  color: var(--green);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 8px auto 18px;
}

.comprovante-card h1 { font-size: 1.25rem; margin: 0 0 8px; }
.comprovante-card p.lead-text { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 22px; }

.comprovante-card .detail-box {
  background: #f8fafc;
  border-radius: 10px;
  padding: 16px 18px;
  text-align: left;
  margin-bottom: 18px;
}

.comprovante-card .ref {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 18px;
}

.footer-note {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 30px;
}

.email-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.email-preview iframe { width: 100%; height: 480px; border: none; }

.muted { color: var(--text-muted); }
.small { font-size: 0.82rem; }
.mt-0 { margin-top: 0; }

/* ── Responsivo ─────────────────────────────────────────────────────────── */

/* Hamburger button — escondido no desktop */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  z-index: 100;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  margin: 5px 0;
  transition: transform 0.25s, opacity 0.25s;
}

.hamburger.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger.open span:nth-child(2) {
  opacity: 0;
}
.hamburger.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Topbar: empilha no mobile */
@media (max-width: 768px) {
  .hamburger {
    display: block;
  }

  .topbar {
    flex-wrap: wrap;
    padding: 12px 16px;
    gap: 10px;
  }

  .topbar .brand {
    font-size: 0.95rem;
  }

  .topbar nav {
    order: 3;
    width: 100%;
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 8px 0;
    border-top: 1px solid rgba(255,255,255,0.15);
  }

  .topbar nav.open {
    display: flex;
  }

  .topbar nav a {
    white-space: nowrap;
    padding: 12px 4px;
    font-size: 0.92rem;
    border-bottom: none;
    border-left: 3px solid transparent;
  }

  .topbar nav a:hover, .topbar nav a.active {
    border-bottom: none;
    border-left-color: var(--gold);
    background: rgba(255,255,255,0.06);
  }

  .topbar .user {
    display: none;
    font-size: 0.85rem;
    order: 4;
    width: 100%;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.15);
    justify-content: space-between;
    align-items: center;
  }

  .topbar .user.open {
    display: flex;
  }

  .container {
    padding: 20px 14px 40px;
  }

  .card {
    padding: 16px;
  }
}

/* Tabelas: responsivas */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Botões menores: toque maior */
@media (max-width: 768px) {
  .btn-sm {
    padding: 10px 14px;
    font-size: 0.85rem;
    min-height: 44px;
  }
}

/* Detail row: overflow protection */
.detail-row {
  min-width: 0;
}

.detail-row .k,
.detail-row .v {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-row .k {
  flex: 1 1 auto;
  min-width: 0;
}

.detail-row .v {
  flex: 0 0 auto;
  max-width: 55%;
  margin-left: 12px;
  text-align: right;
}

/* Calendário: compacto no mobile */
@media (max-width: 768px) {
  table.calendar {
    border-spacing: 2px;
  }

  .cal-day {
    height: 44px;
  }

  .cal-num {
    font-size: 0.78rem;
  }

  .cal-dot {
    font-size: 0.6rem;
    padding: 0 4px;
  }

  .cal-header {
    margin-bottom: 10px;
  }

  .cal-title {
    font-size: 0.9rem;
  }
}

/* Horários padrão (chips): maior toque */
@media (max-width: 768px) {
  .horario-chip {
    padding: 10px 14px;
    font-size: 0.88rem;
  }
}

/* Ações de tabela: empilha no mobile */
@media (max-width: 768px) {
  .td-acoes {
    white-space: normal !important;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .td-acoes form {
    display: flex !important;
    gap: 6px;
  }

  .td-acoes .btn-sm {
    flex: 1;
    min-height: 40px;
  }
}

/* Filtros: empilha selects no mobile */
@media (max-width: 480px) {
  .filters {
    width: 100%;
  }

  .filters select {
    width: 100%;
  }
}

/* Login / 404 / Comprovante: já responsivos, mas ajusta padding */
@media (max-width: 480px) {
  .login-card {
    padding: 28px 20px;
  }

  .comprovante-card {
    padding: 24px 18px;
  }

  .comprovante-shell {
    padding: 24px 12px;
  }
}

/* Formulário de edição inline: empilha no mobile */
.edit-form {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.edit-field {
  flex: 1 1 160px;
  min-width: 0;
}

@media (max-width: 600px) {
  .edit-form {
    flex-direction: column;
    gap: 12px;
  }

  .edit-field {
    flex: 1 1 100%;
  }

  .edit-form .btn {
    width: 100%;
  }

  .flex-split {
    flex-direction: column;
    gap: 8px;
  }

  .flex-split form {
    width: 100%;
  }

  .flex-split .btn {
    width: 100%;
  }
}
