/* ════════════════════════════════════════════════════════
   MAIS GESTÃO MUNICIPAL — Design System
   ════════════════════════════════════════════════════════ */

/* ── Variáveis ─────────────────────────────────────────── */
:root {
  --primary:       #5553DF;
  --primary-dark:  #3F3DB8;
  --primary-light: #EEEEFF;
  --bg:            #F4F6FB;
  --surface:       #FFFFFF;
  --border:        #E8ECF2;
  --text:          #1A1A2E;
  --text-muted:    #6B7280;
  --text-light:    #9CA3AF;
  --success:       #10B981;
  --warning:       #F59E0B;
  --danger:        #EF4444;
  --info:          #3B82F6;
  --radius:        12px;
  --radius-sm:     8px;
  --shadow:        0 2px 12px rgba(0,0,0,0.06);
  --shadow-md:     0 4px 20px rgba(0,0,0,0.10);
  --sidebar-w:     240px;
  --header-h:      64px;
  --transition:    0.2s ease;
}

/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

/* ── Sidebar ───────────────────────────────────────────── */
.mg-sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition);
}
.mg-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.mg-sidebar-logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}
.mg-sidebar-logo-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.mg-sidebar-logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
}
.mg-nav-section {
  padding: 16px 12px 4px;
}
.mg-nav-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-light);
  text-transform: uppercase;
  padding: 0 8px;
  margin-bottom: 4px;
}
.mg-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  margin-bottom: 2px;
}
.mg-nav-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.mg-nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
.mg-nav-item .material-symbols-outlined {
  font-size: 20px;
  flex-shrink: 0;
}
.mg-nav-item.locked {
  opacity: 0.45;
  cursor: default;
  pointer-events: none;
}
.mg-nav-item.locked:hover {
  background: transparent;
  color: var(--text-muted);
}
.mg-sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.mg-user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.mg-user-chip:hover { background: var(--bg); }
.mg-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}
.mg-avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 11px;
}
.mg-avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 18px;
}
.mg-user-info { flex: 1; min-width: 0; }
.mg-user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mg-user-role {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Header ────────────────────────────────────────────── */
.mg-header {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  z-index: 90;
}
.mg-search {
  flex: 1;
  max-width: 440px;
  position: relative;
}
.mg-search input {
  width: 100%;
  height: 38px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0 14px 0 38px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.mg-search input:focus { border-color: var(--primary); }
.mg-search input::placeholder { color: var(--text-light); }
.mg-search .material-symbols-outlined {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--text-light);
  pointer-events: none;
}
.mg-header-spacer { flex: 1; }
.mg-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
  position: relative;
}
.mg-icon-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}
.mg-icon-btn .material-symbols-outlined { font-size: 20px; }
.mg-badge-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--surface);
}
.mg-header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.mg-header-user:hover { background: var(--bg); }
.mg-header-user-info { text-align: right; }
.mg-header-user-name { font-size: 13px; font-weight: 600; }
.mg-header-user-role { font-size: 11px; color: var(--text-muted); }

/* ── Main content ──────────────────────────────────────── */
.mg-main {
  margin-left: var(--sidebar-w);
  margin-top: var(--header-h);
  padding: 28px 28px 40px;
  min-height: calc(100vh - var(--header-h));
  flex: 1;
}
.mg-page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.mg-page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}
.mg-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 20px;
}
.mg-breadcrumb a:hover { color: var(--primary); }
.mg-breadcrumb .material-symbols-outlined { font-size: 14px; }

