/* Revenue Dashboard (Leadership View) — Mothership-sourced per-LO revenue.
   Three KPI cards per LO: Total Revenue / Projected / Realized. Reuses
   the same dark glass-morphism aesthetic and class names as the rest of
   the /embed/*-v2 suite. Revenue-specific overrides live at the bottom. */

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { min-height: 100%; }
body {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: rgb(20, 20, 20);
  color: #e2e8f0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: url("../assets/altair-wordmark.png") center / min(92%, 1900px) no-repeat;
  opacity: 0.12;
  pointer-events: none;
  z-index: 0;
}

#root { min-height: 100vh; position: relative; z-index: 1; }

/* ---- Nav (server-injected) ---- */
.psr-nav {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.45);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.psr-nav-link {
  padding: 6px 16px;
  border-radius: 6px;
  text-decoration: none;
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 500;
}
.psr-nav-link--restricted {
  color: #FFFDD0;
  background: rgba(255, 253, 208, 0.06);
  border: 1px solid rgba(255, 253, 208, 0.15);
  letter-spacing: 0.4px;
}
/* Match the v2 nav tab styling (this dashboard is a public v2 tab). */
.psr-nav-link:hover { background: rgba(255, 253, 208, 0.08); color: #FFFDD0; }
.psr-nav-link.active { background: #1985a1; color: #fff; }

/* ---- Content shell ---- */
.psr-content {
  padding: 20px 20px 60px;
  max-width: 1900px;
  margin: 0 auto;
}

/* ---- Filter bar ---- */
.psr-filters {
  background: linear-gradient(135deg, rgba(50,65,88,0.50) 0%, rgba(28,32,44,0.50) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 14px 18px;
  margin-bottom: 18px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}
.psr-filter-label {
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 8px;
}
.psr-filter-row {
  display: flex;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
}
.psr-filter-group {
  flex: 1;
  min-width: 280px;
}
.psr-filter-group label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.5px;
  color: #94a3b8;
  margin-bottom: 6px;
}
.psr-date-range {
  display: flex;
  align-items: center;
  gap: 10px;
}
.psr-date-range input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #f1f5f9;
  font-family: inherit;
  color-scheme: dark;
}
.psr-date-range input:focus {
  outline: none;
  border-color: rgba(255, 253, 208, 0.4);
  background: rgba(255, 253, 208, 0.04);
}
.psr-arrow { color: #94a3b8; font-size: 16px; }

.psr-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}
.psr-presets button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #cbd5e1;
  border-radius: 14px;
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.psr-presets button:hover:not(:disabled) {
  background: rgba(255, 253, 208, 0.06);
  border-color: rgba(255, 253, 208, 0.25);
  color: #FFFDD0;
}

.psr-apply {
  background: #FFFDD0;
  color: #1C202C;
  border: 0;
  border-radius: 8px;
  padding: 10px 24px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
  align-self: flex-end;
}
.psr-apply:hover:not(:disabled) { transform: translateY(-1px); }
.psr-apply:disabled { opacity: 0.6; cursor: wait; }

/* ---- QB refresh button + progress bar ---- */
.rev-qb-refresh {
  flex-basis: 100%;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}
.rev-qb-refresh-btn {
  background: transparent;
  border: 1px solid rgba(56, 189, 248, 0.35);
  color: #7dd3fc;
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.3px;
  transition: all 0.15s;
}
.rev-qb-refresh-btn:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.10);
  border-color: rgba(56, 189, 248, 0.55);
  color: #38bdf8;
}
.rev-qb-refresh-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.rev-qb-refresh-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}
.rev-qb-refresh-label {
  font-size: 12px;
  color: #7dd3fc;
  font-weight: 500;
  letter-spacing: 0.2px;
  min-width: 220px;
}
.rev-qb-refresh-bar {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.rev-qb-refresh-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #38bdf8 0%, #7dd3fc 100%);
  border-radius: 3px;
  transition: width 0.4s ease-out;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.4);
}
/* A Glue stage gives no granular % (it just holds until the job finishes), so
   while running we show an indeterminate sliding stripe — clearly "working"
   rather than a frozen bar. The width-based fill is only used on completion. */
@keyframes revBarSlide {
  0%   { transform: translateX(-120%); }
  100% { transform: translateX(400%); }
}
.rev-qb-refresh-bar-fill--indeterminate {
  width: 26%;
  animation: revBarSlide 1.25s ease-in-out infinite;
}
.rev-qb-refresh-hint { color: rgba(125, 211, 252, 0.55); font-weight: 400; }

/* ---- Error / empty states ---- */
.psr-error {
  background: rgba(248, 113, 113, 0.10);
  border: 1px solid rgba(248, 113, 113, 0.30);
  color: #fca5a5;
  padding: 12px 16px;
  border-radius: 10px;
  margin-bottom: 16px;
  font-size: 13px;
}
.psr-empty-page {
  text-align: center;
  color: #94a3b8;
  padding: 60px 20px;
  font-size: 14px;
}

