/**
 * Melhor Espaço - Design System Unificado
 * Versão: 2.0 (Design System com suporte nativo a Tema Claro / Escuro & WCAG 2.2 AA)
 * Arquitetura: CSS puro baseado em Design Tokens, sem dependência de pré-processadores.
 */

/* ==========================================================================
   1. DESIGN TOKENS (LIGHT & DARK THEMES)
   ========================================================================== */

:root {
  /* Paleta Base - Modo Claro (Default) */
  --color-primary-50: #f0f7f4;
  --color-primary-100: #dcefe5;
  --color-primary-200: #b9e0cd;
  --color-primary-500: #1a6b56;
  --color-primary-600: #145c49;
  --color-primary-700: #0f493a;
  --color-primary-900: #0a352a;

  --color-accent-gold: #c8933b;
  --color-accent-amber: #dfa243;
  --color-accent-sand: #f6f2ea;

  /* Superfícies e Linhas */
  --ds-bg: #f7f9f8;
  --ds-surface: #ffffff;
  --ds-surface-elevated: #ffffff;
  --ds-surface-subtle: #f1f5f3;
  --ds-line: #e4ebe7;
  --ds-line-strong: #cbd8d2;
  --ds-soft: #eaf4ef;

  /* Tipografia */
  --ds-ink: #122620;
  --ds-muted: #52685f;
  --ds-subtle: #7b9187;
  --ds-inverse: #ffffff;

  /* Sidebar e Topbar do Dashboard */
  --ds-sidebar-bg: #0c2b23;
  --ds-sidebar-border: #143e33;
  --ds-sidebar-text: #c2d9cc;
  --ds-sidebar-text-muted: #80a996;
  --ds-sidebar-hover: rgba(255, 255, 255, 0.08);
  --ds-sidebar-active: #145c49;
  --ds-topbar-bg: #ffffff;
  --ds-topbar-border: #e4ebe7;

  /* Feedback Semântico */
  --ds-success: #15803d;
  --ds-success-bg: #ecfdf5;
  --ds-success-border: #bbf7d0;

  --ds-warning: #b45309;
  --ds-warning-bg: #fffbeb;
  --ds-warning-border: #fde68a;

  --ds-danger: #b91c1c;
  --ds-danger-bg: #fef2f2;
  --ds-danger-border: #fecaca;

  --ds-info: #0369a1;
  --ds-info-bg: #f0f9ff;
  --ds-info-border: #bae6fd;

  /* Tipografia e Escalas */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', -apple-system, sans-serif;

  /* Sombras */
  --shadow-xs: 0 1px 2px rgba(18, 38, 32, 0.04);
  --shadow-sm: 0 2px 4px rgba(18, 38, 32, 0.05), 0 1px 2px rgba(18, 38, 32, 0.03);
  --shadow-md: 0 4px 8px -1px rgba(18, 38, 32, 0.06), 0 2px 4px -2px rgba(18, 38, 32, 0.04);
  --shadow-lg: 0 12px 20px -3px rgba(18, 38, 32, 0.08), 0 4px 6px -4px rgba(18, 38, 32, 0.03);

  /* Raios de Arredondamento */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transição Global Suave */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Largura Global do Portal Público (+30% em relação aos 1200px originais = 1560px) */
  --public-gutter: clamp(16px, 2.5vw, 32px);
  --public-max-width: 1560px;
  --public-container-width: min(var(--public-max-width), calc(100% - (var(--public-gutter) * 2)));

  /* Variáveis de Compatibilidade Legadas */
  --ds-green: #145c49;
  --ds-deep: #0c2b23;
  --ink: var(--ds-ink);
  --muted: var(--ds-muted);
  --green: var(--ds-green);
  --deep: var(--ds-deep);
  --line: var(--ds-line);
  --soft: var(--ds-soft);
  --surface: var(--ds-surface);
}

/* ==========================================================================
   2. TEMA ESCURO (DARK MODE ATIVADO VIA [data-theme="dark"])
   ========================================================================== */

