/* ============================================
   PLACIDO PILATES & FISIOTERAPIA
   Sistema de Gerenciamento - Estilos Globais
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;500;600;700&family=Inter:wght@300;400;500;600;700&display=swap');

/* ---- CSS Variables ---- */
:root {
  /* Paleta Principal - Tons quentes e sofisticados */
  --primary: #8B6F4E;
  --primary-light: #A88B6E;
  --primary-dark: #6B5238;
  --primary-50: #F5EFE8;
  --primary-100: #E8D9C8;

  /* Tons secundários */
  --secondary: #5C8A7A;
  --secondary-light: #7DAF9E;
  --secondary-dark: #3E6A5B;
  --secondary-50: #EBF3F0;

  /* Neutros */
  --white: #FFFFFF;
  --gray-50: #FAFAF8;
  --gray-100: #F4F2EF;
  --gray-200: #E8E4DE;
  --gray-300: #D4CFC7;
  --gray-400: #A8A29A;
  --gray-500: #8A8480;
  --gray-600: #6B6560;
  --gray-700: #4A4540;
  --gray-800: #2E2A25;
  --gray-900: #1A1714;

  /* Status */
  --success: #2E8B5A;
  --success-light: #E8F5EE;
  --warning: #D4A017;
  --warning-light: #FDF6E3;
  --danger: #C0392B;
  --danger-light: #FDECEA;
  --info: #2980B9;
  --info-light: #EBF5FB;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 70px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;

  /* Sombras */
  --shadow-sm: 0 1px 3px rgba(139, 111, 78, 0.08), 0 1px 2px rgba(139, 111, 78, 0.06);
  --shadow: 0 4px 6px rgba(139, 111, 78, 0.07), 0 2px 4px rgba(139, 111, 78, 0.06);
  --shadow-md: 0 10px 25px rgba(139, 111, 78, 0.1), 0 4px 10px rgba(139, 111, 78, 0.08);
  --shadow-lg: 0 20px 40px rgba(139, 111, 78, 0.12);

  /* Transições */
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-fast: all 0.15s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---- Tipografia ---- */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Playfair Display', Georgia, serif;
  line-height: 1.3;
  color: var(--gray-900);
}

a {
  text-decoration: none;
  color: inherit;
  transition: var(--transition-fast);
}

/* ============================================
   LAYOUT PRINCIPAL
   ============================================ */

.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;          /* garante largura do viewport */
  overflow-x: hidden;   /* bloqueia scroll horizontal global */
  position: relative;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(165deg, #3D2C1E 0%, #5C3D22 40%, #6B4C2A 100%);
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: var(--transition);
  overflow: hidden;
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.02'%3E%3Ccircle cx='30' cy='30' r='20'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  pointer-events: none;
}

/* Logo da Sidebar */
.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}

.sidebar-logo-icon {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sidebar-logo-text {
  flex: 1;
}

.sidebar-logo-title {
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-weight: 700;
  color: #FFFFFF;
  line-height: 1.2;
}

.sidebar-logo-subtitle {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.55);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 500;
}

/* Navegação */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: rgba(255, 255, 255, 0.35);
  padding: 8px 12px 6px;
  margin-top: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 10px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 2px;
  position: relative;
  border: 1px solid transparent;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.95);
  transform: translateX(2px);
}

.nav-item.active {
  background: linear-gradient(135deg, rgba(139, 111, 78, 0.35), rgba(139, 111, 78, 0.2));
  color: #FFFFFF;
  border-color: rgba(168, 139, 110, 0.25);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary-light);
  border-radius: 0 3px 3px 0;
}

.nav-item-icon {
  font-size: 18px;
  width: 22px;
  text-align: center;
  flex-shrink: 0;
}

.nav-item-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

/* Footer da Sidebar */
.sidebar-footer {
  padding: 16px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}

.sidebar-user:hover {
  background: rgba(255, 255, 255, 0.06);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: white;
  font-weight: 600;
  flex-shrink: 0;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
  /* NÃO usar width:100% aqui — com margin-left causaria overflow */
  /* flex:1 já ocupa o espaço restante corretamente */
}

/* ---- Top Header ---- */
.top-header {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  gap: 16px;
  width: 100%;          /* não ultrapassa o viewport */
  overflow: hidden;     /* garante que não vaza */
  box-sizing: border-box;
}

.header-title-area {
  flex: 1;
  min-width: 0;       /* permite truncar em vez de expanir */
  overflow: hidden;
}

.header-page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  font-family: 'Playfair Display', serif;
}

.header-breadcrumb {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-100);
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  padding: 8px 14px;
  transition: var(--transition);
}

.header-search:focus-within {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(139, 111, 78, 0.1);
}

.header-search input {
  border: none;
  background: transparent;
  font-size: 14px;
  color: var(--gray-700);
  outline: none;
  width: 200px;
  font-family: 'Inter', sans-serif;
}

