/* =============================================
   InfoBancos — Design System (Light Theme)
   ============================================= */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ---- CSS Custom Properties ---- */
:root {
  /* Colors */
  --color-bg: #f5f7fa;
  --color-bg-alt: #edf0f5;
  --color-surface: #ffffff;
  --color-surface-hover: #f8fafc;
  --color-primary: #0d6efd;
  --color-primary-dark: #0a58ca;
  --color-primary-light: #e7f1ff;
  --color-secondary: #198754;
  --color-secondary-light: #d1e7dd;
  --color-accent: #6f42c1;
  --color-danger: #dc3545;
  --color-danger-light: #f8d7da;
  --color-warning: #ffc107;
  --color-warning-light: #fff3cd;
  --color-text: #1a1a2e;
  --color-text-secondary: #5a6070;
  --color-text-muted: #8b92a5;
  --color-border: #dee2e8;
  --color-border-light: #eef1f6;

  /* Typography */
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.5rem;

  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Borders */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 50px rgba(0, 0, 0, 0.12);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;

  /* Layout */
  --max-width: 1200px;
  --navbar-height: 64px;
}

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
}

img {
  max-width: 100%;
  height: auto;
}

/* ---- Navbar ---- */
.navbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  height: var(--navbar-height);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.navbar-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-weight: 800;
  font-size: var(--font-size-xl);
  color: var(--color-text);
  text-decoration: none;
  letter-spacing: -0.5px;
}

.navbar-brand:hover {
  color: var(--color-primary);
}

.navbar-brand .brand-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  list-style: none;
}

.navbar-links a {
  color: var(--color-text-secondary);
  font-weight: 500;
  font-size: var(--font-size-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}

.navbar-links a:hover,
.navbar-links a.active {
  color: var(--color-primary);
  background: var(--color-primary-light);
}

.navbar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: var(--font-size-xl);
  color: var(--color-text);
  cursor: pointer;
  padding: var(--space-sm);
}

/* ---- Hero ---- */
.hero {
  background: linear-gradient(135deg, #0d6efd 0%, #0a58ca 50%, #084298 100%);
  color: white;
  padding: var(--space-3xl) var(--space-lg);
  text-align: center;
  position: relative;
  z-index: 10;
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.5;
}

.hero-content {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
}

.hero h1 {
  font-size: var(--font-size-4xl);
  font-weight: 800;
  margin-bottom: var(--space-md);
  letter-spacing: -1px;
  line-height: 1.2;
}

.hero p {
  font-size: var(--font-size-lg);
  opacity: 0.9;
  margin-bottom: var(--space-xl);
  max-width: 550px;
  margin-left: auto;
  margin-right: auto;
}

/* ---- Search ---- */
.search-container {
  position: relative;
  max-width: 520px;
  margin: 0 auto;
}

.search-input {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  padding-left: 48px;
  font-size: var(--font-size-base);
  font-family: var(--font-family);
  border: 2px solid transparent;
  border-radius: var(--radius-full);
  background: white;
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
  transition: all var(--transition-base);
  outline: none;
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

.search-input:focus {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-xl), 0 0 0 4px rgba(13, 110, 253, 0.15);
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  font-size: var(--font-size-lg);
  pointer-events: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 320px;
  overflow-y: auto;
  display: none;
  z-index: 50;
}

.search-results.active {
  display: block;
  animation: slideDown 0.2s ease;
}

.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--color-border-light);
  text-decoration: none;
  color: var(--color-text);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: var(--color-primary-light);
  color: var(--color-text);
}

.search-result-item .result-name {
  flex: 0 1 auto;
  min-width: 0;
  font-weight: 600;
  font-size: var(--font-size-sm);
  overflow-wrap: anywhere;
}

.search-result-item .result-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex: 0 0 auto;
  margin-left: auto;
}

.search-result-item .result-type {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  background: var(--color-bg);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  text-align: center;
  line-height: 1.3;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-full);
  padding: 2px 8px;
  font-size: var(--font-size-xs);
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
  vertical-align: middle;
}