[data-theme="dark"] {
  --color-primary-50: #10261f;
  --color-primary-100: #17382d;
  --color-primary-200: #1e4d3e;
  --color-primary-500: #22c55e;
  --color-primary-600: #16a34a;
  --color-primary-700: #15803d;
  --color-primary-900: #052e16;

  --color-accent-gold: #eab308;
  --color-accent-amber: #f59e0b;
  --color-accent-sand: #1f2723;

  /* Superfícies e Linhas no Dark */
  --ds-bg: #0c1512;
  --ds-surface: #14211c;
  --ds-surface-elevated: #1a2a24;
  --ds-surface-subtle: #192722;
  --ds-line: #22372f;
  --ds-line-strong: #2f4b40;
  --ds-soft: #182d25;

  /* Tipografia no Dark */
  --ds-ink: #f0f7f3;
  --ds-muted: #9bb5a9;
  --ds-subtle: #738e81;
  --ds-inverse: #0c1512;

  /* Sidebar e Topbar do Dashboard no Dark */
  --ds-sidebar-bg: #08100d;
  --ds-sidebar-border: #182722;
  --ds-sidebar-text: #b5cdc2;
  --ds-sidebar-text-muted: #749284;
  --ds-sidebar-hover: rgba(255, 255, 255, 0.06);
  --ds-sidebar-active: #183d30;
  --ds-topbar-bg: #101c17;
  --ds-topbar-border: #1f332b;

  /* Feedback Semântico no Dark */
  --ds-success: #4ade80;
  --ds-success-bg: #063119;
  --ds-success-border: #166534;

  --ds-warning: #fcd34d;
  --ds-warning-bg: #372304;
  --ds-warning-border: #854d0e;

  --ds-danger: #f87171;
  --ds-danger-bg: #3b0c0c;
  --ds-danger-border: #991b1b;

  --ds-info: #7dd3fc;
  --ds-info-bg: #082a47;
  --ds-info-border: #075985;

  /* Sombras no Dark */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 20px rgba(0, 0, 0, 0.55);

  --ds-green: #22c55e;
  --ds-deep: #08100d;
  --ink: var(--ds-ink);
  --muted: var(--ds-muted);
  --green: var(--ds-green);
  --deep: var(--ds-deep);
  --line: var(--ds-line);
  --soft: var(--ds-soft);
  --surface: var(--ds-surface);
}

/* ==========================================================================
   3. RESET & ESTILOS GLOBAIS
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-family: var(--font-sans);
  color: var(--ds-ink);
  background-color: var(--ds-bg);
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: 0.9375rem; /* 15px */
  color: var(--ds-ink);
  background-color: var(--ds-bg);
}

img, svg, video {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--ds-green);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   4. TIPOGRAFIA HIERÁRQUICA
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--ds-ink);
  margin-top: 0;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  margin-bottom: 0.5rem;
}

h2 {
  font-size: clamp(1.35rem, 2.5vw, 1.75rem);
  margin-bottom: 0.5rem;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 0.35rem;
}

p {
  color: var(--ds-muted);
  line-height: 1.6;
  margin: 0 0 1rem;
}

.text-muted, .muted {
  color: var(--ds-muted);
  font-size: 0.875rem;
}

.text-subtle {
  color: var(--ds-subtle);
  font-size: 0.8125rem;
}

/* ==========================================================================
   5. BOTÕES E ELEMENTOS DE AÇÃO
   ========================================================================== */

.btn, button.btn, a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  min-height: 44px;
  padding: 0 18px;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  color: #ffffff;
  background-color: var(--color-primary-600);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: all var(--transition-fast);
  user-select: none;
}