.header-search input::placeholder {
  color: var(--gray-400);
}

.header-search-icon {
  color: var(--gray-400);
  font-size: 15px;
}

.header-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1.5px solid var(--gray-200);
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  color: var(--gray-500);
  transition: var(--transition);
  position: relative;
}

.header-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-50);
}

.header-btn .badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background: var(--danger);
  border-radius: 50%;
  font-size: 9px;
  color: white;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--white);
}

/* ---- Page Content ---- */
.page-content {
  flex: 1;
  padding: 28px;
  display: none;
  min-width: 0;     /* previne overflow em column-flex */
  width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
}

.page-content.active {
  display: block;
}

/* ============================================
   COMPONENTS
   ============================================ */

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  transition: var(--transition);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  font-family: 'Playfair Display', serif;
}

.card-subtitle {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 2px;
}

.card-body {
  padding: 20px 24px;
}

/* ---- Stat Cards ---- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 22px 24px;
  border: 1px solid var(--gray-100);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--stat-color, var(--primary)), transparent);
}

.stat-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.stat-icon-wrap {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--stat-bg, var(--primary-50));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-info {
  flex: 1;
  min-width: 0;
}

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

.stat-value {
  font-size: 28px;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  color: var(--gray-900);
  line-height: 1;
  margin-bottom: 6px;
}

.stat-change {
  font-size: 12px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }
.stat-change.neutral { color: var(--gray-500); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: var(--transition);
  border: 1.5px solid transparent;
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.4;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  border-color: var(--primary-dark);
  box-shadow: 0 2px 8px rgba(139, 111, 78, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-dark), #5A3F25);
  box-shadow: 0 4px 14px rgba(139, 111, 78, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--secondary);
  color: white;
  border-color: var(--secondary-dark);
  box-shadow: 0 2px 8px rgba(92, 138, 122, 0.3);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--secondary-dark);
  box-shadow: 0 4px 14px rgba(92, 138, 122, 0.4);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}

.btn-outline:hover:not(:disabled) {
  background: var(--primary-50);
}

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border-color: var(--gray-200);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--gray-100);
  color: var(--gray-800);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: #A93226;
}

.btn-danger:hover:not(:disabled) {
  background: #A93226;
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
  border-radius: 6px;
}

.btn-lg {
  padding: 13px 24px;
  font-size: 15px;
  border-radius: 12px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 8px;
}

/* ---- Badges / Status ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #A07810; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-secondary { background: var(--secondary-50); color: var(--secondary-dark); }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }
.badge-primary { background: var(--primary-100); color: var(--primary-dark); }

/* ---- Forms ---- */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 7px;
}

.form-label.required::after {
  content: ' *';
  color: var(--danger);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--gray-800);
  background: var(--white);
  transition: var(--transition-fast);
  outline: none;
  appearance: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 111, 78, 0.12);
}

.form-control::placeholder {
  color: var(--gray-400);
}

.form-control:disabled {
  background: var(--gray-100);
  cursor: not-allowed;
}

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238A8480' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 38px;
  cursor: pointer;
}

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.form-hint {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 5px;
}

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

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

/* ---- Tables ---- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--border-radius-sm);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1.5px solid var(--gray-200);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: var(--transition-fast);
}

.data-table tbody tr:hover {
  background: var(--primary-50);
}

.data-table tbody tr:last-child {
  border-bottom: none;
}

.data-table tbody td {
  padding: 14px 16px;
  color: var(--gray-700);
  vertical-align: middle;
}

.data-table .td-name {
  font-weight: 600;
  color: var(--gray-900);
}

/* ---- Modais ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95) translateY(10px);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-lg { max-width: 800px; }
.modal-sm { max-width: 420px; }

.modal-header {
  padding: 22px 26px 18px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  color: var(--gray-900);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--gray-100);
  color: var(--gray-500);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: var(--transition-fast);
}

.modal-close:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}

.modal-body {
  padding: 24px 26px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 18px 26px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

/* ---- Avatar / Aluno ---- */
.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.avatar-sm {
  width: 30px;
  height: 30px;
  font-size: 11px;
}

.avatar-lg {
  width: 56px;
  height: 56px;
  font-size: 20px;
  border-radius: 16px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 60px 30px;
  color: var(--gray-500);
}

.empty-state-icon {
  font-size: 52px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  font-family: 'Playfair Display', serif;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 14px;
  margin-bottom: 20px;
}

/* ---- Loading ---- */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ---- Toast Notifications ---- */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}

.toast {
  background: var(--white);
  border-radius: var(--border-radius-sm);
  box-shadow: var(--shadow-md);
  padding: 14px 18px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border-left: 4px solid var(--primary);
  animation: slideInRight 0.3s ease;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-body { flex: 1; }
.toast-title { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.toast-msg { font-size: 13px; color: var(--gray-600); margin-top: 2px; }

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- Filtros e Toolbar ---- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  padding: 8px 14px;
  transition: var(--transition-fast);
}

.search-input-wrap:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 111, 78, 0.1);
}