.status-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex: 0 0 auto;
}

.status-badge-compact {
  padding: 2px 7px;
  font-size: 0.6875rem;
}

.status-badge.status-active {
  color: var(--color-secondary);
  background: var(--color-secondary-light);
}

.status-badge.status-inactive {
  color: var(--color-danger);
  background: var(--color-danger-light);
}

.status-badge.status-liquidation {
  color: #9a650f;
  background: var(--color-warning-light);
}

.status-badge.status-unknown {
  color: var(--color-text-secondary);
  background: var(--color-bg-alt);
}

/* ---- Container ---- */
.container {
  max-width: var(--max-width);
  width: 100%;
  margin: 0 auto;
  padding: var(--space-xl) var(--space-lg);
  box-sizing: border-box;
}

/* ---- Section ---- */
.section-title {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-lg);
  letter-spacing: -0.5px;
}

.section-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-top: calc(-1 * var(--space-md));
  margin-bottom: var(--space-xl);
}

/* ---- Cards Grid ---- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-lg);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  transition: all var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  color: var(--color-text);
  display: block;
}

.card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  color: var(--color-text);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: var(--space-md);
}

.card-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.card-badge {
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  background: var(--color-primary-light);
  color: var(--color-primary);
  white-space: nowrap;
}

.card-badge.green {
  background: var(--color-secondary-light);
  color: var(--color-secondary);
}

.card-badge.red {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.card-metric {
  margin-bottom: var(--space-sm);
}

.card-metric-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.card-metric-value {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.card-footer {
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border-light);
}

.card-footer-item {
  text-align: center;
  flex: 1;
}

.card-footer-item .label {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  display: block;
}

.card-footer-item .value {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
}

/* ---- Quick Links ---- */
.quick-links {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

.quick-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--color-text);
  transition: all var(--transition-base);
}

.quick-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
  color: var(--color-text);
}

.quick-link .ql-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xl);
  flex-shrink: 0;
}

.quick-link .ql-icon.blue {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.quick-link .ql-icon.green {
  background: var(--color-secondary-light);
  color: var(--color-secondary);
}

.quick-link .ql-icon.purple {
  background: #f3e8ff;
  color: var(--color-accent);
}

.quick-link .ql-text h3 {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: 2px;
}

.quick-link .ql-text p {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
}

/* ---- Table ---- */
.table-wrapper {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow-x: auto;
  max-width: 100%;
  box-sizing: border-box;
  box-shadow: var(--shadow-sm);
}

.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
}

.table-wrapper td {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-sm);
  border-bottom: 1px solid var(--color-border-light);
  /* Permitir quebra de texto nas colunas maiores para caber na tela */
  white-space: normal;
  vertical-align: middle;
}

.table-wrapper th {
  background: var(--color-bg);
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--color-border);
}

.table-wrapper tr:last-child td {
  border-bottom: none;
}

.table-wrapper tr:hover td {
  background: var(--color-surface-hover);
}

.table-wrapper .text-right {
  text-align: right;
  white-space: nowrap;
}

.table-wrapper .text-center {
  text-align: center;
  white-space: nowrap;
}

/* Permitir quebra no mobile para os nomes das instituições */
@media (max-width: 768px) {
  .table-wrapper td,
  .table-wrapper th {
    padding: var(--space-sm) var(--space-sm);
    font-size: var(--font-size-xs);
  }
}

.table-wrapper .font-bold {
  font-weight: 600;
}

.table-wrapper .text-positive {
  color: var(--color-secondary);
  font-weight: 600;
}

.table-wrapper .text-negative {
  color: var(--color-danger);
  font-weight: 600;
}

.table-wrapper .text-neutral {
  color: var(--color-text-muted);
  font-weight: 600;
}

/* ---- Histórico expandível (tabela de balanços com muitos trimestres) ---- */
.table-wrapper .history-hidden-row {
  display: none;
}

