/* ==========================================================================
   DESIGN TOKENS - DASHBOARD DE CRÉDITO 2.0 (FIGMACRAFT / ONE-X DESIGN SYSTEM)
   Base de Apoio Logístico do Exército · SIAFI / Tesouro Gerencial
   WCAG 2.2 AAA · 60fps GPU · IBCS & Tufte Standards · Mobile-First (360px-1860px)
   ========================================================================== */

:root {
  /* ==========================================================================
     1. TIPOGRAFIA FLUIDA & FAMÍLIAS
     ========================================================================== */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', "SFMono-Regular", Consolas, monospace;
  --font-serif: 'Newsreader', Georgia, serif;

  /* Escala Modular Fluida com clamp() */
  --font-size-xs: clamp(0.6875rem, 0.65rem + 0.15vw, 0.75rem);   /* 11px - 12px */
  --font-size-sm: clamp(0.75rem, 0.72rem + 0.2vw, 0.8125rem);    /* 12px - 13px */
  --font-size-base: clamp(0.8125rem, 0.78rem + 0.25vw, 0.875rem); /* 13px - 14px */
  --font-size-md: clamp(0.875rem, 0.85rem + 0.3vw, 1rem);        /* 14px - 16px */
  --font-size-lg: clamp(1rem, 0.95rem + 0.4vw, 1.125rem);        /* 16px - 18px */
  --font-size-xl: clamp(1.125rem, 1.05rem + 0.5vw, 1.25rem);     /* 18px - 20px */
  --font-size-2xl: clamp(1.25rem, 1.15rem + 0.7vw, 1.5rem);      /* 20px - 24px */
  --font-size-3xl: clamp(1.5rem, 1.35rem + 1vw, 1.875rem);       /* 24px - 30px */

  --font-weight-regular: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --font-weight-black: 800;

  --line-height-tight: 1.15;
  --line-height-snug: 1.3;
  --line-height-normal: 1.5;

  /* ==========================================================================
     2. ESPAÇAMENTOS & DIMENSÕES (ESCALA 4px)
     ========================================================================== */
  --space-0-5: 0.125rem; /* 2px */
  --space-1:   0.25rem;  /* 4px */
  --space-1-5: 0.375rem; /* 6px */
  --space-2:   0.5rem;   /* 8px */
  --space-2-5: 0.625rem; /* 10px */
  --space-3:   0.75rem;  /* 12px */
  --space-4:   1rem;     /* 16px */
  --space-5:   1.25rem;  /* 20px */
  --space-6:   1.5rem;   /* 24px */
  --space-8:   2rem;     /* 32px */
  --space-10:  2.5rem;   /* 40px */
  --space-12:  3rem;     /* 48px */

  /* Raios de Arredondamento */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  /* Transições 60fps GPU */
  --tr-instant: 100ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr-fast:    150ms cubic-bezier(0.4, 0, 0.2, 1);
  --tr-smooth:  250ms cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ==========================================================================
   3. TEMA ESCURO (PADRÃO MILITAR EXECUTIVO FIGMA ONE-X)
   ========================================================================== */
html[data-theme="dark"], :root[data-theme="dark"], :root:not([data-theme="light"]) {
  color-scheme: dark;

  /* Superfícies & Fundo */
  --figma-bg-base:        #0B0F19; /* Canvas principal ultra-escuro */
  --figma-bg-card:        #111827; /* Cards, Topbar e Containers */
  --figma-bg-card-hover:  #172236; /* Hover em cards */
  --figma-bg-surface:     #1E293B; /* Superfície intermediária */
  --figma-bg-surface-2:   #24344D; /* Superfície elevada */
  --figma-bg-subtle:      rgba(255, 255, 255, 0.04);
  --figma-bg-row-alt:     #151D2C; /* Linha alternada em tabelas */

  /* Bordas */
  --figma-border:         #1E293B;
  --figma-border-subtle:  rgba(255, 255, 255, 0.08);
  --figma-border-strong:  rgba(255, 255, 255, 0.16);
  --figma-border-focus:   #3B82F6;

  /* Textos & Tipografia (WCAG AAA >= 7:1) */
  --figma-text-primary:   #F8FAFC; /* Branco gelo */
  --figma-text-secondary: #94A3B8; /* Ardósia clara */
  --figma-text-tertiary:  #64748B; /* Ardósia média */
  --figma-text-num:       #F1F5F9; /* Tabular nums */

  /* Cores Semânticas Oficiais */
  --figma-blue:           #3B82F6; /* Dotação Atualizada / Aporte */
  --figma-blue-bg:        rgba(59, 130, 246, 0.12);
  --figma-blue-border:    rgba(59, 130, 246, 0.3);

  --figma-amber:          #F59E0B; /* Total Empenhado / 1º Lugar / Alerta */
  --figma-amber-bg:       rgba(245, 158, 11, 0.12);
  --figma-amber-border:   rgba(245, 158, 11, 0.3);

  --figma-purple:         #8B5CF6; /* Total Liquidado */
  --figma-purple-bg:      rgba(139, 92, 246, 0.12);
  --figma-purple-border:  rgba(139, 92, 246, 0.3);

  --figma-emerald:        #10B981; /* Saldo Disponível / SIAFI Conectado */
  --figma-emerald-pill:   #064E3B; /* Pílula verde escura */
  --figma-emerald-bg:     rgba(16, 185, 129, 0.14);
  --figma-emerald-border: #10B981;

  --figma-rose:           #EF4444; /* Esgotado / Erro / Defasagem */
  --figma-rose-bg:        rgba(239, 68, 68, 0.12);
  --figma-rose-border:    rgba(239, 68, 68, 0.3);

  --figma-silver:         #94A3B8; /* 2º Lugar Pódio */
  --figma-bronze:         #CD7F32; /* 3º Lugar Pódio */

  /* Sombras & Elevações */
  --figma-shadow-card:    0 4px 16px rgba(0, 0, 0, 0.35);
  --figma-shadow-hover:   0 8px 24px rgba(0, 0, 0, 0.45);
  --figma-shadow-modal:   0 24px 70px rgba(0, 0, 0, 0.75);

  /* Variáveis de Compatibilidade v1 -> v2 */
  --bg:           var(--figma-bg-base);
  --bg-surface:   var(--figma-bg-card);
  --bg-elevated:  var(--figma-bg-surface);
  --bg-subtle:    var(--figma-bg-subtle);
  --surface:      var(--figma-bg-card);
  --surface-2:    var(--figma-bg-surface);
  --border:       var(--figma-border);
  --border-strong:var(--figma-border-strong);
  --ink:          var(--figma-text-primary);
  --ink-muted:    var(--figma-text-secondary);
  --ink-soft:     var(--figma-text-tertiary);
  --primary:      var(--figma-blue);
  --primary-600:  #2563EB;
  --success:      var(--figma-emerald);
  --success-strong: #34D399;
  --success-bg:   var(--figma-emerald-bg);
  --success-border: rgba(16, 185, 129, 0.3);
  --warning:      var(--figma-amber);
  --warning-bg:   var(--figma-amber-bg);
  --danger:       var(--figma-rose);
  --danger-bg:    var(--figma-rose-bg);
  --gold:         var(--figma-amber);
}

/* ==========================================================================
   4. TEMA CLARO (ALTO CONTRASTE CORPORATIVO)
   ========================================================================== */
html[data-theme="light"], :root[data-theme="light"] {
  color-scheme: light;

  --figma-bg-base:        #F8FAFC;
  --figma-bg-card:        #FFFFFF;
  --figma-bg-card-hover:  #F1F5F9;
  --figma-bg-surface:     #E2E8F0;
  --figma-bg-surface-2:   #CBD5E1;
  --figma-bg-subtle:      rgba(0, 0, 0, 0.03);
  --figma-bg-row-alt:     #F8FAFC;

  --figma-border:         #E2E8F0;
  --figma-border-subtle:  rgba(0, 0, 0, 0.06);
  --figma-border-strong:  rgba(0, 0, 0, 0.14);
  --figma-border-focus:   #2563EB;

  --figma-text-primary:   #0F172A;
  --figma-text-secondary: #475569;
  --figma-text-tertiary:  #64748B;
  --figma-text-num:       #0F172A;

  --figma-blue:           #2563EB;
  --figma-blue-bg:        #EFF6FF;
  --figma-blue-border:    #BFDBFE;

  --figma-amber:          #D97706;
  --figma-amber-bg:       #FFFBEB;
  --figma-amber-border:   #FDE68A;

  --figma-purple:         #7C3AED;
  --figma-purple-bg:      #F5F3FF;
  --figma-purple-border:  #DDD6FE;

  --figma-emerald:        #059669;
  --figma-emerald-pill:   #ECFDF5;
  --figma-emerald-bg:     #ECFDF5;
  --figma-emerald-border: #A7F3D0;

  --figma-rose:           #DC2626;
  --figma-rose-bg:        #FEF2F2;
  --figma-rose-border:    #FECACA;

  --figma-silver:         #64748B;
  --figma-bronze:         #B45309;

  --figma-shadow-card:    0 4px 16px rgba(15, 23, 42, 0.06);
  --figma-shadow-hover:   0 8px 24px rgba(15, 23, 42, 0.1);
  --figma-shadow-modal:   0 24px 60px rgba(15, 23, 42, 0.2);

  --bg:           var(--figma-bg-base);
  --bg-surface:   var(--figma-bg-card);
  --bg-elevated:  var(--figma-bg-surface);
  --bg-subtle:    var(--figma-bg-subtle);
  --surface:      var(--figma-bg-card);
  --surface-2:    var(--figma-bg-surface);
  --border:       var(--figma-border);
  --border-strong:var(--figma-border-strong);
  --ink:          var(--figma-text-primary);
  --ink-muted:    var(--figma-text-secondary);
  --ink-soft:     var(--figma-text-tertiary);
  --primary:      var(--figma-blue);
  --primary-600:  #1D4ED8;
  --success:      var(--figma-emerald);
  --success-strong: #047857;
  --success-bg:   var(--figma-emerald-bg);
  --success-border: var(--figma-emerald-border);
  --warning:      var(--figma-amber);
  --warning-bg:   var(--figma-amber-bg);
  --danger:       var(--figma-rose);
  --danger-bg:    var(--figma-rose-bg);
  --gold:         var(--figma-amber);
}

/* ==========================================================================
   5. BLINDAGEM VISUAL V2 PRO (SCROLLBARS, TABULAR-NUMS & TOPBAR DESKTOP)
   ========================================================================== */
.tabs, .nav, .toptabs, .omds-nav, .seg {
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}
.tabs::-webkit-scrollbar,
.nav::-webkit-scrollbar,
.toptabs::-webkit-scrollbar,
.omds-nav::-webkit-scrollbar,
.seg::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

table td.num,
table th.num,
.pregoes-table td.num,
.pregoes-table th.num,
.tb-sag td.num,
.tb-sag th.num,
.kpi .v,
.kpi-value,
.bval,
.pl-card-n,
.pl-card-cap,
.sag-kpi-val,
.desagio-pill {
  font-variant-numeric: tabular-nums !important;
  font-feature-settings: "tnum" 1 !important;
}

@media (min-width: 1025px) {
  .topbar,
  .topbar-actions,
  .hdr-in,
  .hdr-r,
  .toolbar-actions {
    flex-wrap: nowrap !important;
  }
  .topbar-actions,
  .hdr-r {
    flex-shrink: 0 !important;
  }
}

