/* ==========================================================================
   Cosecurity Design System — Foundation
   --------------------------------------------------------------------------
   Fonte da verdade: estilo_cosecurity/ui.md (marca oficial Cosecurity)
   Estrutura/componentes inspirados em static/placas/placa.css (padrão validado)

   Objetivo: um único CSS canônico, com cores em OKLCH, tokens semânticos
   (background / foreground / border / ring / primary / secondary / hover /
   active ...). Suporte apenas a modo claro — tema escuro removido de
   propósito, inclusive o automático via preferência do sistema.

   Uso: <link rel="stylesheet" href="/static/css/cosecurity.css">
   Coexiste com o Bootstrap — os tokens e componentes daqui têm prioridade.
   ========================================================================== */

/* ==========================================================================
   0. FONTE DA MARCA — AmpleSoft Pro (uso exclusivo do logotipo/título-marca)
   --------------------------------------------------------------------------
   Arquivos em static/assets/font/. Só o peso Bold é embutido aqui porque é o
   único usado por --font-logo (.cos-header-title); os demais pesos já
   existem em static/assets/font/stylesheet.css para quem precisar deles.
   Headings normais (h1–h6 fora do logo) usam Montserrat via --font-display,
   nunca AmpleSoft Pro — ver seção 4.
   ========================================================================== */
