:root {
  color-scheme: dark;
  --bg: #040711;
  --panel: rgba(12, 19, 38, 0.82);
  --panel-strong: rgba(15, 25, 50, 0.95);
  --line: rgba(139, 180, 255, 0.18);
  --text: #edf4ff;
  --muted: #97a7c6;
  --cyan: #63dcff;
  --blue: #5d7cff;
  --violet: #a26dff;
  --pink: #ff72c6;
  --green: #4ce0a4;
  --yellow: #ffd166;
  --red: #ff6b7a;
  --shadow: 0 28px 80px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 20%, rgba(82, 76, 255, 0.13), transparent 34%),
    radial-gradient(circle at 86% 12%, rgba(255, 77, 190, 0.10), transparent 28%),
    linear-gradient(140deg, #03050d 0%, #071025 50%, #050713 100%);
  overflow-x: hidden;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

#starfield {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -4;
}

.nebula {
  position: fixed;
  width: 48vw;
  height: 48vw;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .13;
  z-index: -3;
  pointer-events: none;
}
.nebula-one { background: var(--violet); top: -20vw; right: -14vw; }
.nebula-two { background: var(--cyan); bottom: -28vw; left: -18vw; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 270px 1fr; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  border-right: 1px solid var(--line);
  background: rgba(3, 7, 18, 0.78);
  backdrop-filter: blur(22px);
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 24px; }
.brand-logo { width: 52px; height: 52px; object-fit: contain; flex: 0 0 auto; filter: drop-shadow(0 0 14px rgba(91, 212, 255, .45)); }
.brand strong { display: block; letter-spacing: .13em; font-size: .92rem; }
.brand small { color: var(--muted); }
.brand-orbit { width: 42px; height: 42px; border: 1px solid rgba(99, 220, 255, .55); border-radius: 50%; position: relative; box-shadow: 0 0 26px rgba(99, 220, 255, .25); }
.brand-orbit::before { content: ''; position: absolute; inset: 7px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff, #5bd4ff 25%, #4e55d9 70%); }
.brand-orbit span { position: absolute; width: 7px; height: 7px; border-radius: 50%; background: var(--pink); top: 2px; left: 25px; box-shadow: 0 0 10px var(--pink); }

.nav-list { display: grid; gap: 6px; }
.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  padding: 11px 13px;
  text-align: left;
  transition: .2s ease;
}
.nav-item span { width: 24px; color: var(--cyan); font-size: 1.15rem; }
.nav-item:hover { color: var(--text); background: rgba(99, 220, 255, .06); border-color: rgba(99, 220, 255, .12); }
.nav-item.active { color: #fff; background: linear-gradient(90deg, rgba(89, 118, 255, .22), rgba(99, 220, 255, .07)); border-color: rgba(99, 220, 255, .25); box-shadow: inset 3px 0 var(--cyan); }
.sidebar-footer { margin-top: auto; border-top: 1px solid var(--line); padding: 18px 8px 0; display: flex; gap: 10px; align-items: center; }
.sidebar-footer strong, .sidebar-footer small { display: block; }
.sidebar-footer strong { font-size: .82rem; }
.sidebar-footer small { color: var(--muted); font-size: .72rem; }
.status-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 13px var(--green); }