.table-wrapper .history-expanded .history-hidden-row {
  display: table-row;
}

.history-toggle-btn {
  display: block;
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg);
  border: none;
  border-top: 1px solid var(--color-border-light);
  color: var(--color-primary);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
}

.history-toggle-btn:hover {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.history-toggle-btn.expanded {
  border-top: 1px solid var(--color-border);
}

.table-wrapper .rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  font-weight: 700;
  font-size: var(--font-size-xs);
}

.rank-badge.gold {
  background: #fef3c7;
  color: #92400e;
}

.rank-badge.silver {
  background: #e5e7eb;
  color: #4b5563;
}

.rank-badge.bronze {
  background: #fed7aa;
  color: #9a3412;
}

.rank-badge.normal {
  background: var(--color-bg);
  color: var(--color-text-muted);
}

.ranking-name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ranking-name-cell a {
  white-space: normal;
}

/* ---- Tabs ---- */
.tabs {
  display: flex;
  flex-wrap: wrap;
  /* Envolve as abas sem precisar de scroll na maioria das telas */
  gap: var(--space-xs);
  margin-bottom: var(--space-xl);
  border-bottom: 2px solid var(--color-border);
  padding-bottom: 0;
  /* Removed overflow-x: auto; to prevent ugly scrollbars */
}

.tab-btn {
  padding: var(--space-md) var(--space-lg);
  font-size: var(--font-size-sm);
  font-weight: 600;
  font-family: var(--font-family);
  color: var(--color-text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: var(--color-primary);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* ---- Charts ---- */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: var(--space-lg);
  margin-top: var(--space-xl);
}

.chart-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.chart-card h3 {
  font-size: var(--font-size-base);
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.chart-container {
  position: relative;
  width: 100%;
  height: 280px;
}

/* ---- Institution Header ---- */
.inst-header {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-xl) var(--space-lg);
}

.inst-header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-xl);
  flex-wrap: wrap;
}

.inst-avatar {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: var(--font-size-2xl);
  font-weight: 800;
  flex-shrink: 0;
}

/* ---- Institution Logo (inline, for cards and rankings) ---- */

.inst-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  vertical-align: middle;
}

.inst-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.inst-logo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
  color: white;
  font-weight: 800;
  border-radius: var(--radius-sm);
  line-height: 1;
}

/* Institution page: logo in existing avatar container */
.inst-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.inst-avatar-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

/* When avatar has a working logo img, switch to white bg */
.inst-avatar.has-logo {
  background: #fff;
}

.inst-info {
  min-width: 0;
}

.inst-info h1 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  letter-spacing: -0.5px;
  line-height: 1.3;
  word-wrap: break-word;
}

.inst-meta {
  display: flex;
  gap: var(--space-lg);
  margin-top: var(--space-xs);
  flex-wrap: wrap;
}