@font-face {
  font-family: 'AmpleSoft Pro';
  src: url('../assets/font/AmpleSoftPro-Bold.woff2') format('woff2'),
       url('../assets/font/AmpleSoftPro-Bold.woff') format('woff'),
       url('../assets/font/AmpleSoftPro-Bold.ttf') format('truetype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* ==========================================================================
   1. PRIMITIVAS — escalas de cor em OKLCH ancoradas na marca Cosecurity
   --------------------------------------------------------------------------
   Âncoras oficiais (ui.md):
     Navy   PANTONE 281        oklch(25.98% 0.076 255.4)  #001F45
     Cyan   Process Cyan C     oklch(71.08% 0.159 230.6)  #00AEEF
     Gray   PANTONE 424        oklch(52.68% 0.005 264.8)  #6D6E71
     Pink   PANTONE 214        oklch(57.49% 0.225 10.4)   #EC1651
     Gold   PANTONE 116        oklch(84.95% 0.171 86.3)   #FFCA05
   ========================================================================== */
:root {
  /* Navy — cor institucional primária (hue ~255) */
  --navy-50:  oklch(0.970 0.012 255);
  --navy-100: oklch(0.930 0.025 255);
  --navy-200: oklch(0.850 0.050 255);
  --navy-300: oklch(0.720 0.090 255);
  --navy-400: oklch(0.620 0.120 255);
  --navy-500: oklch(0.520 0.130 255);
  --navy-600: oklch(0.420 0.110 255);
  --navy-700: oklch(0.330 0.090 255);
  --navy-800: oklch(0.260 0.076 255); /* âncora oficial #001F45 */
  --navy-900: oklch(0.210 0.060 255);
  --navy-950: oklch(0.160 0.045 255);

  /* Cyan — acento institucional vivo (hue ~231) */
  --cyan-50:  oklch(0.970 0.020 231);
  --cyan-100: oklch(0.940 0.040 231);
  --cyan-200: oklch(0.900 0.070 231);
  --cyan-300: oklch(0.840 0.100 231);
  --cyan-400: oklch(0.780 0.135 231);
  --cyan-500: oklch(0.711 0.159 231); /* âncora oficial #00AEEF */
  --cyan-600: oklch(0.620 0.150 231);
  --cyan-700: oklch(0.520 0.125 231);
  --cyan-800: oklch(0.430 0.100 231);
  --cyan-900: oklch(0.350 0.078 231);

  /* Neutros — cinza institucional com leve viés navy para coesão (hue ~255) */
  --neutral-0:   oklch(1.000 0     0);       /* branco puro */
  --neutral-50:  oklch(0.985 0.003 255);
  --neutral-100: oklch(0.968 0.005 255);
  --neutral-200: oklch(0.930 0.008 255);
  --neutral-300: oklch(0.880 0.010 255);
  --neutral-400: oklch(0.740 0.012 255);
  --neutral-500: oklch(0.600 0.012 255);     /* ~ #6D6E71 institucional */
  --neutral-600: oklch(0.500 0.013 255);
  --neutral-700: oklch(0.400 0.014 255);
  --neutral-800: oklch(0.300 0.020 255);
  --neutral-900: oklch(0.220 0.025 255);
  --neutral-950: oklch(0.160 0.020 255);

  /* Pink — secundária de alerta/destaque (hue ~10) */
  --pink-100: oklch(0.930 0.050 10.4);
  --pink-300: oklch(0.780 0.130 10.4);
  --pink-500: oklch(0.575 0.225 10.4);       /* âncora oficial #EC1651 */
  --pink-600: oklch(0.510 0.210 10.4);
  --pink-700: oklch(0.450 0.185 10.4);

  /* Gold — secundária de sinalização (hue ~86) */
  --gold-100: oklch(0.965 0.055 86.3);
  --gold-300: oklch(0.910 0.120 86.3);
  --gold-500: oklch(0.850 0.171 86.3);       /* âncora oficial #FFCA05 */
  --gold-600: oklch(0.760 0.155 86.3);
  --gold-700: oklch(0.660 0.135 86.3);

  /* Verde — apenas para estado de sucesso (hue ~150) */
  --green-100: oklch(0.940 0.045 150);
  --green-500: oklch(0.680 0.150 150);
  --green-600: oklch(0.600 0.145 150);
  --green-700: oklch(0.520 0.125 150);

  /* Vermelho — apenas para estado de erro/perigo (hue ~25) */
  --red-100: oklch(0.940 0.040 25);
  --red-500: oklch(0.600 0.205 25);
  --red-600: oklch(0.535 0.200 25);
  --red-700: oklch(0.470 0.180 25);
}

/* ==========================================================================
   2. TOKENS SEMÂNTICOS — modo claro (padrão)
   --------------------------------------------------------------------------
   Referencie SEMPRE estes tokens nos componentes/telas, nunca as primitivas
   diretamente. Trocar de tema = trocar apenas este mapeamento.
   ========================================================================== */
:root {
  /* Superfícies e texto base */
  --background:            var(--neutral-50);   /* fundo da página */
  --foreground:            var(--navy-900);     /* texto principal */
  --surface:               var(--neutral-100);  /* fundo rebaixado/sunken */
  --card:                  var(--neutral-0);    /* fundo de cartões/painéis */
  --card-foreground:       var(--navy-900);
  --popover:               var(--neutral-0);
  --popover-foreground:    var(--navy-900);

  /* Texto por ênfase */
  --foreground-strong:     var(--navy-900);
  --foreground-muted:      var(--neutral-700);  /* neutral-500 tinha contraste insuficiente sobre --background */
  --foreground-subtle:     var(--neutral-400);
  --foreground-on-brand:   oklch(0.94 0.01 255); /* texto sobre navy/cyan — branco suavizado, menos agressivo que #fff puro */

  /* Muted (áreas secundárias, chips) */
  --muted:                 var(--neutral-100);
  --muted-foreground:      var(--neutral-700);  /* mesmo ajuste de contraste de --foreground-muted */

  /* Primária — identidade institucional (navy) */
  --primary:               var(--navy-800);
  --primary-foreground:    var(--neutral-0);
  --primary-hover:         var(--navy-700);
  --primary-active:        var(--navy-900);

  /* Secundária — botão/área discreta */
  --secondary:            var(--neutral-100);
  --secondary-foreground: var(--navy-800);
  --secondary-hover:      var(--neutral-200);
  --secondary-active:     var(--neutral-300);

  /* Acento — cyan vivo (CTA, links ativos, realces) */
  --accent:               var(--cyan-500);
  --accent-foreground:    var(--navy-950);
  --accent-hover:         var(--cyan-600);
  --accent-active:        var(--cyan-700);

  /* Bordas, campos e foco */
  --border:               var(--neutral-200);
  --border-strong:        var(--neutral-300);
  --input:                var(--neutral-300);
  --ring:                 var(--cyan-700);      /* anel de foco (contraste WCAG 2.1 §1.4.11 ≥ 3:1) */

  /* Estados semânticos (cor + fundo de apoio) */
  --success:              var(--green-600);
  --success-foreground:   var(--neutral-0);
  --success-surface:      var(--green-100);
  --warning:              var(--gold-700);
  --warning-foreground:   var(--navy-950);
  --warning-surface:      var(--gold-100);
  --danger:               var(--red-600);
  --danger-foreground:    var(--neutral-0);
  --danger-surface:       var(--red-100);
  --info:                 var(--cyan-600);
  --info-foreground:      var(--neutral-0);
  --info-surface:         var(--cyan-100);

  /* Overlays */
  --overlay:              oklch(0.16 0.02 255 / 0.55);
  --overlay-strong:       oklch(0.16 0.02 255 / 0.82);

  /* ---- Escala tipográfica ---- */
  --font-display: 'Montserrat', system-ui, -apple-system, sans-serif;
  --font-body:    'Montserrat', system-ui, -apple-system, sans-serif;
  --font-mono:    'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
  --font-logo:    'AmpleSoft Pro', 'AmplesoftPro', 'Montserrat', sans-serif; /* uso exclusivo: .cos-header-title (logo/marca) */

  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;
  --fw-extrabold: 800;

  --text-3xs: 0.625rem;  /* 10px */
  --text-2xs: 0.6875rem; /* 11px */
  --text-xs:  0.75rem;   /* 12px */
  --text-sm:  0.875rem;  /* 14px */
  --text-base:1rem;      /* 16px */
  --text-lg:  1.125rem;  /* 18px */
  --text-xl:  1.25rem;   /* 20px */
  --text-2xl: 1.5rem;    /* 24px */
  --text-3xl: 2rem;      /* 32px */

  --leading-none: 1;
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;

  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide: 0.04em;
  --tracking-caps: 0.14em;

  /* ---- Espaçamento (base 4px) ---- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;

  /* ---- Raios ---- */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 16px;
  --radius-pill: 999px;

  /* ---- Sombras (ancoradas no navy) ---- */
  --shadow-xs: 0 1px 2px oklch(0.26 0.076 255 / 0.06);
  --shadow-sm: 0 1px 3px oklch(0.26 0.076 255 / 0.10), 0 1px 2px oklch(0.26 0.076 255 / 0.06);
  --shadow-md: 0 4px 12px oklch(0.26 0.076 255 / 0.10), 0 2px 4px oklch(0.26 0.076 255 / 0.06);
  --shadow-lg: 0 12px 28px oklch(0.26 0.076 255 / 0.14), 0 4px 8px oklch(0.26 0.076 255 / 0.08);
  --shadow-xl: 0 24px 56px oklch(0.26 0.076 255 / 0.20);
  --shadow-focus: 0 0 0 3px oklch(0.711 0.159 231 / 0.45);

  /* ---- Movimento ---- */
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 120ms;
  --dur-base: 200ms;
  --dur-slow: 320ms;

  color-scheme: light;
}

/* ==========================================================================
   3. Somente modo claro — suporte a tema escuro removido intencionalmente
   (nem preferência do sistema, nem data-theme/classe explícita alteram os
   tokens acima; --background/--foreground etc. permanecem sempre os do
   modo claro definidos na seção 2).
   ========================================================================== */

/* ==========================================================================
   4. RESET / BASE — escopado em .cos-scope para não brigar com o Bootstrap
   --------------------------------------------------------------------------
   Aplique a classe `cos-scope` no <body> (ou num contêiner raiz) das telas
   novas. Assim os estilos base só valem onde você quer o novo padrão, sem
   afetar telas legadas que ainda dependem do Bootstrap/style.css antigo.
   ========================================================================== */
.cos-scope {
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.cos-scope *,
.cos-scope *::before,
.cos-scope *::after {
  box-sizing: border-box;
}
/* :where() zera a especificidade do seletor de tags — assim qualquer classe de
   componente (ex.: .cos-header-title) sempre pode sobrescrever a cor padrão do
   heading sem depender de ordem no arquivo ou de !important. */
.cos-scope :where(h2, h3, h4, h5, h6) {
  margin: 0;
}
/* :where() zera a especificidade aqui também — sem isso, este seletor
   (classe + tag) vence qualquer botão/link de componente de classe única
   (ex.: .cos-btn--accent, .card-link), fazendo o texto herdar a cor de link
   genérica em vez da cor do próprio componente. */
:where(.cos-scope a) {
  color: var(--accent);
  text-decoration: none;
}
:where(.cos-scope a):hover { color: var(--accent-hover); text-decoration: underline; }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--muted); }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover { background: var(--foreground-subtle); }

/* Suporte para Firefox e navegadores modernos */
html, body {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) var(--muted);
}