/* ---- LO list ---- */
.psr-lo-list { display: flex; flex-direction: column; gap: 18px; }
.psr-lo-list--loading { opacity: 0.4; pointer-events: none; transition: opacity 0.2s; }

.psr-lo {
  background: linear-gradient(135deg, rgba(50, 65, 88, 0.55) 0%, rgba(28, 32, 44, 0.55) 100%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.30);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
}

.psr-lo-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 253, 208, 0.10);
}
.psr-lo-bar {
  width: 4px;
  height: 32px;
  border-radius: 2px;
  background: linear-gradient(180deg, #FFFDD0, rgba(255, 253, 208, 0.3));
}
.psr-lo-name-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-right: auto;
}
.psr-lo-name {
  font-size: 18px;
  font-weight: 700;
  color: #FFFDD0;
  letter-spacing: 0.5px;
}
.rev-lo-title {
  font-size: 11px;
  color: #94a3b8;
  letter-spacing: 0.5px;
}
.psr-lo-meta {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: #94a3b8;
  letter-spacing: 0.3px;
}
.psr-lo-meta strong { color: #f1f5f9; font-weight: 600; }

/* ---- Portrait ---- */
.psr-portrait {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(135deg, #FFFDD0 0%, #b6a268 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 253, 208, 0.30);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
.psr-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 18%;
  display: block;
}
.psr-portrait-initials {
  position: absolute;
  font-size: 16px;
  font-weight: 800;
  color: #1C202C;
  letter-spacing: 0.5px;
  z-index: 1;
}
.psr-portrait img:not([style*="display: none"]) ~ .psr-portrait-initials { display: none; }
.psr-portrait--fallback .psr-portrait-initials { display: inline; }

/* =============================================================================
   Revenue-specific layout — 3 KPI cards per LO + a top "totals" strip
   ========================================================================== */

.rev-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-bottom: 22px;
  padding: 18px 22px;
  background: linear-gradient(135deg, rgba(255, 253, 208, 0.06) 0%, rgba(255, 253, 208, 0.01) 100%);
  border: 1px solid rgba(255, 253, 208, 0.18);
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.30);
}
@media (max-width: 800px) { .rev-summary-strip { grid-template-columns: 1fr; } }

.rev-summary-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px 12px;
  border-left: 2px solid rgba(255, 253, 208, 0.30);
}
.rev-summary-item:first-child { border-left: 0; padding-left: 0; }
.rev-summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #94a3b8;
  font-weight: 500;
}
.rev-summary-value {
  font-size: 28px;
  font-weight: 800;
  color: #FFFDD0;
  letter-spacing: -0.5px;
}
.rev-summary-subline {
  font-size: 11px;
  color: #cbd5e1;
  opacity: 0.75;
}

/* ---- Section + KPI grid per LO ---- */
.rev-section { margin-bottom: 14px; }
.rev-section:last-child { margin-bottom: 0; }
.rev-section-label {
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #94a3b8;
  font-weight: 500;
  margin-bottom: 8px;
}

