:root {
  --bg: #000000;
  --surface: #1C1C1E;
  --surface-2: #2C2C2E;
  --text: #F5F5F7;
  --text-secondary: #A1A1A6;
  --primary: #5B47FB;
  --primary-dark: #7c6bfa;
  --accent: #34d399;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --border: #38383A;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-accent: 0 4px 16px rgba(91, 71, 251, 0.20);
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Sticky header wrapper */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg);
}

/* Top navigation */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  background: rgba(0, 0, 0, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  position: relative;
}

.topnav-left {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  min-width: 0;
}

.brand > :not(.logo-wrap) {
  min-width: 0;
}

.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--surface);
  padding: 4px;
  border-radius: 999px;
}

.view-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.view-btn:hover {
  color: var(--text);
}

.view-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-accent);
}

.logo-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.logo-img {
  height: 40px;
  width: 40px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  display: block;
  object-fit: cover;
}

.version-pill {
  display: inline-block;
  background: var(--primary);
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 8px;
  box-shadow: var(--shadow-accent);
  white-space: nowrap;
}

.brand-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  min-width: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.tabs {
  display: flex;
  gap: 12px;
  background: var(--surface);
  padding: 8px 10px;
  border-radius: 999px;
  min-width: 0;
  flex: 1;
  overflow-x: auto;
  flex-wrap: nowrap;
}

.tab {
  flex-shrink: 0;
  padding: 8px 20px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-accent);
}

.tab-custom {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 4px;
  flex-shrink: 0;
}

.tab-custom input {
  width: 72px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
  outline: none;
}

.tab-custom input:focus {
  border-color: var(--primary);
}

.tab-custom button {
  padding: 5px 10px;
  border: none;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-custom button:hover {
  background: var(--primary);
  color: #ffffff;
}

#watchlist-input {
  width: 8.5rem;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: none;
  outline: none;
}

#watchlist-input:hover,
#watchlist-input:focus {
  border-color: var(--primary);
}

@media (max-width: 1100px) {
  .topnav {
    flex-wrap: wrap;
  }
  .tabs {
    flex: 1 1 100%;
  }
}

/* Scenario bar */
.scenario-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.scenario-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.scenario-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-right: 4px;
}

.scenario-btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

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

.scenario-btn.active {
  background: var(--primary);
  color: #ffffff;
  border-color: transparent;
  box-shadow: var(--shadow-accent);
}

.scenario-bar [data-sdc-set] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

.scenario-bar [data-sdc-set].active .sdc-set-name {
  color: #ffffff;
}

.sdc-set-name {
  pointer-events: none;
}

.sdc-set-name-input {
  background: var(--bg);
  border: 1px solid var(--primary);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 2px 8px;
  width: 120px;
  text-align: center;
  outline: none;
}

.scenario-btn.save-btn {
  background: var(--surface-2);
  border-style: dashed;
}

.scenario-btn.save-btn:hover {
  background: var(--primary);
  color: #ffffff;
  border-style: solid;
}

.scenario-select {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
}

.scenario-select:hover,
.scenario-select:focus {
  border-color: var(--primary);
}

/* Main content */
.main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  margin: 0;
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.ticker {
  margin: 4px 0 0;
  color: var(--primary);
  font-weight: 600;
  font-size: 0.95rem;
}