.btn:hover, button.btn:hover, a.btn:hover {
  background-color: var(--color-primary-700);
  color: #ffffff;
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn:focus-visible {
  outline: 3px solid var(--color-primary-200);
  outline-offset: 2px;
}

/* Variantes de Botão */
.btn.secondary, .btn-secondary {
  background-color: var(--ds-soft);
  color: var(--ds-green);
  border-color: transparent;
}

.btn.secondary:hover, .btn-secondary:hover {
  background-color: var(--color-primary-100);
  color: var(--color-primary-700);
}

.btn.outline, .btn-outline {
  background-color: transparent;
  color: var(--ds-ink);
  border-color: var(--ds-line-strong);
}

.btn.outline:hover, .btn-outline:hover {
  background-color: var(--ds-surface-subtle);
  border-color: var(--ds-green);
  color: var(--ds-green);
}

.btn.ghost, .btn-ghost {
  background-color: transparent;
  color: var(--ds-muted);
  border-color: transparent;
  box-shadow: none;
}

.btn.ghost:hover, .btn-ghost:hover {
  background-color: var(--ds-surface-subtle);
  color: var(--ds-ink);
}

.btn.danger, .btn-danger {
  background-color: var(--ds-danger-bg);
  color: var(--ds-danger);
  border-color: var(--ds-danger-border);
}

.btn.danger:hover, .btn-danger:hover {
  background-color: var(--ds-danger);
  color: #ffffff;
}

/* Tamanhos de Botão */
.btn-sm, .btn.sm {
  height: 36px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.8125rem;
}

.btn-lg, .btn.lg {
  height: 50px;
  min-height: 50px;
  padding: 0 24px;
  font-size: 1rem;
}

/* ==========================================================================
   6. FORMULÁRIOS & CAMPOS
   ========================================================================== */

.form-group, .field {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

label, .form-label, .field label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ds-ink);
  margin-bottom: 2px;
  letter-spacing: 0.01em;
}

input:not([type=checkbox]):not([type=radio]),
select,
textarea,
.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--ds-ink);
  background-color: var(--ds-surface);
  border: 1px solid var(--ds-line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

textarea, .form-textarea {
  height: auto;
  min-height: 110px;
  padding: 12px 14px;
  line-height: 1.5;
  resize: vertical;
}

input:focus, select:focus, textarea:focus,
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--ds-green);
  box-shadow: 0 0 0 3px var(--color-primary-100);
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}

input::placeholder, textarea::placeholder {
  color: var(--ds-subtle);
  opacity: 0.8;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--ds-muted);
  margin-top: 2px;
}

.form-error {
  font-size: 0.75rem;
  color: var(--ds-danger);
  font-weight: 500;
  margin-top: 2px;
}

/* ==========================================================================
   7. CARDS, SUPERFÍCIES & PAINÉIS
   ========================================================================== */

.card, .panel-card, article {
  background-color: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: var(--radius-lg);
  padding: clamp(18px, 3vw, 28px);
  box-shadow: var(--shadow-xs);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--ds-line);
}

.card-header h2, .card-header h3 {
  margin: 0;
}

/* ==========================================================================
   8. TABELAS DE DADOS RESPONSIVAS
   ========================================================================== */

.table-responsive {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--ds-line);
  border-radius: var(--radius-lg);
  background-color: var(--ds-surface);
  box-shadow: var(--shadow-xs);
  margin-bottom: 1.5rem;
  -webkit-overflow-scrolling: touch;
}

table, .data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  color: var(--ds-ink);
}

table th {
  background-color: var(--ds-surface-subtle);
  color: var(--ds-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 13px 16px;
  border-bottom: 1px solid var(--ds-line);
  text-align: left;
  white-space: nowrap;
}

table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ds-line);
  color: var(--ds-ink);
  vertical-align: middle;
}

table tr:last-child td {
  border-bottom: none;
}

table tbody tr {
  transition: background-color var(--transition-fast);
}

table tbody tr:hover {
  background-color: var(--ds-surface-subtle);
}

/* ==========================================================================
   9. CARDS DE MÉTRICAS & KPIS
   ========================================================================== */

.kpi-grid, .metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric, .kpi-card {
  display: flex;
  flex-direction: column;
  background-color: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-xs);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.metric:hover, .kpi-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.metric strong, .kpi-card strong, .kpi-value {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--ds-green);
  letter-spacing: -0.04em;
}

