/* ── xlsx viewer ──────────────────────────────────────── */
.xlsx-viewer {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  /* Critical: viewer must never stretch wider than its parent */
  max-width: 100%;
  min-width: 0;
}

/* ── Tabs: equal width, scroll if needed ─────────────── */
.xv-tabs {
  display: flex;
  overflow-x: auto;
  background: #0F172A;
  scrollbar-width: thin;
  scrollbar-color: #334155 transparent;
}
.xv-tabs::-webkit-scrollbar { height: 3px; }
.xv-tabs::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.xv-tab {
  flex: 1 1 0;
  min-width: 72px;
  max-width: 140px;
  padding: 11px 6px;
  background: transparent;
  border: none;
  border-right: 1px solid rgba(255,255,255,0.07);
  color: #94A3B8;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  text-align: center;
}
.xv-tab:hover  { color: #fff; background: rgba(255,255,255,0.07); }
.xv-tab.active { color: #0F172A; background: #F8FAFC; font-weight: 700; }

/* ── Meta bar ────────────────────────────────────────── */
.xv-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}
.xv-filename {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--slate);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Body: horizontal scroll INSIDE the viewer, never breaks page ── */
.xv-body {
  /* Scrolls both axes within the viewer box */
  overflow-x: auto;
  overflow-y: auto;
  max-height: 600px;
  max-width: 100%;
  padding: 0;
  /* Force browser to honour the containment */
  display: block;
  position: relative;
}
.xv-body.xv-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 180px;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--slate);
  padding: 20px;
}
.xv-spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--line-mid);
  border-top-color: var(--blue);
  border-radius: 50%;
  flex-shrink: 0;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.xv-empty, .xv-error {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--slate);
  padding: 24px 20px;
}
.xv-error { color: #DC2626; }

/* ── The div that wraps the table also needs containment ── */
.xv-body > div {
  /* Don't let the inner wrapper push out either */
  max-width: 100%;
  overflow-x: auto;
}

/* ── Financial table ──────────────────────────────────── */
.fin-table {
  border-collapse: collapse;
  /* Do NOT set width:100% — let table size to content naturally */
  /* The scroll wrapper above handles overflow */
  font-size: 0.82rem;
  table-layout: auto;
}
.fin-table td {
  padding: 6px 12px;
  border-bottom: 1px solid #F1F5F9;
  color: var(--ink-soft);
  vertical-align: middle;
  /* Allow wrapping on label cells only, not data cells */
  white-space: nowrap;
}
.fin-table td.lbl {
  white-space: normal;
  min-width: 160px;
  max-width: 300px;
}
.fin-table td.num {
  font-family: var(--mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.fin-table td.neg { color: #DC2626; }

/* Section header row */
.fin-table tr.r-section td {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--blue);
  padding-top: 14px;
  border-bottom: 1px solid var(--line);
  background: #F8FAFC;
  white-space: nowrap;
}

/* Total row */
.fin-table tr.r-total td {
  font-weight: 700;
  color: var(--ink);
  border-top: 1.5px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}

/* Empty spacer row */
.fin-table tr.r-empty td {
  padding: 2px;
  border: none;
}

/* Hover - only on rows without explicit bg colour */
.fin-table tr:not(.r-section):not(.r-total):hover td:not([style*="background"]) {
  background: #F8FAFC;
}

/* COMPLETE badge */
.complete-badge {
  display: inline-block;
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 100px;
  background: #D1FAE5;
  color: #065F46;
}
