/* Bolsas Quissamã — Material 3 Design System (Mobile First & Robust) */
@import url("https://fonts.googleapis.com/css2?family=Open+Sans:wght@300..800&display=swap");

:root {
  /* DARK THEME (Base) */
  --md-sys-color-primary: #7ec2ff;
  --md-sys-color-on-primary: #00213f;
  --md-sys-color-primary-container: rgba(37, 99, 235, 0.32);
  --md-sys-color-on-primary-container: #e8f4ff;
  --md-sys-color-secondary: #a8d4fe;
  --md-sys-color-on-secondary: #0a1e35;
  --md-sys-color-surface: #060c18;
  --md-sys-color-on-surface: #eef6ff;
  --md-sys-color-surface-variant: rgba(255, 255, 255, 0.08);
  --md-sys-color-on-surface-variant: #98b8d4;
  --md-sys-color-outline: rgba(255, 255, 255, 0.11);
  --md-sys-color-error: #fb7185;
  --md-sys-color-on-error: #3d0015;
  --md-sys-color-success: #34d399;
  --md-sys-color-on-success: #022c22;

  /* Aliases */
  --brand: var(--md-sys-color-primary);
  --brand-gradient: var(--md-sys-color-primary-container);
  --bg: var(--md-sys-color-surface);
  --surface: var(--md-sys-color-surface-variant);
  --text: var(--md-sys-color-on-surface);
  --text-muted: var(--md-sys-color-on-surface-variant);
  --border: var(--md-sys-color-outline);
  --radius: 28px;
}

[data-theme="light"] {
  /* LIGHT THEME */
  --md-sys-color-primary: #1a47be;
  --md-sys-color-on-primary: #ffffff;
  --md-sys-color-primary-container: rgba(26, 71, 190, 0.09);
  --md-sys-color-on-primary-container: #0d2264;
  --md-sys-color-secondary: #1338a8;
  --md-sys-color-on-secondary: #ffffff;
  --md-sys-color-surface: #f0f6ff;
  --md-sys-color-on-surface: #040d1a;
  --md-sys-color-surface-variant: rgba(255, 255, 255, 0.85);
  --md-sys-color-on-surface-variant: #0f2550;
  --md-sys-color-outline: rgba(26, 71, 190, 0.16);
  --md-sys-color-error: #be123c;
  --md-sys-color-on-error: #ffffff;
  --md-sys-color-success: #15803d;
  --md-sys-color-on-success: #ffffff;

  --border: rgba(37, 99, 235, 0.13);
}

/* ── Animations ──────────────────────────────────────────────────────── */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes blink {
  50% {
    opacity: 0.3;
  }
}