.metric span, .kpi-card span, .kpi-label {
  display: block;
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--ds-muted);
  font-weight: 500;
}

/* ==========================================================================
   10. BADGES, STATUS & PILLS
   ========================================================================== */

.status-pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge-success, .status-pill.active, .status-pill.approved {
  background-color: var(--ds-success-bg);
  color: var(--ds-success);
  border: 1px solid var(--ds-success-border);
}

.badge-warning, .status-pill.pending, .status-pill.suspended {
  background-color: var(--ds-warning-bg);
  color: var(--ds-warning);
  border: 1px solid var(--ds-warning-border);
}

.badge-danger, .status-pill.rejected, .status-pill.cancelled {
  background-color: var(--ds-danger-bg);
  color: var(--ds-danger);
  border: 1px solid var(--ds-danger-border);
}

.badge-info, .status-pill.info {
  background-color: var(--ds-info-bg);
  color: var(--ds-info);
  border: 1px solid var(--ds-info-border);
}

/* ==========================================================================
   11. ALERTAS & BANNERS DE FEEDBACK
   ========================================================================== */

.alert, .ok {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 20px;
}

.alert-success, .ok {
  background-color: var(--ds-success-bg);
  color: var(--ds-success);
  border: 1px solid var(--ds-success-border);
}

.alert-warning {
  background-color: var(--ds-warning-bg);
  color: var(--ds-warning);
  border: 1px solid var(--ds-warning-border);
}

.alert-danger, .alert:not(.alert-success):not(.alert-warning):not(.alert-info) {
  background-color: var(--ds-danger-bg);
  color: var(--ds-danger);
  border: 1px solid var(--ds-danger-border);
}

.alert-info {
  background-color: var(--ds-info-bg);
  color: var(--ds-info);
  border: 1px solid var(--ds-info-border);
}

/* ==========================================================================
   12. BOTÃO TOGGLE DE TEMA (CLARO / ESCURO)
   ========================================================================== */

.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--ds-line);
  background-color: var(--ds-surface);
  color: var(--ds-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.theme-toggle-btn:hover {
  background-color: var(--ds-surface-subtle);
  color: var(--ds-green);
  border-color: var(--ds-green);
}

.theme-toggle-btn svg {
  width: 20px;
  height: 20px;
}

/* Alternância de ícones via atributo */
[data-theme="dark"] .theme-icon-moon {
  display: none;
}
[data-theme="dark"] .theme-icon-sun {
  display: block;
}
:root:not([data-theme="dark"]) .theme-icon-sun {
  display: none;
}
:root:not([data-theme="dark"]) .theme-icon-moon {
  display: block;
}

/* ==========================================================================
   13. LAYOUT SHELL DO DASHBOARD (SIDEBAR & TOPBAR)
   ========================================================================== */

.dashboard-shell {
  min-height: 100vh;
  display: flex;
  background-color: var(--ds-bg);
}

.dashboard-sidebar {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  width: 320px;
  background-color: var(--ds-sidebar-bg);
  border-right: 1px solid var(--ds-sidebar-border);
  color: var(--ds-sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  transition: width var(--transition-normal), background-color var(--transition-normal);
}

.dashboard-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #ffffff;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  padding: 0 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.dashboard-brand:hover {
  text-decoration: none;
}

.dashboard-brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
}

.dashboard-brand-mark img {
  width: 28px;
  height: 28px;
}

.dashboard-context {
  padding: 10px 10px 6px;
}

.dashboard-context span {
  display: block;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ds-sidebar-text-muted);
  font-weight: 700;
}

.dashboard-context strong {
  display: block;
  font-size: 0.875rem;
  color: #ffffff;
  margin-top: 2px;
}

.dashboard-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  padding-top: 8px;
  text-align: left;
}

.dashboard-nav small, .dash-nav-group-title {
  display: block;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ds-sidebar-text-muted);
  font-weight: 700;
  padding: 8px 10px 2px;
  text-align: left !important;
  align-self: flex-start;
}

