: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: flex-end;
  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;
  justify-content: center;
  flex: 1;
  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;
}

/* ── Sidebar (admin / construtora) ──────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 200px;
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width 0.25s ease;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  min-height: 48px;
}

.sidebar-header .mark-logo {
  height: 22px;
  width: auto;
  flex-shrink: 0;
}

.sidebar-brand {
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px 0;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #cfd8e6;
  text-decoration: none;
  font-size: 0.85rem;
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  position: relative;
}

.sidebar-link:hover {
  color: #fff;
  background: rgba(255,255,255,0.06);
}

.sidebar-link.active {
  color: #fff;
  border-left-color: var(--gold);
  background: rgba(255,255,255,0.08);
}

.sidebar-link i,
.sidebar-link svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.sidebar-badge {
  margin-left: auto;
  background: var(--gold);
  color: var(--navy);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.4;
}

.sidebar-toggle {
  background: none;
  border: none;
  border-top: 1px solid rgba(255,255,255,0.1);
  color: #cfd8e6;
  cursor: pointer;
  padding: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.sidebar-toggle:hover {
  color: #fff;
}

.sidebar-toggle i,
.sidebar-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.25s ease;
}

/* ── Sidebar colapsada ──────────────────────────────────────────────────── */

.sidebar.collapsed {
  width: 64px;
}

.sidebar.collapsed .sidebar-brand {
  display: none;
}

.sidebar.collapsed .sidebar-link span {
  display: none;
}

.sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 12px;
}

.sidebar.collapsed .sidebar-badge {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 0 5px;
  font-size: 0.6rem;
}

.sidebar.collapsed .sidebar-header {
  justify-content: center;
  padding: 14px 6px;
}

.sidebar.collapsed .sidebar-toggle i,
.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

/* ── Topbar slim (admin / construtora) ──────────────────────────────────── */

.topbar--slim {
  margin-left: 200px;
  transition: margin-left 0.25s ease;
}

.user-menu-toggle {
  display: none;
  margin-left: auto;
  min-height: 44px;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.user-menu-toggle svg { width: 18px; height: 18px; }

.sidebar.collapsed ~ .topbar--slim {
  margin-left: 64px;
}

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

/* ── Container com sidebar ──────────────────────────────────────────────── */

.container--sidebar {
  margin-left: 200px;
  transition: margin-left 0.25s ease;
}

.sidebar.collapsed ~ .container--sidebar {
  margin-left: 64px;
}

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

.container--sidebar.narrow {
  margin-left: max(200px, calc((100% - 280px) / 2));
}

.sidebar.collapsed ~ .container--sidebar.narrow {
  margin-left: max(64px, calc((100% - 416px) / 2));
}

.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);
}

/* ── Password toggle ─────────────────────────────────────────────────── */
.password-toggle-wrap {
  position: relative;
}
.password-toggle-wrap input {
  padding-right: 42px;
}
.password-toggle-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color 0.15s, background 0.15s;
}
.password-toggle-btn:hover {
  color: var(--navy);
  background: rgba(0,0,0,0.05);
}
.password-toggle-btn svg {
  width: 18px;
  height: 18px;
}

.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; }

.action-row { display: grid; gap: 8px; margin-top: 12px; }
.action-row form { margin: 0; }
.action-row .btn { width: 100%; }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; }
.public-action-primary { width: 100%; margin-top: 16px; }
.public-action { width: 100%; margin-top: 10px; }
.public-alert-status {
  border-radius: 10px;
  margin: 16px 0;
  padding: 12px 14px;
  font-size: 0.88rem;
  line-height: 1.5;
}
.public-alert-status-enviado { background: var(--green-bg); color: var(--green); }
.public-alert-status-simulado,
.public-alert-status-parcial,
.public-alert-status-nao_configurado { background: #fff7e0; color: #7a4b00; }
.public-alert-status-falhou { background: var(--red-bg); color: var(--red); }
.form-inline { display: inline; }

.consent-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0 4px;
  cursor: pointer;
  font-size: 0.88rem;
  line-height: 1.45;
}
.consent-check input { width: auto; margin-top: 3px; }

