/* TechVestor Revenue Dashboard — Overview tab (adapted from the legacy single-file dashboard). */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #f7f5fc;
  color: #111827;
}
.container { max-width: 1600px; margin: 0 auto; padding: 24px 28px 60px; }

.header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.header h1 { font-size: 24px; font-weight: 800; margin: 0; color: #2e1065; }
.header p { margin: 4px 0 0; font-size: 13px; color: #6b7280; }

.nav { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid #e5e0f5; }
.nav button {
  font-size: 13px; font-weight: 600; padding: 9px 16px; border: none; background: none;
  color: #6b7280; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.nav button.active { color: #6d28d9; border-bottom-color: #6d28d9; }
.nav button:disabled { color: #c4b5fd; cursor: not-allowed; }

.status-box { padding: 16px 18px; border-radius: 10px; background: #fff; border: 1px solid #e5e0f5; font-size: 13px; color: #6b7280; }
.status-box.status-warn { border-color: #fecaca; background: #fef2f2; color: #b91c1c; }
.status-box.status-ok { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
.status-box.status-neutral { border-color: #e5e0f5; background: #faf9ff; color: #6b7280; }

/* ── Tabs ── */
.tab { display: none; }

/* ── Overview toolbar ── */
.ov-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.ov-search { font-size: 13px; padding: 7px 12px; border: 1px solid #e5e0f5; border-radius: 8px; background: #fff; color: #111827; outline: none; width: 240px; }
.ov-search:focus { border-color: #c4b5fd; }
.ov-count { font-size: 12px; color: #9ca3af; }
.ov-legend { font-size: 11px; color: #9ca3af; margin-left: auto; }
.ov-fb-key { color: #b45309; font-weight: 700; }

/* ── Overview table ── */
/* The table is its own scroll viewport: a native horizontal scrollbar sits at the BOTTOM, and the
   capped height keeps the sticky header (month names) on screen while you scroll rows. */
.ov-wrap {
  overflow: auto; max-height: calc(100vh - 210px);
  border: 1px solid #e5e0f5; border-radius: 10px; width: 100%; background: #fff;
}
.ov-wrap::-webkit-scrollbar { height: 12px; width: 12px; }
.ov-wrap::-webkit-scrollbar-track { background: #f3f0ff; }
.ov-wrap::-webkit-scrollbar-thumb { background: #c4b5fd; border-radius: 10px; border: 2px solid #f3f0ff; }
.ov-wrap::-webkit-scrollbar-thumb:hover { background: #a78bda; }
/* border-collapse: separate keeps borders attached to sticky cells (collapse drops them on scroll). */
.ov-table { border-collapse: separate; border-spacing: 0; font-size: 11px; white-space: nowrap; width: 100%; }

/* Sticky property column. The header cell is the corner — sticky on BOTH axes (stays top-left). */
.ov-table th.prop-col {
  text-align: left; position: sticky; left: 0; top: 0; z-index: 5; background: #f3f0ff;
  min-width: 180px; padding: 6px 12px; font-size: 9px; font-weight: 700; color: #6b7280;
  text-transform: uppercase; letter-spacing: 0.04em; border-right: 2px solid #e5e0f5; border-bottom: 2px solid #e5e0f5;
}
.ov-table td.prop-cell {
  text-align: left; font-weight: 600; font-size: 13px; color: #111827; position: sticky; left: 0;
  background: #fff; border-right: 2px solid #e5e0f5; z-index: 1; padding: 8px 12px;
  min-width: 180px; max-width: 220px; overflow: hidden; text-overflow: ellipsis;
}
.ov-table td.prop-cell .prop-launch { font-size: 10px; font-weight: 500; color: #9ca3af; }
.ov-table tr:hover td.prop-cell { background: #f9f8ff; }

/* Year + month headers — sticky to the top so month names stay visible when scrolling rows.
   The two header rows stack: year row at top:0 (height 22px), month row at top:22px. */
.ov-table thead th { position: sticky; z-index: 2; }
.ov-table th.year-header {
  top: 0; height: 22px;
  text-align: center; background: #ede9fe; color: #5b21b6; font-size: 10px; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase; border-bottom: 1px solid #c4b5fd;
  border-left: 2px solid #c4b5fd; padding: 4px 0; cursor: pointer; user-select: none;
}
.ov-table th.year-header:hover { background: #ddd6fe; }
/* Collapsed (hidden) year — a narrow clickable strip */
.ov-table th.year-collapsed, .ov-table th.mo-head.year-collapsed { min-width: 34px; cursor: pointer; }
.ov-table th.mo-head.year-collapsed { color: #6d28d9; font-size: 13px; background: #f3f0ff; }
.ov-table th.mo-head.year-collapsed:hover { background: #ede9fe; }
.ov-table td.year-collapsed-cell { min-width: 34px; cursor: pointer; background: #faf9ff; }
.ov-table tr:hover td.year-collapsed-cell { background: #f3f0ff; }
.ov-table th.mo-head {
  top: 22px;
  text-align: center; background: #f3f0ff; color: #6b7280; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; padding: 5px 8px;
  border-right: 1px solid #e5e0f5; border-bottom: 2px solid #e5e0f5; min-width: 88px;
}
.ov-table th.mo-head.cur-mo { background: #ede9fe; color: #5b21b6; }
.ov-table th.mo-head.future-mo { color: #9ca3af; }
.ov-table th.mo-head.year-start { border-left: 2px solid #c4b5fd; }
.ov-badge-cur { font-size: 8px; background: #6d28d9; color: #fff; border-radius: 4px; padding: 1px 4px; margin-left: 4px; vertical-align: middle; }

/* Data cells */
.ov-table td.mo-cell { text-align: center; padding: 5px 8px; border-right: 1px solid #f3f0ff; border-bottom: 1px solid #f3f0ff; vertical-align: middle; }
.ov-table td.mo-cell.year-start { border-left: 2px solid #e5e0f5; }
.ov-table td.mo-cell.cur-mo-cell { background: #faf8ff; }
.ov-table tr:hover td { background: #f9f8ff; }
.ov-table tr:hover td.prop-cell { background: #f3f0ff; }
.ov-rev { font-size: 13px; font-weight: 700; color: #111827; line-height: 1.3; }
.ov-sub { font-size: 11px; color: #9ca3af; line-height: 1.3; }
.ov-empty { color: #d1d5db; font-size: 13px; }
.ov-future .ov-rev { color: #9ca3af; }
.ov-future .ov-sub { color: #c4c4c4; }
.ov-fb { color: #b45309; font-weight: 700; cursor: help; }

/* ── Pacing tab ── */
.pac-controls { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.pac-controls label { font-size: 12px; color: #6b7280; }
.pac-select {
  font-size: 13px; padding: 7px 10px; border: 1px solid #e5e0f5; border-radius: 8px;
  background: #fff; color: #111827; outline: none; cursor: pointer;
}
.pac-select:focus { border-color: #c4b5fd; }
.pac-prop-select { min-width: 220px; }
.pac-controls .pac-sep { color: #d1d5db; }

.pac-roll-caption { font-size: 12px; color: #6b7280; margin-bottom: 10px; }
.pac-roll-caption b { color: #5b21b6; font-weight: 700; }

.pac-metrics {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.pac-card { background: #fff; border: 1px solid #e5e0f5; border-radius: 10px; padding: 14px 16px; }
.pac-card-label { font-size: 10px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em; }
.pac-card-val { font-size: 22px; font-weight: 800; color: #111827; margin-top: 6px; line-height: 1.1; }
.pac-card-sub { font-size: 11px; color: #9ca3af; margin-top: 6px; }
.pac-badge { display: inline-block; font-size: 11px; font-weight: 700; border-radius: 5px; padding: 1px 6px; margin-top: 6px; }
.pac-badge-pos { background: #dcfce7; color: #15803d; }
.pac-badge-neg { background: #fee2e2; color: #b91c1c; }

.pac-status { margin-bottom: 20px; }

.chart-section { background: #f3f0ff; border: 1px solid #e5e0f5; border-radius: 10px; padding: 16px; margin-bottom: 20px; }
.chart-label { font-size: 13px; font-weight: 700; color: #2e1065; margin-bottom: 12px; }
.chart-wrap { position: relative; height: 280px; }

/* ── Forecast tab ─────────────────────────────────────────────────────────── */
.conf-green, .conf-yellow, .conf-red { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.conf-green { background: #22c55e; }
.conf-yellow { background: #eab308; }
.conf-red { background: #ef4444; }

.fc-total {
  background: #6d28d9; color: #fff; border-radius: 12px; padding: 18px 26px;
  display: flex; gap: 36px; align-items: center; margin-bottom: 20px; flex-wrap: wrap;
}
.fc-total-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.8; margin-bottom: 4px; }
.fc-total-val { font-size: 28px; font-weight: 800; line-height: 1.1; }
.fc-total-sub { font-size: 12px; opacity: 0.85; margin-top: 3px; }
.fc-total-comp { border-left: 1px solid rgba(255,255,255,0.3); padding-left: 32px; }

.fc-legend { display: flex; gap: 18px; font-size: 12px; color: #6b7280; margin-bottom: 16px; flex-wrap: wrap; }
.fc-legend > span { display: inline-flex; align-items: center; gap: 6px; }

.fc-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fc-table th {
  text-align: center; padding: 8px 10px; font-weight: 700; color: #6b7280; font-size: 11px;
  border-bottom: 2px solid #e5e0f5; text-transform: uppercase; letter-spacing: 0.04em; background: #f3f0ff;
}
.fc-table th:first-child { text-align: left; }
.fc-table td { padding: 10px; border-bottom: 1px solid #e5e0f5; text-align: center; white-space: nowrap; }
.fc-table td:first-child { text-align: left; font-weight: 600; }
.fc-peak-tag {
  font-size: 9px; font-weight: 700; color: #7c3aed; background: #ede9fe;
  border-radius: 4px; padding: 1px 5px; margin-left: 4px; text-transform: uppercase;
}

/* ── "show math" inline breakdown (ported like-for-like from Austin's renderDbg) ── */
.show-math-btn {
  font-size: 11px; padding: 2px 8px; border: 1px solid #6d28d9; border-radius: 4px;
  background: #fff; cursor: pointer; color: #6d28d9; font-weight: 600; margin-left: 6px;
}
.show-math-btn:hover { background: #f3f0ff; }
.fc-math-row { display: none; }
.fc-math-row > td {
  text-align: left !important; background: #f9f8ff; padding: 14px 18px !important;
  border-left: 3px solid #6d28d9; white-space: normal !important;
  font-size: 12px; line-height: 2; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.math-line-title { font-weight: 700; font-size: 14px; color: #6d28d9; margin-bottom: 6px; }
.math-line-header { font-weight: 700; color: #111827; margin-top: 10px; margin-bottom: 2px; font-size: 13px; }
.math-line-detail { color: #374151; padding-left: 12px; line-height: 2; }
.math-divider { border-top: 1px solid #e5e0f5; margin: 6px 0; }
.fc-math-notes { margin: 0 0 8px 0; padding-left: 16px; font-size: 11px; color: #6b7280; line-height: 1.6; }
.fc-math-done { font-size: 12px; color: #6b7280; font-style: italic; }

/* Pacing mini-bars + calendars row */
.fc-math-flex { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 8px; flex-wrap: wrap; }
.fc-pacing-card { flex: 0 0 auto; background: #f8f7ff; border-radius: 8px; padding: 10px 12px; border: 1px solid #e5e0f5; }
.fc-pacing-h { font-size: 11px; font-weight: 700; color: #6d28d9; margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em; }
.fc-pacing-div { height: 1px; background: #e5e0f5; margin: 8px 0; }
.fc-mini-row { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.fc-mini-lbl { width: 150px; font-size: 11px; color: #6b7280; }
.fc-mini-bar { display: inline-block; height: 10px; border-radius: 2px; vertical-align: middle; }
.fc-mini-val { font-size: 11px; font-weight: 600; color: #111827; min-width: 60px; }

.fc-cal-wrap { flex: 1; min-width: 0; }
.fc-cal-title { font-size: 11px; font-weight: 700; color: #6d28d9; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; text-align: center; }
.fc-cal-row { display: flex; gap: 10px; }
.fc-cal { background: #f8f7ff; border: 1px solid #e5e0f5; border-radius: 8px; padding: 10px; flex: 1; min-width: 0; }
.fc-cal-label { font-size: 11px; font-weight: 700; color: #6d28d9; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; text-align: center; }
.fc-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.fc-cal-dow { text-align: center; font-size: 9px; font-weight: 700; color: #9ca3af; padding: 2px 0; }
.fc-cal-dow.fc-cal-we { background: #f3f0ff; }
.fc-cal-cell { background: #f9f8ff; border-radius: 3px; padding: 3px 1px; text-align: center; min-height: 32px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.fc-cal-cell .fc-cal-day { font-size: 9px; font-weight: 600; color: #d1d5db; }
.fc-cal-cell .fc-cal-rate { font-size: 8px; font-weight: 500; }
.fc-cal-weekend { background: #f3f0ff; }
.fc-cal-bk { background: #6d28d9; }
.fc-cal-bk .fc-cal-day, .fc-cal-bk .fc-cal-rate { color: #fff; }
.fc-cal-peak { background: #fbf3da; }
.fc-cal-peak-bk { background: #fbbf24; }
.fc-cal-peak-bk .fc-cal-day, .fc-cal-peak-bk .fc-cal-rate { color: #5b3d00; }

/* Summary + scenario cards */
.fc-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; padding: 8px 0 4px; }
.fc-card { background: #f3f0ff; border: 1px solid #e5e0f5; border-radius: 8px; padding: 10px 12px; }
.fc-card-peak { background: #faf5ff; border-color: #e9d5ff; }
.fc-card-label { font-size: 10px; color: #6b7280; text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px; }
.fc-card-val { font-size: 16px; font-weight: 700; color: #111827; }
.fc-card-sub { font-size: 11px; color: #9ca3af; margin-top: 2px; }
.fc-occ-note { color: #c4b5fd; }
.fc-card-total { background: #6d28d9; border-color: #6d28d9; }
.fc-card-total .fc-card-label { color: rgba(255, 255, 255, 0.7); }
.fc-card-total .fc-card-val { color: #fff; }
.fc-card-total .fc-card-lo { font-size: 13px; font-weight: 700; color: rgba(255, 255, 255, 0.7); }
.fc-card-total .fc-card-subw { font-size: 10px; color: rgba(255, 255, 255, 0.6); margin-top: 2px; }
.fc-card-low { background: #f87171; border-color: #f87171; }
.fc-card-low .fc-card-label, .fc-card-low .fc-card-val { color: #fff; }
.fc-card-high { background: #059669; border-color: #059669; }
.fc-card-high .fc-card-label, .fc-card-high .fc-card-val { color: #fff; }
.fc-cap-badge {
  display: inline-block; font-size: 9px; font-weight: 700; color: #92400e; background: #fef3c7;
  border: 1px solid #fde68a; border-radius: 3px; padding: 1px 5px; margin-left: 4px; vertical-align: middle;
}
.fc-scen-block { margin-top: 16px; }
.fc-scen-hdr { font-size: 11px; font-weight: 700; color: #6b7280; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; }

/* ── Alerts tab ───────────────────────────────────────────────────────────── */
.alert-row {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 14px;
  background: #fef2f2; border-radius: 8px; border: 1px solid #fecaca; border-left: 3px solid #dc2626;
  margin-bottom: 8px; flex-wrap: wrap; gap: 8px;
}
.alert-name { font-weight: 600; flex: 1; min-width: 120px; color: #111827; }
.alert-meta { display: flex; gap: 12px; align-items: center; font-size: 12px; color: #6b7280; flex-shrink: 0; }
.alert-meta .pac-badge { margin-top: 0; }

/* ── Skeleton loading ─────────────────────────────────────────────────────── */
@keyframes skel-shimmer { 0% { background-position: -300px 0; } 100% { background-position: 300px 0; } }
.skel {
  background: linear-gradient(90deg, #ece9f7 25%, #f5f3ff 37%, #ece9f7 63%);
  background-size: 400% 100%;
  animation: skel-shimmer 1.4s ease infinite;
  border-radius: 6px;
}
.skel-cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.skel-card { height: 78px; }
.skel-row { height: 34px; margin-bottom: 8px; }
.chart-skel { position: absolute; inset: 0; z-index: 1; }
