:root {
  --font-family: 'DM Sans', system-ui, -apple-system, sans-serif;

  --surface-0: oklch(0.97 0.005 85);
  --surface-1: oklch(0.94 0.008 85);
  --surface-2: oklch(0.90 0.010 85);
  --surface-card: oklch(0.99 0.004 85);
  --surface-card-hover: oklch(0.97 0.008 85);

  --text-primary: oklch(0.15 0.01 85);
  --text-secondary: oklch(0.35 0.01 85);
  --text-muted: oklch(0.45 0.008 85);

  --brand-dark: oklch(0.18 0.008 85);
  --brand-dark-light: oklch(0.25 0.008 85);
  --brand-dark-subtle: oklch(0.92 0.008 85);
  --brand-gold: oklch(0.68 0.15 85);
  --brand-gold-light: oklch(0.74 0.13 85);
  --brand-gold-subtle: oklch(0.93 0.04 85);

  --cat-investigacao: oklch(0.52 0.16 25);
  --cat-inteligencia: oklch(0.50 0.16 300);
  --cat-administrativo: oklch(0.65 0.14 75);
  --cat-veiculos: oklch(0.50 0.14 150);
  --cat-academico: oklch(0.52 0.12 240);
  --cat-infraestrutura: oklch(0.45 0.06 240);
  --cat-estatistica: oklch(0.50 0.12 195);

  --border: oklch(0.86 0.010 85);
  --border-hover: oklch(0.72 0.02 85);

  --shadow-sm: 0 1px 2px oklch(0.15 0.01 85 / 0.07);
  --shadow-md: 0 2px 8px oklch(0.15 0.01 85 / 0.09), 0 1px 2px oklch(0.15 0.01 85 / 0.05);
  --shadow-lg: 0 4px 16px oklch(0.15 0.01 85 / 0.12), 0 2px 4px oklch(0.15 0.01 85 / 0.06);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --transition: 180ms ease-out;
  --font-scale: 1;

  color-scheme: light;
}

.high-contrast {
  --surface-0: oklch(1 0 0);
  --surface-1: oklch(0.97 0 0);
  --surface-2: oklch(0.92 0 0);
  --surface-card: oklch(1 0 0);
  --surface-card-hover: oklch(0.96 0 0);
  --text-primary: oklch(0.05 0 0);
  --text-secondary: oklch(0.15 0 0);
  --text-muted: oklch(0.25 0 0);
  --border: oklch(0.30 0 0);
  --border-hover: oklch(0.10 0 0);
  --brand-dark: oklch(0.08 0 0);
  --brand-dark-light: oklch(0.15 0 0);
  --brand-gold: oklch(0.55 0.16 85);
  --brand-gold-light: oklch(0.62 0.14 85);
}

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: calc(16px * var(--font-scale));
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background: var(--surface-0);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.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;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-gold);
  color: var(--text-primary);
  padding: 0.75rem 1.5rem;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  font-weight: 600;
  z-index: 1000;
  text-decoration: none;
  transition: top var(--transition);
}

.skip-link:focus {
  top: 0;
  outline: 3px solid var(--brand-gold);
  outline-offset: 2px;
}

/* Header */
.header {
  background: var(--brand-dark);
  color: oklch(0.98 0.005 85);
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  height: 5.5rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.header-logo {
  width: 56px;
  height: 56px;
  border-radius: 6px;
  background: oklch(0.98 0.005 85 / 0.1);
  padding: 3px;
  box-shadow: 0 0 0 1.5px oklch(0.68 0.15 85 / 0.25);
}

.header-title {
  font-family: 'Saira', var(--font-family);
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 19px;
  text-transform: uppercase;
  margin-top: 5px;
}

.header-subtitle {
  font-family: 'Saira', var(--font-family);
  font-size: 0.8125rem;
  font-weight: 600;
  opacity: 0.9;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-gold-light);
}