.main-content { min-width: 0; padding: 0 30px 22px; }
.topbar { min-height: 96px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.topbar h1 { margin: 4px 0 0; font-size: clamp(1.45rem, 2vw, 2.1rem); }
.eyebrow { margin: 0; color: var(--cyan); font-size: .72rem; letter-spacing: .16em; font-weight: 800; }
.topbar-actions { display: flex; gap: 10px; }
.menu-toggle { display: none; }

.view { display: none; animation: viewIn .35s ease; }
.active-view { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero-panel {
  min-height: 420px;
  display: grid;
  grid-template-columns: 1.2fr .8fr;
  align-items: center;
  border: 1px solid rgba(99, 220, 255, .2);
  border-radius: 28px;
  overflow: hidden;
  position: relative;
  background:
    linear-gradient(120deg, rgba(12, 20, 42, .96), rgba(12, 17, 38, .68)),
    radial-gradient(circle at 70% 40%, rgba(99, 220, 255, .2), transparent 35%);
  box-shadow: var(--shadow);
}
.hero-panel::after { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 74px, rgba(255,255,255,.015) 75px); pointer-events: none; }
.hero-copy { padding: clamp(34px, 6vw, 72px); position: relative; z-index: 2; }
.hero-copy h2 { font-size: clamp(2.2rem, 5vw, 4.8rem); line-height: .98; max-width: 850px; margin: 18px 0; letter-spacing: -.045em; }
.hero-copy p { color: #b6c5df; font-size: 1.05rem; max-width: 680px; line-height: 1.75; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; color: #bfffe5; background: rgba(76, 224, 164, .09); border: 1px solid rgba(76, 224, 164, .25); border-radius: 999px; padding: 7px 12px; font-size: .72rem; font-weight: 800; letter-spacing: .08em; }
.hero-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }

.primary-button, .secondary-button, .ghost-button, .danger-button, .text-button, .icon-button {
  border-radius: 12px;
  padding: 11px 16px;
  border: 1px solid transparent;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}
.primary-button { background: linear-gradient(135deg, var(--blue), var(--violet)); color: white; box-shadow: 0 12px 30px rgba(93, 124, 255, .28); font-weight: 800; }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 16px 35px rgba(93, 124, 255, .4); }
.secondary-button, .ghost-button { background: rgba(255,255,255,.035); color: var(--text); border-color: var(--line); }
.secondary-button:hover, .ghost-button:hover { background: rgba(99,220,255,.09); }
.danger-button { color: #ffd7dc; background: rgba(255,107,122,.12); border-color: rgba(255,107,122,.25); }
.danger-button.subtle { padding: 9px 12px; }
.text-button { color: var(--cyan); background: transparent; padding: 6px; }
.icon-button { background: rgba(255,255,255,.05); color: white; border-color: var(--line); }
.full-button { width: 100%; margin-top: 14px; }

.hero-visual { min-height: 400px; position: relative; display: grid; place-items: center; }
.planet-main { width: min(260px, 28vw); aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle at 30% 22%, #f8ffff 0 3%, #72d8ff 8%, #2257c9 35%, #172663 70%, #070b25 100%); box-shadow: inset -28px -25px 60px rgba(0,0,0,.55), 0 0 45px rgba(99,220,255,.35), 0 0 110px rgba(93,124,255,.22); position: relative; z-index: 3; animation: floatPlanet 7s ease-in-out infinite; }
.planet-main::before { content: ''; position: absolute; inset: 18% -15%; border: 12px solid rgba(167, 192, 255, .32); border-left-color: rgba(255,255,255,.12); border-right-color: rgba(99,220,255,.65); border-radius: 50%; transform: rotate(-15deg); box-shadow: 0 0 28px rgba(99,220,255,.2); }
.planet-main span { position: absolute; width: 28%; height: 12%; background: rgba(90, 223, 179, .3); border-radius: 60% 40% 50% 30%; left: 25%; top: 42%; filter: blur(1px); }
@keyframes floatPlanet { 50% { transform: translateY(-12px) rotate(2deg); } }
.orbit { position: absolute; border: 1px solid rgba(120,167,255,.25); border-radius: 50%; transform: rotate(-15deg); }
.orbit-a { width: 86%; height: 38%; }
.orbit-b { width: 66%; height: 62%; transform: rotate(38deg); }
.orbit i { position: absolute; width: 10px; height: 10px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 12px var(--pink); animation: orbitDot 6s linear infinite; }
.orbit-a i { top: 42%; left: 1%; }
.orbit-b i { right: 6%; bottom: 20%; background: var(--yellow); box-shadow: 0 0 12px var(--yellow); animation-duration: 8s; }
@keyframes orbitDot { 50% { transform: translate(30px, -18px); } }
.scan-ring { position: absolute; width: 72%; aspect-ratio: 1; border: 1px dashed rgba(99,220,255,.3); border-radius: 50%; animation: spin 18s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 14px; margin: 20px 0; }
.metric-grid.compact { margin-top: 0; }
.metric-card { padding: 20px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgba(18,29,55,.9), rgba(8,13,29,.78)); box-shadow: 0 14px 42px rgba(0,0,0,.18); }
.metric-card small { color: var(--muted); display: block; }
.metric-card strong { display: block; font-size: 2rem; margin: 7px 0 2px; }
.metric-card span { color: var(--cyan); font-size: .78rem; }

.dashboard-grid, .reports-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 18px; }
.panel { border: 1px solid var(--line); border-radius: 20px; background: var(--panel); backdrop-filter: blur(18px); box-shadow: 0 18px 52px rgba(0,0,0,.2); padding: 22px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 18px; }
.panel-heading h3, .panel h3 { margin: 5px 0 0; font-size: 1.2rem; }
.wide-panel { grid-column: 1 / -1; }