/* ── Cards ─────────────────────────────────────────────── */
.mg-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 20px;
}
.mg-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.mg-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.mg-card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── KPI Cards ─────────────────────────────────────────── */
.mg-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.mg-kpi {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mg-kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}
.mg-kpi-icon.indigo  { background: #EEEEFF; color: var(--primary); }
.mg-kpi-icon.green   { background: #D1FAE5; color: #059669; }
.mg-kpi-icon.amber   { background: #FEF3C7; color: #D97706; }
.mg-kpi-icon.red     { background: #FEE2E2; color: #DC2626; }
.mg-kpi-icon.blue    { background: #DBEAFE; color: #2563EB; }
.mg-kpi-icon.teal    { background: #CCFBF1; color: #0D9488; }
.mg-kpi-icon.orange  { background: #FFEDD5; color: #EA580C; }
.mg-kpi-icon.violet  { background: #EDE9FE; color: #7C3AED; }
.mg-kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}
.mg-kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Buttons ───────────────────────────────────────────── */
.mg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.mg-btn .material-symbols-outlined { font-size: 16px; }
.mg-btn-primary {
  background: var(--primary);
  color: #fff;
}
.mg-btn-primary:hover { background: var(--primary-dark); }
.mg-btn-secondary {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
}
.mg-btn-secondary:hover { background: var(--border); }
.mg-btn-danger {
  background: #FEE2E2;
  color: #DC2626;
  border: 1px solid #FECACA;
}
.mg-btn-danger:hover { background: #FECACA; }
.mg-btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
}
.mg-btn-ghost:hover { background: var(--bg); border-color: var(--border); }
.mg-btn-sm { padding: 5px 12px; font-size: 12px; }
.mg-btn-sm .material-symbols-outlined { font-size: 14px; }
.mg-btn-lg { padding: 11px 24px; font-size: 15px; }
.mg-btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── Form elements ─────────────────────────────────────── */
.mg-form-group { display: flex; flex-direction: column; gap: 6px; }
.mg-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}
.mg-label.required::after { content: ' *'; color: var(--danger); }
.mg-input,
.mg-select,
.mg-textarea {
  width: 100%;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition);
}
.mg-input:focus,
.mg-select:focus,
.mg-textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(85,83,223,0.1); }
.mg-input::placeholder,
.mg-textarea::placeholder { color: var(--text-light); }
.mg-textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 80px; }
.mg-select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.mg-input.error,
.mg-select.error { border-color: var(--danger); }
.mg-hint { font-size: 11px; color: var(--text-muted); }
.mg-error-msg { font-size: 11px; color: var(--danger); }
.mg-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.mg-form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.mg-form-full { grid-column: 1 / -1; }
.mg-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ── Table ─────────────────────────────────────────────── */
.mg-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.mg-table {
  width: 100%;
  border-collapse: collapse;
}
.mg-table th {
  background: var(--bg);
  padding: 10px 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.mg-table td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.mg-table tr:last-child td { border-bottom: none; }
.mg-table tbody tr:hover { background: var(--bg); }
.mg-table .mg-table-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ── Badges / Chips ────────────────────────────────────── */
.mg-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
}
.mg-badge-green   { background: #D1FAE5; color: #065F46; }
.mg-badge-red     { background: #FEE2E2; color: #991B1B; }
.mg-badge-amber   { background: #FEF3C7; color: #92400E; }
.mg-badge-blue    { background: #DBEAFE; color: #1E40AF; }
.mg-badge-gray    { background: #F3F4F6; color: #374151; }
.mg-badge-indigo  { background: #EEF2FF; color: #3730A3; }
.mg-badge-teal    { background: #CCFBF1; color: #0F766E; }
.mg-badge-orange  { background: #FFEDD5; color: #9A3412; }
.mg-badge-violet  { background: #EDE9FE; color: #5B21B6; }
.mg-badge-pink    { background: #FCE7F3; color: #831843; }

/* Status específicos */
.status-vigente    { background: #D1FAE5; color: #065F46; }
.status-a_vencer   { background: #FEF3C7; color: #92400E; }
.status-vencido    { background: #FEE2E2; color: #991B1B; }
.status-rescindido { background: #F3F4F6; color: #374151; }
.status-suspenso   { background: #FFEDD5; color: #9A3412; }
.status-rascunho   { background: #F3F4F6; color: #374151; }
.status-solicitado { background: #DBEAFE; color: #1E40AF; }
.status-em_analise { background: #FEF3C7; color: #92400E; }
.status-aprovado   { background: #D1FAE5; color: #065F46; }
.status-rejeitado  { background: #FEE2E2; color: #991B1B; }
.status-atendido   { background: #EEF2FF; color: #3730A3; }
.status-cancelado  { background: #F3F4F6; color: #374151; }

/* ── Status Dropdown — trigger pill ────────────────────── */
.mg-status-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
  transition: box-shadow 0.2s, filter 0.15s, transform 0.1s;
  letter-spacing: 0.01em;
}
.mg-status-btn:hover {
  filter: brightness(0.92);
  transform: translateY(-1px);
}
.mg-status-btn:active { transform: scale(0.97); }
.mg-status-btn:focus-visible { outline: 2px solid rgba(85,83,223,0.4); outline-offset: 2px; }

/* glow por status */
.mg-status-btn.status-solicitado { box-shadow: 0 2px 8px rgba(59,130,246,0.35); }
.mg-status-btn.status-em_analise { box-shadow: 0 2px 8px rgba(245,158,11,0.35); }
.mg-status-btn.status-aprovado   { box-shadow: 0 2px 8px rgba(16,185,129,0.35); }
.mg-status-btn.status-rejeitado  { box-shadow: 0 2px 8px rgba(239,68,68,0.35);  }
.mg-status-btn.status-atendido   { box-shadow: 0 2px 8px rgba(99,102,241,0.35); }
.mg-status-btn.status-vigente    { box-shadow: 0 2px 8px rgba(16,185,129,0.35); }
.mg-status-btn.status-a_vencer  { box-shadow: 0 2px 8px rgba(245,158,11,0.35); }
.mg-status-btn.status-vencido   { box-shadow: 0 2px 8px rgba(239,68,68,0.35);  }
.mg-status-btn.status-suspenso  { box-shadow: 0 2px 8px rgba(249,115,22,0.35); }
.mg-status-btn.status-rescindido,
.mg-status-btn.status-rascunho,
.mg-status-btn.status-cancelado  { box-shadow: 0 2px 6px rgba(0,0,0,0.08); }

/* ── Status Dropdown — menu ─────────────────────────────── */
.mg-status-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 300;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.06);
  padding: 5px;
  min-width: 158px;
  animation: mg-dropdown-in 0.15s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes mg-dropdown-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Status Dropdown — opções ───────────────────────────── */
.mg-status-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  background: transparent;
  color: var(--text);
  transition: background 0.1s;
}
.mg-status-opt:hover       { background: var(--bg); }
.mg-status-opt-active      { background: var(--bg); font-weight: 700; }

/* ── Status dots ────────────────────────────────────────── */
.mg-status-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-rascunho, .dot-cancelado,
.dot-rescindido                { background: #9CA3AF; }
.dot-solicitado, .dot-vigente  { background: #10B981; }
.dot-em_analise, .dot-a_vencer { background: #F59E0B; }
.dot-aprovado                  { background: #10B981; }
.dot-rejeitado, .dot-vencido   { background: #EF4444; }
.dot-atendido                  { background: #6366F1; }
.dot-suspenso                  { background: #F97316; }

/* ── Modal ─────────────────────────────────────────────── */
.mg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.mg-modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: mg-modal-in 0.18s ease;
}
.mg-modal-lg { max-width: 760px; }
.mg-modal-xl { max-width: 960px; }
@keyframes mg-modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
.mg-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
}
.mg-modal-title { font-size: 16px; font-weight: 700; }
.mg-modal-close {
  width: 32px; height: 32px;
  border: none; background: none;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition);
}
.mg-modal-close:hover { background: var(--bg); }
.mg-modal-close .material-symbols-outlined { font-size: 20px; }
.mg-modal-body { padding: 20px 24px; }
.mg-modal-footer {
  padding: 12px 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--border);
}

/* ── Tabs ───────────────────────────────────────────────── */
.mg-tab-bar {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  gap: 0;
}
.mg-tab-item {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}
.mg-tab-item .material-symbols-outlined { font-size: 16px; }
.mg-tab-item:hover { color: var(--primary); }
.mg-tab-item.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

/* ── Progress bar ──────────────────────────────────────── */
.mg-progress {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.mg-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.mg-progress-fill.success { background: var(--success); }
.mg-progress-fill.warning { background: var(--warning); }
.mg-progress-fill.danger  { background: var(--danger); }

/* ── Toasts ─────────────────────────────────────────────── */
#mg-toasts {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.mg-toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  min-width: 280px;
  max-width: 360px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: all;
  animation: mg-toast-in 0.22s ease;
}
@keyframes mg-toast-in {
  from { opacity: 0; transform: translateX(12px); }
  to   { opacity: 1; transform: translateX(0); }
}
.mg-toast.success { border-left: 3px solid var(--success); }
.mg-toast.error   { border-left: 3px solid var(--danger); }
.mg-toast.warning { border-left: 3px solid var(--warning); }
.mg-toast.info    { border-left: 3px solid var(--info); }
.mg-toast-icon .material-symbols-outlined { font-size: 18px; margin-top: 1px; }
.mg-toast.success .mg-toast-icon { color: var(--success); }
.mg-toast.error   .mg-toast-icon { color: var(--danger); }
.mg-toast.warning .mg-toast-icon { color: var(--warning); }
.mg-toast.info    .mg-toast-icon { color: var(--info); }
.mg-toast-msg { font-size: 13px; line-height: 1.4; flex: 1; }
.mg-toast-msg strong { font-weight: 600; display: block; margin-bottom: 2px; }

/* ── Empty state ───────────────────────────────────────── */
.mg-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  text-align: center;
}
.mg-empty .material-symbols-outlined {
  font-size: 48px;
  opacity: 0.3;
  margin-bottom: 12px;
}
.mg-empty-title { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.mg-empty-sub   { font-size: 13px; }

/* ── Loading ────────────────────────────────────────────── */
.mg-spinner {
  width: 24px; height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: mg-spin 0.7s linear infinite;
}
@keyframes mg-spin { to { transform: rotate(360deg); } }
.mg-loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

/* ── Dashboard two-column grid ────────────────────────── */
.mg-dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

/* ── Module cards (dashboard) ─────────────────────────── */
.mg-module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.mg-module-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  text-decoration: none;
  color: var(--text);
}
.mg-module-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(85,83,223,0.12);
  transform: translateY(-2px);
}
.mg-module-card.locked {
  opacity: 0.5;
  cursor: default;
  pointer-events: none;
}
.mg-module-card-icon {
  width: 44px; height: 44px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.mg-module-card-name { font-size: 12px; font-weight: 600; line-height: 1.3; }
.mg-module-card-lock { font-size: 14px; color: var(--text-light); }

/* ── Stepper ───────────────────────────────────────────── */
.mg-stepper {
  display: flex;
  align-items: center;
  padding: 20px 32px;
}
.mg-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.mg-step-circle {
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border-strong, #CBD5E1);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  position: relative;
}
.mg-step-label {
  font-size: 11px; font-weight: 600;
  color: var(--text-muted);
  transition: color var(--transition);
  white-space: nowrap;
}
.mg-step.active .mg-step-circle {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(85,83,223,0.15);
}
.mg-step.active .mg-step-label { color: var(--primary); }
.mg-step.done .mg-step-circle {
  background: var(--success, #10B981);
  border-color: var(--success, #10B981);
  color: #fff;
}
.mg-step.done .mg-step-label { color: var(--success, #10B981); }
.mg-step-connector {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 8px;
  margin-bottom: 20px; /* alinha com o centro dos círculos */
  transition: background var(--transition);
}
.mg-step-connector.done { background: var(--success, #10B981); }

/* ── Toggle switch ─────────────────────────────────────── */
.mg-toggle {
  position: relative;
  display: inline-flex;
  width: 40px;
  height: 22px;
  cursor: pointer;
}
.mg-toggle input { opacity: 0; width: 0; height: 0; }
.mg-toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 11px;
  transition: background var(--transition);
}
.mg-toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 3px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.mg-toggle input:checked + .mg-toggle-slider { background: var(--primary); }
.mg-toggle input:checked + .mg-toggle-slider::before { transform: translateX(18px); }

/* ── Divider ────────────────────────────────────────────── */
.mg-divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Utilities ─────────────────────────────────────────── */
.text-muted   { color: var(--text-muted) !important; }
.text-primary { color: var(--primary) !important; }
.text-danger  { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-sm      { font-size: 12px !important; }
.text-xs      { font-size: 11px !important; }
.fw-600       { font-weight: 600 !important; }
.fw-700       { font-weight: 700 !important; }
.d-flex       { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-0  { margin-bottom: 0 !important; }
.mb-8  { margin-bottom: 8px !important; }
.mb-12 { margin-bottom: 12px !important; }
.mb-16 { margin-bottom: 16px !important; }
.mb-24 { margin-bottom: 24px !important; }
.mt-16 { margin-top: 16px !important; }

/* ── Responsive ─────────────────────────────────────────── */
.mg-menu-btn {
  display: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all var(--transition);
}
.mg-menu-btn:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }
.mg-menu-btn .material-symbols-outlined { font-size: 22px; }

.mg-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
}
.mg-sidebar-backdrop.open { display: block; }

/* Telas médias: sidebar visível mas coluna esquerda ainda estreita */
@media (max-width: 1100px) {
  .mg-dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .mg-menu-btn { display: flex; }
  .mg-sidebar { transform: translateX(-100%); box-shadow: none; }
  .mg-sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .mg-header { left: 0; }
  .mg-main { margin-left: 0; padding: 16px; }
  .mg-form-grid { grid-template-columns: 1fr; }
  .mg-kpi-grid { grid-template-columns: 1fr 1fr; }
  .mg-module-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
}

/* ── Auth pages ─────────────────────────────────────────── */
.mg-auth-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #F4F6FB 0%, #EEEEFF 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.mg-auth-card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.10);
  padding: 40px;
  width: 100%;
  max-width: 420px;
}
.mg-auth-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
  text-align: center;
}
.mg-auth-logo-icon {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 28px;
}
.mg-auth-logo-name { font-size: 20px; font-weight: 800; color: var(--text); }
.mg-auth-logo-sub  { font-size: 12px; color: var(--text-muted); }