.search-input-wrap input {
  border: none;
  outline: none;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  color: var(--gray-700);
  background: transparent;
  width: 220px;
}

.search-input-wrap input::placeholder {
  color: var(--gray-400);
}

/* ---- Página de Seção ---- */
.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;   /* permite quebrar em telas menores */
  width: 100%;       /* ocupa largura total do pai */
  box-sizing: border-box;
  min-width: 0;
}

.section-title {
  font-size: 22px;
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  color: var(--gray-900);
}

.section-subtitle {
  font-size: 14px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ---- Calendar / Agenda ---- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: var(--gray-200);
  border-radius: 10px;
  overflow: hidden;
}

.calendar-day-header {
  background: var(--gray-50);
  text-align: center;
  padding: 10px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gray-500);
  letter-spacing: 0.5px;
}

.calendar-day {
  background: var(--white);
  min-height: 90px;
  padding: 8px;
  cursor: pointer;
  transition: var(--transition-fast);
}

.calendar-day:hover {
  background: var(--primary-50);
}

.calendar-day.other-month {
  background: var(--gray-50);
  opacity: 0.5;
}

.calendar-day.today {
  background: var(--primary-50);
}

.calendar-day-number {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.calendar-day.today .calendar-day-number {
  background: var(--primary);
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.calendar-event {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--primary-100);
  color: var(--primary-dark);
  font-weight: 500;
}

/* ---- Progress Bars ---- */
.progress-bar {
  height: 6px;
  background: var(--gray-200);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 0.6s ease;
}

/* ---- Quick Actions ---- */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.quick-action-btn {
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 18px 16px;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.quick-action-btn:hover {
  border-color: var(--primary);
  background: var(--primary-50);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.quick-action-icon {
  font-size: 28px;
}

.quick-action-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
}

/* ---- Responsive ---- */
/* ============================================
   RESPONSIVIDADE — FASE 3 (v2 — corrigido)
   ============================================ */

/* ── OVERLAY MOBILE (fora de media query) ── */
.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 149;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeOverlay .2s ease;
}
.mobile-overlay.active { display: block; }
@keyframes fadeOverlay { from{opacity:0} to{opacity:1} }

/* Hamburger — oculto em desktop */
#menu-toggle { display: none; }

/* ============================================
   TABLET (≤ 1024px)
   Só reduz a sidebar. NÃO quebra grids gerais.
   ============================================ */
@media (max-width: 1024px) {
  :root { --sidebar-width: 220px; }

  /* BI: grids de 2 colunas → 1 no tablet */
  .bi-chart-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================
   MOBILE (≤ 768px)
   ============================================ */
@media (max-width: 768px) {

  /* ── Sidebar como drawer lateral ─────────── */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 150;
    width: var(--sidebar-width);
    transform: translateX(-100%);
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    box-shadow: 4px 0 24px rgba(0,0,0,.18);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0 !important;
  }

  /* ── Header ────────────────────────────── */
  #menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
  }

  .top-header {
    padding: 0 12px;
    gap: 8px;
  }

  .header-search { display: none; }
  .header-page-title { font-size: 15px; }
  .header-breadcrumb { display: none; }

  /* ── Layout da página ───────────────────── */
  .page-content {
    padding: 14px 12px;
  }

  /* ── Section header: coluna total no mobile ── */
  .section-header {
    flex-direction: column;
    align-items: stretch;   /* cada filho ocupa 100% da largura */
    gap: 10px;
    width: 100%;
  }

  /* Div de texto (título + subtítulo) */
  .section-header > div:first-child {
    width: 100%;
    min-width: 0;
  }

  /* Div de botões ocupa largura total */
  .section-header > div:last-child {
    width: 100%;
    flex-wrap: wrap;
    display: flex;
    gap: 8px;
  }

  /* ── Formulários ────────────────────────── */
  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  /* ── Stats / KPI grid ────────────────────── */
  .stat-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .stat-card { padding: 16px 14px; }

  /* ── Toolbar: empilha filtragem ─────────── */
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
    flex-wrap: wrap;
  }

  /* Selects e inputs da toolbar ficam full-width */
  .toolbar-left select,
  .toolbar-left input,
  .toolbar-right select,
  .toolbar-right input {
    flex: 1;
    min-width: 120px;
  }

  /* Botões de ação da toolbar NÃO esticam (apenas filtros) */
  .toolbar .btn-primary,
  .toolbar .btn-ghost,
  .toolbar .btn-outline {
    flex: 0 0 auto;
  }

  /* ── TABELAS: scroll horizontal ─────────── */
  /* Importante: NÃO converter em cards pois as TDs não têm data-label.
     Scroll horizontal é a solução mais confiável. */
  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Sombra nas arestas indica que há scroll disponível */
    background:
      linear-gradient(to right, white 30%, rgba(255,255,255,0)) center left,
      linear-gradient(to left,  white 30%, rgba(255,255,255,0)) center right,
      radial-gradient(farthest-side at 0   50%, rgba(0,0,0,.08), transparent) center left,
      radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.08), transparent) center right;
    background-repeat: no-repeat;
    background-attachment: local, local, scroll, scroll;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  }

  /* Garante que tabelas não colem umas nas outras */
  .data-table {
    min-width: 540px;
  }

  /* ── Card de avaliação na lista: scroll ── */
  .aval-metrics-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* ── MODAIS — bottom-sheet (não full-screen) */
  /* Modais ficam presos na base, rolam internamente */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-overlay .modal,
  .modal-overlay .modal-lg,
  .modal-overlay .modal-sm {
    width: 100% !important;
    max-width: 100% !important;
    max-height: 92vh;          /* Deixa 8% de espaço acima para fechar tocando */
    height: auto;              /* Altura pelo conteúdo, não fixa */
    border-radius: 20px 20px 0 0; /* Arredondado só no topo */
    margin: 0;
    display: flex;
    flex-direction: column;
    animation: slideUpModal .28s cubic-bezier(.4,0,.2,1);
  }

  @keyframes slideUpModal {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
  }

  /* Handle visual de "arraste para fechar" */
  .modal-header::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 0 auto 12px;
  }

  .modal-overlay .modal-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    /* Limita altura do body para que footer fique sempre visível */
    max-height: calc(92vh - 130px);
  }

  .modal-overlay .modal-footer {
    position: sticky;
    bottom: 0;
    background: var(--white);
    border-top: 1px solid var(--gray-100);
    z-index: 2;
    padding: 12px 20px;
    /* Safe area para notch/home bar em iPhones */
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  /* ── Pagamentos — resumo 2 colunas ──────── */
  .payment-summary {
    grid-template-columns: 1fr 1fr !important;
    gap: 10px;
  }

  .payment-metric {
    padding: 12px !important;
  }

  /* ── Dashboard ──────────────────────────── */
  .quick-actions-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  /* ── BI: gráficos 1 coluna ──────────────── */
  #bi-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Todos os grids de gráficos do BI */
  .bi-chart-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Relatórios: 1 coluna ────────────────── */
  .relatorios-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Configurações: empilha colunas ─────── */
  .config-grid {
    grid-template-columns: 1fr !important;
  }

  /* ── Inadimplência KPIs: 2 colunas ──────── */
  .inad-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── Dropdowns exportação ────────────────── */
  .dropdown-export {
    flex: 1;
  }

  .dropdown-export .btn {
    width: 100%;
    justify-content: center;
  }

  .export-menu {
    left: 0;
    right: 0;
    min-width: unset;
  }

  /* ── Notificações ────────────────────────── */
  .notif-panel {
    width: calc(100vw - 24px);
    right: -60px;
    max-height: 80vh;
  }

  /* ── CRM KPIs ────────────────────────────── */
  #crm-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* ── Calendário ──────────────────────────── */
  .cal-controls {
    flex-wrap: wrap;
    gap: 8px;
  }

  .cal-period-label {
    font-size: 13px;
    order: -1;
    width: 100%;
    text-align: center;
  }
}