.rev-grid {
  display: grid;
  grid-template-columns: repeat(var(--rev-cards, 3), minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 800px) { .rev-grid { grid-template-columns: 1fr; } }

.rev-kpi {
  display: block;
  width: 100%;
  text-align: center;
  cursor: pointer;
  padding: 18px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.20);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  color: inherit;
  font: inherit;
}
.rev-kpi:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.015);
  box-shadow: 0 8px 24px rgba(255, 253, 208, 0.10), 0 0 0 1px rgba(255, 253, 208, 0.15);
  border-color: rgba(255, 253, 208, 0.20);
  background: rgba(255, 255, 255, 0.07);
}
.rev-kpi-value {
  font-size: 24px;
  font-weight: 800;
  color: #FFFDD0;
  letter-spacing: -0.5px;
}
/* Profitability + ROI color signals */
.rev-kpi-value--pos { color: #34d399; }   /* green */
.rev-kpi-value--neg { color: #f87171; }   /* red */
/* Non-clickable summary cards (Profitability / ROI) */
.rev-kpi--noclick {
  cursor: default;
  background: linear-gradient(135deg, rgba(255, 253, 208, 0.04) 0%, rgba(255, 253, 208, 0.01) 100%);
  border-color: rgba(255, 253, 208, 0.10);
}
.rev-kpi--noclick:hover:not(:disabled) {
  transform: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.20);
  background: linear-gradient(135deg, rgba(255, 253, 208, 0.04) 0%, rgba(255, 253, 208, 0.01) 100%);
  border-color: rgba(255, 253, 208, 0.10);
}
.rev-kpi-label {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 8px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 500;
}
.rev-kpi-subline {
  font-size: 10px;
  color: #cbd5e1;
  margin-top: 4px;
  opacity: 0.75;
}
.rev-kpi--skel { cursor: default; pointer-events: none; }

/* =============================================================================
   Popup table — wider columns, per-status color pills
   ========================================================================== */

.psr-popup-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.70);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.psr-popup {
  position: relative;
  background: linear-gradient(135deg, #324158 0%, #1C202C 100%);
  border: 1px solid rgba(255, 253, 208, 0.15);
  border-radius: 16px;
  width: 95vw;
  max-width: 1400px;
  max-height: 88vh;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  color: #e2e8f0;
}
.psr-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  gap: 12px;
}
.psr-popup-title {
  font-size: 15px;
  font-weight: 700;
  color: #FFFDD0;
  letter-spacing: 0.3px;
}
.psr-popup-summary {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: #94a3b8;
  letter-spacing: 0.3px;
  margin-top: 4px;
}
.psr-popup-sum strong { color: #FFFDD0; font-weight: 700; font-size: 13px; }

.psr-popup-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.psr-popup-export {
  background: #FFFDD0;
  color: #1C202C;
  border: 0;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
}
.psr-popup-export:hover { opacity: 0.85; }
.psr-popup-export:disabled { opacity: 0.4; cursor: default; }
.psr-popup-close {
  background: transparent;
  border: 0;
  color: #94a3b8;
  font-size: 22px;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 1;
  font-family: inherit;
}
.psr-popup-close:hover { background: rgba(255, 255, 255, 0.08); color: #f1f5f9; }

.psr-popup-table-wrap {
  padding: 14px 22px 22px;
  overflow-y: auto;
  flex: 1;
}

.psr-popup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}
.psr-popup-table thead tr { background: rgba(255, 253, 208, 0.06); }
.psr-popup-table th {
  padding: 11px 10px;
  font-size: 11px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: #FFFDD0;
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid rgba(255, 253, 208, 0.12);
}
.psr-popup-table td {
  padding: 8px 10px;
  font-size: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
  white-space: nowrap;
}
.psr-popup-table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
.rev-num { text-align: right; }

.rev-loan-name { font-weight: 600; color: #f1f5f9; }
.rev-loan-id { font-size: 10px; color: #94a3b8; opacity: 0.7; margin-top: 1px; max-width: 380px; overflow: hidden; text-overflow: ellipsis; }
.rev-empty-row { text-align: center; color: #94a3b8; padding: 24px !important; font-style: italic; }
.rev-memo {
  max-width: 360px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 11px;
  color: #94a3b8;
}
.rev-memo:hover { white-space: normal; overflow: visible; }

/* Status pills — color-coded per Mothership lifecycle */
.rev-status {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  background: rgba(148, 163, 184, 0.20);
  color: #cbd5e1;
}
.rev-status--active     { background: rgba(52, 211, 153, 0.18); color: #34d399; }
.rev-status--lo-action  { background: rgba(251, 191, 36, 0.18); color: #fbbf24; }
.rev-status--on-hold    { background: rgba(168, 162, 158, 0.18); color: #d6d3d1; }
.rev-status--lost       { background: rgba(248, 113, 113, 0.18); color: #fca5a5; }

.psr-popup-pagination {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  padding: 12px 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 12px;
  color: #94a3b8;
}
.psr-popup-pagination button {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: #cbd5e1;
  border-radius: 6px;
  padding: 4px 12px;
  font-family: inherit;
  cursor: pointer;
  min-width: 32px;
}
.psr-popup-pagination button:hover:not(:disabled) {
  background: rgba(255, 253, 208, 0.08);
  color: #FFFDD0;
}
.psr-popup-pagination button:disabled { opacity: 0.4; cursor: default; }

/* =============================================================================
   Skeleton loader (shimmer while React fetches data)
   ========================================================================== */
.psr-skeleton-row { opacity: 0.85; }
.psr-skel {
  border-radius: 6px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.04) 0%,
    rgba(255, 255, 255, 0.10) 50%,
    rgba(255, 255, 255, 0.04) 100%
  );
  background-size: 200% 100%;
  animation: psr-skel-shimmer 1.4s ease-in-out infinite;
}
@keyframes psr-skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.psr-skel--portrait      { width: 48px; height: 48px; border-radius: 50%; flex-shrink: 0; }
.psr-skel--name          { width: 180px; height: 18px; }
.psr-skel--section-label { width: 110px; height: 10px; margin-bottom: 8px; }
.psr-skel--value-sm      { width: 50%; height: 18px; margin: 0 auto; }
.psr-skel--label         { width: 70%; height: 9px; margin: 6px auto 0; }