.dash-nav-item {
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  text-align: left !important;
  gap: 12px;
  border-radius: var(--radius-md);
  padding: 7px 12px;
  color: var(--ds-sidebar-text);
  font-size: 0.875rem;
  font-weight: 500;
  width: 100%;
  box-sizing: border-box;
  transition: all var(--transition-fast);
}

.dash-nav-item span {
  text-align: left;
}

.dash-nav-item:hover, .dash-nav-item:focus {
  background-color: var(--ds-sidebar-hover);
  color: #ffffff;
  text-decoration: none;
}

.dash-nav-item.active {
  background-color: var(--ds-sidebar-active);
  color: #ffffff;
  font-weight: 600;
}

.dash-icon {
  width: 20px;
  text-align: center;
  font-size: 1.1rem;
  color: var(--ds-sidebar-text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dash-nav-item:hover .dash-icon,
.dash-nav-item.active .dash-icon {
  color: #ffffff;
}

.dashboard-sidebar-bottom {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.public-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: var(--radius-md);
  color: var(--ds-sidebar-text);
  font-size: 0.8125rem;
  transition: all var(--transition-fast);
}

.public-link:hover {
  background-color: var(--ds-sidebar-hover);
  color: #ffffff;
  text-decoration: none;
}

.dashboard-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 6px 0;
  margin-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--color-primary-100);
  color: var(--color-primary-700);
  font-weight: 700;
  font-size: 0.875rem;
}

.dashboard-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.dashboard-user-info b {
  color: #ffffff;
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-user-info small {
  color: var(--ds-sidebar-text-muted);
  font-size: 0.6875rem;
}

.dashboard-user-logout {
  color: var(--ds-sidebar-text-muted);
  font-size: 1.1rem;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.dashboard-user-logout:hover {
  color: var(--ds-danger);
}

/* ==========================================================================
   14. TOPBAR & MAIN CONTENT
   ========================================================================== */

.dashboard-main {
  margin-left: 320px;
  min-width: 0;
  min-height: 100vh;
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--ds-bg);
  transition: margin-left var(--transition-normal);
}

.dashboard-topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  height: 70px;
  background-color: var(--ds-topbar-bg);
  border-bottom: 1px solid var(--ds-topbar-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 32px;
  box-shadow: var(--shadow-xs);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ds-subtle);
  font-size: 0.75rem;
  margin-bottom: 2px;
}

.breadcrumb b {
  color: var(--ds-line-strong);
}

.dashboard-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  color: var(--ds-ink);
}

.dashboard-top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.dashboard-content {
  padding: 24px 32px 60px;
  max-width: 1400px;
  width: 100%;
  flex: 1;
}

/* Regra Soberana de Espaçamento do Painel: anula margens centrais inconsistentes (margin: auto) em todas as telas */
/* Regra Soberana de Espaçamento e Largura:
   Todas as páginas do painel herdam rigorosamente a mesma largura da Visão Geral (100% de .dashboard-content),
   anulando max-width restritivos e margens centrais inconsistentes herdados de estilos inline. */
.dashboard-content > div:not(.alert):not(.card-error) {
  margin-left: 0 !important;
  margin-right: auto !important;
  max-width: 100% !important;
  width: 100% !important;
  box-sizing: border-box !important;
}

/* ==========================================================================
   15. HEADER & FOOTER PÚBLICOS
   ========================================================================== */

.site-header {
  height: 74px;
  background-color: var(--ds-surface);
  border-bottom: 1px solid var(--ds-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 52px);
  position: sticky;
  top: 0;
  z-index: 30;
  box-shadow: var(--shadow-xs);
  transition: background-color var(--transition-normal);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ds-ink);
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 0.875rem;
  font-weight: 600;
}

.site-nav a {
  color: var(--ds-ink);
  transition: color var(--transition-fast);
}

.site-nav a:hover {
  color: var(--ds-green);
  text-decoration: none;
}