/* Container utilitário */
.cos-container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

/* Movimento reduzido (ui.md §12.3) */
@media (prefers-reduced-motion: reduce) {
  .cos-scope *,
  .cos-scope *::before,
  .cos-scope *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   5. TIPOGRAFIA UTILITÁRIA
   ========================================================================== */
.cos-kicker {
  font: var(--fw-bold) var(--text-3xs)/1 var(--font-display);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--accent);
}
.cos-title {
  font: var(--fw-extrabold) var(--text-2xl)/var(--leading-tight) var(--font-display);
  letter-spacing: var(--tracking-tight);
  color: var(--foreground-strong);
}
.cos-subtitle {
  font: var(--fw-bold) var(--text-lg)/var(--leading-tight) var(--font-display);
  color: var(--foreground-strong);
}
.cos-text-muted { color: var(--foreground-muted); }
.cos-mono { font-family: var(--font-mono); }

/* ==========================================================================
   6. BOTÕES
   ========================================================================== */
.cos-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 var(--space-5);
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard),
              border-color var(--dur-fast) var(--ease-standard),
              transform var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard);
  user-select: none;
}
.cos-btn:hover { text-decoration: none; }
.cos-btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.cos-btn:disabled,
.cos-btn.is-loading { opacity: 0.6; pointer-events: none; }
.cos-btn.is-loading { cursor: progress; }
.cos-btn--sm { height: 36px; font-size: var(--text-xs); padding: 0 var(--space-4); }
.cos-btn--block { width: 100%; }

