:root {
  color-scheme: light;
  --bg: #f7f6fb;
  --surface: #ffffff;
  --surface-strong: #f0f4f8;
  --ink: #171827;
  --muted: #667085;
  --line: #dfe4ee;
  --magenta: #d91b8f;
  --cyan: #00a9d6;
  --teal: #087f92;
  --blue: #2477d8;
  --green: #16845b;
  --amber: #b7791f;
  --red: #c2413c;
  --shadow: 0 12px 32px rgba(45, 32, 66, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar,
.control-band,
.panel,
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 106px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px;
}

.editorial-hero {
  position: relative;
  min-height: 262px;
  overflow: hidden;
  align-items: stretch;
  background:
    linear-gradient(110deg, rgba(255, 255, 255, 0.96) 0%, rgba(255, 255, 255, 0.9) 42%, rgba(255, 255, 255, 0.28) 100%),
    linear-gradient(135deg, rgba(217, 27, 143, 0.12), rgba(0, 169, 214, 0.14));
  border-color: rgba(217, 27, 143, 0.18);
}

.hero-copy {
  position: relative;
  z-index: 2;
  width: min(640px, 58%);
  display: grid;
  align-content: center;
  gap: 10px;
}

.topbar h1,
.panel h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.05;
}

.brand-logo {
  width: min(260px, 72vw);
  height: auto;
  display: block;
  margin-bottom: 4px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(223, 228, 238, 0.8);
  border-radius: 8px;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.hero-tags span {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  padding: 0 10px;
  border: 1px solid rgba(0, 169, 214, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

.hero-visual {
  position: absolute;
  inset: 0 0 0 auto;
  width: min(650px, 54%);
  margin: 0;
}

.hero-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(255,255,255,0.58), rgba(255,255,255,0.08) 42%, rgba(23,24,39,0.08));
}

.hero-visual img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--magenta);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-meta {
  position: relative;
  z-index: 2;
  align-self: center;
  min-width: 170px;
  display: grid;
  gap: 4px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.84);
  border: 1px solid rgba(0, 169, 214, 0.26);
  border-radius: 8px;
  text-align: right;
}

.topbar-meta span {
  color: var(--muted);
  font-size: 13px;
}

.topbar-meta strong {
  color: var(--magenta);
  font-size: 30px;
}

.control-band {
  margin-top: 16px;
  padding: 14px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: end;
}

.field-group {
  display: grid;
  gap: 7px;
}

.field-group.grow {
  flex: 1 1 260px;
}

label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

select,
input[type="search"] {
  min-height: 42px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: var(--surface);
  color: var(--ink);
}

input[type="search"] {
  width: 100%;
}

.segmented {
  min-height: 42px;
  display: inline-grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  background: var(--surface-strong);
}

.segment {
  min-width: 86px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-weight: 800;
  cursor: pointer;
}

.segment:last-child {
  border-right: 0;
}

.segment.is-active {
  background: linear-gradient(135deg, var(--magenta), var(--cyan));
  color: white;
}

.kpi-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(7, minmax(140px, 1fr));
  gap: 12px;
}

.kpi-card {
  min-height: 126px;
  padding: 16px;
  display: grid;
  grid-template-rows: 26px auto 1fr;
  gap: 8px;
}

.kpi-icon {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #ffeaf6;
  color: var(--magenta);
  font-weight: 900;
}

.accent-blue .kpi-icon { background: #e6f8ff; color: var(--cyan); }
.accent-red .kpi-icon { background: #fff0f7; color: var(--magenta); }
.accent-amber .kpi-icon { background: #fff6df; color: var(--amber); }
.accent-green .kpi-icon { background: #eaf7ef; color: var(--green); }
.accent-cyan .kpi-icon { background: #e6f8ff; color: var(--cyan); }

.kpi-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpi-card strong {
  align-self: end;
  font-size: 28px;
  line-height: 1;
}

.workspace-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(320px, 0.85fr);
  gap: 16px;
}

.lower-grid {
  grid-template-columns: 1.2fr 1fr 1fr;
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-header {
  min-height: 42px;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 20px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
}

.icon-button svg {
  width: 19px;
  height: 19px;
  fill: var(--ink);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

td strong {
  display: block;
  font-size: 14px;
}

td span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.positive { color: var(--green); }
.negative { color: var(--red); }

.pill {
  display: inline-grid;
  min-width: 86px;
  place-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  color: white;
  font-size: 12px;
  font-weight: 900;
}

.critical { background: var(--red); }
.high { background: #d06a2c; }
.medium { background: var(--amber); }
.ok { background: var(--green); }

.alerts-list {
  display: grid;
  gap: 10px;
}

.alert-item {
  display: grid;
  grid-template-columns: 12px 1fr;
  gap: 10px;
  padding: 12px;
  background: #f9fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.alert-dot {
  width: 10px;
  height: 10px;
  margin-top: 4px;
  border-radius: 50%;
}

.alert-item strong {
  font-size: 14px;
}

.alert-item p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.bar-chart {
  display: grid;
  gap: 14px;
}

.bar-row {
  display: grid;
  grid-template-columns: 155px 1fr 88px;
  gap: 12px;
  align-items: center;
}

.bar-label {
  display: grid;
  gap: 2px;
}

.bar-label strong {
  font-size: 12px;
}

.bar-label span,
.bar-values span {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bars {
  display: grid;
  gap: 4px;
}

.bar {
  width: var(--w);
  min-width: 4px;
  height: 10px;
  border-radius: 999px;
}

.bar.initial { background: #b6c2d2; }
.bar.adjusted { background: linear-gradient(90deg, var(--magenta), var(--cyan)); }

.bar-values {
  display: grid;
  gap: 2px;
  text-align: right;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr minmax(120px, 200px) 52px;
  gap: 10px;
  align-items: center;
  margin: 16px 0;
}

input[type="range"] {
  accent-color: var(--magenta);
}

.scenario-result {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.result-metric {
  min-height: 104px;
  display: grid;
  align-content: center;
  gap: 5px;
  padding: 12px;
  background: #f9fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.result-metric span,
.result-metric small {
  color: var(--muted);
  font-size: 12px;
}

.result-metric strong {
  font-size: 23px;
}

.phase-timeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.phase-timeline span {
  min-height: 52px;
  display: grid;
  place-items: center;
  padding: 8px;
  background: var(--surface-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.phase-timeline .is-current {
  background: #fff0f8;
  border-color: rgba(217, 27, 143, 0.28);
  color: var(--magenta);
}

.explain-box {
  margin-top: 14px;
  padding: 14px;
  background: #f9fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.explain-box p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 14px;
  background: var(--ink);
  color: white;
  border-radius: 8px;
  opacity: 0;
  transform: translateY(10px);
  transition: 180ms ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .workspace-grid,
  .lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100vw - 20px, 1480px);
    padding-top: 10px;
  }

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .editorial-hero {
    min-height: 0;
    padding: 18px;
  }

  .hero-copy {
    width: 100%;
  }

  .hero-visual {
    position: relative;
    width: 100%;
    height: 210px;
    border-radius: 8px;
    overflow: hidden;
  }

  .topbar-meta {
    text-align: left;
  }

  .control-band {
    align-items: stretch;
  }

  .field-group,
  select {
    width: 100%;
  }

  .segmented {
    width: 100%;
  }

  .segment {
    min-width: 0;
    padding: 0 8px;
  }

  .kpi-grid,
  .scenario-result,
  .phase-timeline {
    grid-template-columns: 1fr;
  }

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

  .bar-values {
    text-align: left;
  }
}
