:root {
  --ink: #1f2933;
  --muted: #667085;
  --line: #d7dde5;
  --panel: #ffffff;
  --soft: #f5f7fa;
  --red: #d31145;
  --green: #1f8f5f;
  --teal: #0f766e;
  --blue: #2563eb;
  --amber: #b7791f;
  --shadow: 0 16px 40px rgba(31, 41, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: #eef2f6;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 22px;
}

.topbar,
.actions,
.panel-heading,
.legend {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.topbar {
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--red);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  letter-spacing: 0;
}

h1,
h2 {
  margin: 0;
}

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

h2 {
  font-size: 19px;
  line-height: 1.2;
}

.primary-button,
.ghost-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  color: var(--ink);
  background: #fff;
}

.primary-button {
  color: #fff;
  border-color: var(--red);
  background: var(--red);
}

.ghost-button:hover {
  border-color: var(--red);
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 18px;
  border: 1px solid #e7cfd7;
  border-left: 5px solid var(--red);
  border-radius: 8px;
  background: #fff;
  padding: 12px 14px;
  color: #4b5563;
  line-height: 1.45;
}

.notice strong {
  color: var(--ink);
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(0, 1.5fr);
  gap: 18px;
  align-items: start;
}

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

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

.panel-heading {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.input-panel {
  position: sticky;
  top: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 20px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span,
.metric-panel span,
.mechanic-panel span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.3;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

input:focus,
select:focus,
button:focus {
  outline: 3px solid rgba(211, 17, 69, 0.18);
  outline-offset: 1px;
}

.section-divider {
  height: 1px;
  background: var(--line);
}

.details-block {
  border-top: 1px solid var(--line);
}

.details-block summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  font-weight: 850;
  cursor: pointer;
}

.details-grid {
  padding-top: 0;
}

.checkbox-field {
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.checkbox-field input {
  width: 18px;
  min-height: 18px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metric-panel {
  min-height: 116px;
  padding: 16px;
  border-left-width: 5px;
}

.metric-panel strong {
  display: block;
  margin-top: 12px;
  font-size: 25px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.accent-red {
  border-left-color: var(--red);
}

.accent-green {
  border-left-color: var(--green);
}

.accent-blue {
  border-left-color: var(--blue);
}

.accent-teal {
  border-left-color: var(--teal);
}

.pill {
  display: inline-grid;
  min-height: 34px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  padding: 0 12px;
  font-size: 12px;
  font-weight: 850;
  text-align: center;
}

.chart-panel {
  overflow: hidden;
}

.legend {
  justify-content: flex-end;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  width: 18px;
  height: 4px;
  display: inline-block;
  border-radius: 999px;
}

.legend .lower {
  background: var(--red);
}

.legend .base {
  background: var(--teal);
}

.legend .higher {
  background: var(--blue);
}

.chart-shell {
  min-height: 360px;
  padding: 12px 14px 18px;
}

canvas {
  width: 100%;
  height: 360px;
  display: block;
}

.mechanics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.mechanic-panel {
  min-height: 160px;
  padding: 16px;
}

.mechanic-panel strong {
  display: block;
  margin: 8px 0;
  font-size: 20px;
}

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

.table-panel {
  overflow: hidden;
}

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

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

th,
td {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

th {
  color: var(--muted);
  background: var(--soft);
  font-size: 12px;
  font-weight: 850;
}

td {
  font-size: 13px;
}

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

  .input-panel {
    position: static;
  }

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

@media (max-width: 720px) {
  .shell {
    padding: 14px;
  }

  .topbar,
  .notice {
    display: grid;
  }

  .actions {
    justify-content: stretch;
  }

  .actions button {
    flex: 1;
  }

  .form-grid,
  .summary-grid,
  .mechanics-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
  }

  h1 {
    font-size: 26px;
  }
}

@media print {
  body {
    background: #fff;
  }

  .actions,
  .input-panel,
  .notice {
    display: none;
  }

  .shell {
    padding: 0;
  }

  .workspace,
  .summary-grid,
  .mechanics-grid {
    display: block;
  }

  .panel,
  .metric-panel,
  .mechanic-panel {
    box-shadow: none;
    break-inside: avoid;
    margin-bottom: 12px;
  }
}
