@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap");

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --orange: #f97316;
  --purple: #c026d3;
  --orange-light: #fdba74;
  --purple-light: #e879f9;
  --bg: #08040f;
  --bg2: #120920;
  --card-bg: rgba(20, 12, 40, 0.78);
  --card-border: rgba(255,255,255,0.07);
  --text: #f1f5f9;
  --text-muted: rgba(255,255,255,0.40);
  --text-dim: rgba(255,255,255,0.22);
  --input-bg: rgba(0,0,0,0.35);
  --input-border: rgba(255,255,255,0.10);
  --radius: 10px;
  --font: 'Space Grotesk', 'Inter', sans-serif;
}

body {
  font-family: var(--font);
  background: linear-gradient(160deg, #0d0517 0%, #180a2e 45%, #1e0a0a 100%);
  min-height: 100vh;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Loading Screen ───────────────────────────────────── */
#loading-screen {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0d0517 0%, #1a0a2e 40%, #2d0a0a 100%);
  transition: opacity 0.6s ease;
}
#loading-screen.hidden { opacity: 0; pointer-events: none; }

.stars {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}
.star {
  position: absolute; border-radius: 50%; background: white;
}

.solar-system {
  position: relative; display: flex; align-items: center; justify-content: center;
  margin-bottom: 2.5rem;
}
.orbit-ring {
  position: absolute;
  transform-origin: center;
}
.orbit-1 { animation: spin 4s linear infinite; }
.orbit-2 { animation: spin-rev 6s linear infinite; }

.solar-core {
  position: absolute;
  width: 72px; height: 72px;
  border-radius: 50%;
  background: radial-gradient(circle, #fbbf24 0%, #f97316 50%, #c026d3 100%);
  box-shadow: 0 0 40px rgba(249,115,22,0.6), 0 0 80px rgba(192,38,211,0.3);
  display: flex; align-items: center; justify-content: center;
  animation: pulse-glow 2s ease-in-out infinite;
}

.loading-title {
  font-size: 3.2rem; font-weight: 700;
  letter-spacing: 0.12em; text-align: center;
  background: linear-gradient(135deg, #f97316, #e879f9);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: fade-up 0.6s ease forwards;
}
.loading-subtitle {
  font-size: 1rem; font-weight: 500; color: rgba(255,255,255,0.70);
  text-align: center; margin-top: 0.5rem;
  animation: fade-up 0.6s 0.2s ease both;
}
.loading-uni {
  font-size: 0.72rem; letter-spacing: 0.15em; text-transform: uppercase;
  color: rgba(255,255,255,0.35); text-align: center; margin-top: 0.25rem;
  animation: fade-up 0.6s 0.5s ease both;
}
.nasa-badge {
  display: inline-flex; align-items: center; gap: 0.5rem;
  margin-top: 1.8rem; padding: 0.5rem 1rem; border-radius: 999px;
  background: rgba(249,115,22,0.14); border: 1px solid rgba(249,115,22,0.38);
  color: #fdba74; font-size: 0.8rem; font-weight: 600;
  animation: fade-up 0.6s 0.8s ease both;
}
.progress-wrap {
  width: 100%; max-width: 260px; margin: 2rem auto 0;
  animation: fade-up 0.6s 1.1s ease both;
}
.progress-label {
  display: flex; justify-content: space-between;
  font-size: 0.65rem; letter-spacing: 0.15em; text-transform: uppercase;
  color: rgba(255,255,255,0.30); margin-bottom: 0.4rem;
}
.progress-track {
  height: 5px; border-radius: 999px; overflow: hidden;
  background: rgba(255,255,255,0.07);
}
.progress-bar {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #f97316, #c026d3);
  animation: progress 7s linear forwards;
}
.loading-credit {
  margin-top: 2.5rem; font-size: 0.65rem;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: rgba(255,255,255,0.20);
  animation: fade-up 0.6s 1.1s ease both;
}

/* ── Header ───────────────────────────────────────────── */
header {
  position: relative; z-index: 10;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  background: rgba(10,5,20,0.82);
  backdrop-filter: blur(20px);
}
.header-glow {
  position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(249,115,22,0.14) 0%, transparent 40%, rgba(192,38,211,0.14) 100%);
}
.header-inner {
  max-width: 1280px; margin: 0 auto; padding: 1rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between;
  position: relative;
}
.logo-icon {
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  filter: drop-shadow(0 0 10px rgba(249,115,22,0.55)) drop-shadow(0 0 18px rgba(168,85,247,0.35));
}
.logo-icon svg { color: white; }
.logo-text h1 {
  font-size: 1.35rem; font-weight: 700; letter-spacing: 0.16em;
  background: linear-gradient(135deg, #f97316, #e879f9);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.logo-text p {
  font-size: 0.65rem; color: rgba(255,255,255,0.40);
  letter-spacing: 0.12em; text-transform: uppercase; margin-top: 2px;
}
.header-badges { display: flex; align-items: center; gap: 0.6rem; }
.badge-nasa {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.75rem; border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  background: rgba(249,115,22,0.12); border: 1px solid rgba(249,115,22,0.35); color: #fdba74;
}
.badge-makers {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.3rem 0.75rem; border-radius: 999px; font-size: 0.72rem;
  background: rgba(192,38,211,0.12); border: 1px solid rgba(192,38,211,0.3); color: #e879f9;
}
@media (max-width: 640px) { .badge-makers { display: none; } }

/* ── Info bar ─────────────────────────────────────────── */
.info-bar {
  padding: 0.4rem 1.5rem; text-align: center; font-size: 0.68rem;
  color: rgba(255,255,255,0.35);
  background: linear-gradient(90deg, rgba(249,115,22,0.06), rgba(192,38,211,0.06));
  border-bottom: 1px solid rgba(255,255,255,0.04);
  display: flex; align-items: center; justify-content: center; gap: 0.4rem;
}

/* ── Main Layout ──────────────────────────────────────── */
main {
  max-width: 1280px; margin: 0 auto; padding: 1.5rem;
  display: grid; grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 1024px) {
  main { grid-template-columns: 4fr 3fr 5fr; }
}

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  backdrop-filter: blur(16px);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.card-title {
  font-size: 0.88rem; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 0.5rem;
}
.card-title svg { flex-shrink: 0; }
.card-desc {
  font-size: 0.68rem; color: var(--text-muted); margin-top: 0.2rem;
}
.card-body { padding: 1rem 1.25rem; }

/* ── Map ──────────────────────────────────────────────── */
#map {
  height: 320px; border-radius: 8px; overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
}
.ghi-status {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 1rem; padding-top: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.ghi-label { font-size: 0.68rem; color: var(--text-muted); letter-spacing: 0.08em; text-transform: uppercase; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.status-ready { color: #34d399; }
.status-ready .status-dot { background: #34d399; }
.status-loading { color: rgba(249,115,22,0.8); }
.status-loading .status-dot { background: #f97316; animation: ping 1s ease-in-out infinite; }
.status-pending { color: var(--text-dim); }
.coord-display { font-size: 0.65rem; color: var(--text-dim); margin-top: 0.4rem; }

/* ── Form ─────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 0.3rem; margin-bottom: 1rem; }
.field:last-of-type { margin-bottom: 0; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1rem; }
label {
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted);
}
input[type="number"] {
  background: var(--input-bg); border: 1px solid var(--input-border);
  border-radius: 6px; padding: 0.5rem 0.75rem;
  color: var(--text); font-size: 0.88rem; font-family: var(--font);
  width: 100%; outline: none;
  transition: border-color 0.2s;
}
input[type="number"]:focus { border-color: rgba(249,115,22,0.5); }
.divider { border-top: 1px solid rgba(255,255,255,0.07); margin: 0.75rem 0; }

.btn-analyze {
  width: 100%; height: 46px; border: none; border-radius: 8px;
  font-family: var(--font); font-size: 0.88rem; font-weight: 700;
  letter-spacing: 0.08em; color: white; cursor: pointer;
  background: linear-gradient(135deg, #f97316, #c026d3);
  box-shadow: 0 0 20px rgba(249,115,22,0.3);
  transition: opacity 0.2s, transform 0.1s;
  margin-top: 0.75rem;
}
.btn-analyze:hover:not(:disabled) { opacity: 0.92; transform: translateY(-1px); }
.btn-analyze:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Results ──────────────────────────────────────────── */
.results-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 480px; text-align: center; padding: 3rem;
}
.placeholder-icon {
  width: 60px; height: 60px; border-radius: 14px;
  background: rgba(249,115,22,0.08); border: 1px solid rgba(249,115,22,0.15);
  display: flex; align-items: center; justify-content: center; margin-bottom: 1.2rem;
}
.placeholder-title { font-size: 1rem; font-weight: 600; color: rgba(255,255,255,0.65); margin-bottom: 0.5rem; }
.placeholder-body { font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; max-width: 280px; }
.placeholder-note { display: flex; align-items: center; gap: 0.4rem; margin-top: 1.2rem; font-size: 0.68rem; color: rgba(249,115,22,0.5); }

.spinner-wrap {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 480px; gap: 1rem;
}
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid transparent;
  border-top-color: #f97316; border-bottom-color: #c026d3;
  animation: spin 0.8s linear infinite;
}
.spinner-text { font-size: 0.78rem; color: var(--text-muted); letter-spacing: 0.06em; }

.results-header {
  padding: 0.9rem 1.25rem; display: flex; align-items: center; justify-content: space-between;
  background: linear-gradient(90deg, rgba(249,115,22,0.07), rgba(192,38,211,0.07));
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.results-title { font-size: 0.88rem; font-weight: 600; }
.badge-payback {
  font-size: 0.68rem; font-weight: 700; padding: 0.25rem 0.75rem;
  border-radius: 999px;
}
.badge-excellent { background: rgba(16,185,129,0.18); color: #34d399; border: 1px solid rgba(16,185,129,0.3); }
.badge-good { background: rgba(59,130,246,0.18); color: #60a5fa; border: 1px solid rgba(59,130,246,0.3); }
.badge-moderate { background: rgba(245,158,11,0.18); color: #fbbf24; border: 1px solid rgba(245,158,11,0.3); }
.badge-poor { background: rgba(239,68,68,0.18); color: #f87171; border: 1px solid rgba(239,68,68,0.3); }

.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid rgba(255,255,255,0.07); }
.kpi-cell {
  padding: 0.85rem 1.1rem;
  border-right: 1px solid rgba(255,255,255,0.07);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.kpi-cell:nth-child(even) { border-right: none; }
.kpi-cell:nth-last-child(-n+2) { border-bottom: none; }
.kpi-label { font-size: 0.62rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 0.2rem; }
.kpi-value { font-size: 1.2rem; font-weight: 700; }
.kpi-unit { font-size: 0.7rem; font-weight: 400; color: var(--text-muted); margin-left: 2px; }
.kpi-orange { color: #f97316; }
.kpi-purple { color: #c026d3; }
.kpi-green { color: #10b981; }

/* ── Gauge ────────────────────────────────────────────── */
.gauge-section {
  padding: 0.9rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.07);
  display: flex; flex-direction: column; align-items: center;
}
.gauge-title { font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-muted); margin-bottom: 0.5rem; }
#gauge-svg { overflow: visible; }
.gauge-legend { display: flex; gap: 0.75rem; flex-wrap: wrap; justify-content: center; margin-top: 0.5rem; }
.gauge-legend-item { display: flex; align-items: center; gap: 4px; font-size: 0.65rem; color: rgba(255,255,255,0.55); }
.legend-dot { width: 8px; height: 8px; border-radius: 2px; }

/* ── Chart ────────────────────────────────────────────── */
.chart-section { padding: 1rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.07); }
.section-title { font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-muted); margin-bottom: 0.75rem; }
#monthly-chart { width: 100%; height: 200px; }

/* ── Table ────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead { background: rgba(249,115,22,0.06); }
th {
  font-size: 0.62rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--text-muted); padding: 0.6rem 0.9rem; text-align: right;
}
th:first-child { text-align: left; }
td { font-size: 0.78rem; color: rgba(255,255,255,0.65); padding: 0.5rem 0.9rem; text-align: right; border-bottom: 1px solid rgba(255,255,255,0.04); }
td:first-child { text-align: left; font-weight: 500; color: rgba(255,255,255,0.75); }
.td-orange { color: #f97316; font-weight: 600; }
.tr-total { background: rgba(249,115,22,0.05); }
.tr-total td { font-weight: 700; color: rgba(255,255,255,0.8); border-bottom: none; }
.tr-total .td-orange { color: #f97316; }

/* ── Footer ───────────────────────────────────────────── */
footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  background: rgba(5,2,12,0.6);
  padding: 1rem 1.5rem;
}
.footer-inner {
  max-width: 1280px; margin: 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  text-align: center;
}
@media (min-width: 640px) { .footer-inner { flex-direction: row; justify-content: space-between; text-align: left; } }
.footer-left { font-size: 0.65rem; color: rgba(255,255,255,0.22); display: flex; align-items: center; gap: 0.4rem; }
.footer-right { font-size: 0.65rem; color: rgba(255,255,255,0.18); }
.footer-right strong { color: rgba(255,255,255,0.32); letter-spacing: 0.1em; }

/* ── Animations ───────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-rev { to { transform: rotate(-360deg); } }
@keyframes pulse-glow {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes progress {
  from { width: 0; }
  to { width: 100%; }
}
@keyframes ping {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.5; }
}