.header-tagline {
  font-size: 0.75rem;
  font-style: italic;
  color: oklch(0.98 0 0 / 0.5);
  letter-spacing: 0.02em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* Search */
.search-wrapper {
  position: relative;
  width: 320px;
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: oklch(0.98 0 0 / 0.5);
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2.5rem;
  border: 1.5px solid oklch(0.98 0 0 / 0.2);
  border-radius: var(--radius-md);
  background: oklch(0.98 0 0 / 0.1);
  color: oklch(0.98 0 0);
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

.search-input::placeholder {
  color: oklch(0.98 0 0 / 0.45);
}

.search-input:focus {
  border-color: var(--brand-gold);
  background: oklch(0.98 0 0 / 0.15);
}

/* A11y controls */
.a11y-controls {
  display: flex;
  gap: 0.25rem;
}

.a11y-btn {
  width: 36px;
  height: 36px;
  border: 1.5px solid oklch(0.98 0 0 / 0.2);
  border-radius: var(--radius-sm);
  background: oklch(0.98 0 0 / 0.08);
  color: oklch(0.98 0 0);
  font-size: 0.8125rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), border-color var(--transition);
}

.a11y-btn:hover {
  background: oklch(0.98 0 0 / 0.18);
}

.a11y-btn:focus-visible {
  outline: 3px solid var(--brand-gold);
  outline-offset: 2px;
}

.a11y-btn.active {
  background: var(--brand-gold);
  border-color: var(--brand-gold);
  color: var(--text-primary);
}

/* Main */
.main {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 1.5rem 0rem;
}

/* === ACESSO RÁPIDO (destaque) === */
.favorites-section {
  margin-bottom: 2rem;
  background: var(--brand-dark);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.875rem;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: oklch(0.98 0.005 85);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title svg {
  color: var(--brand-gold);
}

.section-hint {
  font-size: 0.8125rem;
  color: oklch(0.98 0 0 / 0.45);
}

.favorites-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  list-style: none;
}

.favorites-empty {
  font-size: 0.8125rem;
  color: oklch(0.98 0 0 / 0.4);
  padding: 0.875rem 1rem;
  background: oklch(0.98 0 0 / 0.06);
  border-radius: var(--radius-md);
  border: 1.5px dashed oklch(0.98 0 0 / 0.15);
  width: 100%;
}

.fav-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0 0.5rem 1rem;
  background: oklch(0.68 0.15 85 / 0.15);
  border: 1.5px solid oklch(0.68 0.15 85 / 0.25);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brand-gold-light);
  list-style: none;
  overflow: hidden;
  transition: background var(--transition), border-color var(--transition), transform 120ms ease-out;
}

.fav-chip:hover {
  background: oklch(0.68 0.15 85 / 0.25);
  border-color: var(--brand-gold);
  transform: translateY(-1px);
}

.fav-link {
  color: inherit;
  text-decoration: none;
}

.fav-link:focus-visible {
  outline: 2px solid var(--brand-gold);
  outline-offset: 2px;
  border-radius: 2px;
}

.fav-chip .fav-remove {
  background: none;
  border: none;
  color: oklch(0.98 0 0 / 0.35);
  cursor: pointer;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: -0.5rem -0.5rem -0.5rem 0;
  font-size: 1rem;
  line-height: 1;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  transition: background var(--transition), color var(--transition);
}

.fav-chip .fav-remove:hover {
  color: oklch(0.98 0 0 / 0.8);
  background: oklch(0.98 0 0 / 0.08);
}

.fav-chip .fav-remove:focus-visible {
  outline: 2px solid var(--brand-gold);
  outline-offset: -2px;
}

/* Filter bar (tablist) */
.filter-bar {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1.5px solid var(--border);
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: 100px;
  background: var(--surface-card);
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.filter-btn:focus-visible {
  outline: 3px solid var(--brand-gold);
  outline-offset: 2px;
}

.filter-btn.active {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
  color: oklch(0.98 0 0);
}

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cat-color);
  flex-shrink: 0;
}

.filter-count {
  font-size: 0.6875rem;
  opacity: 0.7;
}

/* Systems grid */
.systems-grid {
  display: grid;
  list-style: none;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.875rem;
}

/* System card */
.system-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--surface-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  transition: border-color var(--transition), box-shadow var(--transition), transform 120ms ease-out;
  outline: none;
}

.system-card:hover {
  border-color: var(--border-hover);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.system-card:focus-within {
  border-color: var(--brand-gold);
  box-shadow: 0 0 0 3px oklch(0.68 0.15 85 / 0.2);
}

.system-card[data-status="unavailable"] {
  opacity: 0.7;
}

.card-badge-unavailable {
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  padding: 0.1875rem 0.625rem;
  background: oklch(0.68 0.15 85 / 0.12);
  border: 1px solid oklch(0.68 0.15 85 / 0.25);
  border-radius: 100px;
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--brand-gold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  height: 1.5rem;
  white-space: nowrap;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.625rem;
  min-height: 1.5rem;
}

.card-category {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--card-cat-color, var(--text-muted));
  line-height: 1;
  height: 1.5rem;
}

.card-category-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--card-cat-color, var(--text-muted));
  flex-shrink: 0;
}

.card-fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.125rem;
  width: 2.75rem;
  height: 2.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition), transform 120ms ease-out;
  flex-shrink: 0;
  padding: 0;
  line-height: 1;
  margin: -0.625rem -0.625rem -0.625rem 0;
  border-radius: var(--radius-sm);
}

.card-fav-btn:hover {
  color: var(--brand-gold);
  transform: scale(1.15);
}

.card-fav-btn:focus-visible {
  outline: 3px solid var(--brand-gold);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

.card-fav-btn.is-fav {
  color: var(--brand-gold);
}

.card-name {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.25rem;
  letter-spacing: -0.01em;
}

.card-name-tooltip {
  cursor: help;
  border-bottom: 1px dotted var(--border-hover);
}

.card-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 1rem;
  flex: 1;
}