/* ============================================
   SMARTPHONES PEQUENOS (≤ 480px)
   ============================================ */
@media (max-width: 480px) {

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

  .payment-summary {
    grid-template-columns: 1fr !important;
  }

  .quick-actions-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .page-content {
    padding: 10px 8px;
  }

  .stat-card-value {
    font-size: 22px;
  }

  .section-title {
    font-size: 18px;
  }

  #bi-kpi-grid {
    grid-template-columns: 1fr !important;
  }

  .aval-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  #crm-kpi-grid {
    grid-template-columns: 1fr !important;
  }

  /* Modais ainda menores: 96vh */
  .modal-overlay .modal,
  .modal-overlay .modal-lg,
  .modal-overlay .modal-sm {
    max-height: 96vh;
  }

  .modal-overlay .modal-body {
    max-height: calc(96vh - 130px);
  }
}

/* ---- Utilitários ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.w-100 { width: 100%; }

/* Scrollbar global */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ============================================
   LOGIN SCREEN
   ============================================ */

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: linear-gradient(135deg, #0c0b09 0%, #16120d 45%, #0b1210 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-screen.hidden {
  display: none;
}

.login-screen::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(139,111,78,0.08) 0%, transparent 70%);
  top: 5%;
  left: 15%;
  pointer-events: none;
}

.login-screen::after {
  content: '';
  position: absolute;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(92,138,122,0.06) 0%, transparent 70%);
  bottom: 5%;
  right: 15%;
  pointer-events: none;
}

