:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --panel-alt: #f9fbfd;
  --line: #d8dee6;
  --ink: #13212b;
  --muted: #627180;
  --accent: #0f766e;
  --accent-2: #d97706;
  --accent-3: #2563eb;
  --accent-soft: rgba(15, 118, 110, 0.12);
  --shadow: 0 20px 45px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.16), transparent 28%),
    radial-gradient(circle at top right, rgba(37, 99, 235, 0.10), transparent 24%),
    linear-gradient(180deg, #fbfcfe 0%, var(--bg) 100%);
}

.page {
  width: min(100%, 1840px);
  margin: 0 auto;
  padding: 24px;
}

.hero,
.panel,
.cards,
.page-nav {
  margin-bottom: 18px;
}

.hero,
.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 251, 253, 0.98));
  border: 1px solid rgba(216, 222, 230, 0.9);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(320px, 0.9fr);
  gap: 18px;
  padding: 26px;
  min-height: 220px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  line-height: 1.08;
}

h1 {
  font-size: clamp(2.5rem, 5vw, 4.8rem);
  max-width: 920px;
}

h2 {
  font-size: clamp(1.6rem, 2vw, 2.1rem);
}

h3 {
  font-size: 1.05rem;
}

.subtitle,
.note,
label,
#status {
  color: var(--muted);
}

.subtitle {
  font-size: 1.02rem;
  line-height: 1.65;
  max-width: 980px;
}

.picker {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(216, 222, 230, 0.9);
  background:
    linear-gradient(180deg, rgba(242, 250, 249, 1) 0%, rgba(255, 255, 255, 1) 100%);
}

input,
button {
  font: inherit;
  border-radius: 14px;
  padding: 13px 14px;
}

input {
  border: 1px solid var(--line);
  background: white;
}

button {
  border: 0;
  color: white;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent), #0b5e58);
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.22);
}

.secondary-btn {
  color: #0e4d48;
  background: linear-gradient(180deg, #eaf4f3 0%, #dff1ef 100%);
}

.button-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#export-links {
  display: grid;
  gap: 8px;
}

.export-box {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fbfdfd;
  padding: 12px 14px;
}

.export-box a {
  text-decoration: none;
  color: var(--accent-3);
  margin-right: 12px;
  font-weight: 600;
}

.plot-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  padding: 14px;
  margin-top: 14px;
}

.plot-card + .plot-card {
  margin-top: 16px;
}

.plot-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.plot-toolbar strong {
  font-size: 1rem;
}

.plotly-host {
  width: 100%;
  min-height: 380px;
}

.chart-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
}

.chart-modal.is-open {
  display: block;
}

.chart-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.64);
  backdrop-filter: blur(6px);
}