.inst-meta span {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.inst-meta span strong {
  color: var(--color-text-secondary);
}

.inst-meta .status-badge {
  font-size: var(--font-size-xs);
}

/* ---- Summary Cards ---- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}

.summary-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  text-align: center;
  min-width: 0;
}

.summary-card .sc-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.summary-card .sc-label.no-wrap {
  white-space: normal;
}

.summary-card .sc-value {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--color-text);
  word-break: break-word;
}

.summary-card.with-risk {
  position: relative;
  overflow: visible;
  z-index: 1;
}

.summary-card.with-risk:hover,
.summary-card.with-risk:focus-within {
  z-index: 10;
}

.summary-card.with-risk .sc-value-line {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  max-width: 100%;
  line-height: 1.25;
}

.summary-card .sc-value.positive {
  color: var(--color-secondary);
}

.summary-card .sc-value.negative {
  color: var(--color-danger);
}

.summary-card .sc-value.neutral {
  color: var(--color-text-muted);
}

.risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: var(--radius-full);
  padding: 2px 7px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.35;
  white-space: nowrap;
  cursor: help;
  position: relative;
  transform: translateY(1px);
}

.risk-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
  flex: 0 0 auto;
}

.risk-badge.good {
  color: var(--color-secondary);
  background: var(--color-secondary-light);
}

.risk-badge.warn {
  color: #9a650f;
  background: var(--color-warning-light);
}

.risk-badge.bad {
  color: var(--color-danger);
  background: var(--color-danger-light);
}

.risk-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: min(260px, 80vw);
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--color-text);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  text-align: left;
  white-space: normal;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

.risk-badge:hover .risk-tooltip,
.risk-badge:focus .risk-tooltip {
  opacity: 1;
  transform: translate(-50%, 0);
}

.risk-meter {
  position: absolute;
  left: var(--space-lg);
  right: var(--space-lg);
  bottom: 9px;
  height: 6px;
  border-radius: var(--radius-full);
  background: #e3e8ef;
  overflow: visible;
}

.risk-meter::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -8px;
  bottom: -8px;
}

.risk-meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--risk-meter-value);
  border-radius: var(--radius-full);
  background: var(--color-secondary);
  z-index: 1;
}

.risk-warn .risk-meter-fill {
  background: #d99022;
}

.risk-bad .risk-meter-fill {
  background: var(--color-danger);
}

.risk-meter-ref {
  position: absolute;
  left: var(--risk-meter-ref);
  top: 50%;
  width: 0;
  height: 0;
  transform: translate(-50%, -50%);
  --risk-ref-color: var(--color-text);
  opacity: 1;
  z-index: 2;
}

.risk-meter-ref.minimum {
  --risk-ref-color: #b84230;
}

.risk-meter-ref.adequate {
  --risk-ref-color: #9a650f;
}

.risk-meter-ref.warning {
  --risk-ref-color: #9a650f;
}

.risk-meter-ref.limit {
  --risk-ref-color: #b84230;
}

.risk-meter-ref::before {
  content: "";
  position: absolute;
  left: 0;
  top: -7px;
  width: 3px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: var(--radius-full);
  background: var(--risk-ref-color, var(--color-text));
  box-shadow: 0 0 0 1px #fff;
}

.risk-meter-ref::after {
  content: "";
  position: absolute;
  left: 0;
  top: -11px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  transform: translateX(-50%);
  background: var(--risk-ref-color, var(--color-text));
  box-shadow: 0 0 0 2px #fff;
  opacity: 0;
  transition: opacity var(--transition-fast);
}

.risk-meter:hover .risk-meter-ref::after,
.summary-card.with-risk:focus-within .risk-meter-ref::after {
  opacity: 1;
}

/* ---- Educational Tooltips ---- */

/* Container genérico — posiciona o balão relativo ao gatilho */
.edu-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: help;
}

/* Estilo A: Ícone ⓘ discreto */
.edu-tooltip-icon {
  color: var(--color-text-muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 400;
  margin-left: 4px;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
  line-height: 1;
}

.edu-tooltip:hover .edu-tooltip-icon,
.edu-tooltip:focus-within .edu-tooltip-icon {
  opacity: 1;
}

/* Estilo B: Sublinhado pontilhado (sem ícone) */
.tooltip-text-trigger {
  text-decoration: underline dotted var(--color-text-muted);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  cursor: help;
}

/* Balão do tooltip — visual compartilhado */
.edu-tooltip-content {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  z-index: 20;
  width: min(280px, 85vw);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--color-text);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.5;
  text-align: left;
  text-transform: none;
  letter-spacing: normal;
  white-space: normal;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity var(--transition-fast), transform var(--transition-fast);
}

/* Seta do balão */
.edu-tooltip-content::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: var(--color-text);
}

/* Reveal no hover e focus */
.edu-tooltip:hover .edu-tooltip-content,
.edu-tooltip:focus-within .edu-tooltip-content {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
}

/* Variante: balão aparece abaixo (quando perto do topo) */
.edu-tooltip-content.tooltip-below {
  bottom: auto;
  top: calc(100% + 10px);
}