.last-updated {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Status */
.status {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  display: none;
  font-weight: 500;
}

.status.error { background: rgba(248, 113, 113, 0.15); color: #fecaca; display: block; border: 1px solid rgba(248, 113, 113, 0.3); }
.status.info { background: rgba(91, 71, 251, 0.15); color: #C4B5FD; display: block; border: 1px solid rgba(91, 71, 251, 0.3); }
.status.success { background: rgba(52, 211, 153, 0.15); color: #a7f3d0; display: block; border: 1px solid rgba(52, 211, 153, 0.3); }

.delisted-banner {
  display: block;
  padding: 32px 24px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  background: rgba(248, 113, 113, 0.12);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: #fecaca;
  text-align: center;
}
.delisted-banner h2 {
  margin: 0 0 12px;
  font-size: 1.5rem;
}
.delisted-banner p {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.5;
}
.delisted-banner.hidden { display: none; }

.dcf-na-banner {
  display: block;
  padding: 20px 24px;
  border-radius: var(--radius);
  margin-bottom: 24px;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
  text-align: center;
}
.dcf-na-banner h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
  color: #fbbf24;
}
.dcf-na-banner p {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.55;
  color: #fef3c7;
}
.dcf-na-banner.hidden { display: none; }

/* Cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}

.card:hover { transform: translateY(-2px); }

.card.highlight {
  background: rgba(91, 71, 251, 0.12);
  border-color: rgba(91, 71, 251, 0.35);
}

.card .label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.card .value {
  font-size: 1.75rem;
  font-weight: 800;
}

.card .sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Sections */
section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

section h2 {
  margin: 0 0 20px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Reference metrics */
.reference-metrics .cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
}

.metric-card {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 16px;
}

.metric-card .label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.metric-card .value {
  font-size: 1.35rem;
  font-weight: 700;
}

.metric-card .sub {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

/* Two column layout */
.two-col {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

@media (max-width: 1024px) {
  .two-col { grid-template-columns: 1fr; }
}

/* Assumptions */
.assumption-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.detail-inputs {
  margin-bottom: 16px;
}

.field {
  display: flex;
  flex-direction: column;
}

.field label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  font-weight: 500;
}

.field input[type="number"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input[type="number"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 71, 251, 0.15);
}

.pct-field {
  position: relative;
}

.pct-field input {
  padding-right: 28px;
}

.pct-field::after {
  content: '%';
  position: absolute;
  right: 12px;
  bottom: 10px;
  color: var(--text-secondary);
  font-weight: 600;
  pointer-events: none;
}

.toggle-field {
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

.toggle-field input {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

.actions {
  margin-top: 20px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
}

button:hover {
  background: var(--border);
}

button.primary {
  background: var(--primary);
  color: #ffffff;
  border: none;
}

button.primary:hover {
  opacity: 0.9;
}

/* ---- Save status bar (DCF + Special Views) ---- */
.save-status-bar {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0 10px;
  padding: 10px 12px;
  border-radius: var(--radius, 8px);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--text-secondary);
  transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.save-status-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.25rem;
  font-weight: 800;
  line-height: 1;
}

.save-status-text {
  flex: 1 1 auto;
}

.save-status-saved {
  border-color: rgba(52, 211, 153, 0.55);
  background: rgba(52, 211, 153, 0.1);
  color: var(--text);
}

.save-status-saved .save-status-icon {
  color: #059669;
}

.save-status-saving {
  border-color: rgba(91, 71, 251, 0.5);
  background: rgba(91, 71, 251, 0.08);
}

.save-status-unsaved {
  border-color: rgba(251, 191, 36, 0.65);
  background: rgba(251, 191, 36, 0.12);
  color: var(--text);
}

.save-status-unsaved .save-status-icon {
  color: #d97706;
}

.save-status-defaults {
  border-color: var(--border);
  background: var(--surface);
}

.save-status-flash {
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.45);
}

button.reset-defaults-btn,
#neo-reset-defaults,
#spcx-reset-defaults {
  border: 1px solid var(--border);
}

button.reset-defaults-btn.reset-available,
#neo-reset-defaults.reset-available,
#spcx-reset-defaults.reset-available {
  border-color: rgba(52, 211, 153, 0.55);
  font-weight: 600;
}

/* Special View ↔ DCF sticky link button (neo cloud + SPCX) */
button.dcf-link-btn,
.scenario-btn.dcf-link-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.25;
  padding: 10px 14px;
  text-align: left;
  max-width: 280px;
  cursor: pointer;
}

.dcf-link-btn .dcf-link-main {
  font-weight: 700;
  font-size: 0.92rem;
}

.dcf-link-btn .dcf-link-sub {
  font-weight: 500;
  font-size: 0.72rem;
  opacity: 0.85;
  letter-spacing: 0.01em;
}

/* Linked = green sticky state (still clickable to unlink) */
button.apply-success,
.scenario-btn.apply-success,
button.primary.apply-success,
button.dcf-link-linked,
.scenario-btn.dcf-link-linked {
  background: linear-gradient(135deg, #34d399, #059669) !important;
  color: #000000 !important;
  border: none !important;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.45);
  cursor: pointer;
}

button.dcf-link-linked:hover,
.scenario-btn.dcf-link-linked:hover {
  opacity: 0.92;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.7);
}

/* Unlinked = standard primary blue */
button.dcf-link-unlinked,
.scenario-btn.dcf-link-unlinked {
  cursor: pointer;
}

.apply-success-msg {
  color: #34d399 !important;
  font-weight: 600;
  margin-top: 8px;
}

.dcf-link-status-unlinked {
  color: var(--text-secondary) !important;
  font-weight: 500;
  margin-top: 8px;
}

