/* ==========================================================================
   Cerne — Design System CSS
   Baseado em 02_UX/design_system.md
   ========================================================================== */

/* Fonte Inter servida pelo próprio Cerne (public/css/fontes.css), sem requisição ao Google Fonts:
   evita enviar o IP do usuário a terceiros (LGPD) e mantém a CSP restrita a 'self'. */

:root {
  /* Cores primárias */
  --color-primary: #1E3A5F;
  --color-primary-medium: #2E5C9E;
  --color-primary-light: #EBF2FF;

  /* Status */
  --color-success: #1A7F4B;
  --color-success-bg: #E6F7EF;
  --color-warning: #B45309;
  --color-warning-bg: #FEF3C7;
  --color-danger: #C0392B;
  --color-danger-bg: #FEE2E2;
  --color-neutral-status: #6B7280;
  --color-neutral-status-bg: #F3F4F6;
  --color-info: #1D6FA4;
  --color-info-bg: #DBEAFE;

  /* Neutras */
  --color-white: #FFFFFF;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-600: #4B5563;
  --gray-900: #111827;

  /* Sidebar */
  --sidebar-bg: #1E3A5F;
  --sidebar-text: #CBD5E1;
  --sidebar-active-bg: #2E5C9E;
  --sidebar-active-text: #FFFFFF;
  --sidebar-hover-bg: #27487A;

  /* Espaçamento */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Sombras */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);

  /* Campos do sistema, exceto login: ajuste estes tokens para mudar todos. */
  --field-height: 44px;
  --field-radius: 10px;
  --field-border: #C7D2DF;
  --field-shadow: 0 1px 3px rgba(30,58,95,0.09);
  --field-font-size: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--gray-900);
  background: var(--gray-50);
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--color-primary-medium); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0; }

.h-display { font-size: 28px; font-weight: 700; line-height: 1.2; }
.h1 { font-size: 24px; font-weight: 700; line-height: 1.3; }
.h2 { font-size: 20px; font-weight: 600; line-height: 1.3; }
.h3 { font-size: 16px; font-weight: 600; line-height: 1.4; }
.text-body-lg { font-size: 16px; }
.text-body { font-size: 14px; }
.text-body-sm { font-size: 13px; }
.text-label { font-size: 12px; font-weight: 500; }
.text-micro { font-size: 11px; }

.text-secondary { color: var(--gray-600); }
.text-disabled { color: var(--gray-400); }
.text-danger { color: var(--color-danger); }
.text-link { color: var(--color-primary-medium); cursor: pointer; }

/* Focus visível (acessibilidade) */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--color-primary-light);
  border-color: var(--color-primary-medium);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: auto;
}
.skip-link:focus {
  left: 8px;
  top: 8px;
  background: var(--color-white);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  z-index: 1000;
}

/* ==========================================================================
   Botões
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: background-color 150ms ease-in-out, opacity 150ms ease-in-out;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--color-primary); color: var(--color-white); }
.btn-primary:hover:not(:disabled) { background: #16304f; }
.btn-primary:active:not(:disabled) { background: #102640; }

.btn-secondary { background: var(--color-white); color: var(--color-primary); border: 1px solid var(--gray-200); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); }

.btn-danger { background: var(--color-danger); color: var(--color-white); }
.btn-danger:hover:not(:disabled) { background: #a5301f; }

.btn-ghost { background: transparent; color: var(--color-primary-medium); padding: 0; height: auto; }
.btn-ghost:hover:not(:disabled) { text-decoration: underline; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--gray-600);
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  line-height: 1;
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-900); }

.btn-lg { height: 48px; padding: 0 24px; font-size: 16px; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }

.btn svg { width: 18px; height: 18px; }

/* ==========================================================================
   Formulários
   ========================================================================== */

.field { margin-bottom: var(--space-5); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }

.field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-600);
  margin-bottom: var(--space-1);
}
.field label .required { color: var(--color-danger); }

.input, select.input, textarea.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--color-white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  transition: border-color 150ms, box-shadow 150ms;
}
.input::placeholder { color: var(--gray-400); }
.input:focus {
  outline: none;
  border-color: var(--color-primary-medium);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}
.input.error { border-color: var(--color-danger); }
.input:disabled { background: var(--gray-100); color: var(--gray-400); cursor: not-allowed; }

textarea.input { height: auto; min-height: 80px; padding: 10px 12px; resize: vertical; }

.field-error {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--color-danger);
}
.field-hint {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--gray-400);
}