.edu-tooltip-content.tooltip-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--color-text);
}

/* Summary card tooltip: ajuste para labels uppercase menores */
.summary-card .edu-tooltip {
  justify-content: center;
}

/* Inst-meta tooltip: inline-block para que position:relative funcione */
.inst-meta .edu-tooltip {
  display: inline-block;
  position: relative;
}

.inst-meta .edu-tooltip-content {
  left: 0;
  transform: translateX(0) translateY(-4px);
}

.inst-meta .edu-tooltip-content.tooltip-below {
  transform: translateX(0) translateY(4px);
}

.inst-meta .edu-tooltip:hover .edu-tooltip-content,
.inst-meta .edu-tooltip:focus-within .edu-tooltip-content {
  transform: translateX(0) translateY(0);
}

.inst-meta .edu-tooltip-content::after {
  left: 20px;
  transform: none;
}

.inst-meta .edu-tooltip-content.tooltip-below::after {
  top: auto;
  bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: var(--color-text);
}

/* Responsivo: em telas pequenas, fixar largura reduzida */
@media (max-width: 480px) {
  .edu-tooltip-content {
    width: min(240px, 85vw);
    font-size: 11px;
  }
}

/* ---- Info / About Page ---- */
.about-content {
  max-width: 800px;
  margin: 0 auto;
}

.about-content h2 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  color: var(--color-text);
}

.about-content p {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: 1.8;
  margin-bottom: var(--space-md);
}

.about-content ul {
  margin-left: var(--space-lg);
  margin-bottom: var(--space-md);
}

.about-content li {
  font-size: var(--font-size-base);
  color: var(--color-text-secondary);
  line-height: 1.8;
}

.disclaimer {
  background: var(--color-warning-light);
  border: 1px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-top: var(--space-xl);
}

.disclaimer h3 {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: #856404;
  margin-bottom: var(--space-sm);
}

.disclaimer p {
  font-size: var(--font-size-sm);
  color: #664d03;
  line-height: 1.6;
}

/* ---- Footer ---- */
.footer {
  margin-top: auto;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  padding: var(--space-xl) var(--space-lg);
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.footer-text {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.footer-links {
  display: flex;
  gap: var(--space-lg);
  list-style: none;
}

.footer-links a {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

.footer-links a:hover {
  color: var(--color-primary);
}

/* ---- Utilities ---- */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-md {
  margin-top: var(--space-md);
}

.mt-lg {
  margin-top: var(--space-lg);
}

.mt-xl {
  margin-top: var(--space-xl);
}

.mb-md {
  margin-bottom: var(--space-md);
}

.mb-lg {
  margin-bottom: var(--space-lg);
}

/* ---- Animations ---- */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.4s ease;
}

/* ---- Loading Skeleton ---- */
.skeleton {
  background: linear-gradient(90deg, var(--color-bg) 25%, var(--color-bg-alt) 50%, var(--color-bg) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }

  100% {
    background-position: -200% 0;
  }
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .hero h1 {
    font-size: var(--font-size-3xl);
  }

  .hero p {
    font-size: var(--font-size-base);
  }

  .navbar-links {
    display: none;
    position: absolute;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    padding: var(--space-md);
    box-shadow: var(--shadow-md);
  }

  .navbar-links.open {
    display: flex;
  }

  .navbar-toggle {
    display: block;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .inst-header-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  .summary-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }

  .table-wrapper {
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .summary-grid {
    grid-template-columns: 1fr;
  }

  .hero h1 {
    font-size: var(--font-size-2xl);
  }

  .search-result-item {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-result-item .result-meta {
    justify-content: flex-start;
    max-width: 100%;
  }

  .search-result-item .result-type {
    max-width: min(260px, 100%);
  }

  .inst-meta {
    flex-direction: column;
    gap: var(--space-xs);
  }
}

/* ---- Table Link Styles ---- */
.table-wrapper a {
  color: var(--color-primary);
  font-weight: 600;
  text-decoration: none;
}

.table-wrapper a:hover {
  text-decoration: underline;
}

/* ---- No results ---- */
.no-results {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  color: var(--color-text-muted);
}

.no-results .icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.no-results h3 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-sm);
  color: var(--color-text-secondary);
}

/* ---- Back link ---- */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
  transition: color var(--transition-fast);
}

.back-link:hover {
  color: var(--color-primary);
}



/* ---- Contact Form ---- */
.contact-info-box {
  display: flex;
  gap: var(--space-lg);
  flex-wrap: wrap;
  margin: var(--space-xl) 0;
}

.contact-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  flex: 1;
  min-width: 240px;
}