.card-link {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  background: var(--brand-dark);
  color: oklch(0.98 0 0);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--transition);
  align-self: flex-start;
}

.card-link:hover {
  background: var(--brand-gold);
  color: var(--text-primary);
}

.card-link:focus-visible {
  outline: 3px solid var(--brand-gold);
  outline-offset: 2px;
}

.card-link svg {
  transition: transform var(--transition);
}

.card-link:hover svg {
  transform: translateX(2px);
}

/* No results */
.no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.no-results svg {
  margin-bottom: 1rem;
  opacity: 0.4;
}

.no-results p {
  font-size: 1rem;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  background: var(--brand-dark);
  color: oklch(0.98 0.005 85);
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
  opacity: 0;
}

.toast.visible {
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
  opacity: 1;
}

.toast-undo {
  background: var(--brand-gold);
  color: var(--text-primary);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.25rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition);
}

.toast-undo:hover {
  background: var(--brand-gold-light);
}

.toast-undo:focus-visible {
  outline: 2px solid oklch(0.98 0 0);
  outline-offset: 2px;
}

/* Footer */
.footer {
  background: var(--brand-dark);
  border-top: 1.5px solid var(--border);
  padding: 2.5rem 1.5rem 1.5rem;
  margin-top: auto;
  color: oklch(0.98 0.005 85);
}

.footer-inner {
  max-width: 1280px;
  margin: 0 auto;
}

.footer-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid oklch(0.98 0 0 / 0.1);
}

.footer-heading {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--brand-gold);
  margin-bottom: 0.75rem;
}

.footer-list {
  list-style: none;
  font-size: 0.8125rem;
  color: oklch(0.98 0 0 / 0.6);
  line-height: 1.8;
}

.footer-list strong {
  color: oklch(0.98 0 0 / 0.8);
}

kbd {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background: var(--brand-dark);
  border: 1px solid oklch(0.98 0 0 / 0.15);
  border-radius: 4px;
  font-family: inherit;
  font-size: 0.6875rem;
  font-weight: 600;
  color: oklch(0.98 0 0 / 0.85);
  line-height: 1.4;
}

.footer-bottom {
  text-align: center;
  font-size: 0.75rem;
  color: oklch(0.98 0 0 / 0.35);
}

/* Onboarding modal */
.onboard-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: oklch(0.08 0.005 85 / 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.onboard-overlay[hidden] {
  display: none;
}

.onboard-modal {
  background: var(--surface-card);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow-lg), 0 0 0 1px var(--border);
  overflow: hidden;
}

.onboard-header {
  background: var(--brand-dark);
  color: oklch(0.98 0.005 85);
  padding: 2.5rem 1.5rem 2rem;
  text-align: center;
}

.onboard-logo {
  width: 72px;
  height: 72px;
  margin-bottom: 1rem;
  filter: drop-shadow(0 2px 8px oklch(0.68 0.15 85 / 0.3));
}

.onboard-header h2 {
  font-family: 'Saira', var(--font-family);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.375rem;
}

.onboard-sub {
  font-size: 0.8125rem;
  color: var(--brand-gold);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.onboard-body {
  padding: 1.5rem;
}

.onboard-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.onboard-step {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  background: var(--surface-1);
}

.onboard-icon {
  width: 2rem;
  height: 2rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
}

.onboard-step strong {
  display: block;
  font-size: 0.875rem;
  color: var(--text-primary);
  margin-bottom: 0.125rem;
}

.onboard-step p {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

.onboard-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.onboard-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  cursor: pointer;
}

.onboard-check input {
  accent-color: var(--brand-gold);
}

.onboard-btn {
  padding: 0.5rem 1.5rem;
  background: var(--brand-dark);
  color: oklch(0.98 0 0);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition);
}

.onboard-btn:hover {
  background: var(--brand-gold);
  color: var(--text-primary);
}

.onboard-btn:focus-visible {
  outline: 3px solid var(--brand-gold);
  outline-offset: 2px;
}

/* Animations */
@keyframes card-enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.system-card.animate-in {
  animation: card-enter 250ms ease-out backwards;
}

/* Responsive */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 0;
    gap: 0.75rem;
  }

  .search-wrapper {
    width: 100%;
    order: 3;
  }

  .a11y-controls {
    margin-left: auto;
  }

  .main {
    padding: 1.25rem 1rem 2rem;
  }

  .systems-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .filter-bar {
    gap: 0.25rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
  }

  .filter-btn {
    font-size: 0.75rem;
    padding: 0.375rem 0.625rem;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .onboard-modal {
    max-width: 100%;
  }

  .section-header {
    flex-direction: column;
    gap: 0.25rem;
  }

  .favorites-section {
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .header-title {
    font-size: 1.125rem;
  }

  .header-subtitle {
    font-size: 0.6875rem;
  }

  .header-logo {
    width: 42px;
    height: 42px;
  }

  .header-tagline {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

:focus-visible {
  outline: 3px solid var(--brand-gold);
  outline-offset: 2px;
}