:root {
  --navy: #0B1F3A;
  --navy-light: #16305A;
  --text-muted: #5B6472;
  --text-faint: #9AA2B1;
  --border: #E1E5EB;
  --bg-soft: #F2F4F7;
  --bg-card: #F7F8FA;
  --green: #1B8A5A;
  --red: #C4402A;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: #E9ECF2;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--navy);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 40px rgba(11, 31, 58, 0.08);
}

.view { display: flex; flex-direction: column; flex: 1; }
.view.hidden { display: none; }

.topbar {
  background: var(--navy);
  color: #fff;
  padding: 18px 20px calc(18px + env(safe-area-inset-top, 0px));
  padding-top: max(18px, env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  gap: 10px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0;
}

.btn-back {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.btn-back:active { background: rgba(255,255,255,0.24); }

.content {
  padding: 20px 20px 48px;
  flex: 1;
}

.heading {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  margin: 4px 0 6px;
}

.subheading {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 22px;
  line-height: 1.4;
}

.field { margin-bottom: 16px; }

.field label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.field select {
  width: 100%;
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-soft) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="%235B6472"><path d="M5.5 7.5l4.5 5 4.5-5z"/></svg>') no-repeat right 14px center;
  background-size: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 13px 38px 13px 14px;
  font-size: 15px;
  color: var(--navy);
  font-family: inherit;
}

.field select:disabled {
  opacity: 0.5;
}

.btn-primary {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 15px;
  font-size: 16px;
  font-weight: 700;
  margin-top: 8px;
  cursor: pointer;
  font-family: inherit;
}
.btn-primary:active { background: var(--navy-light); }

.footnote {
  font-size: 11px;
  color: var(--text-faint);
  line-height: 1.5;
  margin-top: 24px;
}

.level-tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  background: #E8ECF3;
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 4px 0 0;
}

.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 20px;
}

.metric-card {
  background: var(--bg-card);
  border-radius: 12px;
  padding: 14px;
}

.metric-card .label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  display: block;
}

.metric-card .value {
  font-size: 19px;
  font-weight: 800;
  color: var(--navy);
  margin-top: 6px;
  display: block;
}

.metric-card .delta {
  font-size: 13px;
  font-weight: 700;
  margin-top: 4px;
  display: block;
}
.metric-card .delta.positive { color: var(--green); }
.metric-card .delta.negative { color: var(--red); }

.chart-card {
  background: #fff;
  border: 1px solid #EEF0F3;
  border-radius: 12px;
  padding: 14px;
  margin-top: 8px;
}

.chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin: 0 0 8px;
}

#trend-chart {
  width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 380px) {
  .cards-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .content { padding: 16px 16px 40px; }
}