select.input { appearance: none; 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='%234B5563' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

/* Campos com ou sem classe .input usam o mesmo estilo, exceto no login. */
:is(.app-shell, .auth-pagina:not(.auth-login)) :where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]), select, textarea) {
  width: 100%;
  min-width: 0;
  height: var(--field-height);
  padding: 0 14px;
  font: 400 var(--field-font-size)/1.5 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--gray-900);
  background: var(--color-white);
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  box-shadow: var(--field-shadow);
  transition: border-color 150ms, box-shadow 150ms, background-color 150ms;
}
:is(.app-shell, .auth-pagina:not(.auth-login)) :where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]), select, textarea):hover:not(:disabled) {
  border-color: var(--gray-400);
}
:is(.app-shell, .auth-pagina:not(.auth-login)) :where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]), select, textarea):focus {
  outline: none;
  border-color: var(--color-primary-medium);
  box-shadow: var(--field-shadow), 0 0 0 3px var(--color-primary-light);
}
:is(.app-shell, .auth-pagina:not(.auth-login)) :where(input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="color"]):not([type="button"]):not([type="submit"]):not([type="reset"]), select, textarea):disabled {
  background: var(--gray-100);
  color: var(--gray-600);
  cursor: not-allowed;
}
:is(.app-shell, .auth-pagina:not(.auth-login)) :where(input, textarea)::placeholder { color: var(--gray-400); }
:is(.app-shell, .auth-pagina:not(.auth-login)) textarea { height: auto; min-height: 96px; padding: 11px 14px; resize: vertical; }
:is(.app-shell, .auth-pagina:not(.auth-login)) select {
  appearance: none;
  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='%234B5563' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
:is(.app-shell, .auth-pagina:not(.auth-login)) input[type="color"] {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--field-border);
  border-radius: var(--field-radius);
  box-shadow: var(--field-shadow);
  background: var(--color-white);
  cursor: pointer;
}
:is(.app-shell, .auth-pagina:not(.auth-login)) :is(input[type="checkbox"], input[type="radio"]) { accent-color: var(--color-primary-medium); }

.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--color-primary); }

.toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background-color: var(--gray-200);
  border-radius: var(--radius-full);
  transition: background-color 150ms;
}
.toggle-slider::before {
  content: ""; position: absolute; width: 16px; height: 16px;
  left: 2px; bottom: 2px; background: white; border-radius: 50%;
  transition: transform 150ms;
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-slider { background-color: var(--color-success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

.field-group-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: var(--space-5);
  margin-top: var(--space-8);
}
.field-group-title:first-child { margin-top: 0; }

/* ==========================================================================
   Tabelas
   ========================================================================== */

.table-wrap { background: var(--color-white); border: 1px solid var(--gray-200); border-radius: var(--radius-md); overflow: hidden; }
table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--gray-600);
  background: var(--gray-50);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-200);
}
table.data-table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--gray-200);
  font-size: 14px;
  vertical-align: middle;
}
table.data-table tbody tr { cursor: pointer; transition: background-color 100ms; }
table.data-table tbody tr:hover { background: var(--gray-50); }
table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table .row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.pagination { display: flex; align-items: center; justify-content: space-between; padding: var(--space-4); }
.pagination-pages { display: flex; gap: 4px; }
.pagination-pages button {
  width: 32px; height: 32px; border-radius: var(--radius-sm); border: none;
  background: transparent; color: var(--gray-600); cursor: pointer; font-size: 13px;
}
.pagination-pages button.active { background: var(--color-primary); color: white; }
.pagination-info { font-size: 13px; color: var(--gray-600); }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--color-white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
}
.card.clickable { cursor: pointer; transition: box-shadow 150ms; }
.card.clickable:hover { box-shadow: var(--shadow-md); }

.card-title {
  font-size: 12px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-card { text-align: left; }
.stat-card .stat-number { font-size: 32px; font-weight: 700; color: var(--color-primary); line-height: 1.1; }
.stat-card .stat-label { font-size: 13px; color: var(--gray-600); margin-top: 4px; }

.finance-card { text-align: left; border-radius: var(--radius-md); padding: var(--space-4); }
.finance-card.success { background: var(--color-success-bg); }
.finance-card.danger { background: var(--color-danger-bg); }
.finance-card.neutral { background: var(--gray-100); }
.finance-card .finance-label { font-size: 12px; text-transform: uppercase; font-weight: 600; opacity: 0.8; }
.finance-card .finance-value { font-size: 24px; font-weight: 700; margin-top: 6px; }
.finance-card.success .finance-value, .finance-card.success .finance-label { color: var(--color-success); }
.finance-card.danger .finance-value, .finance-card.danger .finance-label { color: var(--color-danger); }
.finance-card.neutral .finance-value, .finance-card.neutral .finance-label { color: var(--gray-900); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--space-4); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-4); }