.site-nav a.nav-advertise-cta {
  background: linear-gradient(135deg, #123d36 0%, #15803d 100%);
  color: #ffffff;
  padding: 9px 18px;
  border-radius: 9999px;
  font-weight: 700;
  font-size: 0.875rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 3px 12px rgba(21, 128, 61, 0.24);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), filter var(--transition-fast);
}

.site-nav a.nav-advertise-cta:hover {
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(21, 128, 61, 0.34);
  filter: brightness(1.06);
}

.page-shell {
  max-width: var(--public-max-width);
  width: 100%;
  flex: 1 0 auto;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 56px) var(--public-gutter);
  box-sizing: border-box;
}

/* Reset de casca para Landing Page / Homepage (100% largura sem box cinza) */
.page-shell.landing-page {
  max-width: 100% !important;
  width: 100% !important;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
}

.card.landing-page {
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  width: 100% !important;
  max-width: 100% !important;
}

/* ==========================================================================
   15. RODAPÉ PÚBLICO (SITE-FOOTER / PUBLIC-FOOTER)
   ========================================================================== */

.site-footer, .public-footer {
  background-color: var(--ds-surface);
  border-top: 1px solid var(--ds-line);
  padding: 48px 24px 36px;
  text-align: center;
  font-size: 0.875rem;
  color: var(--ds-muted);
  margin-top: auto;
  width: 100%;
  box-sizing: border-box;
  clear: both;
}

.footer-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ds-ink);
  font-family: var(--font-display);
}

.footer-brand .brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.footer-brand .brand-mark img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  display: block;
}

.footer-brand img {
  height: 50px;
  width: auto;
  max-width: 280px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 14px 28px;
  margin: 0 auto 20px;
  padding: 0;
  max-width: 860px;
  list-style: none;
}

.footer-links a {
  color: var(--ds-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--ds-green);
  text-decoration: underline;
}

.site-footer p {
  margin: 8px 0;
  font-size: 0.8125rem;
  color: var(--ds-subtle);
}

.site-footer small {
  display: block;
  font-size: 0.75rem;
  color: var(--ds-subtle);
  opacity: 0.7;
  margin-top: 4px;
}

/* ==========================================================================
   16. RESPONSIVIDADE (MOBILE & TABLET)
   ========================================================================== */

@media (max-width: 860px) {
  .dashboard-sidebar {
    width: 72px;
    padding: 16px 8px;
  }

  .dashboard-brand {
    justify-content: center;
    padding: 0 0 16px;
  }

  .dashboard-brand span:last-child,
  .dashboard-context,
  .dashboard-nav small,
  .dash-nav-item span:last-child,
  .public-link span,
  .dashboard-user-info,
  .dashboard-user-logout {
    display: none;
  }

  .dash-nav-item {
    justify-content: center;
    padding: 12px;
  }

  .dash-icon {
    margin: 0;
    font-size: 1.25rem;
  }

  .dashboard-main {
    margin-left: 72px;
  }

  .dashboard-topbar {
    padding: 0 20px;
  }

  .dashboard-content {
    padding: 20px 16px;
  }
}

@media (max-width: 640px) {
  .site-header {
    padding: 0 16px;
    height: 64px;
  }

  .site-nav {
    gap: 10px;
  }

  .site-nav a:not(:last-child):not(.nav-advertise-cta) {
    display: none;
  }

  .site-nav a.nav-advertise-cta {
    padding: 7px 12px;
    font-size: 0.78rem;
  }

  .dashboard-sidebar {
    width: 60px;
    padding: 12px 6px;
  }

  .dashboard-main {
    margin-left: 60px;
  }

  .dashboard-topbar {
    height: 64px;
    padding: 0 14px;
  }

  .dashboard-title {
    font-size: 1.15rem;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   17. ACESSIBILIDADE & REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

:focus-visible {
  outline: 3px solid var(--color-primary-200);
  outline-offset: 2px;
}

/* ==========================================================================
   18. MODERN ADMIN & ADVERTISER DESIGN KIT (UI/UX LUXURY UPGRADE)
   ========================================================================== */

/* Universal Form Control Styling */
.form-control,
.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  height: 44px;
  min-height: 44px;
  padding: 10px 16px;
  font-family: var(--font-body);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--ds-ink);
  background-color: var(--ds-surface);
  border: 1.5px solid var(--ds-line);
  border-radius: var(--radius-md);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

select.form-control,
select.form-select {
  padding-right: 42px;
  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='%2364748b' stroke-width='2.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 14px center;
  background-size: 16px 16px;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
}

[data-theme="dark"] select.form-control,
[data-theme="dark"] select.form-select {
  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='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.form-control:hover,
.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--ds-line-strong);
}