.login-card {
  background: rgba(255, 255, 255, 0.035);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(139, 111, 78, 0.22);
  border-radius: 24px;
  padding: 52px 44px 44px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 40px 80px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.03), inset 0 1px 0 rgba(255,255,255,0.07);
  animation: loginCardIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(28px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(139,111,78,0.5), transparent);
}

.login-brand {
  text-align: center;
  margin-bottom: 36px;
}

.login-brand-icon {
  width: 76px;
  height: 76px;
  background: linear-gradient(135deg, rgba(139,111,78,0.25), rgba(92,138,122,0.15));
  border: 1px solid rgba(139,111,78,0.35);
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  margin: 0 auto 20px;
  box-shadow: 0 8px 28px rgba(139,111,78,0.18);
}

.login-brand-title {
  font-family: 'Playfair Display', serif;
  font-size: 26px;
  font-weight: 700;
  color: #f5f0ea;
  letter-spacing: -0.3px;
  margin-bottom: 5px;
}

.login-brand-subtitle {
  font-size: 12.5px;
  color: rgba(255,255,255,0.3);
  letter-spacing: 0.5px;
}

.login-heading {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.35);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 28px;
}

.login-field {
  margin-bottom: 16px;
}

.login-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  margin-bottom: 8px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.login-input {
  width: 100%;
  background: rgba(255,255,255,0.055);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 13px 16px;
  font-size: 14px;
  color: #f5f0ea;
  font-family: 'Inter', sans-serif;
  transition: all 0.2s ease;
  box-sizing: border-box;
  outline: none;
}

.login-input::placeholder {
  color: rgba(255,255,255,0.18);
}

.login-input:focus {
  border-color: rgba(139,111,78,0.55);
  background: rgba(139,111,78,0.07);
  box-shadow: 0 0 0 3px rgba(139,111,78,0.12);
}

.login-password-wrap {
  position: relative;
}

.login-password-wrap .login-input {
  padding-right: 46px;
}

.login-eye-btn {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.25);
  font-size: 15px;
  padding: 4px;
  transition: color 0.2s;
  line-height: 1;
}

.login-eye-btn:hover {
  color: rgba(255,255,255,0.55);
}

.login-error {
  display: none;
  background: rgba(192,57,43,0.12);
  border: 1px solid rgba(192,57,43,0.3);
  color: #ff7b6b;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 14px;
  text-align: center;
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, #8B6F4E 0%, #7a5f3f 100%);
  border: none;
  border-radius: 10px;
  color: white;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  margin-top: 4px;
  transition: all 0.2s ease;
  box-shadow: 0 4px 18px rgba(139,111,78,0.38);
  letter-spacing: 0.3px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #9a7d5a 0%, #8B6F4E 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(139,111,78,0.5);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-footer-text {
  text-align: center;
  font-size: 11.5px;
  color: rgba(255,255,255,0.18);
  margin-top: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.3px;
}

/* Botão de logout na sidebar */
.logout-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: rgba(192,57,43,0.08);
  border: 1px solid rgba(192,57,43,0.18);
  border-radius: 8px;
  color: rgba(255,110,95,0.75);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 10px;
  font-family: 'Inter', sans-serif;
}

.logout-btn:hover {
  background: rgba(192,57,43,0.16);
  color: rgba(255,125,110,1);
  border-color: rgba(192,57,43,0.3);
}

/* Banner de atualização do sistema */
@keyframes updateSlideUp {
  from { opacity: 0; transform: translateX(-50%) translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* Seletor de horários (modal professor) */
.schedule-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  transition: background 0.15s;
}
.schedule-row:hover {
  background: rgba(var(--primary-rgb, 139,90,43), 0.06);
}
.schedule-row + .schedule-row {
  border-top: 1px solid var(--border, rgba(255,255,255,0.06));
}
.schedule-times {
  display: none;
  gap: 6px;
  align-items: center;
  flex: 1;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity:0; transform:translateX(-4px); } to { opacity:1; transform:none; } }

/* ============================================
   MÓDULO DE RELATÓRIOS — DROPDOWN DE EXPORTAÇÃO
   ============================================ */

.dropdown-export {
  position: relative;
}

.export-menu {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 190px;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 500;
  overflow: hidden;
  animation: dropdownIn 0.15s ease;
}

.export-menu.open {
  display: block;
}

@keyframes dropdownIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.export-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--gray-700);
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid var(--gray-100);
}

.export-menu-item:last-child {
  border-bottom: none;
}

.export-menu-item:hover {
  background: var(--gray-50);
  color: var(--gray-900);
}

/* ============================================
   PÁGINA DE RELATÓRIOS — CARDS
   ============================================ */

.relatorio-card {
  transition: var(--transition);
  cursor: default;
}

.relatorio-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--primary-100);
}

.relatorio-card .btn {
  transition: var(--transition);
}

/* ============================================
   MÓDULO DE AVALIAÇÃO FÍSICA
   ============================================ */