/* Primária (navy) */
.cos-btn--primary {
  background: var(--primary);
  color: var(--primary-foreground);
}
.cos-btn--primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.cos-btn--primary:active { background: var(--primary-active); transform: translateY(0) scale(0.98); box-shadow: none; }

/* Acento (cyan — CTA vivo) */
.cos-btn--accent {
  background: var(--accent);
  color: var(--accent-foreground);
}
.cos-btn--accent:hover { background: var(--accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.cos-btn--accent:active { background: var(--accent-active); transform: translateY(0) scale(0.98); }

/* Secundária (outline) */
.cos-btn--secondary {
  background: transparent;
  color: var(--secondary-foreground);
  border-color: var(--primary);
}
.cos-btn--secondary:hover { background: var(--primary); color: var(--primary-foreground); }

/* Ghost */
.cos-btn--ghost {
  background: transparent;
  color: var(--foreground-muted);
}
.cos-btn--ghost:hover { background: var(--muted); color: var(--foreground-strong); }

/* Perigo */
.cos-btn--danger {
  background: var(--danger);
  color: var(--danger-foreground);
}
.cos-btn--danger:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: var(--shadow-md); }

/* ==========================================================================
   7. CAMPOS DE FORMULÁRIO
   ========================================================================== */
.cos-field { display: flex; flex-direction: column; gap: var(--space-2); }
.cos-label {
  font-family: var(--font-body);
  font-weight: var(--fw-semibold);
  font-size: var(--text-xs);
  color: var(--foreground-strong);
}
.cos-input,
.cos-select,
.cos-textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--foreground-strong);
  background: var(--card);
  border: 2px solid var(--input);
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color var(--dur-fast) var(--ease-standard),
              box-shadow var(--dur-fast) var(--ease-standard);
}
.cos-textarea { min-height: 96px; resize: vertical; }
.cos-input::placeholder,
.cos-textarea::placeholder { color: var(--foreground-subtle); }
.cos-input:focus,
.cos-select:focus,
.cos-textarea:focus {
  border-color: var(--ring);
  box-shadow: var(--shadow-focus);
}
.cos-input[aria-invalid="true"],
.cos-field.is-invalid .cos-input { border-color: var(--danger); }
.cos-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  cursor: pointer;
  padding-right: 38px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%236D6E71' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 16px;
}
.cos-hint { font-size: var(--text-2xs); color: var(--foreground-muted); }
.cos-error-text { font-size: var(--text-2xs); color: var(--danger); }

/* ==========================================================================
   8. CARTÕES E PAINÉIS
   ========================================================================== */