@media (max-width: 900px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Badges
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-danger  { background: var(--color-danger-bg);  color: var(--color-danger); }
.badge-neutral { background: var(--color-neutral-status-bg); color: var(--color-neutral-status); }
.badge-info    { background: var(--color-info-bg);    color: var(--color-info); }

/* ==========================================================================
   Layout: Shell (Sidebar + Header)
   ========================================================================== */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  transition: width 200ms ease-in-out;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
}
.sidebar.collapsed { width: 64px; }
.sidebar.collapsed ~ .main-area { margin-left: 64px; }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .user-info-text { display: none; }

.sidebar-brand {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 var(--space-4);
  color: var(--color-white);
  font-weight: 700;
  font-size: 16px;
  border-bottom: 1px solid var(--sidebar-hover-bg);
  flex-shrink: 0;
}
.sidebar-brand .brand-icon {
  width: 28px; height: 28px; background: var(--color-white); color: var(--color-primary);
  border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.sidebar-logo {
  height: 110px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}
/* Logo completo (aberta) x ícone "C" (recolhida) */
.sidebar-logo-icon { display: none; }
.sidebar.collapsed .sidebar-logo-full { display: none; }
.sidebar.collapsed .sidebar-logo-icon {
  display: block;
  height: 32px;
  width: auto;
  max-width: 100%;
  object-fit: contain;
  margin: 0 auto;
}

.sidebar-nav { flex: 1; padding: var(--space-3) var(--space-2); overflow-y: auto; }
.sidebar-nav .nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-md);
  color: var(--sidebar-text);
  font-size: 14px;
  cursor: pointer;
  margin-bottom: 4px;
  border-left: 3px solid transparent;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-nav .nav-item:hover { background: var(--sidebar-hover-bg); color: var(--color-white); }
.sidebar-nav .nav-item.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); border-left-color: var(--color-white); }
.sidebar-nav .nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.sidebar-divider { height: 1px; background: var(--sidebar-hover-bg); margin: var(--space-2) 8px; }

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid var(--sidebar-hover-bg);
  flex-shrink: 0;
}
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius-md); cursor: pointer; text-decoration: none; }
.sidebar-user:hover { background: var(--sidebar-hover-bg); text-decoration: none; }
.sidebar-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--color-primary-medium);
  color: white; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.sidebar-avatar-img { object-fit: cover; }
.user-info-text { overflow: hidden; }
.user-info-text .user-name { color: var(--color-white); font-size: 13px; font-weight: 500; white-space: nowrap; }
.user-info-text .user-role { color: var(--sidebar-text); font-size: 11px; white-space: nowrap; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; margin-left: 240px; }

.app-header {
  height: 64px;
  background: var(--color-white);
  border-bottom: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-search { position: relative; flex: 1; max-width: 480px; }
.app-shell .header-search input {
  width: 100%; height: 40px; padding: 0 12px 0 38px; background: var(--gray-50);
}
.app-shell .header-search input:focus { background: white; }
.header-search svg.search-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--gray-400); }

.header-actions { display: flex; align-items: center; gap: var(--space-3); margin-left: auto; }
.header-icon-btn { position: relative; }
.notif-badge {
  position: absolute; top: -2px; right: -2px; background: var(--color-danger); color: white;
  font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

.page-content { flex: 1; padding: var(--space-8); max-width: 1200px; margin: 0 auto; width: 100%; }

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-6); }
.page-header .page-actions { display: flex; gap: var(--space-2); }

.breadcrumb { font-size: 13px; color: var(--gray-600); margin-bottom: var(--space-4); }
.breadcrumb a { color: var(--color-primary-medium); }
.breadcrumb .sep { color: var(--gray-400); margin: 0 6px; }
.breadcrumb .current { color: var(--gray-900); font-weight: 500; }

.toolbar { display: flex; gap: var(--space-3); margin-bottom: var(--space-5); flex-wrap: wrap; align-items: center; }
.toolbar .input, .toolbar select.input { width: auto; }
.toolbar .search-box { flex: 1; min-width: 240px; position: relative; }
.toolbar .search-box input { padding-left: 36px; }
.toolbar .search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--gray-400); }