.form-control:focus,
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--ds-green);
  box-shadow: 0 0 0 4px rgba(18, 61, 54, 0.12);
  background-color: var(--ds-surface);
}

[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus,
[data-theme="dark"] .form-textarea:focus {
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.22);
}

textarea.form-control,
.form-textarea {
  height: auto;
  min-height: 110px;
  padding: 12px 16px;
  line-height: 1.6;
  resize: vertical;
}

.field label,
.form-group label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ds-ink);
  letter-spacing: 0.01em;
  margin-bottom: 6px;
}

.field .helper,
.field .hint,
.form-hint {
  display: block;
  font-size: 0.775rem;
  color: var(--ds-muted);
  margin-top: 5px;
  line-height: 1.4;
}

.req-star {
  color: #ef4444;
  font-weight: 700;
}

/* Modern File Dropzone */
.modern-dropzone {
  border: 2px dashed var(--ds-line-strong);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  background-color: var(--ds-surface-subtle);
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.modern-dropzone:hover,
.modern-dropzone.dragover {
  border-color: var(--ds-green);
  background-color: rgba(18, 61, 54, 0.04);
}

[data-theme="dark"] .modern-dropzone:hover {
  background-color: rgba(34, 197, 94, 0.06);
}

.modern-dropzone-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(18, 61, 54, 0.08);
  color: var(--ds-green);
}

.modern-dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Status Badges & Pills */
.badge,
.badge-modern,
.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-success {
  background-color: #dcfce7;
  color: #15803d;
  border: 1px solid #bbf7d0;
}

.badge-warning {
  background-color: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.badge-danger {
  background-color: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.badge-info {
  background-color: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.badge-primary,
.badge-brand {
  background-color: rgba(18, 61, 54, 0.1);
  color: var(--ds-green);
  border: 1px solid rgba(18, 61, 54, 0.2);
}

.badge-neutral {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

[data-theme="dark"] .badge-success {
  background-color: rgba(34, 197, 94, 0.16);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.3);
}

[data-theme="dark"] .badge-warning {
  background-color: rgba(245, 158, 11, 0.16);
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .badge-danger {
  background-color: rgba(239, 68, 68, 0.16);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

[data-theme="dark"] .badge-info {
  background-color: rgba(14, 165, 233, 0.16);
  color: #38bdf8;
  border-color: rgba(14, 165, 233, 0.3);
}

[data-theme="dark"] .badge-primary,
[data-theme="dark"] .badge-brand {
  background-color: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border-color: rgba(34, 197, 94, 0.3);
}

[data-theme="dark"] .badge-neutral {
  background-color: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border-color: rgba(148, 163, 184, 0.25);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

/* Modern Data Table Card */
.table-card-modern {
  background: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.04);
  margin-bottom: 24px;
}

.table-modern {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}

.table-modern th {
  background-color: var(--ds-surface-subtle);
  color: var(--ds-muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 18px;
  border-bottom: 1px solid var(--ds-line);
  text-align: left;
  white-space: nowrap;
}

.table-modern td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--ds-line);
  color: var(--ds-ink);
  vertical-align: middle;
}

.table-modern tbody tr {
  transition: background-color var(--transition-fast);
}

.table-modern tbody tr:hover {
  background-color: rgba(18, 61, 54, 0.03);
}

[data-theme="dark"] .table-modern tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.table-modern tr:last-child td {
  border-bottom: none;
}

/* Modern Filter & Action Toolbars */
.toolbar-card-modern {
  background: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: var(--radius-xl);
  padding: 16px 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

/* KPI Luxury Stat Card */
.stat-card-luxury {
  background: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: var(--radius-xl);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.stat-card-luxury:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -4px rgba(0, 0, 0, 0.08);
}

.stat-card-luxury::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--ds-green), var(--ds-gold));
}

.stat-card-luxury .stat-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stat-card-luxury .stat-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ds-muted);
}