.contact-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
}

.contact-item strong {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  display: block;
  margin-bottom: 2px;
}

.contact-item p {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  margin: 0;
}

.contact-form {
  margin-top: var(--space-lg);
}

.form-group {
  margin-bottom: var(--space-lg);
}

.form-group label {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: var(--space-xs);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: var(--space-md);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.12);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--color-text-muted);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-xl);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-primary:hover {
  color: white;
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md) var(--space-xl);
  background: white;
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--font-size-base);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
  color: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.form-note {
  font-size: var(--font-size-xs);
  color: var(--color-text-muted);
  margin-top: var(--space-md);
}

.contact-success {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
}

.contact-success .success-icon {
  font-size: 3rem;
  margin-bottom: var(--space-md);
}

.contact-success h3 {
  font-size: var(--font-size-2xl);
  font-weight: 700;
  color: var(--color-secondary);
  margin-bottom: var(--space-sm);
}

.contact-success p {
  color: var(--color-text-muted);
}

/* ---- Ad Slots ---- */
.ad-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: var(--max-width);
  margin: var(--space-lg) auto;
  padding: 0;
  min-height: 0;
  overflow: hidden;
}

.ad-slot:empty {
  display: none;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {

  .contact-info-box {
    flex-direction: column;
  }
}

/* ---- Comparator ---- */
.comparator-selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  justify-content: center;
}

.comparator-chip {
  background-color: var(--color-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  padding: 0.25rem 0.75rem;
  font-size: var(--font-size-sm);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
}

.comparator-chip:hover {
  border-color: var(--primary);
}

.comparator-chip-remove {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 0.25rem;
  transition: color 0.2s;
}

.comparator-chip-remove:hover {
  color: var(--danger);
}

.comparator-table th:first-child,
.comparator-table td:first-child {
  position: sticky;
  left: 0;
  background-color: var(--color-surface);
  z-index: 2;
  font-weight: 600;
  min-width: 150px;
}

.comparator-table th {
  text-align: center;
  min-width: 120px;
}

.comparator-table td {
  text-align: center;
}

.comparator-value-highlight {
  font-weight: 600;
  color: var(--primary);
}

/* ── View Selector (Rankings & Comparator) ────────────────────────────── */

.view-selector {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}

.view-selector-btn {
  padding: 8px 20px;
  border: 2px solid var(--border);
  border-radius: var(--radius-full, 50px);
  background: var(--bg-card, #fff);
  color: var(--text-secondary, #5a6070);
  font-size: var(--font-size-sm, 0.875rem);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.view-selector-btn:hover {
  border-color: var(--primary, #0d6efd);
  color: var(--primary, #0d6efd);
  background: var(--primary-light, #e8f4fd);
}

.view-selector-btn.active {
  border-color: var(--primary, #0d6efd);
  background: var(--primary, #0d6efd);
  color: #fff;
}

/* ── View Selector — Hero variant ──────────────────────────────────────── */

.view-selector-hero {
  margin-bottom: var(--space-md);
}

.view-selector-hero .view-selector-btn {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(4px);
  font-size: var(--font-size-sm, 0.875rem);
  padding: 6px 16px;
}

.view-selector-hero .view-selector-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

.view-selector-hero .view-selector-btn.active {
  background: #fff;
  border-color: #fff;
  color: var(--primary, #0d6efd);
}