@media (max-width: 900px) {
  .main-area, .sidebar.collapsed ~ .main-area { margin-left: 0; width: 100%; }
  .sidebar, .sidebar.collapsed { width: min(280px, calc(100vw - 48px)); z-index: 202; height: 100dvh; left: 0; transform: translateX(-100%); transition: transform 200ms ease-in-out; }
  .sidebar.mobile-open { transform: translateX(0); }
  .sidebar.collapsed .sidebar-label, .sidebar.collapsed .user-info-text { display: initial; }
  .sidebar.collapsed .sidebar-logo-full { display: block; }
  .sidebar.collapsed .sidebar-logo-icon { display: none; }
  .page-content { padding: var(--space-4); }
}

/* ==========================================================================
   Abas internas
   ========================================================================== */

.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--gray-200); margin-bottom: var(--space-6); overflow-x: auto; }
.tabs .tab {
  padding: var(--space-3) var(--space-4);
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-600);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  background: none; border: none; border-bottom: 2px solid transparent;
  font-family: inherit;
}
.tabs .tab:hover { color: var(--gray-900); }
.tabs .tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* ==========================================================================
   Modais
   ========================================================================== */

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: var(--space-4);
  animation: fadeIn 200ms ease-out;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: var(--color-white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  width: 480px; max-width: 100%; max-height: 85vh; overflow-y: auto;
  animation: scaleIn 200ms ease-out;
}
.modal-box.wide { width: 560px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--gray-200);
}
.modal-body { padding: var(--space-6); }
.modal-footer {
  display: flex; justify-content: flex-end; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--gray-200);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

.modal-alert-icon { font-size: 20px; }

/* ==========================================================================
   Toasts
   ========================================================================== */

.toast-container { position: fixed; top: 24px; right: 24px; z-index: 900; display: flex; flex-direction: column; gap: 10px; }
.toast {
  width: 360px; background: var(--color-white); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); padding: 12px 16px; display: flex; gap: 10px; align-items: flex-start;
  border-left: 4px solid var(--gray-400);
  animation: slideIn 250ms ease-out;
  font-size: 14px;
}
.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-danger); }
.toast.info { border-left-color: var(--color-info); }
.toast.warning { border-left-color: var(--color-warning); }
.toast.fade-out { animation: fadeOutToast 300ms ease-in forwards; }

@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOutToast { to { opacity: 0; } }

/* Skeleton */
.skeleton { background: var(--gray-200); border-radius: var(--radius-sm); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* Estado vazio */
.empty-state { text-align: center; padding: var(--space-12) var(--space-6); color: var(--gray-600); }
.empty-state .empty-icon { font-size: 40px; margin-bottom: var(--space-3); opacity: 0.5; }
.empty-state .empty-title { font-size: 16px; font-weight: 600; color: var(--gray-900); margin-bottom: 6px; }
.empty-state .empty-desc { font-size: 14px; margin-bottom: var(--space-5); }

/* Notification list dropdown */
.notif-panel {
  position: absolute; top: 56px; right: 0; width: 340px; background: white;
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); border: 1px solid var(--gray-200);
  z-index: 300; max-height: 400px; overflow-y: auto;
}
.notif-panel.hidden { display: none; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); font-size: 13px; }
.notif-item:last-child { border-bottom: none; }
.notif-item .notif-title { font-weight: 500; color: var(--gray-900); }
.notif-item .notif-time { color: var(--gray-400); font-size: 11px; margin-top: 2px; }

.user-dropdown {
  position: absolute; top: 56px; right: 0; width: 200px; background: white;
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); border: 1px solid var(--gray-200);
  z-index: 300; overflow: hidden;
}
.user-dropdown.hidden { display: none; }
.user-dropdown a, .user-dropdown button {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 10px 16px; font-size: 14px;
  color: var(--gray-900); background: none; border: none; cursor: pointer; font-family: inherit;
}
.user-dropdown a:hover, .user-dropdown button:hover { background: var(--gray-50); text-decoration: none; }
.user-dropdown a svg, .user-dropdown button svg { width: 16px; height: 16px; flex-shrink: 0; }

/* Autocomplete busca global */
.search-dropdown {
  position: absolute; top: 46px; left: 0; width: 100%; background: white;
  border-radius: var(--radius-md); box-shadow: var(--shadow-lg); border: 1px solid var(--gray-200);
  z-index: 300; max-height: 420px; overflow-y: auto; text-align: left;
}
.search-dropdown.hidden { display: none; }
.search-group-title { padding: 8px 14px 4px; font-size: 11px; text-transform: uppercase; font-weight: 600; color: var(--gray-400); }
.search-result-item { display: flex; flex-direction: column; padding: 8px 14px; cursor: pointer; }
.search-result-item:hover { background: var(--gray-50); }
.search-result-item .sr-title { font-size: 14px; color: var(--gray-900); }
.search-result-item .sr-sub { font-size: 12px; color: var(--gray-600); }
.search-empty { padding: 16px; text-align: center; color: var(--gray-400); font-size: 13px; }

