*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #3b82f6;
  --blue-light: #eff6ff;
  --blue-dark: #1d4ed8;
  --green: #22c55e;
  --green-light: #dcfce7;
  --green-text: #16a34a;
  --yellow: #f59e0b;
  --yellow-light: #fef3c7;
  --yellow-text: #b45309;
  --red: #ef4444;
  --red-light: #fee2e2;
  --red-text: #b91c1c;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --sidebar-w: 220px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.5;
}

/* ─── Sidebar ─── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--gray-200);
}

.sidebar-brand h1 {
  font-size: 15px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -.2px;
}

.sidebar-brand p {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  color: var(--gray-600);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background .15s, color .15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-item:hover { background: var(--gray-100); color: var(--gray-900); }
.nav-item.active { background: var(--blue-light); color: var(--blue); }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-section {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--gray-400);
}

.nav-sub {
  padding-left: 24px;
  font-size: 12.5px;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--gray-200);
}

.user-info {
  margin-bottom: 8px;
}

.user-label {
  display: block;
  font-size: 10px;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.user-name {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin-top: 2px;
}

.logout-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-500);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 0;
  transition: color .15s;
}

.logout-btn:hover { color: var(--red); }

/* ─── Main layout ─── */
.main-content {
  margin-left: var(--sidebar-w);
  padding: 32px;
  min-height: 100vh;
}

.page-header {
  margin-bottom: 24px;
}

.page-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-900);
}

.page-header p {
  color: var(--gray-500);
  margin-top: 4px;
  font-size: 13px;
}

/* ─── Cards ─── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 16px;
}

/* ─── Login page ─── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #eff6ff 0%, #f1f5f9 100%);
}

.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--blue);
}

.login-logo p {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ─── Forms ─── */
.form-section {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.form-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row.triple {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-row.single {
  grid-template-columns: 1fr;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
}

label .required { color: var(--red); }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="number"],
input[type="email"],
input[type="tel"],
select,
textarea {
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
  color: var(--gray-900);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  outline: none;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

input::placeholder, textarea::placeholder { color: var(--gray-400); }

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

.hint {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

/* ─── Buttons ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  text-decoration: none;
}

.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--blue-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #16a34a; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b91c1c; }
.btn-outline {
  background: #fff;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover:not(:disabled) { background: var(--gray-50); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; width: 100%; }
.btn-icon { padding: 6px; }

/* ─── Calendar ─── */
.calendar-wrapper {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: start;
}

.calendar-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.calendar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-900);
}

.cal-nav {
  display: flex;
  gap: 4px;
}

.cal-nav-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  transition: background .15s;
}

.cal-nav-btn:hover { background: var(--gray-100); }

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-weekday {
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  padding: 8px 4px;
}

.cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius);
  padding: 6px;
  cursor: pointer;
  transition: all .15s;
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  min-height: 68px;
}

.cal-day:hover { border-color: var(--blue); background: var(--blue-light); }
.cal-day.selected { border-color: var(--blue) !important; background: var(--blue-light) !important; }
.cal-day.empty { cursor: default; }
.cal-day.empty:hover { border-color: transparent; background: transparent; }
.cal-day.today .cal-day-num {
  background: var(--blue);
  color: #fff;
  border-radius: 50%;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
}

.cal-day.avail-0 { background: #f0fdf4; }
.cal-day.avail-partial { background: #fefce8; }
.cal-day.avail-full { background: #fff1f2; }

.cal-day-num {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

.cal-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 10px;
  align-self: flex-end;
}

.badge-avail { background: var(--green-light); color: var(--green-text); }
.badge-partial { background: var(--yellow-light); color: var(--yellow-text); }
.badge-full { background: var(--red-light); color: var(--red-text); }

/* ─── Day details panel ─── */
.day-details {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  position: sticky;
  top: 32px;
}

.day-details-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--gray-200);
}

.day-empty-msg {
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
  padding: 24px 0;
  line-height: 1.6;
}

.visita-item {
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s;
}

.visita-item:hover { border-color: var(--blue); }
.visita-item-escola { font-weight: 600; font-size: 13px; color: var(--gray-900); }
.visita-item-info { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* ─── Table ─── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

td {
  padding: 12px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 13px;
  color: var(--gray-700);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

/* ─── Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-agendada { background: var(--blue-light); color: var(--blue); }
.badge-realizada { background: var(--green-light); color: var(--green-text); }
.badge-cancelada { background: var(--red-light); color: var(--red-text); }
.badge-admin { background: #fdf4ff; color: #7e22ce; }
.badge-user { background: var(--gray-100); color: var(--gray-600); }

/* ─── Stats ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-900);
  margin-top: 6px;
}

.stat-sub {
  font-size: 11px;
  color: var(--gray-400);
  margin-top: 2px;
}

.stat-blue .stat-value { color: var(--blue); }
.stat-green .stat-value { color: var(--green-text); }
.stat-yellow .stat-value { color: var(--yellow-text); }
.stat-red .stat-value { color: var(--red-text); }

/* ─── Multi-select colaboradores ─── */
.colab-select-container {
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  padding: 6px 8px;
  min-height: 42px;
  cursor: text;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}

.colab-select-container:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}

.colab-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 4px;
}

.colab-chip {
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.colab-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--blue);
  font-size: 14px;
  line-height: 1;
  padding: 0;
  opacity: .7;
}

.colab-chip button:hover { opacity: 1; }

.colab-input {
  border: none !important;
  padding: 2px 4px !important;
  box-shadow: none !important;
  min-width: 120px;
  background: transparent !important;
  font-size: 13px;
}

.colab-input:focus { box-shadow: none !important; }

.colab-dropdown {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  max-height: 200px;
  overflow-y: auto;
  margin-top: 2px;
}

.colab-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: var(--gray-700);
  transition: background .1s;
}

.colab-option:hover { background: var(--gray-50); }
.colab-option.selected { color: var(--gray-400); cursor: default; }
.colab-wrap { position: relative; }

/* ─── Modal ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
}

.modal {
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
}

.modal-close:hover { background: var(--gray-100); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ─── Alert / Toast ─── */
.alert {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
}

.alert-error { background: var(--red-light); color: var(--red-text); }
.alert-success { background: var(--green-light); color: var(--green-text); }

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  max-width: 320px;
  animation: slideIn .2s ease;
}

.toast-success { background: #fff; border-left: 4px solid var(--green); color: var(--gray-800); }
.toast-error { background: #fff; border-left: 4px solid var(--red); color: var(--gray-800); }

@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ─── Loading ─── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--gray-400);
  font-size: 13px;
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-right: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty state ─── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 16px;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  color: var(--gray-400);
}

/* ─── Filters bar ─── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filters-bar select,
.filters-bar input {
  width: auto;
  min-width: 140px;
}

/* ─── Ranking ─── */
.rank-list { display: flex; flex-direction: column; gap: 8px; }

.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.rank-pos {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-300);
  width: 32px;
  text-align: center;
}

.rank-pos.gold { color: #f59e0b; }
.rank-pos.silver { color: #94a3b8; }
.rank-pos.bronze { color: #d97706; }

.rank-name { flex: 1; font-weight: 600; font-size: 14px; }
.rank-count { color: var(--gray-500); font-size: 13px; }

.rank-bar-wrap { width: 120px; background: var(--gray-100); border-radius: 10px; height: 8px; }
.rank-bar { height: 8px; border-radius: 10px; background: var(--blue); transition: width .5s; }

/* ─── Responsivo ─── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .calendar-wrapper { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .form-row.triple { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