.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); }
.flash-warning { background: #fff7e0; color: #7a4b00; }

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.cal-fora-mes { 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: #e0f2fe; color: #0369a1; }
.pill-ativo { background: var(--green-bg); color: var(--green); }
.pill-realizado { background: #e5e7eb; color: #374151; }
.pill-proposta { background: #e0f2fe; color: #075985; }
.pill-negociacao { background: #fef3c7; color: #854d0e; }
.pill-fechado { background: #dcfce7; color: #166534; }
.pill-perdido { background: #fee2e2; color: #991b1b; }
.pill-recusado, .pill-cancelado { background: var(--red-bg); color: var(--red); }
.pill-aguardando_confirmacao { background: var(--amber-bg); color: var(--amber); }
.pill-confirmado { background: var(--green-bg); color: var(--green); }
.pill-contestado { background: var(--red-bg); color: var(--red); }
.pill-visita_recusada { background: var(--red-bg); color: var(--red); }
.pill-enviado { background: #dcfce7; color: #166534; }
.pill-simulado { background: #e9ecff; color: #4338ca; }
.pill-falhou { background: #fee2e2; color: #991b1b; }
.pill-neutral { background: #eef0f3; color: #4b5563; }

.context-link {
  color: var(--text-muted);
  font-size: 0.82rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.context-link:hover, .context-link:focus-visible { color: var(--navy); }

.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; }
.filters .btn { flex: 0 0 auto; width: auto; }
.filters-stretch { align-items: end; margin-bottom: 14px; }
.filters-stretch .btn { width: auto; }

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

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-2 > * { min-width: 0; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; width: 100%; } }

.grid-agenda { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(320px, .8fr); gap: 20px; align-items: start; }
@media (max-width: 960px) { .grid-agenda { grid-template-columns: 1fr; } }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; text-decoration: none; display: flex; flex-direction: column; gap: 4px; }
.stat-card:hover { border-color: var(--green); box-shadow: 0 8px 22px rgba(36,36,44,.08); }
.stat-card strong { font-size: 1.8rem; line-height: 1; color: var(--navy); }
.stat-card small, .stat-label { color: var(--text-muted); }
.stat-label { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 820px) { .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .stats-grid { 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;
  margin: 0;
  cursor: pointer;
}

/* 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-passado { background: #f2f2f2; opacity: .55; }
.cal-marcado { background: var(--green-bg); border-color: var(--green); box-shadow: 0 0 0 2px rgba(49,180,84,.12); }
.calendar-batch .cal-day { height: 82px; padding: 6px; }
.cal-select-label { display: flex; align-items: center; justify-content: center; gap: 5px; margin: 0; cursor: pointer; }
.cal-select-label input { width: auto; margin: 0; }
.calendar-batch .cal-edit-link { display: block; height: auto; margin-top: 5px; font-size: .64rem; color: var(--text-muted); text-decoration: underline; }
.calendar-batch .cal-dot { position: absolute; right: 4px; bottom: 4px; }
.batch-toolbar { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.batch-settings { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 16px; align-items: end; margin-top: 16px; }
.batch-settings h3, .agenda-day-panel h3 { margin: 0 0 8px; font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.capacity-field label { margin-top: 0; }
.selection-summary { margin-top: 10px; padding: 8px 10px; border-radius: 8px; background: #f7f8fa; color: var(--text-muted); font-size: .82rem; }
.agenda-day-panel { min-width: 0; }
.agenda-day-table { min-width: 520px; }
.btn-inline { width: auto; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 18px; color: var(--text-muted); font-size: .85rem; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.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 .check-success { background: #e7f7ee; color: #1a9c5b; }
.comprovante-card .check-question { background: #eef2ff; color: #4338ca; }
.comprovante-card .check-warning { background: #fff7ed; color: #c2410c; }
.comprovante-card .check-danger { background: #fef2f2; color: #dc2626; }

.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;
}

.comprovante-actions { display: grid; gap: 8px; }
.comprovante-actions .btn { width: 100%; }

.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); }
.cpf-status { display: block; min-height: 1.2em; margin-top: .25rem; }
.small { font-size: 0.82rem; }
.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 1rem; }
/* ── Responsivo ─────────────────────────────────────────────────────────── */

/* Sidebar: colapsa automaticamente em telas menores, mas permite expandir */
@media (max-width: 786px) {
  .sidebar {
    width: 64px;
  }

  .sidebar .sidebar-brand {
    display: none;
  }

  .sidebar .sidebar-link span {
    display: none;
  }

  .sidebar .sidebar-link {
    justify-content: center;
    padding: 12px;
  }

  .sidebar .sidebar-header {
    justify-content: center;
    padding: 14px 6px;
  }

  .sidebar .sidebar-badge {
    position: absolute;
    top: 6px;
    right: 8px;
    padding: 0 5px;
    font-size: 0.6rem;
  }

  .sidebar .sidebar-toggle i,
  .sidebar .sidebar-toggle svg {
    transform: rotate(180deg);
  }

  /* Expandido: sobrepõe o conteúdo */
  .sidebar:not(.collapsed) {
    width: 200px;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }

  .sidebar:not(.collapsed) .sidebar-brand {
    display: inline;
  }

  .sidebar:not(.collapsed) .sidebar-link span {
    display: inline;
  }

  .sidebar:not(.collapsed) .sidebar-link {
    justify-content: flex-start;
    padding: 9px 16px;
  }

  .sidebar:not(.collapsed) .sidebar-header {
    justify-content: flex-start;
    padding: 14px 16px;
  }

  .sidebar:not(.collapsed) .sidebar-toggle i,
  .sidebar:not(.collapsed) .sidebar-toggle svg {
    transform: rotate(0deg);
  }

  /* Backdrop */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 190;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .topbar--slim {
    margin-left: 64px;
  }

  .topbar--slim .user-menu-toggle {
    display: inline-flex;
  }

  .topbar--slim .user {
    flex-wrap: wrap;
  }

  .topbar--slim .user > span {
    flex: 1 0 100%;
  }

  .container--sidebar {
    margin-left: 64px;
  }

  .container--sidebar.narrow {
    margin-left: max(64px, calc((100% - 416px) / 2));
  }

  .container--sidebar .filters-stretch {
    flex-direction: column;
    align-items: stretch;
  }

  .container--sidebar .filters-stretch .btn {
    width: 100%;
  }

  .container--sidebar .grid-2 {
    grid-template-columns: 1fr;
    width: 100%;
  }

  .container--sidebar .grid-2 .edit-field {
    min-width: 0;
  }

  .container--sidebar .grid-2 .edit-field input,
  .container--sidebar .grid-2 .edit-field select {
    width: 100%;
  }

  .container--sidebar .card {
    padding: 16px;
  }

  .container--sidebar .page-title {
    font-size: 1.15rem;
  }
}

/* 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%;
    flex: none;
    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;
  }

  .calendar-batch .cal-day {
    height: 72px;
    padding: 3px;
  }

  .cal-select-label { gap: 2px; }
  .cal-edit-link { font-size: .58rem; }
  .batch-settings { grid-template-columns: 1fr; }
}

/* 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;
    align-items: normal;
  }

  .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%;
  }
}

/* Agenda unificada e calendário de disponibilidade do corretor */
.agenda-presets { margin-bottom: 20px; }
.agenda-interval { margin-bottom: 20px; }
.agenda-range-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.agenda-range-fields label { margin-top: 0; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin: 14px 0; }
.preset-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; justify-content: space-between; gap: 10px; background: #fff; }
.preset-card p { margin: 4px 0 0; }
.preset-create { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 14px; }
.preset-create summary { cursor: pointer; font-weight: 700; color: var(--navy); }
.preset-form { margin-top: 14px; }
.weekday-options { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 14px; }
.weekday-options label { display: inline-flex; align-items: center; gap: 5px; margin: 0; }
.weekday-options input { width: auto; margin: 0; }
.is-hidden { display: none !important; }
.text-error { color: var(--red) !important; }

.booking-calendar { margin: 16px 0; }
.booking-calendar-header { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; margin-bottom: 12px; }
.booking-calendar-header h3 { margin: 0; text-align: center; }
.booking-calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.booking-weekday { color: var(--text-muted); font-size: .72rem; font-weight: 700; text-align: center; padding: 4px 0; text-transform: uppercase; }
.booking-day { min-height: 68px; border: 1px solid var(--border); border-radius: 10px; background: var(--green-bg); color: var(--text); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 6px; }
.booking-day strong { font-size: .95rem; }
.booking-day span { font-size: .62rem; color: var(--green); line-height: 1.15; text-align: center; }
.booking-day:hover:not(:disabled), .booking-day.is-selected { border-color: var(--green); box-shadow: 0 0 0 2px rgba(49,180,84,.16); }
.booking-day:disabled { background: #f5f5f5; color: #a0a0a0; cursor: not-allowed; opacity: .72; }
.booking-day:disabled span { color: #999; }
.booking-day-empty { background: transparent; border-color: transparent; }
.booking-calendar-status { min-height: 20px; margin: 10px 0; }
.booking-slots { border-top: 1px solid var(--border); margin-top: 12px; padding-top: 12px; }
.booking-slots h3 { margin-top: 0; }

@media (max-width: 640px) {
  .agenda-range-fields { grid-template-columns: 1fr; }
  .booking-calendar-grid { gap: 3px; }
  .booking-day { min-height: 56px; padding: 4px 2px; border-radius: 7px; }
  .booking-day span { font-size: .54rem; }
  .booking-weekday { font-size: .62rem; }
  .preset-grid { grid-template-columns: 1fr; }
}

/* Admin dashboard — calendário de agendamentos */
[data-admin-calendar] table.calendar { border-spacing: 6px; }
[data-admin-calendar] .cal-day { height: 90px; padding: 8px 4px; vertical-align: middle; text-align: center; }
[data-admin-calendar] .cal-day-button { width: 100%; min-height: 74px; display: flex; flex-direction: column; align-items: center; justify-content: center; border: 0; border-radius: 8px; background: transparent; color: inherit; font: inherit; cursor: pointer; }
[data-admin-calendar] .cal-day-button:hover { background: rgba(49,180,84,.08); }
[data-admin-calendar] .cal-day-button:focus-visible { outline: 3px solid rgba(49,180,84,.45); outline-offset: 1px; }
[data-admin-calendar] .cal-num { font-size: 1.15rem; font-weight: 700; display: block; margin-bottom: 4px; }
[data-admin-calendar] .cal-dot { font-size: 0.85rem; font-weight: 700; padding: 2px 8px; min-width: 24px; display: block; margin: 0 auto; text-align: center; border-radius: 999px; }
[data-admin-calendar] .cal-passado { opacity: 0.6; }
.cal-dot-azul { background: #e8f0fe; color: #1a73e8; }
.cal-filtrado { background: #e8f0fe; border-color: #a8c7fa; }

.filter-bar-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filter-bar-row label { display: block; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 3px; text-transform: uppercase; letter-spacing: 0.03em; }
.filter-bar-row select,
.filter-bar-row input[type="date"] { min-width: 140px; }
.filter-bar-actions { display: flex; gap: 6px; align-items: flex-end; padding-bottom: 1px; }
.action-row-admin {display: flex; flex-wrap: wrap; gap: 8px;}
@media (max-width: 768px) {
  [data-admin-calendar] table.calendar { border-spacing: 3px; }
  [data-admin-calendar] .cal-day { height: 52px; padding: 4px 2px; }
  [data-admin-calendar] .cal-day-button { min-height: 42px; padding: 2px; }
  [data-admin-calendar] .cal-num { font-size: 0.85rem; margin-bottom: 2px; }
  [data-admin-calendar] .cal-dot { font-size: 0.65rem; padding: 1px 5px; min-width: 18px; }
  .filter-bar-row { flex-direction: column; gap: 8px; }
  .filter-bar-row > div {width: 100%;}
  .filter-bar-row select,
  .filter-bar-row input[type="date"] { min-width: 100%; }
  .filter-bar-actions { width: 100%; }
}