.cos-card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-sm);
}
.cos-card--interactive {
  transition: transform var(--dur-base) var(--ease-standard),
              box-shadow var(--dur-base) var(--ease-standard),
              border-color var(--dur-base) var(--ease-standard);
}
.cos-card--interactive:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}
.cos-panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Cabeçalho de seção com barra de acento */
.cos-section-header {
  border-left: 4px solid var(--accent);
  padding-left: var(--space-4);
  margin-bottom: var(--space-1);
}
.cos-section-title {
  font: var(--fw-extrabold) var(--text-xl)/1.2 var(--font-display);
  font-size: var(--text-2xl);
  text-transform: uppercase;
}
.cos-section-desc { margin-top: var(--space-2); font-size: var(--text-sm); color: var(--foreground-muted); }

/* ==========================================================================
   9. CABEÇALHO INSTITUCIONAL (hero navy)
   ========================================================================== */
.cos-header {
  background: linear-gradient(135deg, var(--navy-950) 0%, var(--navy-800) 55%, var(--navy-700) 100%);
  color: var(--foreground-on-brand);
  padding: var(--space-10) var(--space-6) var(--space-16);
}
.cos-header .cos-kicker { color: var(--cyan-300); }
.cos-header-title {
  /* fw-bold (700) porque é o único peso de AmpleSoft Pro embutido — ver seção 0 */
  font: var(--fw-bold) var(--text-3xl)/var(--leading-tight) var(--font-logo);
  text-transform: uppercase;
  letter-spacing: var(--tracking-tight);
  color: var(--foreground-on-brand);
}
.cos-header-desc {
  margin-top: var(--space-3);
  max-width: 640px;
  color: oklch(0.85 0.05 255);
  font-size: var(--text-base);
}

/* ==========================================================================
   10. BADGES E PILLS
   ========================================================================== */
.cos-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  font: var(--fw-bold) var(--text-3xs)/1.4 var(--font-display);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  border-radius: var(--radius-pill);
  background: var(--muted);
  color: var(--muted-foreground);
}
.cos-badge--success { background: var(--success-surface); color: var(--success); }
.cos-badge--warning { background: var(--warning-surface); color: var(--warning); }
.cos-badge--danger  { background: var(--danger-surface);  color: var(--danger); }
.cos-badge--info    { background: var(--info-surface);    color: var(--info); }

/* Placa (componente-assinatura, herdado do padrão validado) */
.cos-plate {
  display: inline-flex;
  flex-direction: column;
  border: 2px solid var(--navy-900);
  border-radius: 5px;
  overflow: hidden;
  background: var(--neutral-0);
  box-shadow: var(--shadow-sm);
}
.cos-plate-top {
  background: var(--navy-600);
  color: var(--neutral-0);
  font: var(--fw-bold) 7px/1 var(--font-display);
  letter-spacing: 0.22em;
  text-align: center;
  padding: 3px 0;
  text-transform: uppercase;
}
.cos-plate-value {
  font: var(--fw-bold) 18px/1 var(--font-mono);
  letter-spacing: 0.08em;
  padding: 5px 10px;
  text-align: center;
  color: var(--navy-950);
}

/* ==========================================================================
   11. TABS
   ========================================================================== */
.cos-tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); background: var(--muted); }
.cos-tab {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  font: var(--fw-bold) var(--text-sm)/1 var(--font-display);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--foreground-muted);
  background: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color var(--dur-fast), background var(--dur-fast), border-color var(--dur-fast);
}
.cos-tab:hover { color: var(--foreground-strong); }
.cos-tab.active {
  color: var(--foreground-strong);
  background: var(--card);
  border-bottom-color: var(--accent);
}

/* ==========================================================================
   12. TABELAS
   ========================================================================== */
.cos-table-wrap { overflow-x: auto; }
.cos-table { width: 100%; border-collapse: collapse; }
.cos-table th {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  font: var(--fw-bold) var(--text-3xs)/1 var(--font-display);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--foreground-muted);
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.cos-table td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-xs);
  color: var(--foreground);
  border-bottom: 1px solid var(--border);
}
.cos-table tbody tr { transition: background var(--dur-fast); }
.cos-table tbody tr:hover { background: var(--muted); }
.cos-table td.cos-mono { font-family: var(--font-mono); font-weight: var(--fw-bold); color: var(--foreground-strong); }

/* ==========================================================================
   13. KPIs
   ========================================================================== */
