/* ============================================================
   Conecta — CSS Principal
   Design: Institucional / Saúde
   ============================================================ */

:root {
  /* ── Paleta de cores ──────────────────────────────────────── */
  --primary: #1a6fad;
  --primary-light: #2d8fd4;
  --primary-dark: #0f4d7d;
  --primary-subtle: #e8f3fb;

  --accent: #2ebd8c;
  --accent-light: #e8f9f3;
  --accent-dark: #1e9c72;

  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-300: #cbd5e1;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-600: #475569;
  --neutral-700: #334155;
  --neutral-800: #1e293b;
  --neutral-900: #0f172a;

  --danger: #e53e3e;
  --danger-subtle: #fff5f5;
  --warning: #d69e2e;
  --warning-subtle: #fffff0;
  --success: #38a169;
  --success-subtle: #f0fff4;
  --info: #3182ce;
  --info-subtle: #ebf8ff;

  /* ── Tipografia ───────────────────────────────────────────── */
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-display: 'Calibri', 'Calibri Light', sans-serif;

  /* ── Espaçamento e bordas ────────────────────────────────── */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --shadow-xs: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow: 0 10px 15px -3px rgba(0,0,0,0.07), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.08), 0 10px 10px -5px rgba(0,0,0,0.03);

  /* ── Sidebar ─────────────────────────────────────────────── */
  --sidebar-width: 260px;
  --sidebar-bg: var(--neutral-900);
  --topbar-h: 64px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--neutral-800);
  background: var(--neutral-50);
  -webkit-font-smoothing: antialiased;
}

/* ── Layout Autenticado ───────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 28px 24px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 22px;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.nav-section {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--neutral-500);
  padding: 0 12px 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--neutral-400);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  transition: all 0.15s ease;
  position: relative;
}

.nav-item i { font-size: 17px; flex-shrink: 0; }

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,0.07);
}

.nav-item.active {
  color: #fff;
  background: rgba(255,255,255,0.1);
  font-weight: 500;
}

.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 4px 4px 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  min-width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.07);
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.user-details { display: flex; flex-direction: column; min-width: 0; }

.user-name {
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--neutral-500);
}

.logout-btn {
  color: var(--neutral-500);
  font-size: 17px;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.15s;
  flex-shrink: 0;
}

.logout-btn:hover { color: var(--danger); background: rgba(229,62,62,0.1); }

/* ── Main Content ─────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--neutral-200);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--neutral-600);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--neutral-800);
  flex: 1;
}

.notification-dot {
  position: relative;
  color: var(--neutral-500);
  font-size: 20px;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.15s;
}

.notification-dot:hover { background: var(--neutral-100); }

.notification-dot.active::after {
  content: '';
  position: absolute;
  top: 6px; right: 6px;
  width: 8px; height: 8px;
  background: var(--accent);
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ── Alertas ──────────────────────────────────────────────────── */
.alerts-container {
  padding: 16px 28px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alert-custom {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 400;
  border: 1px solid transparent;
}

.alert-custom i:first-child { font-size: 16px; flex-shrink: 0; }

.alert-custom .alert-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  font-size: 16px;
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 4px;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.alert-custom .alert-close:hover { opacity: 1; }

.alert-success { background: var(--success-subtle); color: #276749; border-color: #c6f6d5; }
.alert-danger { background: var(--danger-subtle); color: #9b2c2c; border-color: #fed7d7; }
.alert-warning { background: var(--warning-subtle); color: #744210; border-color: #fefcbf; }
.alert-info { background: var(--info-subtle); color: #2c5282; border-color: #bee3f8; }

/* ── Content wrapper ──────────────────────────────────────────── */
.content-wrapper {
  flex: 1;
  padding: 28px;
}

/* ── Legal Notice ─────────────────────────────────────────────── */
.legal-notice {
  padding: 14px 28px;
  background: #fff;
  border-top: 1px solid var(--neutral-200);
  font-size: 12px;
  color: var(--neutral-400);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Cards ────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

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

.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--neutral-800);
}

.card-body { padding: 24px; }

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

.stat-card {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--neutral-200);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.2s;
}

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

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

.stat-icon.blue { background: var(--primary-subtle); color: var(--primary); }
.stat-icon.green { background: var(--accent-light); color: var(--accent-dark); }
.stat-icon.orange { background: #fff7ed; color: #c05621; }
.stat-icon.purple { background: #f3f0ff; color: #6b46c1; }

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--neutral-900);
  line-height: 1;
  font-feature-settings: 'tnum';
}

.stat-label {
  font-size: 13px;
  color: var(--neutral-500);
  margin-top: 3px;
}

/* ── Page Header ──────────────────────────────────────────────── */
.page-header {
  margin-bottom: 28px;
}

.page-header h1 {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--neutral-900);
  font-weight: 400;
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.page-header p {
  font-size: 15px;
  color: var(--neutral-500);
  margin-top: 6px;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1;
  white-space: nowrap;
}

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

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

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

.btn-ghost {
  background: transparent;
  color: var(--neutral-600);
  border-color: var(--neutral-200);
}
.btn-ghost:hover { background: var(--neutral-100); color: var(--neutral-800); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.btn-danger:hover { background: #c53030; border-color: #c53030; color: #fff; }

.btn-sm { padding: 7px 14px; font-size: 13px; }
.btn-lg { padding: 13px 28px; font-size: 16px; }
.btn-full { width: 100%; justify-content: center; }

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--neutral-700);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--neutral-200);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--neutral-800);
  background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
  appearance: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,111,173,0.1);
}

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