.stat-card-luxury .stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  background: rgba(18, 61, 54, 0.08);
}

.stat-card-luxury .stat-value {
  font-family: var(--font-display);
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  color: var(--ds-ink);
  letter-spacing: -0.04em;
  margin-bottom: 6px;
}

.stat-card-luxury .stat-desc {
  font-size: 0.8125rem;
  color: var(--ds-muted);
}

/* Modern Checkbox & Radio Chips */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.chip-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--ds-surface);
  border: 1.5px solid var(--ds-line);
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ds-ink);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.chip-label:hover {
  border-color: var(--ds-green);
  background: rgba(18, 61, 54, 0.02);
}

.chip-label input[type="checkbox"],
.chip-label input[type="radio"] {
  display: none;
}

.chip-label.active,
.chip-label:has(input:checked) {
  background: rgba(18, 61, 54, 0.1);
  border-color: var(--ds-green);
  color: var(--ds-green);
  font-weight: 600;
}

[data-theme="dark"] .chip-label.active,
[data-theme="dark"] .chip-label:has(input:checked) {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
  color: #4ade80;
}

/* Section Card Header */
.section-header-modern {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 14px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--ds-line);
}

.section-header-modern h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
  color: var(--ds-ink);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header-modern p {
  font-size: 0.8125rem;
  color: var(--ds-muted);
  margin: 4px 0 0;
}

/* Action Button Styles */
.btn-action-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-icon-sm {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--ds-line);
  background: var(--ds-surface);
  color: var(--ds-ink);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-icon-sm:hover {
  background: var(--ds-surface-subtle);
  border-color: var(--ds-line-strong);
  color: var(--ds-green);
}

.btn-icon-sm.danger:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: #b91c1c;
}


/* ==========================================================
   SECTION 19: MODERN AUTH EXPERIENCES (SPLIT & LUXURY CARDS)
   ========================================================== */
.page-shell.auth-page {
  max-width: 100% !important;
  width: 100% !important;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 !important;
  margin: 0 !important;
  background: transparent !important;
}

.card.auth-page {
  padding: 0 !important;
  margin: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  width: 100% !important;
  max-width: 100% !important;
}

.auth-split-wrapper {
  width: 100%;
  max-width: min(1320px, var(--public-container-width));
  margin: clamp(24px, 4vw, 56px) auto clamp(40px, 6vw, 80px);
  padding: 0;
}

.auth-split-card {
  display: grid;
  grid-template-columns: 1.15fr 0.95fr;
  background: var(--ds-surface);
  border: 1px solid var(--ds-line);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 20px 60px -15px rgba(0, 0, 0, 0.08), 0 0 1px rgba(0,0,0,0.05);
}

@media (max-width: 900px) {
  .auth-split-card {
    grid-template-columns: 1fr;
    max-width: 520px;
    margin: 0 auto;
  }
  .auth-split-brand-side {
    display: none !important;
  }
}

.auth-split-form-side {
  padding: clamp(32px, 5vw, 48px);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-split-brand-side {
  background: linear-gradient(145deg, #0b2216 0%, #153e28 50%, #0d2a1c 100%);
  padding: clamp(32px, 5vw, 48px);
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-split-brand-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 20%, rgba(34, 197, 94, 0.15) 0%, transparent 60%);
  pointer-events: none;
}

/* Brand Logo Image Enhancements */
.brand img {
  height: 44px;
  width: auto;
  max-width: 250px;
  object-fit: contain;
}
.footer-brand img {
  height: 48px;
  width: auto;
  max-width: 270px;
  object-fit: contain;
}
.dashboard-brand img {
  max-height: 44px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}