.chart-modal-panel {
  position: relative;
  width: min(96vw, 1700px);
  height: min(92vh, 1100px);
  margin: 4vh auto;
  background: linear-gradient(180deg, rgba(255,255,255,0.99), rgba(248,251,253,0.99));
  border: 1px solid rgba(216, 222, 230, 0.9);
  border-radius: 28px;
  box-shadow: 0 40px 90px rgba(15, 23, 42, 0.28);
  padding: 22px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.chart-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.chart-modal-body {
  min-height: 0;
}

.chart-modal-body .plotly-host {
  height: 100%;
  min-height: 100%;
}

.page-nav {
  position: sticky;
  top: 12px;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(216, 222, 230, 0.85);
  border-radius: 18px;
  backdrop-filter: blur(14px);
}

.nav-chip {
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  padding: 10px 14px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
}

.nav-chip.is-active {
  background: linear-gradient(135deg, var(--accent), #0b5e58);
  color: white;
  border-color: transparent;
}

.cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.card,
.mini-card,
.zone-card,
.insight-card {
  border-radius: 20px;
  border: 1px solid var(--line);
  background: white;
}

.card {
  padding: 20px;
}

.card small,
.mini-card small {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric {
  font-size: clamp(1.65rem, 2vw, 2.2rem);
  font-weight: 800;
  line-height: 1.05;
}

.report-page {
  display: none;
}

.report-page.is-active {
  display: block;
}

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin: 8px 2px 14px;
}

.panel {
  padding: 22px;
}

.grid-2,
.grid-3 {
  display: grid;
  gap: 18px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.executive-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 18px;
}

.insight-stack {
  display: grid;
  gap: 14px;
}

.insight-card {
  padding: 18px;
  background: linear-gradient(180deg, #ffffff 0%, var(--panel-alt) 100%);
}

.insight-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1rem;
}

.r-chart-image {
  width: 100%;
  height: auto;
  display: block;
  margin-top: 12px;
  border-radius: 18px;
  border: 1px solid #dfe6ee;
  background: #ffffff;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: white;
}

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

.table th,
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid #e8edf3;
  vertical-align: top;
  text-align: left;
}

.table th {
  position: sticky;
  top: 0;
  background: #f6f8fb;
  color: #2f3a45;
  z-index: 1;
}

.table tr:hover td {
  background: #fbfdff;
}

.table .neutral {
  color: var(--muted);
}

.table .pos {
  color: #0f766e;
  font-weight: 700;
}

.table .neg {
  color: #b45309;
  font-weight: 700;
}

.bar-list,
.chart,
.mini-cards,
.zone-map {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr minmax(95px, 115px);
  gap: 10px;
  align-items: center;
}

.bar-track {
  height: 14px;
  background: #edf2f6;
  border-radius: 999px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.stack-row {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 12px;
  align-items: center;
}

.stack {
  display: flex;
  height: 20px;
  border-radius: 999px;
  overflow: hidden;
  background: #edf2f6;
}

.stack-seg {
  height: 100%;
}

.seg-a { background: #0f766e; }
.seg-b { background: #2563eb; }
.seg-c { background: #d97706; }
.seg-d { background: #7c3aed; }

.mini-cards {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 16px;
}

.mini-card {
  padding: 14px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
}

.mini-card strong {
  display: block;
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.zone-map {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.zone-card {
  padding: 16px;
  background: linear-gradient(180deg, #ffffff 0%, #fafcfe 100%);
}

.zone-card strong {
  display: block;
  margin-bottom: 8px;
}

.svg-chart {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  padding: 12px 12px 14px;
  margin-top: 14px;
  overflow: hidden;
}

.svg-chart svg {
  width: 100%;
  height: auto;
  display: block;
}

.axis-label {
  fill: #6b7280;
  font-size: 11px;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: #32404c;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.chart-tooltip {
  position: absolute;
  min-width: 170px;
  max-width: 250px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 12px));
  transition: opacity 0.12s ease;
  background: rgba(19, 33, 43, 0.94);
  color: white;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.88rem;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.18);
}

.chart-tooltip strong {
  display: block;
  margin-bottom: 4px;
}

.chart-point {
  cursor: pointer;
}

.chart-area {
  fill: transparent;
  cursor: crosshair;
}

.pill-note {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: #0d5c57;
  font-size: 0.86rem;
  font-weight: 700;
}

.severity {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  margin-right: 8px;
}

.severity-high {
  background: #fee2e2;
  color: #991b1b;
}

.severity-medium {
  background: #ffedd5;
  color: #9a3412;
}

.severity-low {
  background: #dcfce7;
  color: #166534;
}

@media (max-width: 1180px) {
  .hero,
  .executive-grid,
  .grid-2,
  .grid-3,
  .cards,
  .zone-map,
  .mini-cards {
    grid-template-columns: 1fr;
  }

  .page {
    padding: 16px;
  }

  .page-nav {
    top: 8px;
  }
}

@media (max-width: 720px) {
  .button-row {
    grid-template-columns: 1fr;
  }

  .bar-row,
  .stack-row {
    grid-template-columns: 1fr;
  }

  .panel,
  .hero {
    padding: 18px;
  }

  h1 {
    font-size: 2.35rem;
  }
}