.ranking-list { display: grid; gap: 10px; }
.rank-row { display: grid; grid-template-columns: 34px 1fr auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.045); }
.rank-number { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 9px; background: rgba(99,220,255,.10); color: var(--cyan); font-weight: 800; }
.rank-info strong, .rank-info small { display: block; }
.rank-info small { color: var(--muted); margin-top: 3px; }
.rank-value { font-weight: 800; color: #dff8ff; }
.mini-bar { height: 6px; background: rgba(255,255,255,.06); border-radius: 999px; margin-top: 7px; overflow: hidden; }
.mini-bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), var(--cyan)); }

.classification-overview { display: grid; gap: 14px; }
.classification-line { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 10px; }
.classification-line span { color: var(--muted); font-size: .85rem; }
.classification-track { height: 10px; background: rgba(255,255,255,.06); border-radius: 999px; overflow: hidden; }
.classification-track i { display: block; height: 100%; border-radius: inherit; }
.classification-track .high { background: var(--green); }
.classification-track .medium { background: var(--yellow); }
.classification-track .low { background: var(--red); }

.section-toolbar { display: flex; gap: 12px; justify-content: space-between; margin-bottom: 18px; }
.search-box { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 520px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.035); padding: 0 13px; }
.search-box input { border: 0; outline: 0; background: transparent; color: white; width: 100%; padding: 12px 0; }
select, input, textarea { color: var(--text); background: rgba(5,10,25,.84); border: 1px solid rgba(139,180,255,.22); border-radius: 11px; padding: 11px 12px; outline: none; }
select:focus, input:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(99,220,255,.1); }
textarea { resize: vertical; }