@keyframes cinematicIn {
  from {
    opacity: 0;
    transform: translateY(250px);
    filter: blur(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Base ────────────────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* Clipa overflow horizontal no ROOT (propaga p/ a viewport) em vez de no body.
   No body, overflow-x:hidden força overflow-y:auto e transforma o body em
   container de rolagem — foi isso que "colava" o toggle/atalhos fixed e os
   fazia rolar. No html é seguro e não quebra position:fixed. */
html {
  overflow-x: hidden;
}

/* Acessibilidade/SEO: conteúdo só para leitores de tela e indexação */
.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;
}

body {
  font-family: "Open Sans", sans-serif;
  background-color: var(--bg);
  background-image:
    radial-gradient(
      ellipse at 18% 32%,
      rgba(37, 99, 235, 0.14) 0%,
      transparent 52%
    ),
    radial-gradient(
      ellipse at 82% 72%,
      rgba(29, 78, 216, 0.09) 0%,
      transparent 50%
    );
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 0;
  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

[data-theme="light"] body {
  background-image:
    radial-gradient(
      ellipse at 20% 20%,
      rgba(147, 197, 253, 0.11) 0%,
      transparent 50%
    ),
    radial-gradient(
      ellipse at 80% 80%,
      rgba(96, 165, 250, 0.07) 0%,
      transparent 50%
    );
}

.wrap {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 20px;
}

.theme-transition,
.theme-transition * {
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

main {
  position: relative;
  z-index: 1;
  transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ── Header & Search ──────────────────────────────────── */
.topo {
  position: relative;
  text-align: center;
  padding: 48px 20px;
  transition: transform 1.5s cubic-bezier(0.16, 1, 0.3, 1), min-height 0.6s cubic-bezier(0.16, 1, 0.3, 1), padding 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

/* initial-state: page is now a full landing page, centering search wrapper */
body.initial-state .topo {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  padding: 48px 20px 90px 20px;
  position: relative;
}

body.initial-state .busca-wrapper {
  width: 100%;
}

.scroll-down-btn {
  display: none;
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 500;
  transition: opacity 0.3s ease, transform 0.3s ease, color 0.3s ease;
  user-select: none;
  z-index: 10;
  text-decoration: none;
}

body.initial-state .scroll-down-btn {
  display: flex;
}

.scroll-down-btn:hover {
  color: var(--brand);
}

.scroll-down-icon {
  animation: bounce 2s infinite;
  margin-top: 4px;
}

@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-6px);
  }
  60% {
    transform: translateY(-3px);
  }
}

@media (min-width: 768px) {
  body.initial-state .topo {
    padding: 64px 24px 110px 24px;
  }
}

.theme-toggle {
  /* absolute (não fixed): ancorado ao topo do documento, rola junto com a página */
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  z-index: 100;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.theme-toggle svg {
  transition: transform 0.5s ease;
}

@media (max-width: 768px) {
  body.data-visible .theme-toggle {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

[data-theme="dark"] .theme-toggle svg {
  transform: rotate(360deg);
}

.topo h1 {
  font-size: clamp(2rem, 10vw, 3.5rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  margin-bottom: 8px;
  line-height: 1.1;
}
.topo h1 span {
  color: var(--brand);
}
.topo .sub {
  font-size: clamp(0.85rem, 4vw, 1.1rem);
  color: var(--text-muted);
  margin-bottom: 24px;
}

.busca-wrapper {
  position: relative;
  max-width: 600px;
  margin: 0 auto;
}

.busca-container {
  background: var(--surface);
  padding: 6px;
  border-radius: 28px;
  border: 1px solid var(--border);
  display: flex;
  gap: 4px;
}
.busca-container:focus-within {
  border-color: var(--brand);
}
.busca-container input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 12px 16px;
  color: var(--text);
  font-size: 1rem;
  outline: none;
  min-width: 0;
}
.btn-search {
  background-color: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  border: none;
  padding: 0 14px;
  border-radius: 22px;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-search-text { display: none; }
.btn-search-icon { display: block; flex-shrink: 0; }

#sugestoes {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  backdrop-filter: blur(20px);
  border-radius: 16px;
  border: 1px solid var(--border);
  overflow-y: auto;
  max-height: 250px;
  z-index: 9999;
  display: none;
  margin-top: 2px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#sugestoes::-webkit-scrollbar {
  display: none;
}

#sugestoes.active {
  display: block;
  animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.sugestao-item {
  padding: 14px 20px;
  cursor: pointer;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.sugestao-item:last-child {
  border-bottom: none;
}
.sugestao-item:hover,
.sugestao-item.selected {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
}

/* ── Dashboard Content ─────────────────────────────────── */
#resultado {
  display: grid;
  gap: 16px;
  margin-top: 16px;
  transition: opacity 1.5s cubic-bezier(0.16, 1, 0.3, 1);
}
#resultado:not(.hidden) {
  animation: cinematicIn 2.5s cubic-bezier(0.16, 1, 0.3, 1) 0.3s both;
}
#resultado.hidden {
  display: none !important;
}

/* Hero */
.hero-card {
  background-color: var(--md-sys-color-primary-container);
  padding: 32px 24px;
  border-radius: var(--radius);
  color: var(--md-sys-color-on-primary-container);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.hero-card::after {
  content: "";
  position: absolute;
  top: -30%;
  right: -5%;
  width: 360px;
  height: 360px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  filter: blur(55px);
}
/* Hero — identity zone */
.hero-id { position: relative; z-index: 1; }
.hero-nome {
  font-size: clamp(1.1rem, 5vw, 1.65rem);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 10px;
}
.hero-curso {
  font-size: 0.95rem;
  font-weight: 600;
  opacity: 0.9;
}
.hero-inst {
  font-size: 0.82rem;
  opacity: 0.65;
  margin-top: 3px;
  margin-bottom: 12px;
}
.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.hero-tag {
  display: inline-flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
[data-theme="light"] .hero-tag {
  background: rgba(0, 0, 0, 0.07);
  border-color: rgba(0, 0, 0, 0.12);
}

/* Hero — separator */
.hero-sep {
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
  margin: 20px 0;
  position: relative;
  z-index: 1;
}
[data-theme="light"] .hero-sep { background: rgba(0, 0, 0, 0.1); }

/* Hero — financial zone */
.hero-fin {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  z-index: 1;
}
.hero-pago { min-width: 0; }
.hero-plbl {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--md-sys-color-error);
  margin-bottom: 4px;
}
.hero-pval {
  font-size: clamp(2rem, 10vw, 3rem);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--md-sys-color-error);
}



/* Hero — status badges */
.hero-badges {
  display: flex;
  flex-direction: row;
  gap: 8px;
}
.hero-status {
  flex: 1;
  text-align: center;
  padding: 10px 14px;
  border-radius: 14px;
}
.hero-status.recebido {
  background: rgba(126, 194, 255, 0.12);
  border: 1px solid rgba(126, 194, 255, 0.22);
}
[data-theme="light"] .hero-status.recebido {
  background: rgba(26, 71, 190, 0.08);
  border-color: rgba(26, 71, 190, 0.18);
}
.hero-status.empenhado {
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.2);
}
[data-theme="light"] .hero-status.empenhado {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.1);
}
.hero-sv {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.2;
}
.hero-status.recebido .hero-sv,
.hero-status.recebido .hero-sl { color: var(--md-sys-color-success); opacity: 1; }
.hero-sl {
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.7;
  margin-top: 4px;
}


/* Visualization */
.viz-section {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.chart-card {
  background: var(--surface);
  padding: 24px 20px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.chart-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 24px;
}
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.chart-header h2 {
  margin-bottom: 0;
}
.chart-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}
.ct-btn {
  background: none;
  border: none;
  padding: 8px 20px;
  border-radius: 7px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  flex: 1;
  text-align: center;
}
.ct-btn.active {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
}

.chart-expand-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 5px;
  border-radius: 7px;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, background 0.2s;
}
.chart-expand-btn:hover {
  color: var(--text);
  background: var(--surface);
}

.chart-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(5px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-modal.hidden { display: none; }
.chart-modal-card {
  background: var(--md-sys-color-surface-variant);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px 36px;
  width: min(88vw, 1080px);
}
.chart-container-modal { height: 440px; position: relative; }
.chart-container {
  height: 200px;
  position: relative;
}

/* Transaction List */
.data-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow: hidden;
}
.data-header {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.data-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
}
.data-legend {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  font-size: 0.8rem;
}
.data-legend-item {
  width: 100%;
}

.transaction-list {
  padding: 8px;
}
.transaction-item {
  display: grid;
  grid-template-areas: "head" "body" "foot";
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 16px;
  border-radius: 16px;
  background-color: var(--surface);
  margin-bottom: 8px;
  border: 1px solid var(--border);
}
.tr-head {
  grid-area: head;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tr-body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.tr-foot {
  grid-area: foot;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.tr-name {
  font-weight: 500;
  font-size: 0.95rem;
}
.tr-unit {
  font-size: 0.75rem;
  color: var(--brand);
  display: block;
  margin-bottom: 4px;
}
.tr-ref {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
}
.tr-year {
  font-size: 0.75rem;
  color: var(--text-muted);
  opacity: 0.6;
}
.tr-dates {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 10px;
}
.tr-dates b {
  color: var(--text);
}
.tr-amount {
  font-size: 1.15rem;
  font-weight: 900;
}


/* Toast */
#estado {
  position: fixed;
  top: 16px;
  left: 16px;
  right: 16px;
  z-index: 9999;
  pointer-events: none;
}
.aviso-box {
  pointer-events: auto;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  animation: toastIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.aviso-box::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
}
.aviso-box.carregando::before {
  background: #fbbf24;
  animation: blink 1s infinite;
}
.aviso-box.erro {
  border-color: rgba(251, 113, 133, 0.35);
}
.aviso-box.erro::before {
  background: var(--md-sys-color-error);
}
.aviso-fechar {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 6px;
  flex-shrink: 0;
}
.aviso-fechar:hover {
  color: var(--text);
  background: var(--surface-variant);
}

/* Shortcuts */
.shortcuts-guide {
  /* absolute (não fixed): ancorado perto do rodapé da 1ª tela e rola com a página */
  position: absolute;
  top: calc(100dvh - 130px);
  left: 32px;
  display: none;
  flex-direction: column;
  gap: 12px;
  z-index: 1000;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 1;
  visibility: visible;
}

body.data-visible .shortcuts-guide {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.key-hint {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  transition:
    opacity 0.4s ease,
    transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.key-hint kbd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  padding: 2px 8px;
  border-radius: 6px;
  color: var(--text);
}

/* ── Home Stats ──────────────────────────────────────────────────────── */

/* A — pills acima da busca */
.hs-metrics-topo {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  margin-bottom: 20px;
}
body.data-visible .hs-metrics-topo { display: none; }
.hs-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.hs-pill b { color: var(--text); }

/* B + C — home stats section */
#homeStats {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  padding-bottom: 40px;
}
body.data-visible #homeStats { display: none; }

/* B — summary cards (reutiliza .stat-card — precisamos recolocar o CSS) */
.hs-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.stat-card {
  background-color: var(--surface);
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--border);
}
.stat-card .label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.stat-card .value {
  font-size: clamp(0.95rem, 4.2vw, 1.25rem);
  font-weight: 800;
}

/* B — ranking lists */
.hs-rankings {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.rank-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.rank-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rank-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.rank-name {
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.rank-pos {
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 18px;
}
.rank-val {
  font-size: 0.85rem;
  font-weight: 800;
  white-space: nowrap;
  flex-shrink: 0;
}
.rank-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 4px;
  overflow: hidden;
}
.rank-bar-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 4px;
}
.rank-meta {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.rank-resto {
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.rank-resto .rank-name {
  color: var(--text-muted);
  font-weight: 700;
}

/* C — secondary charts grid */
.hs-secondary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

/* ── Desktop Overrides (769px+) ──────────────────────────────────────── */
@media (min-width: 769px) {
  /* Home stats */
  .hs-metrics-topo {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
  .hs-cards { grid-template-columns: repeat(4, 1fr); }
  .hs-rankings { grid-template-columns: repeat(2, 1fr); }
  .hs-secondary { grid-template-columns: repeat(2, 1fr); }

  /* Hero — 2-column layout */
  .hero-card {
    padding: 48px 40px;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
    grid-template-areas: "id fin";
    align-items: center;
  }
  .hero-id { grid-area: id; padding-right: 40px; min-width: 0; }
  .hero-sep { display: none; }
  .hero-fin {
    grid-area: fin;
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
    padding-left: 40px;
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    min-width: 0;
    width: 100%;
  }
  .ct-btn { flex: unset; padding: 4px 14px; font-size: 0.75rem; }
  .chart-expand-btn { display: flex; }
  [data-theme="light"] .hero-fin { border-left-color: rgba(0, 0, 0, 0.1); }
  .hero-nome { font-size: 2.1rem; }
  .hero-curso { font-size: 1.05rem; }
  .hero-pval { font-size: clamp(2rem, 3.8vw, 3.2rem); width: 100%; }
  .hero-pago { width: 100%; min-width: 0; }
  .hero-badges { flex-direction: row; width: 100%; gap: 8px; }
  .hero-status { flex: 1; min-width: unset; }
  .hero-sv { font-size: 1.15rem; }
  .wrap {
    padding: 0 24px;
  }
  .btn-search {
    padding: 0 24px;
  }
  .btn-search-text { display: inline; }
  .btn-search-icon { display: none; }
  .topo {
    padding: 64px 24px;
  }
  .theme-toggle {
    top: 12px;
    right: 24px;
  }
  .viz-section {
    grid-template-columns: 1.6fr 1fr;
    gap: 24px;
  }
  .chart-container {
    height: 260px;
  }
  .data-header {
    padding: 32px 40px;
  }
  .data-legend {
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
  }
  .transaction-item {
    grid-template-areas: "foot body head";
    grid-template-columns: 80px 1fr 150px;
    align-items: center;
    gap: 0 24px;
    padding: 20px 24px;
  }
  .tr-head {
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
  }
  .tr-foot {
    flex-direction: column;
    align-items: flex-start;
    border-top: none;
    padding-top: 0;
    gap: 2px;
  }
  .tr-name {
    font-size: 1rem;
    white-space: normal;
  }
  .tr-dates {
    font-size: 0.75rem;
    margin-top: 4px;
  }
  .tr-amount {
    font-size: 1.2rem;
  }
  .shortcuts-guide {
    display: flex;
  }
  #estado {
    top: auto;
    bottom: 16px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    width: max-content;
    max-width: 520px;
  }
}

/* Light Mode Overrides for Data View */
[data-theme="light"] .stat-card,
[data-theme="light"] body.data-visible .chart-card,
[data-theme="light"] body.data-visible .transaction-item {
  background-color: #f8fafc !important;
  border-color: #e2e8f0 !important;
}

/* Export button */
.btn-export {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.2s, border-color 0.2s;
}
.btn-export:hover {
  color: var(--text);
  border-color: var(--brand);
}

/* ── Rodapé ───────────────────────────────────────────── */
.rodape {
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  padding: 40px 0 20px 0;
  margin-top: 64px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.rodape-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
  margin-bottom: 32px;
}

@media (min-width: 768px) {
  .rodape-content {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

.rodape-logo h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.rodape-logo h2 span {
  color: var(--brand);
}

.rodape-logo p {
  font-size: 0.8rem;
}

.rodape-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 24px;
}

.rodape-links a {
  color: var(--text-muted);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.3s ease;
  font-weight: 600;
}

.rodape-links a:hover {
  color: var(--brand);
}

.external-link-icon {
  flex-shrink: 0;
  opacity: 0.7;
}

.rodape-bottom {
  border-top: 1px solid var(--border);
  padding-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 0.75rem;
  opacity: 0.8;
}

@media (min-width: 768px) {
  .rodape-bottom {
    flex-direction: row;
    justify-content: space-between;
  }
}

/* Print document — hidden on screen */
.print-only { display: none !important; }
.no-print {}

/* ── Print styles ──────────────────────────────────────────────────────── */
@media print {
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  .no-print,
  .topo,
  #resultado,
  .shortcuts-guide,
  .theme-toggle,
  #estado,
  #chartModal { display: none !important; }

  .print-only { display: block !important; }

  body {
    background: #fff !important;
    color: #111 !important;
    font-family: 'Open Sans', sans-serif;
    font-size: 10pt;
    padding: 0;
    margin: 0;
  }

  #printDoc {
    padding: 0;
    max-width: none;
    width: 100%;
  }

  .pd-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 2px solid #1a47be;
    padding-bottom: 10px;
    margin-bottom: 16px;
  }
  .pd-title {
    font-size: 16pt;
    font-weight: 800;
    color: #1a47be;
    letter-spacing: -0.02em;
  }
  .pd-subtitle {
    font-size: 9pt;
    color: #555;
    margin-top: 2px;
  }
  .pd-meta {
    font-size: 9pt;
    color: #555;
    text-align: right;
  }

  .pd-student {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 24px;
    background: #f4f7ff;
    border: 1px solid #d0daff;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 16px;
  }
  .pd-field { display: flex; gap: 8px; align-items: baseline; }
  .pd-label {
    font-size: 7.5pt;
    font-weight: 700;
    text-transform: uppercase;
    color: #555;
    white-space: nowrap;
    min-width: 72px;
  }

  .pd-section-title {
    font-size: 9pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #555;
    margin-bottom: 6px;
  }

  .pd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 9pt;
    page-break-inside: auto;
  }
  .pd-table thead { display: table-header-group; }
  .pd-table th {
    background: #1a47be;
    color: #fff;
    padding: 6px 8px;
    text-align: left;
    font-weight: 700;
    font-size: 8pt;
  }
  .pd-table td {
    padding: 5px 8px;
    border-bottom: 1px solid #e2e8f0;
    vertical-align: top;
  }
  .pd-table tr:nth-child(even) td { background: #f8faff; }

  .pd-summary-table td { font-weight: 700; font-size: 10pt; }

  /* Column widths locked for A4 — total ≈ 178mm */
  .pd-list-table { table-layout: fixed; }
  .pd-list-table th:nth-child(1) { width: 18mm; }  /* Empenho */
  .pd-list-table th:nth-child(2) { width: 52mm; }  /* Referência */
  .pd-list-table th:nth-child(3) { width: 25mm; }  /* Empenhado */
  .pd-list-table th:nth-child(4) { width: 25mm; }  /* Pago */
  .pd-list-table th:nth-child(5) { width: 18mm; }  /* Status */
  .pd-list-table th:nth-child(6) { width: 20mm; }  /* Dt. Empenho */
  .pd-list-table th:nth-child(7) { width: 20mm; }  /* Dt. Pagamento */
  .pd-list-table td { word-wrap: break-word; overflow-wrap: break-word; }
  .pd-danger { color: #be123c !important; }

  .pd-row-pago td { color: #15803d; }
  .pd-row-pendente td { color: #be123c; }

  .pd-status {
    font-size: 7pt;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
  }
  .pd-ok { background: #dcfce7; color: #15803d; }
  .pd-warn { background: #fee2e2; color: #be123c; }

  .pd-footer {
    margin-top: 16px;
    padding-top: 8px;
    border-top: 1px solid #e2e8f0;
    font-size: 8pt;
    color: #888;
  }

  @page {
    size: A4 portrait;
    margin: 0.4in;
  }
}

/* Utils */
.hidden {
  display: none !important;
}
.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* D — cadência de pagamentos */
.hs-cadencia {
  margin-top: 16px;
}
.chart-card.card-full {
  grid-column: 1 / -1;
}
.chart-subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: -6px;
  margin-bottom: 16px;
}

/* ── Insights (Mobile Friendly) ─────────────────────────────────────── */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 8px;
  margin-bottom: 20px;
}
.insight-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.insight-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.insight-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
}
.insight-icon.brand {
  background: var(--md-sys-color-primary-container);
  color: var(--brand);
}
.insight-icon.success {
  background: rgba(52, 211, 153, 0.15);
  color: var(--md-sys-color-success);
}
[data-theme="light"] .insight-icon.success {
  background: rgba(21, 128, 61, 0.12);
}
.insight-icon.danger {
  background: rgba(251, 113, 133, 0.15);
  color: var(--md-sys-color-error);
}
[data-theme="light"] .insight-icon.danger {
  background: rgba(190, 18, 60, 0.1);
}
.insight-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}
.insight-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
}
.insight-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.disclaimer-note {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  opacity: 0.85;
  border-top: 1px dashed var(--border);
  padding-top: 12px;
}
.disclaimer-note svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--brand);
}