.hint {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 16px;
  margin-bottom: 0;
}

.live-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--accent);
  color: var(--bg);
  padding: 2px 6px;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 4px;
  opacity: 0;
  transition: opacity 0.3s;
}

.live-badge.visible {
  opacity: 1;
}

/* Tables */
.table-wrapper {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th, td {
  padding: 10px 12px;
  border: 1px solid var(--border);
  text-align: right;
  white-space: nowrap;
}

th:first-child, td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--surface);
  z-index: 1;
}

th {
  background: var(--surface-2);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.03); }
tbody tr:hover { background: rgba(255, 255, 255, 0.06); }

.forecast { background: rgba(91, 71, 251, 0.08) !important; }
.forecast td:first-child { background: rgba(91, 71, 251, 0.08); }

.table-input {
  width: 100%;
  min-width: 70px;
  padding: 4px 6px;
  border: 1px solid var(--primary);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  text-align: right;
}

.table-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(91, 71, 251, 0.3);
}

/* Detail table */
.detail-table td:first-child {
  font-weight: 500;
  text-align: left;
  color: var(--text-secondary);
}

.detail-table td:last-child {
  text-align: right;
  font-weight: 600;
}

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.chart-box {
  position: relative;
  height: 300px;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 12px;
}

/* Sensitivity */
.sensitivity .hint {
  margin-top: -12px;
  margin-bottom: 16px;
}

.sensitivity th:first-child,
.sensitivity td:first-child {
  text-align: center;
  background: var(--surface-2);
  font-weight: 600;
}

.positive { color: var(--accent); }
.negative { color: var(--danger); }

/* View switching */
.view-content.hidden {
  display: none;
}