/* Abas do modal */
.aval-tabs {
  display: flex;
  border-bottom: 2px solid var(--gray-100);
  background: var(--gray-50);
}

.aval-tab {
  flex: 1;
  padding: 14px 20px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
}

.aval-tab:hover {
  color: var(--primary);
  background: var(--primary-50);
}

.aval-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: white;
}

/* Título de seção do formulário */
.aval-section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 20px 0 12px;
  padding: 8px 12px;
  background: var(--primary-50);
  border-left: 3px solid var(--primary);
  border-radius: 0 6px 6px 0;
}

/* Cards do histórico */
.aval-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 18px 20px;
  margin-bottom: 14px;
  transition: var(--transition);
}

.aval-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--primary-100);
}

.aval-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.aval-card-date {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  font-family: 'Playfair Display', serif;
}

.aval-card-avaliador {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 3px;
}

/* Grid de métricas */
.aval-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.aval-metric {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 10px 12px;
  text-align: center;
}

.aval-metric-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 4px;
}

.aval-metric-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
  font-family: 'Playfair Display', serif;
}

/* IMC colors */
.aval-imc-baixo  { color: var(--info); }
.aval-imc-normal { color: var(--success); }
.aval-imc-sobre  { color: var(--warning); }
.aval-imc-obeso  { color: var(--danger); }

/* IMC result display */
.aval-imc-result {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--gray-50);
  display: inline-block;
}

.aval-imc-result:empty { display: none; }

/* Tags */
.aval-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.aval-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
}

.aval-tag-primary  { background: var(--primary-100); color: var(--primary-dark); }
.aval-tag-secondary { background: var(--secondary-50); color: var(--secondary-dark); }

/* Observações */
.aval-obs {
  font-size: 13px;
  color: var(--gray-600);
  background: var(--gray-50);
  border-radius: 8px;
  padding: 10px 12px;
  border-left: 3px solid var(--gray-200);
  font-style: italic;
}

/* Estado vazio e loading */
.aval-empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--gray-400);
}

.aval-empty h3 {
  font-size: 16px;
  color: var(--gray-600);
  margin-bottom: 8px;
}

.aval-empty p {
  font-size: 13px;
}

.aval-loading {
  text-align: center;
  padding: 32px;
  color: var(--gray-500);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.aval-loading p {
  font-size: 13px;
}

/* ============================================
   MÓDULO BI AVANÇADO
   ============================================ */

.bi-kpi-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.bi-kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.bi-kpi-icon {
  font-size: 26px;
  margin-bottom: 6px;
}

.bi-kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--gray-500);
}

.bi-kpi-value {
  font-size: 22px;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
  color: var(--gray-900);
  line-height: 1.2;
}

/* ============================================
   MÓDULO CALENDÁRIO — FASE 5
   ============================================ */

/* Toggle Lista / Calendário */
.cal-view-toggle {
  display: flex;
  background: var(--gray-100);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.cal-toggle-btn {
  padding: 7px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.cal-toggle-btn:hover {
  background: var(--white);
  color: var(--primary);
}

.cal-toggle-btn.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: 0 1px 4px rgba(0,0,0,.10);
}

/* Controles do calendário */
.cal-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

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

.cal-nav-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--white);
  color: var(--gray-600);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: var(--transition);
}

.cal-nav-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary);
  color: var(--primary);
}

.cal-today-btn {
  padding: 7px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  background: var(--white);
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
}

.cal-today-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary);
  color: var(--primary);
}

.cal-period-label {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-900);
  font-family: 'Playfair Display', serif;
}

/* Legenda */
.cal-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.cal-legend-item {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1.5px solid;
}

/* Card que envolve o grid */
.cal-card {
  overflow: hidden;
  border-radius: 14px;
}

/* ── VISÃO SEMANAL ────────────────────── */
.cal-week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  min-height: 500px;
}

.cal-week-col {
  border-right: 1px solid var(--gray-100);
  transition: background .15s ease;
}

.cal-week-col:last-child { border-right: none; }

.cal-week-col.cal-day-today {
  background: var(--primary-50);
}

.cal-week-day-header {
  padding: 10px 8px 8px;
  text-align: center;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  position: relative;
  transition: background .15s;
}

.cal-week-day-header:hover { background: var(--primary-100); }

.cal-week-day-name {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
  margin-bottom: 4px;
}

.cal-week-day-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
  font-family: 'Playfair Display', serif;
}

.cal-add-hint {
  position: absolute;
  top: 6px;
  right: 6px;
  font-size: 11px;
  color: var(--primary);
  opacity: 0;
  transition: opacity .15s;
}

.cal-week-day-header:hover .cal-add-hint { opacity: 1; }

.cal-week-events {
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 80px;
}

.cal-empty-day {
  text-align: center;
  color: var(--gray-300);
  font-size: 16px;
  margin-top: 20px;
}

/* ── VISÃO MENSAL ─────────────────────── */
.cal-month-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.cal-month-dow {
  padding: 10px 4px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
}

