:root {
  color-scheme: dark;
  --crimson: #a4133c;
  --shadow: #1a1a1a;
  --accent: #7b2cbf;
  --panel: #212124;
  --panel-strong: #2a2026;
  --field: #121214;
  --border: #3d3137;
  --text: #f2f2f4;
  --muted: #bbb8c2;
  --danger: #ff7a90;
  --ok: #88e0b4;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(164, 19, 60, 0.2), rgba(26, 26, 26, 0) 260px),
    var(--shadow);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 132px;
  padding: 18px clamp(16px, 3vw, 36px);
  border-bottom: 1px solid rgba(242, 242, 244, 0.08);
  background: #000;
}

.brand {
  display: flex;
  align-items: center;
  gap: 30px;
  min-width: 0;
}

.brand-logo-wrap {
  position: relative;
  z-index: 0;
  flex: 0 0 auto;
  width: 218px;
  line-height: 0;
}

.brand-logo {
  position: relative;
  z-index: 1;
  display: block;
  width: 218px;
  height: auto;
  max-height: 114px;
  object-fit: contain;
}

.brand h1 {
  margin: 0;
  font-family:
    "Bank Gothic", "Eurostile", "Eurostile Extended", "Arial Black", Impact, sans-serif;
  font-size: 38px;
  font-weight: 900;
  line-height: 0.98;
  letter-spacing: 0;
  text-shadow:
    0 0 16px rgba(164, 19, 60, 0.22),
    0 0 28px rgba(123, 44, 191, 0.16);
}

.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.top-actions select {
  width: auto;
  min-width: 82px;
  min-height: 34px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid rgba(136, 224, 180, 0.35);
  border-radius: 999px;
  color: var(--ok);
  background: rgba(136, 224, 180, 0.08);
  font-size: 0.82rem;
  font-weight: 700;
}

.status-pill.is-bad {
  border-color: rgba(255, 122, 144, 0.4);
  color: var(--danger);
  background: rgba(255, 122, 144, 0.08);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 18px;
  width: min(1520px, 100%);
  margin: 0 auto;
  padding: 18px clamp(12px, 2vw, 28px) 28px;
}

.panel,
.plot-panel,
.summary-strip {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(33, 33, 36, 0.96);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.24);
}

.controls-panel {
  align-self: start;
  padding: 18px;
}

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

.panel-heading h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: 0;
}

.panel-heading span {
  color: var(--muted);
  font-size: 0.85rem;
}

.limits-heading {
  margin-top: 22px;
}

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

label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid #40343c;
  border-radius: 6px;
  padding: 0 11px;
  outline: none;
  background: var(--field);
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(123, 44, 191, 0.22);
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.variant-select-row {
  margin-top: 14px;
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--crimson));
}

.secondary-button {
  border: 1px solid #493842;
  background: #19191b;
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.calculate-button {
  width: 100%;
  margin-top: 16px;
}

.variant-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: auto auto;
  gap: 8px 16px;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(164, 19, 60, 0.35);
  border-radius: 6px;
  background: rgba(164, 19, 60, 0.1);
  font-size: 0.86rem;
}

.variant-meta span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.variant-meta strong {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.95rem;
}

.message {
  min-height: 24px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.message.is-error {
  color: var(--danger);
}

.results-column {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  overflow: hidden;
}

.summary-strip div {
  min-width: 0;
  padding: 16px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(164, 19, 60, 0.2), rgba(33, 33, 36, 0));
}

.summary-strip div:last-child {
  border-right: 0;
}

.summary-strip span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.summary-strip strong {
  display: block;
  min-height: 30px;
  overflow-wrap: anywhere;
  font-size: clamp(1.05rem, 1.8vw, 1.55rem);
}

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

.plot-panel {
  min-width: 0;
  min-height: 456px;
  padding: 8px;
}

.plot {
  width: 100%;
  height: 440px;
}

.surface-plot {
  height: 470px;
}

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

.table-wrap {
  max-height: 320px;
  overflow: auto;
  border: 1px solid #342d32;
  border-radius: 6px;
}

table {
  width: 100%;
  min-width: 800px;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #342d32;
  text-align: right;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #181819;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

td:last-child,
th:last-child {
  text-align: left;
}

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

  .controls-panel {
    align-self: stretch;
  }
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-logo {
    width: 168px;
    max-height: 90px;
  }

  .brand-logo-wrap {
    width: 168px;
  }

  .brand h1 {
    font-size: 26px;
  }

  .input-grid,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .summary-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .summary-strip div:last-child {
    border-bottom: 0;
  }

  .top-actions {
    width: 100%;
    justify-content: space-between;
  }
}