/* ==========================================================================
   Páginas Públicas (Login, Recuperar Senha, etc.)
   ========================================================================== */

.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: var(--space-8);
  background: var(--color-primary);
  background: linear-gradient(160deg, #1E3A5F 0%, #14273f 100%);
  padding-left: var(--space-4);
  padding-right: var(--space-4);
  padding-bottom: var(--space-4);
}
.auth-brand { color: white; text-align: center; }
.auth-brand .brand-icon-lg {
  width: 56px; height: 56px; background: white; color: var(--color-primary); border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 22px;
}
.auth-brand h1 { font-size: 24px; font-weight: 700; }
.auth-brand p { font-size: 14px; color: #CBD5E1; margin-top: 4px; }
.auth-logo {
  height: 150px;
  width: auto;
  object-fit: contain;
}

.auth-card {
  background: var(--color-white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8);
  width: 400px;
  max-width: 100%;
}
.auth-card h2 { font-size: 18px; font-weight: 700; margin-bottom: var(--space-2); }
.auth-card .auth-desc { font-size: 13px; color: var(--gray-600); margin-bottom: var(--space-6); }
.auth-card .auth-footer { text-align: center; margin-top: var(--space-5); font-size: 13px; }
.auth-copy { color: #94A3B8; font-size: 12px; margin-top: var(--space-8); }

.auth-alert {
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; margin-bottom: var(--space-5);
  display: flex; gap: 8px; align-items: flex-start;
}
.auth-alert.error { background: var(--color-danger-bg); color: var(--color-danger); }
.auth-alert.warning { background: var(--color-warning-bg); color: var(--color-warning); }
.auth-alert.success { background: var(--color-success-bg); color: var(--color-success); }
.auth-alert.info { background: var(--color-info-bg); color: var(--color-info); }
.auth-alert.hidden { display: none; }

/* Utilitários */
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; } .mt-5 { margin-top: 20px; } .mt-6 { margin-top: 24px; } .mt-8 { margin-top: 32px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; } .mb-5 { margin-bottom: 20px; } .mb-6 { margin-bottom: 24px; }
.flex { display: flex; } .flex-col { flex-direction: column; } .items-center { align-items: center; }
.justify-between { justify-content: space-between; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; }
.hidden { display: none !important; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.icon-inline { width: 16px; height: 16px; vertical-align: middle; }

/* ==========================================================================
   Loading / Feedback de performance percebida
   (Classes utilitárias novas — não altera tokens, cores ou tema existentes)
   ========================================================================== */

/* Spinner (círculo girando) */
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: var(--radius-full);
  animation: spin 700ms linear infinite;
  vertical-align: middle;
  flex-shrink: 0;
}
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }

/* Overlay de tela cheia com fundo fosco (usado no login) */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 150ms ease-out;
}
.loading-overlay .spinner { color: var(--color-white); }
.loading-overlay.hidden { display: none; }
.loading-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  max-width: 320px;
  padding: 24px;
  color: var(--color-white);
  text-align: center;
}

/* Barra de progresso fina no topo (estilo GitHub/YouTube) */
.top-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-primary-medium) 100%);
  box-shadow: 0 0 6px rgba(46, 92, 158, 0.5);
  z-index: 1100;
  opacity: 1;
  transition: width 300ms ease, opacity 200ms ease;
}
.top-progress.done { opacity: 0; }

/* Skeleton genérico da área de conteúdo (reutiliza .skeleton + @keyframes pulse) */
.skeleton-page { padding: var(--space-2) 0; }
.skeleton-title { height: 28px; width: 40%; margin-bottom: var(--space-6); }
.skeleton-toolbar { height: 40px; width: 60%; margin-bottom: var(--space-6); }
.skeleton-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.skeleton-card { height: 140px; }
.skeleton-block { height: 220px; }

@media (max-width: 900px) {
  .skeleton-cards { grid-template-columns: 1fr; }
}

/* Texto apenas para leitores de tela */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Acessibilidade: respeitar movimento reduzido */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .top-progress { transition: opacity 100ms ease; }
  .skeleton { animation: none; }
  .loading-overlay { animation: none; }
}