.body-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; }
.body-card { position: relative; overflow: hidden; min-height: 285px; border: 1px solid var(--line); border-radius: 20px; background: linear-gradient(145deg, rgba(16,27,53,.9), rgba(7,11,25,.9)); padding: 19px; transition: .2s ease; }
.body-card:hover { transform: translateY(-4px); border-color: rgba(99,220,255,.42); }
.body-card::before { content: ''; position: absolute; width: 130px; height: 130px; border-radius: 50%; right: -36px; top: -38px; background: var(--planet-color); opacity: .2; filter: blur(5px); }
.body-card-header { display: flex; align-items: center; gap: 12px; }
.planet-dot { width: 48px; height: 48px; border-radius: 50%; background: radial-gradient(circle at 30% 25%, #fff, var(--planet-color) 35%, #0c1229 100%); box-shadow: 0 0 18px color-mix(in srgb, var(--planet-color) 50%, transparent); }
.body-card h3 { margin: 0; }
.body-card .type { color: var(--muted); font-size: .78rem; }
.classification-badge { display: inline-flex; margin: 14px 0; padding: 6px 9px; border-radius: 999px; font-size: .72rem; font-weight: 800; }
.classification-badge.high { color: #baffdf; background: rgba(76,224,164,.11); }
.classification-badge.medium { color: #ffe5a6; background: rgba(255,209,102,.11); }
.classification-badge.low { color: #ffd0d5; background: rgba(255,107,122,.11); }
.body-stats { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.body-stat { padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.03); }
.body-stat small { color: var(--muted); display: block; }
.body-stat strong { font-size: .9rem; }
.card-actions { display: flex; gap: 8px; margin-top: 14px; }
.card-actions button { flex: 1; padding: 8px 9px; font-size: .78rem; }

.two-column-layout, .evaluation-layout { display: grid; grid-template-columns: minmax(0,1.2fr) minmax(300px,.8fr); gap: 18px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 13px; }
label { display: grid; gap: 6px; color: #c6d2e9; font-size: .83rem; }
.full-width { grid-column: 1 / -1; }
.form-errors { color: #ffc7cf; margin-top: 12px; line-height: 1.55; }
.form-errors:empty { display: none; }
.feature-list { color: #bac7df; line-height: 1.7; padding-left: 20px; }
.feature-list li { margin: 10px 0; }
.model-note { border-left: 3px solid var(--cyan); background: rgba(99,220,255,.06); padding: 12px 14px; border-radius: 0 10px 10px 0; color: #b7c7df; font-size: .82rem; line-height: 1.6; margin-top: 18px; }

.selector-panel select { width: 100%; margin: 14px 0; }
.selected-body-summary { display: grid; gap: 9px; margin: 12px 0; }
.summary-line { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); border-bottom: 1px dashed rgba(255,255,255,.08); padding-bottom: 7px; }
.summary-line strong { color: var(--text); }
.result-panel { min-height: 410px; }
.empty-state { display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-icon { font-size: 3rem; color: var(--cyan); }
.evaluation-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.index-display { min-width: 120px; text-align: center; padding: 16px; border-radius: 18px; background: radial-gradient(circle, rgba(99,220,255,.15), rgba(93,124,255,.08)); border: 1px solid rgba(99,220,255,.25); }
.index-display strong { display: block; font-size: 2.5rem; }
.index-display small { color: var(--muted); }
.score-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin: 18px 0; }
.score-card { background: rgba(255,255,255,.03); border: 1px solid rgba(255,255,255,.055); border-radius: 12px; padding: 11px; }
.score-card small { color: var(--muted); display: block; }
.score-card strong { display: block; margin-top: 4px; }
.decision-box { padding: 14px; border-radius: 13px; background: rgba(162,109,255,.08); border: 1px solid rgba(162,109,255,.2); line-height: 1.65; color: #d4d9eb; }
.condition-list { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; margin-top: 14px; }
.condition-chip { padding: 8px 10px; border-radius: 10px; background: rgba(255,255,255,.03); font-size: .78rem; }
.condition-chip.true { color: #baffdf; border: 1px solid rgba(76,224,164,.18); }
.condition-chip.false { color: #ffd0d5; border: 1px solid rgba(255,107,122,.18); }

.comparison-table { width: 100%; border-collapse: collapse; margin-top: 12px; }
.comparison-table th, .comparison-table td { padding: 13px 11px; text-align: left; border-bottom: 1px solid rgba(255,255,255,.07); }
.comparison-table th { color: var(--cyan); font-size: .75rem; letter-spacing: .08em; }
.comparison-table td { color: #c8d2e6; }
.comparison-table strong { color: white; }

.classification-groups { display: grid; grid-template-columns: repeat(3,1fr); gap: 14px; }
.classification-group { padding: 16px; border-radius: 15px; background: rgba(255,255,255,.025); border: 1px solid rgba(255,255,255,.055); }
.classification-group ul { margin: 12px 0 0; padding-left: 18px; color: #c1cce1; line-height: 1.8; }

.chart-controls select { min-width: 240px; }
.chart-description { color: var(--muted); line-height: 1.65; }
.chart-container { width: 100%; overflow: hidden; }
.scatter-svg { width: 100%; height: auto; min-height: 360px; }
.chart-grid { stroke: rgba(150,175,225,.1); stroke-width: 1; }
.chart-axis { stroke: rgba(220,235,255,.5); stroke-width: 1.2; }
.chart-label { fill: #8fa0bd; font-size: 12px; }
.chart-title { fill: #c8d9f6; font-size: 14px; font-weight: 700; }
.point-label { fill: #e7f2ff; font-size: 12px; }
.chart-point { stroke: rgba(255,255,255,.75); stroke-width: 1.5; filter: drop-shadow(0 0 6px rgba(99,220,255,.45)); }
.earth-point { stroke: var(--green); stroke-width: 3; }

.simulation-layout .form-panel { display: grid; gap: 13px; }
.mission-list { display: grid; gap: 10px; margin-top: 15px; }
.mission-card { border: 1px solid rgba(255,255,255,.06); border-radius: 12px; padding: 12px; background: rgba(255,255,255,.025); }
.mission-card.approved { border-left: 3px solid var(--green); }
.mission-card.rejected { border-left: 3px solid var(--red); }
.mission-card small { color: var(--muted); }
.resource-remains { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 16px; }
.resource-remain { text-align: center; padding: 10px; border-radius: 12px; background: rgba(99,220,255,.055); }
.resource-remain strong { display: block; font-size: 1.25rem; }
.resource-remain small { color: var(--muted); }

.history-table { width: 100%; border-collapse: collapse; }
.history-table th, .history-table td { padding: 12px; border-bottom: 1px solid rgba(255,255,255,.07); text-align: left; }
.history-table th { color: var(--cyan); font-size: .76rem; }
.empty-message { color: var(--muted); text-align: center; padding: 48px 12px; }

.app-footer { color: #75839e; text-align: center; font-size: .75rem; padding: 30px 0 6px; }
.toast { position: fixed; right: 22px; bottom: 22px; z-index: 100; min-width: 240px; max-width: 380px; padding: 13px 16px; border-radius: 12px; background: rgba(12,20,42,.96); border: 1px solid rgba(99,220,255,.3); box-shadow: var(--shadow); transform: translateY(120px); opacity: 0; transition: .25s ease; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1150px) {
  .body-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .hero-panel { grid-template-columns: 1fr; }
  .hero-visual { min-height: 300px; }
  .planet-main { width: 210px; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; transform: translateX(-105%); width: 270px; transition: transform .25s ease; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 0 18px 20px; }
  .menu-toggle { display: inline-flex; }
  .topbar { justify-content: flex-start; }
  .topbar-actions { margin-left: auto; }
  .dashboard-grid, .reports-grid, .two-column-layout, .evaluation-layout { grid-template-columns: 1fr; }
  .classification-groups { grid-template-columns: 1fr; }
  .wide-panel { grid-column: auto; }
}

@media (max-width: 620px) {
  .main-content { padding: 0 12px 18px; }
  .topbar { align-items: center; min-height: 84px; }
  .topbar-actions .ghost-button { display: none; }
  .hero-copy { padding: 30px 22px; }
  .hero-copy h2 { font-size: 2.35rem; }
  .body-grid, .metric-grid, .form-grid, .score-grid, .condition-list { grid-template-columns: 1fr; }
  .section-toolbar, .panel-heading { align-items: stretch; flex-direction: column; }
  .search-box { max-width: none; }
  .comparison-table, .history-table { font-size: .78rem; }
  .comparison-table th, .comparison-table td, .history-table th, .history-table td { padding: 9px 6px; }
  .resource-remains { grid-template-columns: 1fr; }
}


.startup-error {
  position: fixed;
  z-index: 9999;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  width: min(620px, calc(100% - 32px));
  padding: 16px 18px;
  border: 1px solid rgba(255, 112, 143, .55);
  border-radius: 14px;
  background: rgba(31, 8, 25, .96);
  color: #fff;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.startup-error small { color: rgba(255,255,255,.72); }
