:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9dee7;
  --blue: #2458a6;
  --teal: #087b7b;
  --green: #197a4d;
  --gold: #a36405;
  --red: #b42318;
  --violet: #6f3ab2;
  --shadow: 0 18px 45px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fbfcfe;
  padding: 18px;
  overflow: auto;
}

.brand-block {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.1;
}

h2 {
  font-size: 15px;
}

.brand-block p,
.muted {
  color: var(--muted);
  font-size: 12px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel,
.saved-panel {
  padding: 14px;
  margin-bottom: 14px;
}

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

label {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cfd6e2;
  border-radius: 6px;
  padding: 9px 10px;
  background: white;
  color: var(--ink);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(36, 88, 166, 0.12);
}

textarea {
  resize: vertical;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.slider-row {
  margin: 12px 0;
}

.slider-row > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
  font-size: 12px;
}

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

.primary,
.icon-button,
.tab,
.saved-item {
  border: 1px solid var(--line);
  background: white;
  border-radius: 6px;
  color: var(--ink);
}

.primary {
  background: var(--blue);
  color: white;
  border-color: var(--blue);
  padding: 9px 12px;
  font-weight: 800;
}

.primary.small {
  padding: 6px 9px;
  font-size: 12px;
}

.icon-button {
  width: 32px;
  height: 32px;
  font-weight: 800;
}

.workspace {
  padding: 18px;
  overflow: auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  gap: 6px;
}

.tab {
  padding: 9px 12px;
  font-weight: 800;
  color: #344054;
}

.tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: white;
}

.status-pill {
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 900;
  border: 1px solid var(--line);
  background: white;
}

.status-pill.scale {
  color: var(--green);
  border-color: rgba(25, 122, 77, 0.28);
  background: #effaf4;
}

.status-pill.watch {
  color: var(--gold);
  border-color: rgba(163, 100, 5, 0.28);
  background: #fff7e8;
}

.status-pill.fix {
  color: var(--red);
  border-color: rgba(180, 35, 24, 0.26);
  background: #fff1f0;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) 1.1fr;
  gap: 16px;
}

.score-panel,
.constraint-panel,
.two-col .panel,
.plan-panel,
#simulator > .panel,
.workspace > .view > .panel {
  padding: 18px;
}

.eyebrow {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.ratio-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}

.ratio-line strong {
  font-size: 54px;
  line-height: 0.95;
  color: var(--blue);
}

.ratio-line span {
  color: var(--muted);
  font-weight: 800;
}

.constraint-panel h2 {
  font-size: 28px;
  line-height: 1.05;
  margin-bottom: 10px;
}

.constraint-panel p,
.score-panel p,
.large-copy {
  color: #344054;
  line-height: 1.55;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
}

.operator-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(190px, 1fr));
  gap: 12px;
}

.metric-card {
  padding: 14px;
  min-height: 112px;
}

.metric-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 8px;
}

.metric-card strong {
  display: block;
  font-size: 24px;
  margin-bottom: 6px;
}

.metric-card p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.ranking-list,
.flags-list,
.before-after,
.saved-list {
  display: grid;
  gap: 10px;
}

.rank-item,
.flag-item,
.operator-item,
.saved-item,
.delta-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fcfcfd;
}

.rank-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
}

.rank-number {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #eef4ff;
  color: var(--blue);
  font-weight: 900;
}

.rank-item h3,
.flag-item h3,
.operator-item h3 {
  font-size: 14px;
  margin-bottom: 3px;
}

.rank-item p,
.flag-item p,
.operator-item p,
.delta-row p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.operator-item strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.impact {
  font-weight: 900;
  color: var(--green);
  white-space: nowrap;
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(200px, 1fr));
  gap: 12px;
}

.sim-control {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fcfcfd;
}

.sim-control header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.sim-control strong {
  font-size: 13px;
}

.sim-control output {
  color: var(--blue);
  font-weight: 900;
}

.delta-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
}

.delta-row strong {
  font-size: 18px;
}

pre {
  white-space: pre-wrap;
  margin: 0;
  padding: 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #101828;
  color: #f8fafc;
  line-height: 1.5;
  font-size: 13px;
  min-height: 520px;
}

.saved-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  text-align: left;
  font-size: 12px;
}

.saved-item strong {
  display: block;
}

.saved-item span {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .input-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 0 12px;
  }

  .input-panel .panel-head,
  .input-panel label:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .workspace,
  .sidebar {
    padding: 12px;
  }

  .hero-grid,
  .two-col,
  .metrics-grid,
  .operator-grid,
  .sim-grid,
  .input-panel {
    grid-template-columns: 1fr;
  }

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

  .tabs {
    overflow-x: auto;
  }

  .ratio-line strong {
    font-size: 42px;
  }
}