select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2394a3b8'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 20px;
  padding-right: 36px;
}

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

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

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: 5px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Checkbox customizado */
.checkbox-group {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
  width: 18px; height: 18px;
  margin-top: 1px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.checkbox-label {
  font-size: 14px;
  color: var(--neutral-700);
  line-height: 1.5;
  cursor: pointer;
}

/* ── Badges / Tags ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-blue { background: var(--primary-subtle); color: var(--primary-dark); }
.badge-green { background: var(--accent-light); color: var(--accent-dark); }
.badge-orange { background: #fff7ed; color: #c05621; }
.badge-gray { background: var(--neutral-100); color: var(--neutral-600); }
.badge-red { background: var(--danger-subtle); color: var(--danger); }
.badge-purple { background: #f3f0ff; color: #6b46c1; }

/* ── Match Cards ──────────────────────────────────────────────── */
.match-card {
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: var(--shadow-xs);
  transition: all 0.2s;
  position: relative;
}

.match-card:hover { box-shadow: var(--shadow-sm); border-color: var(--neutral-300); }

.match-card.contato-liberado {
  border-color: var(--accent);
  background: linear-gradient(135deg, #fff 70%, var(--accent-light));
}

.match-avatar {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  flex-shrink: 0;
}

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

.match-anonymous { font-size: 15px; font-weight: 600; color: var(--neutral-800); }
.match-route {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.route-arrow { color: var(--neutral-400); font-size: 14px; }

.match-status {
  font-size: 12px;
  color: var(--neutral-500);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.match-actions { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ── Proposta Cards ───────────────────────────────────────────── */
.proposta-card {
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-xs);
  transition: all 0.2s;
}

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

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

.proposta-route {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.route-from, .route-to {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.route-label { font-size: 11px; color: var(--neutral-400); text-transform: uppercase; letter-spacing: 0.05em; }
.route-value { font-size: 15px; font-weight: 600; color: var(--neutral-800); }
.route-sub { font-size: 12px; color: var(--neutral-500); }

.route-icon {
  color: var(--primary);
  font-size: 20px;
  opacity: 0.6;
}

/* ── Empty State ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-icon {
  font-size: 52px;
  color: var(--neutral-300);
  margin-bottom: 16px;
}

.empty-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--neutral-700);
  margin-bottom: 8px;
}

.empty-text {
  font-size: 14px;
  color: var(--neutral-500);
  max-width: 360px;
  margin: 0 auto 20px;
}

/* ── Divider ──────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--neutral-200);
  margin: 20px 0;
}

/* ── Grid helpers ─────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ── Public layout (Login/Registro) ──────────────────────────── */
.public-layout {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.public-alerts {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}

.auth-page {
  min-height: 100vh;
  display: flex;
}

.auth-panel {
  width: 480px;
  min-height: 100vh;
  background: #fff;
  display: flex;
  flex-direction: column;
  padding: 40px 48px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
  overflow-y: auto;
}

.auth-hero {
  flex: 1;
  background: linear-gradient(135deg, var(--neutral-900) 0%, #0a2340 50%, #0d3b6e 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  padding: 80px 72px;
  position: relative;
  overflow: hidden;
}

.auth-hero::before {
  content: '';
  position: absolute;
  inset: 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.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.auth-hero-content { position: relative; }

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.auth-hero h2 {
  font-family: var(--font-display);
  font-size: 48px;
  color: #fff;
  line-height: 1.1;
  letter-spacing: -0.5px;
  margin-bottom: 20px;
}

.auth-hero p {
  font-size: 16px;
  color: rgba(255,255,255,0.65);
  line-height: 1.7;
  max-width: 380px;
  margin-bottom: 40px;
}

.hero-features {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
}

.hero-feature-icon {
  width: 32px; height: 32px;
  background: rgba(255,255,255,0.1);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent);
  font-size: 15px;
  flex-shrink: 0;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 36px;
}

.auth-logo .brand-icon {
  width: 36px; height: 36px;
}

.auth-logo .brand-name {
  font-size: 20px;
  color: var(--neutral-900);
}

.auth-title {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--neutral-900);
  letter-spacing: -0.3px;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 14px;
  color: var(--neutral-500);
  margin-bottom: 32px;
}

.auth-form { flex: 1; }

.auth-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 14px;
  color: var(--neutral-500);
}

.auth-footer a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}

.auth-footer a:hover { text-decoration: underline; }

/* ── Sugestões Dashboard ──────────────────────────────────────── */
.sugestao-card {
  background: linear-gradient(135deg, var(--primary-subtle), #fff);
  border: 1px solid rgba(26,111,173,0.15);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  transition: all 0.2s;
}

.sugestao-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }

/* ── Filter bar ───────────────────────────────────────────────── */
.filter-bar {
  background: #fff;
  border: 1px solid var(--neutral-200);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-bar .form-group { margin-bottom: 0; flex: 1; min-width: 160px; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .auth-hero { display: none; }
  .auth-panel { width: 100%; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  .sidebar {
    transform: translateX(-260px);
    width: 260px;
  }

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

  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }

  .content-wrapper { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
  .alerts-container { padding: 12px 16px 0; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .match-card { flex-wrap: wrap; }
  .auth-panel { padding: 32px 24px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Animations ───────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease both; }
.fade-in-1 { animation-delay: 0.05s; }
.fade-in-2 { animation-delay: 0.1s; }
.fade-in-3 { animation-delay: 0.15s; }
.fade-in-4 { animation-delay: 0.2s; }
.fade-in-5 { animation-delay: 0.25s; }

/* ── Utilities ────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--neutral-500); }
.text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.list-none { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.fw-600 { font-weight: 600; }
.fs-14 { font-size: 14px; }

/* ── Cessão / Disposição ──────────────────────────────────────── */
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #2f855a; border-color: #2f855a; color: #fff; }
.btn[disabled] { opacity: .6; cursor: not-allowed; }

.detail-layout { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
.detail-col { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.data-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 24px; margin: 0; }
.data-list .full { grid-column: 1 / -1; }
.data-list dt { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--neutral-500); margin-bottom: 2px; }
.data-list dd { margin: 0; font-size: 14px; color: var(--neutral-800); overflow-wrap: anywhere; white-space: pre-line; }

.data-table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; padding: 10px 12px; font-weight: 600; color: var(--neutral-600); border-bottom: 2px solid var(--neutral-200); white-space: nowrap; }
.data-table td { padding: 10px 12px; border-bottom: 1px solid var(--neutral-200); vertical-align: top; }
.data-table tbody tr:hover { background: var(--neutral-50); }
.mono { font-variant-numeric: tabular-nums; }

.decision-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.status-panel { border-radius: var(--radius-sm); padding: 16px; text-align: center; border: 1px solid var(--neutral-200); background: var(--neutral-50); }
.status-panel.autorizada { background: var(--success-subtle); border-color: #c6f6d5; color: var(--success); }
.status-panel.negada { background: var(--danger-subtle); border-color: #fed7d7; color: var(--danger); }
.status-panel.pendente { background: var(--warning-subtle); border-color: #fefcbf; color: #975a16; }
.status-panel i { font-size: 26px; display: block; margin-bottom: 6px; }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.timeline li { border: 1px solid var(--neutral-200); border-radius: var(--radius-sm); padding: 12px; }
.timeline .meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 13px; color: var(--neutral-500); }
.timeline .texto { margin-top: 8px; background: var(--neutral-50); border-left: 3px solid var(--neutral-300); padding: 8px 12px; font-size: 13px; color: var(--neutral-700); white-space: pre-line; overflow-wrap: anywhere; }

.modal-overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); display: none; align-items: center; justify-content: center; padding: 16px; z-index: 1000; }
.modal-overlay.open { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 520px; padding: 24px; }
.modal-box h2 { font-size: 18px; margin: 0 0 8px; }
.modal-box .preview { background: var(--neutral-50); border: 1px solid var(--neutral-200); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 13px; max-height: 200px; overflow: auto; white-space: pre-line; overflow-wrap: anywhere; margin: 8px 0 16px; }

@media (max-width: 900px) {
  .detail-layout { grid-template-columns: 1fr; }
  .data-list { grid-template-columns: 1fr; }
}

/* ============================================================
   Mobile — leitura confortável em telas pequenas
   Mantém paleta, raios e sombras; só reorganiza e dimensiona.
   ============================================================ */
.main-content { min-width: 0; }
.sidebar-backdrop { display: none; }
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--primary-light); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media (max-width: 768px) {
  :root { --topbar-h: 56px; }

  /* Menu lateral como gaveta, com fundo escurecido */
  .sidebar {
    width: min(290px, 86vw);
    transform: translateX(-100%);
    visibility: hidden;
    box-shadow: none;
    transition: transform 0.3s ease, visibility 0.3s, box-shadow 0.3s;
  }
  .sidebar.open { transform: translateX(0); visibility: visible; box-shadow: var(--shadow-lg); }
  .sidebar-backdrop {
    display: block;
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.55);
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 90;
  }
  .sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

  .sidebar-brand { padding: 20px 20px 18px; }
  .sidebar-nav { padding: 16px 12px; gap: 20px; }
  .nav-item { padding: 12px; font-size: 15px; min-height: 44px; }
  .nav-label { font-size: 12px; }
  .sidebar-footer { padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); }
  .logout-btn { padding: 10px; }

  /* Barra superior */
  .topbar { gap: 8px; padding: 0 12px; }
  .sidebar-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; margin-left: -4px;
    border-radius: var(--radius-sm);
  }
  .sidebar-toggle:active { background: var(--neutral-100); }
  .topbar-title { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

  /* Espaçamento geral */
  .content-wrapper { padding: 16px; }
  .alerts-container { padding: 12px 16px 0; }
  .alert-custom { align-items: flex-start; padding: 12px; }
  .legal-notice { display: block; padding: 16px; line-height: 1.6; }

  .page-header { margin-bottom: 20px; }
  .page-header h1 { font-size: 24px; }
  .page-header p { font-size: 14px; }
  .page-header > div[style*="justify-content"] { flex-wrap: wrap !important; gap: 12px !important; }
  .page-header > div[style*="space-between"] > div { flex: 1 1 100%; min-width: 0; }
  .page-header > div[style*="space-between"] > .btn { width: 100%; justify-content: center; }
  .page-header > div > .btn:first-child:not(:last-child) { flex-shrink: 0; }
  .page-header form { width: 100%; }
  .page-header form[style*="display:flex"] { flex-direction: column; }
  .page-header form .btn { width: 100%; justify-content: center; }
  .page-header input.form-control { width: 100% !important; min-width: 0; }

  /* Cartões */
  .card-header { padding: 14px 16px; flex-wrap: wrap; }
  .card-title { font-size: 15px; }
  .card-body { padding: 16px; }
  .empty-state { padding: 40px 16px; }

  /* Números do dashboard: 2 por linha, compactos */
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
  .stat-card { flex-direction: column; align-items: flex-start; gap: 10px; padding: 16px; }
  .stat-icon { width: 40px; height: 40px; font-size: 19px; }
  .stat-value { font-size: 26px; }
  .stat-card-wide,
  .stat-card:nth-child(3):nth-last-child(2) { grid-column: 1 / -1; flex-direction: row; align-items: center; }
  .stat-card-wide .stat-value { font-size: 15px !important; line-height: 1.35; }

  /* Botões e campos: alvos de toque de 44px; 16px evita zoom do iOS ao focar */
  .btn { min-height: 44px; padding: 11px 18px; }
  .btn-sm { min-height: 40px; padding: 9px 14px; }
  .btn-lg { min-height: 48px; }
  .form-group { margin-bottom: 18px; }
  .form-label { font-size: 14px; }
  .form-control { font-size: 16px; padding: 12px 14px; min-height: 46px; }
  input[type="date"].form-control { padding: 12px 8px 12px 12px; font-size: 15px; }
  textarea.form-control { min-height: 110px; }
  .form-hint, .form-error { font-size: 13px; }
  .checkbox-group { gap: 12px; }
  .checkbox-group input[type="checkbox"] { width: 22px; height: 22px; }
  .checkbox-label { font-size: 15px; }

  /* Grades com colunas fixas definidas em estilo inline: uma coluna só */
  [style*="grid-template-columns"][style*="1fr 3"],
  [style*="grid-template-columns"][style*="1fr auto"],
  [style*="grid-template-columns"][style*="130px 1fr"] { grid-template-columns: minmax(0, 1fr) !important; }
  [style*="grid-template-columns"] > .btn { width: 100%; justify-content: center; }

  /* Barras de filtro: campos em grade, busca e botões em largura total */
  .filter-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 14px 16px; align-items: end; }
  .filter-bar > :first-child, .filter-bar > :last-child { grid-column: 1 / -1; }
  .filter-bar form { min-width: 0; }
  .filter-bar .form-group { margin-bottom: 0; min-width: 0 !important; }
  .filter-bar > .btn { width: 100%; justify-content: center; }
  .filter-bar > div:last-child .btn { flex: 1; justify-content: center; }

  /* Matches e propostas */
  .match-card { padding: 16px; gap: 14px; align-items: flex-start; }
  .match-avatar { width: 46px; height: 46px; font-size: 18px; }
  .match-actions { flex: 1 1 100%; }
  .match-actions > * { flex: 1 1 auto; }
  .match-actions .btn { width: 100%; justify-content: center; }
  .proposta-card { padding: 16px; }
  .proposta-header { flex-wrap: wrap; }
  .proposta-route { gap: 8px 12px; }
  .route-value { font-size: 14px; }

  /* Tabelas viram cartões: rótulo pequeno acima do valor, duas colunas */
  .card:has(.table-stack) { background: transparent; border: 0; box-shadow: none; overflow: visible; }
  .card:has(.table-stack) > .card-body { padding: 0; }
  .table-stack { display: block; width: 100%; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack tbody { display: flex; flex-direction: column; gap: 12px; }
  .table-stack tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
    background: #fff;
    border: 1px solid var(--neutral-200) !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    padding: 6px 16px;
  }
  .table-stack td {
    display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
    padding: 10px 0 !important;
    border-bottom: 1px solid var(--neutral-100) !important;
    text-align: left !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
    min-width: 0;
  }
  .table-stack td::before {
    content: attr(data-label);
    font-size: 12px; font-weight: 600;
    color: var(--neutral-500);
  }
  .table-stack td[data-label="Servidor"],
  .table-stack td[data-label="Origem"],
  .table-stack td[data-label="Destino"],
  .table-stack td[data-label="Nome"],
  .table-stack td[data-label="Email"],
  .table-stack td[data-label="Detalhes"],
  .table-stack td[data-label="Registro Afetado"],
  .table-stack td[data-label="Ações"] { grid-column: 1 / -1; }
  .table-stack td[data-label="#"] { display: none; }
  .table-stack td[data-label="Servidor"] { font-size: 16px; padding-top: 14px !important; }
  .table-stack td[data-label="Servidor"]::before { font-size: 12px; }
  .table-stack td:last-child { border-bottom: 0 !important; }
  .table-stack td > * { min-width: 0; }
  .table-stack td details { width: 100%; }
  .table-stack td[data-label="Ações"] { flex-direction: row; flex-wrap: wrap; gap: 8px; align-items: stretch; padding: 12px 0 8px !important; }
  .table-stack td[data-label="Ações"]::before { display: none; }
  .table-stack td[data-label="Ações"] > div { flex-wrap: wrap; justify-content: flex-start !important; width: 100%; }
  .table-stack td[data-label="Ações"] .btn { flex: 1 1 auto; justify-content: center; }

  /* Linhas flex em estilo inline passam para a linha de baixo em vez de cortar */
  main [style*="space-between"] { flex-wrap: wrap; row-gap: 8px; }
  .btn-row { flex-wrap: wrap; }
  .btn-row > .btn { flex: 1 1 auto; justify-content: center; }
  .btn-xs { min-height: 36px; min-width: 36px; justify-content: center; }

  /* Catálogo (o CSS da página vem depois, por isso "body" para ganhar na especificidade) */
  body .catalog-card-header, body .catalog-item-header, body .esp-item { flex-wrap: wrap; }
  body .catalog-card-header > div, body .catalog-item-header > div { flex: 1 1 100% !important; flex-wrap: wrap; min-width: 0; }
  body .catalog-card-header > div:last-child .btn,
  body .catalog-item-header > div:last-child .btn { flex: 1 1 auto; justify-content: center; }
  body .catalog-card-header > div:last-child form,
  body .catalog-item-header > div:last-child form { display: flex !important; flex: 1 1 auto; }
  body .catalog-card-header > div:last-child form .btn,
  body .catalog-item-header > div:last-child form .btn { width: 100%; }
  body .catalog-card-header > div:first-child > strong,
  body .catalog-item-header > div:first-child > span:nth-child(2) { flex: 1 1 140px; min-width: 0; }
  .inline-form-box form > div[style*="display:flex"],
  .inline-form-box form > div[style*="display: flex"] { flex-wrap: wrap; }
  .inline-form-box form > div > [style*="flex:1"],
  .inline-form-box form > div > [style*="flex: 1"] { flex: 1 1 100% !important; }
  .inline-form-box form > div > .btn { flex: 1 1 auto; justify-content: center; }
  .tab-btn { flex: 1; justify-content: center; text-align: center; padding: 10px 8px; }

  /* Cessão/Disposição */
  .decision-actions { flex-direction: column-reverse; }
  .decision-actions .btn { width: 100%; justify-content: center; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box { max-width: none; border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .modal-box .btn { width: 100%; justify-content: center; }
  .timeline .meta { flex-direction: column; gap: 2px; }

  /* Telas públicas (login, cadastro, termos) */
  .auth-panel { width: 100% !important; padding: 28px 20px; }
  .auth-logo { margin-bottom: 24px; }
  .auth-title { font-size: 24px; }
  .auth-subtitle { margin-bottom: 24px; }
  .public-alerts { top: 12px; left: 12px; right: 12px; max-width: none; }
  .public-layout[style*="padding:40px 24px"] { padding: 24px 16px !important; }
}

@media (max-width: 600px) {
  [style*="grid-template-columns"][style*="1fr 1fr"] { grid-template-columns: minmax(0, 1fr) !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 359px) {
  .filter-bar { grid-template-columns: 1fr; }
}