.cal-month-cell {
  min-height: 90px;
  padding: 6px 5px;
  border-right: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  transition: background .15s;
  position: relative;
}

.cal-month-cell:hover { background: var(--primary-50); }

.cal-month-cell.cal-other-month {
  background: var(--gray-50);
  opacity: 0.5;
}

.cal-month-cell.cal-day-today { background: var(--primary-50); }

.cal-month-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-700);
  margin-bottom: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cal-month-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cal-more-events {
  font-size: 10px;
  font-weight: 700;
  color: var(--primary);
  padding: 2px 4px;
  cursor: pointer;
  text-align: center;
}

.cal-more-events:hover { text-decoration: underline; }

/* ── CÍRCULO "HOJE" ───────────────────── */
.today-circle {
  background: var(--primary);
  color: var(--white) !important;
  border-radius: 50%;
}

/* ── CHIPS DE EVENTO ──────────────────── */
.cal-chip {
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  transition: filter .15s, transform .1s;
  line-height: 1.4;
}

.cal-chip:hover {
  filter: brightness(0.93);
  transform: translateY(-1px);
}

.cal-chip-full {
  white-space: normal;
  padding: 8px 10px;
  border-radius: 8px;
}

.cal-chip-time {
  font-size: 10px;
  font-weight: 700;
  opacity: 0.8;
}

.cal-chip-status {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
}

.cal-chip-name {
  font-size: 13px;
  font-weight: 700;
  margin: 3px 0 2px;
}

.cal-chip-aula {
  font-size: 12px;
  opacity: 0.85;
}

.cal-chip-prof {
  font-size: 11px;
  opacity: 0.70;
  margin-top: 2px;
}

/* ── MOBILE ───────────────────────────── */
@media (max-width: 768px) {
  .cal-week-grid {
    grid-template-columns: repeat(7, minmax(100px, 1fr));
    overflow-x: auto;
    display: flex;
  }

  .cal-week-col {
    min-width: 100px;
    flex: 0 0 100px;
  }

  .cal-month-cell { min-height: 64px; }

  .cal-controls { gap: 8px; }
  .cal-period-label { font-size: 13px; }

  .cal-toggle-btn { padding: 6px 10px; font-size: 12px; }

  .cal-legend { gap: 6px; }
  .cal-legend-item { font-size: 10px; padding: 2px 8px; }
}

/* ============================================
   MÓDULO CRM / KANBAN — FASE 7
   ============================================ */

/* Board */
.kanban-board {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: flex-start;
  -webkit-overflow-scrolling: touch;
}

/* Coluna */
.kanban-col {
  flex: 0 0 250px;
  min-width: 250px;
  background: var(--gray-50);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 280px);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 10px;
  border-radius: 14px 14px 0 0;
  background: var(--white);
  border-bottom: 1px solid var(--gray-100);
  position: sticky;
  top: 0;
}

.kanban-col-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-800);
}

.kanban-col-count {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 22px;
  text-align: center;
}

.kanban-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-radius: 0 0 14px 14px;
}

/* Drag-over highlight */
.kanban-col-body.drag-over {
  background: var(--primary-100);
  outline: 2px dashed var(--primary);
  border-radius: 10px;
}

/* Card */
.kanban-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.kanban-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  border-color: var(--primary-light);
}

.kanban-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

/* Card header */
.kanban-card-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.kanban-card-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.kanban-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.3;
}

.kanban-card-tag {
  font-size: 10px;
  color: var(--primary);
  font-weight: 600;
  background: var(--primary-50);
  border-radius: 4px;
  padding: 1px 5px;
  display: inline-block;
  margin-top: 2px;
}

.kanban-card-actions {
  margin-left: auto;
  flex-shrink: 0;
}

/* Card body */
.kanban-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 8px;
}

.kanban-card-info {
  font-size: 11px;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  gap: 5px;
}

.kanban-card-info i {
  font-size: 10px;
  width: 12px;
  text-align: center;
  color: var(--gray-400);
}

/* Card footer */
.kanban-card-footer {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--gray-100);
}

.kanban-card-time {
  font-size: 10px;
  color: var(--gray-400);
  flex: 1;
}

.kanban-advance-btn,
.kanban-convert-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  background: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  transition: var(--transition);
}

.kanban-advance-btn {
  color: var(--primary);
}

.kanban-advance-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary);
}

.kanban-convert-btn {
  color: var(--success);
}

.kanban-convert-btn:hover {
  background: #E8F5E9;
  border-color: var(--success);
}

/* Botão adicionar */
.kanban-add-btn {
  width: 100%;
  padding: 8px;
  border: 1.5px dashed var(--gray-300);
  border-radius: 8px;
  background: transparent;
  color: var(--gray-500);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}

.kanban-add-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-50);
}