/* Special view - Space Data Center model */
.special-desc {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.special-grid {
  display: grid;
  grid-template-columns: 1.5fr 340px 340px;
  gap: 20px;
  align-items: start;
  margin-bottom: 24px;
}

@media (max-width: 1100px) {
  .special-grid {
    grid-template-columns: 1fr;
  }
}

.special-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.special-card h3 {
  margin: 0 0 16px 0;
  font-size: 1rem;
  color: var(--primary);
}

.sdc-card-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sdc-card-subhead {
  margin: 16px 0 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.special-card .field {
  margin-bottom: 14px;
}

.special-card .field:last-child {
  margin-bottom: 0;
}

.special-card label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.special-card input[type="number"] {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
}

.special-card .computed {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.special-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.special-results h3 {
  margin: 32px 0 16px 0;
  color: var(--primary);
}

.special-results h3:first-child {
  margin-top: 0;
}

.special-results p.special-desc {
  margin-top: -10px;
  margin-bottom: 16px;
}

.waterfall-table {
  max-width: 520px;
}

.waterfall-table td.indent {
  padding-left: 28px;
  color: var(--text-secondary);
}

.waterfall-table .total-row td {
  border-top: 2px solid var(--primary);
  font-weight: 700;
  color: var(--text);
}

.waterfall-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.waterfall-table td.num.negative {
  color: var(--danger);
}

.waterfall-table td.num.positive {
  color: var(--success);
}

.waterfall-table .spacer-row td {
  border-bottom: none;
  height: 8px;
  padding: 0;
}

.sdc-waterfall-row {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.sdc-waterfall-col h3 {
  margin-top: 0;
}

.sdc-waterfall-viz {
  padding-top: 0;
}

@media (max-width: 900px) {
  .sdc-waterfall-row {
    grid-template-columns: 1fr;
  }
  .sdc-waterfall-viz {
    padding-top: 0;
  }
}

.special-results table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.special-results th,
.special-results td {
  padding: 10px 12px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.special-results th:first-child,
.special-results td:first-child {
  text-align: left;
}

.special-results th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.special-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.special-summary .metric {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.special-summary .metric .label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.special-summary .metric .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.neo-mix-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
}

@media (max-width: 640px) {
  .neo-mix-grid {
    grid-template-columns: 1fr;
  }
}

.neo-mix-grid .field {
  margin-bottom: 0;
}

.neo-capacity-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin-top: 8px;
}

.neo-capacity-stats .neo-stat {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.neo-footnote {
  margin-top: 14px;
  font-size: 0.85rem;
  opacity: 0.85;
}

.neo-fcf-footnote {
  margin-top: 20px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 0.85rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.neo-fcf-footnote-title {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text);
}

.neo-fcf-footnote p {
  margin: 0 0 10px;
}

.neo-fcf-footnote p:last-child {
  margin-bottom: 0;
}

.neo-fcf-footnote-rules {
  font-size: 0.8rem;
  opacity: 0.95;
}

/* SDC cost build-up visualization */
.sdc-buildup-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  align-items: start;
}

.sdc-buildup-right {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sdc-viz-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.sdc-viz-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 12px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sdc-donut-svg {
  width: 100%;
  height: auto;
  max-height: 220px;
}

.sdc-donut-total {
  font-size: 1.25rem;
  font-weight: 700;
  fill: var(--text);
}

.sdc-donut-unit {
  font-size: 0.7rem;
  fill: var(--text-secondary);
}

.sdc-cost-legend {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
  margin-top: 12px;
}

.sdc-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sdc-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sdc-legend-value {
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.sdc-legend-pct {
  margin-left: auto;
  font-weight: 600;
  color: var(--text-secondary);
}

.sdc-bar-svg {
  width: 100%;
  height: auto;
  max-height: 180px;
}

.sdc-bar-label {
  font-size: 0.7rem;
  font-weight: 600;
  fill: var(--text);
}

.sdc-bar-axis {
  font-size: 0.75rem;
  fill: var(--text-secondary);
}

.sdc-assumptions {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  margin: 12px 0 20px;
}

.sdc-assumptions h4 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: var(--text);
}

.sdc-assumptions ul {
  margin: 0;
  padding-left: 18px;
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.55;
}

.sdc-assumptions li {
  margin-bottom: 4px;
}

.sdc-assumption-limit {
  color: var(--danger, #ff6b6b);
}

.sdc-realization-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.sdc-realization-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sdc-realization-label {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.sdc-realization-cell input[type="number"] {
  width: 100%;
  padding: 6px 4px;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
}

.sdc-launch-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.sdc-launch-cell input[type="number"] {
  min-width: 0;
  width: 100%;
  padding: 5px 4px;
  font-size: 0.85rem;
  text-align: center;
}

.sdc-gw-deployed-input {
  width: 70px;
  padding: 4px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  text-align: right;
}

.sdc-decay-input {
  width: 60px;
  padding: 4px 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  text-align: right;
}

.special-results table td.editable {
  padding: 6px 8px;
}

@media (max-width: 900px) {
  .sdc-buildup-layout {
    grid-template-columns: 1fr;
  }
  .sdc-buildup-right {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sdc-viz-card {
    flex: 1 1 280px;
  }
  .sdc-realization-grid {
    grid-template-columns: repeat(5, 1fr);
  }
  .sdc-launch-grid {
    grid-template-columns: repeat(3, minmax(90px, 1fr));
  }
}

/* Footer */
footer {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  padding: 24px;
  border-top: 1px solid var(--border);
}

/* Mobile */
@media (max-width: 768px) {
  .topnav {
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }
  .main { padding: 16px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .page-header h1 { font-size: 1.5rem; }
  .summary-cards { grid-template-columns: 1fr 1fr; }
  .card .value { font-size: 1.35rem; }
  .chart-box { height: 240px; }
  .sdc-launch-grid {
    grid-template-columns: repeat(2, minmax(90px, 1fr));
  }
}

/* SPCX business-segment revenue forecast */
.spcx-biz-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.spcx-biz-card h4 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1rem;
}

.spcx-biz-table input,
.spcx-biz-table .spcx-biz-base-fixed {
  width: 80px;
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 6px;
  text-align: right;
  font-size: 0.85rem;
}

.spcx-biz-table .spcx-biz-base-fixed {
  display: inline-block;
  background: transparent;
  border: none;
  padding-right: 6px;
}

.spcx-biz-total-card {
  margin-top: 24px;
}

.spcx-master-map {
  margin-top: 24px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.spcx-master-map h4 {
  margin: 0 0 4px;
}

.spcx-master-map-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.spcx-master-map-row label {
  font-weight: 500;
}

.spcx-master-map-row select {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}

@media (max-width: 900px) {
  .spcx-biz-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Member auth / cloud sync chrome --- */
.auth-chrome {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: 0.75rem;
  flex-shrink: 0;
}
.auth-badge {
  font-size: 0.72rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-link-btn {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
}
.auth-link-btn:hover { text-decoration: underline; }
.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.auth-gate.hidden { display: none !important; }
.auth-gate-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  max-width: 420px;
  text-align: center;
  box-shadow: var(--shadow);
}
.auth-gate-card h2 { margin-top: 0; }
.auth-primary-btn {
  margin-top: 1rem;
  background: var(--primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font-weight: 600;
  cursor: pointer;
}
.auth-primary-btn:hover { background: var(--primary-dark); color: #fff; }

/* --- Account menu (top-right button → unfold panel) --- */
.account-menu {
  position: relative;
  flex: 0 0 auto;
  margin-left: auto;
  z-index: 120;
}
.account-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  max-width: min(280px, 42vw);
  padding: 0.4rem 0.7rem 0.4rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.account-menu-btn:hover {
  border-color: rgba(91, 71, 251, 0.55);
  background: rgba(91, 71, 251, 0.08);
}
.account-menu-btn[aria-expanded="true"] {
  border-color: rgba(91, 71, 251, 0.65);
  box-shadow: 0 0 0 3px rgba(91, 71, 251, 0.12);
}
.account-menu-label {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.account-menu-chevron {
  font-size: 0.7rem;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
  flex-shrink: 0;
}
.account-menu-btn[aria-expanded="true"] .account-menu-chevron {
  transform: rotate(180deg);
}
.account-status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-secondary);
  box-shadow: 0 0 0 3px rgba(148, 163, 184, 0.2);
}
.account-menu-btn.account-status-connected .account-status-dot,
.account-status.account-status-connected .account-status-dot {
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.25);
}
.account-menu-btn.account-status-local .account-status-dot,
.account-menu-btn.account-status-unpaid .account-status-dot,
.account-status.account-status-local .account-status-dot,
.account-status.account-status-unpaid .account-status-dot {
  background: var(--warning);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.2);
}
.account-menu-btn.account-status-loading .account-status-dot,
.account-status.account-status-loading .account-status-dot {
  background: var(--primary);
  animation: account-pulse 1.2s ease-in-out infinite;
}
.account-menu-btn.account-status-error .account-status-dot,
.account-status.account-status-error .account-status-dot {
  background: var(--danger);
}
@keyframes account-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Unfolded panel (dropdown under the button) */
.account-status {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(380px, calc(100vw - 24px));
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  font-size: 0.85rem;
  z-index: 130;
}
.account-status.is-open {
  display: flex;
}
.account-status-main {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  min-width: 0;
}
.account-status-title {
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  word-break: break-word;
}
.account-status-detail {
  color: var(--text-secondary);
  font-size: 0.78rem;
  line-height: 1.4;
  margin-top: 0.25rem;
}
.account-status-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.account-pill {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2, rgba(148, 163, 184, 0.08));
  color: var(--text-secondary);
  white-space: nowrap;
}
.account-pill-ok {
  border-color: rgba(52, 211, 153, 0.45);
  color: #6ee7b7;
  background: rgba(52, 211, 153, 0.12);
}
.account-pill-warn {
  border-color: rgba(251, 191, 36, 0.45);
  color: #fcd34d;
  background: rgba(251, 191, 36, 0.12);
}
.account-pill-muted {
  opacity: 0.9;
}
.account-status-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding-top: 0.15rem;
  border-top: 1px solid var(--border);
}
.auth-bar-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 0.75rem;
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  cursor: pointer;
}
.auth-bar-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.auth-bar-btn-primary {
  background: rgba(91, 71, 251, 0.15);
  border-color: rgba(91, 71, 251, 0.45);
  color: var(--primary);
  font-weight: 600;
}
.auth-bar-btn-primary:hover {
  background: rgba(91, 71, 251, 0.28);
  color: #fff;
}
.account-status.account-status-connected {
  border-color: rgba(52, 211, 153, 0.35);
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.1), var(--surface) 40%);
}
.account-status.account-status-local,
.account-status.account-status-unpaid {
  border-color: rgba(251, 191, 36, 0.35);
  background: linear-gradient(180deg, rgba(251, 191, 36, 0.1), var(--surface) 40%);
}
.account-menu-btn.account-status-connected {
  border-color: rgba(52, 211, 153, 0.4);
}
.account-menu-btn.account-status-local,
.account-menu-btn.account-status-unpaid {
  border-color: rgba(251, 191, 36, 0.4);
}

@media (max-width: 900px) {
  .account-menu-label {
    max-width: 9rem;
  }
}
@media (max-width: 720px) {
  .account-menu {
    order: 3;
  }
  .account-menu-label {
    max-width: 6.5rem;
  }
  .account-status {
    position: fixed;
    top: auto;
    right: 12px;
    left: 12px;
    width: auto;
  }
}