.cos-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
}
.cos-kpi {
  background: var(--card);
  border-top: 3px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.cos-kpi-label {
  font: var(--fw-bold) var(--text-3xs)/1.35 var(--font-display);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--foreground-muted);
}
.cos-kpi-value {
  font: var(--fw-extrabold) var(--text-2xl)/1 var(--font-display);
  color: var(--foreground-strong);
}

/* ==========================================================================
   14. MODAL / OVERLAY (inclui mutex visual — ui.md §9.2)
   ========================================================================== */
.cos-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: var(--overlay);
  backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-standard);
}
.cos-overlay.is-visible { opacity: 1; }
.cos-overlay[hidden] { display: none; }

.cos-modal {
  position: fixed;
  z-index: 201;
  top: 50%;
  left: 50%;
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  transform: translate(-50%, calc(-50% + 12px)) scale(0.985);
  opacity: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  transition: opacity var(--dur-base) var(--ease-standard),
              transform var(--dur-base) var(--ease-out);
}
.cos-modal.is-visible { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.cos-modal[hidden] { display: none; }
.cos-modal-header {
  padding: var(--space-5) var(--space-6);
  color: var(--foreground-on-brand);
  background: linear-gradient(135deg, var(--navy-900), var(--navy-800));
  border-bottom: 3px solid var(--accent);
}
.cos-modal-body { overflow-y: auto; padding: var(--space-6); }

/* ==========================================================================
   15. FEEDBACK / LOADING (implementa o guia do ui.md)
   ========================================================================== */

/* 15.1 Spinner (ui.md §2.3) — use dentro do botão para ações curtas */
.cos-spinner {
  display: inline-block;
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: cos-spin 0.7s linear infinite;
}
.cos-spinner--lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes cos-spin { to { transform: rotate(360deg); } }

/* 15.2 Skeleton (ui.md §2.2 / §13) — pulso suave, preserva altura */
.cos-skeleton {
  background: var(--muted);
  border-radius: var(--radius-md);
  animation: cos-pulse 1.5s var(--ease-standard) infinite;
}
.cos-skeleton--text { height: 0.9em; margin: 0.25em 0; }
.cos-skeleton--line { height: 1rem; }
.cos-skeleton--block { min-height: 120px; } /* evita layout shift */
@keyframes cos-pulse { 0%,100% { opacity: 0.55; } 50% { opacity: 1; } }

/* 15.3 Barra de progresso (ui.md §2.5) */
.cos-progress {
  width: 100%;
  height: 8px;
  background: var(--muted);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.cos-progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  border-radius: inherit;
  transition: width var(--dur-slow) var(--ease-out);
}
.cos-progress.is-indeterminate .cos-progress-bar {
  width: 40%;
  animation: cos-indeterminate 1.2s var(--ease-standard) infinite;
}
.cos-progress.is-error .cos-progress-bar { background: var(--danger); }
@keyframes cos-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}

/* 15.4 Ponto pulsante (status "ao vivo") */
.cos-pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: cos-pulse 2s var(--ease-standard) infinite;
}

/* 15.5 Banner de estado (erro/aviso/info/sucesso — ui.md §3 e §5.2) */
.cos-banner {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--fw-medium);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--info);
  background: var(--info-surface);
  color: var(--info);
}
.cos-banner--success { border-left-color: var(--success); background: var(--success-surface); color: var(--success); }
.cos-banner--warning { border-left-color: var(--warning); background: var(--warning-surface); color: var(--warning); }
.cos-banner--danger  { border-left-color: var(--danger);  background: var(--danger-surface);  color: var(--danger); }

/* 15.6 Toast (ui.md §3.1 / §10) */
.cos-toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}
.cos-toast--success { border-left-color: var(--success); }
.cos-toast--danger  { border-left-color: var(--danger); }

/* 15.7 Estado vazio (ui.md §4) — sempre com ação de saída */
.cos-empty {
  text-align: center;
  padding: var(--space-12) var(--space-6);
  color: var(--foreground-muted);
  background: var(--card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

/* 15.8 Realce de item novo (ui.md §10.2) */
.cos-highlight-new { animation: cos-highlight 1s var(--ease-out); }
@keyframes cos-highlight {
  0% { background: var(--info-surface); }
  100% { background: transparent; }
}

/* ==========================================================================
   16. UTILITÁRIOS DE ACESSIBILIDADE
   ========================================================================== */
.cos-visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
[aria-busy="true"] { cursor: progress; }