/* Status badge na lista */
.crm-status-badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* KPI cards do CRM */
.crm-kpi-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.crm-kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.crm-kpi-icon { font-size: 22px; margin-bottom: 4px; }

.crm-kpi-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
}

.crm-kpi-value {
  font-size: 22px;
  font-weight: 700;
  font-family: 'Playfair Display', serif;
}

/* Mobile */
@media (max-width: 768px) {
  .kanban-board {
    flex-direction: column;
  }

  .kanban-col {
    flex: none;
    min-width: unset;
    width: 100%;
    max-height: none;
  }

  .kanban-col-body {
    max-height: 300px;
  }

  #crm-kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

@media (max-width: 480px) {
  #crm-kpi-grid {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================
   MÓDULO FINANCEIRO AUTOMÁTICO — FASE 2
   ============================================ */

/* Cards de inadimplência */
.inad-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-left: 4px solid var(--danger);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.inad-card:hover { box-shadow: var(--shadow-md); }

.inad-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.inad-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.inad-nome {
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-900);
}

.inad-dias {
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
}

.inad-total {
  font-size: 16px;
  font-weight: 800;
  font-family: 'Playfair Display', serif;
  color: var(--danger);
  margin-left: auto;
  white-space: nowrap;
}

/* Parcelas individuais */
.inad-parcelas {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inad-parcela {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--gray-600);
}

.inad-parcela span:first-child { flex: 1; }

/* KPI mini para inadimplência */
.inad-kpi {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: center;
}

.inad-kpi-icon { font-size: 20px; margin-bottom: 4px; }

.inad-kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray-500);
}

.inad-kpi-value {
  font-size: 18px;
  font-weight: 800;
  font-family: 'Playfair Display', serif;
  color: var(--danger);
}

/* Mobile */
@media (max-width: 768px) {
  .inad-card-header { flex-wrap: wrap; }
  .inad-total { margin-left: 0; width: 100%; text-align: right; }
}

/* ============================================
   SISTEMA DE ATUALIZAÇÃO — BOTÃO + MODAL
   ============================================ */

/* ── Botão flutuante de atualização ──────── */
.update-available-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  background: linear-gradient(135deg, #8B6F4E 0%, #6B4C2A 100%);
  color: white;
  border: none;
  border-radius: 50px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(139,111,78,0.45), 0 2px 8px rgba(0,0,0,0.2);
  /* Escondido por padrão — JS adiciona .visible */
  transform: translateY(90px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.4s cubic-bezier(0.16,1,0.3,1), opacity 0.3s ease, box-shadow 0.2s;
}

.update-available-btn.visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.update-available-btn:hover {
  background: linear-gradient(135deg, #9a7d5a 0%, #7a5c36 100%);
  box-shadow: 0 10px 32px rgba(139,111,78,0.55), 0 4px 12px rgba(0,0,0,0.2);
  transform: translateY(-2px);
}

.update-available-btn:active {
  transform: translateY(0);
}

/* Pulso de atenção */
.update-available-btn.pulse {
  animation: updatePulse 2.5s ease-in-out infinite;
}

@keyframes updatePulse {
  0%, 100% {
    box-shadow: 0 6px 24px rgba(139,111,78,0.45), 0 2px 8px rgba(0,0,0,0.2);
  }
  50% {
    box-shadow: 0 6px 24px rgba(139,111,78,0.45),
                0 0 0 8px rgba(139,111,78,0.15),
                0 0 0 16px rgba(139,111,78,0.06);
  }
}

.update-btn-icon {
  font-size: 18px;
  line-height: 1;
}

.update-btn-text {
  white-space: nowrap;
}

/* ── Modal de Changelog ──────────────────── */
.update-notes-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.update-note-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  color: var(--gray-700);
  line-height: 1.5;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: 8px;
  border-left: 3px solid var(--primary-light);
}

.update-note-icon {
  font-size: 16px;
  flex-shrink: 0;
  line-height: 1.5;
}

/* ── Mobile: botão fica na base centralizado */
@media (max-width: 768px) {
  .update-available-btn {
    bottom: 16px;
    right: 50%;
    transform: translateX(50%) translateY(90px);
    font-size: 13px;
    padding: 11px 20px;
  }

  .update-available-btn.visible {
    transform: translateX(50%) translateY(0);
  }

  .update-available-btn:hover {
    transform: translateX(50%) translateY(-2px);
  }

  .update-available-btn.pulse {
    animation: updatePulseMobile 2.5s ease-in-out infinite;
  }

  @keyframes updatePulseMobile {
    0%, 100% { box-shadow: 0 6px 24px rgba(139,111,78,0.45); }
    50% {
      box-shadow: 0 6px 24px rgba(139,111,78,0.45),
                  0 0 0 8px rgba(139,111,78,0.15),
                  0 0 0 16px rgba(139,111,78,0.06);
    }
  }

  .update-note-item {
    font-size: 13px;
    padding: 8px 10px;
  }
}
