:root {
  color-scheme: light;
  --bg: #f7f9f8;
  --panel: #ffffff;
  --ink: #130f33;
  --muted: #6d7e80;
  --line: #d8e1df;
  --line-strong: rgba(19, 15, 51, 0.2);
  --brand-navy: #130f33;
  --brand-navy-2: #162668;
  --brand-blue: #324473;
  --brand-mint: #a5bebe;
  --brand-mint-2: #aac8c8;
  --brand-pale: #c6dad5;
  --brand-gray: #6d7e80;
  --brand-lilac: #aaa5be;
  --accent: #130f33;
  --accent-ink: #ffffff;
  --warn: #7a5a04;
  --danger: #b42318;
  --good: #13614f;
  --shadow: 0 18px 42px rgba(19, 15, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Onest, Roboto, "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(rgba(19, 15, 51, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(19, 15, 51, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
}

a {
  color: var(--brand-blue);
}

.text-link {
  color: var(--brand-blue);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.link-button {
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--brand-blue);
  cursor: pointer;
  display: inline;
  font-size: 13px;
  font-weight: 800;
  height: auto;
  padding: 0;
  text-align: left;
  width: auto;
}

.link-button:hover,
.link-button:focus {
  background: transparent;
  border: 0;
  color: var(--brand-blue);
  outline: none;
  text-decoration: underline;
}

.shell {
  min-height: 100vh;
}

.topbar {
  align-items: center;
  background: var(--brand-navy);
  border-bottom: 1px solid rgba(198, 218, 213, 0.28);
  box-shadow: 0 12px 28px rgba(19, 15, 51, 0.14);
  color: #ffffff;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 14px 24px;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  border-left: 3px solid var(--brand-mint);
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 12px;
}

.brand strong {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.1;
}

.brand span {
  color: var(--brand-pale);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

.topbar .muted {
  color: var(--brand-pale);
}

.content {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  max-width: 100vw;
  padding: 22px;
}

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

.panel-header {
  background:
    linear-gradient(90deg, rgba(165, 190, 190, 0.22), transparent 55%),
    #ffffff;
  border-bottom: 1px solid var(--line);
  padding: 16px 18px;
}

.panel-header h1,
.panel-header h2 {
  color: var(--brand-navy);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  margin: 0;
}

.panel-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}

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

.form-grid {
  display: grid;
  gap: 14px;
}

.row {
  display: grid;
  gap: 7px;
}

label {
  color: var(--brand-navy);
  font-size: 13px;
  font-weight: 750;
}

.field-help {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin: -2px 0 0;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: var(--ink);
  height: 38px;
  padding: 8px 10px;
  width: 100%;
}

input::placeholder {
  color: #7d7882;
}

input:focus,
select:focus {
  border-color: var(--brand-navy);
  box-shadow: 0 0 0 3px rgba(165, 190, 190, 0.45);
  outline: none;
}

input.locked,
input[readonly] {
  background: rgba(198, 218, 213, 0.22);
  border-color: var(--brand-mint);
}

.input-action {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.input-action button {
  min-width: 130px;
}

.brand-chip-list {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  min-height: 30px;
}

.brand-chip {
  align-items: center;
  background: rgba(198, 218, 213, 0.42);
  border: 1px solid var(--brand-mint);
  border-radius: 999px;
  color: var(--brand-navy);
  display: inline-flex;
  font-size: 12px;
  font-weight: 750;
  gap: 6px;
  max-width: 100%;
  min-height: 28px;
  padding: 4px 5px 4px 10px;
}

.brand-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-chip-edit {
  background: #ffffff;
  border: 1px solid rgba(165, 190, 190, 0.85);
  border-radius: 999px;
  color: var(--brand-navy);
  font-size: 13px;
  height: 22px;
  line-height: 1;
  min-width: 0;
  padding: 0;
  width: 22px;
}

.brand-chip-edit:hover {
  background: var(--brand-pale);
  border-color: var(--brand-pale);
  color: var(--brand-navy);
}

.brand-chip-empty {
  color: var(--muted);
  font-size: 12px;
}

button.locked,
.button.locked {
  background: var(--brand-pale);
  border-color: var(--brand-pale);
  color: var(--brand-navy);
}

.group-tools {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.group-filter input {
  height: 34px;
}

.groups-list {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  display: grid;
  max-height: 260px;
  overflow: auto;
}

.group-option {
  align-items: center;
  border-bottom: 1px solid rgba(216, 225, 223, 0.9);
  color: var(--ink);
  cursor: pointer;
  display: grid;
  font-size: 13px;
  font-weight: 560;
  gap: 8px;
  grid-template-columns: 18px 1fr auto;
  min-height: 34px;
  padding: 7px 9px;
}

.group-option:last-child {
  border-bottom: 0;
}

.group-option:hover {
  background: rgba(198, 218, 213, 0.32);
}

.group-option input {
  accent-color: var(--brand-navy);
  height: 16px;
  margin: 0;
  padding: 0;
  width: 16px;
}

.group-option span {
  line-height: 1.25;
  min-width: 0;
  overflow-wrap: anywhere;
}

.group-option em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

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

.button-row {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 4px;
}

.results-pager {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
}

.results-pager[hidden] {
  display: none;
}

.results-pager-info,
.results-pager-controls {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 12px;
  gap: 8px;
}

.results-pager-controls button {
  height: 32px;
}

.results-pager-controls select {
  height: 32px;
  min-width: 82px;
  width: auto;
}

.results-pager-controls label {
  color: var(--muted);
  font-size: 12px;
}

button,
.button {
  align-items: center;
  background: var(--brand-navy);
  border: 1px solid var(--brand-navy);
  border-radius: 6px;
  color: var(--accent-ink);
  cursor: pointer;
  display: inline-flex;
  font-weight: 800;
  gap: 8px;
  height: 38px;
  justify-content: center;
  padding: 0 14px;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease;
  white-space: nowrap;
}

button:hover,
.button:hover {
  background: var(--brand-navy-2);
  border-color: var(--brand-navy-2);
}

button.secondary,
.button.secondary {
  background: #ffffff;
  border-color: var(--brand-mint);
  color: var(--brand-navy);
}

.topbar button.secondary,
.topbar .button.secondary {
  background: transparent;
  border-color: rgba(198, 218, 213, 0.62);
  color: #ffffff;
}

button.secondary:hover,
.button.secondary:hover {
  background: var(--brand-pale);
  border-color: var(--brand-pale);
  color: var(--brand-navy);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.status {
  border: 1px solid transparent;
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 9px;
}

.status.ready,
.status.completed {
  background: rgba(198, 218, 213, 0.72);
  border-color: var(--brand-mint);
  color: var(--good);
}

.status.running,
.status.created {
  background: rgba(170, 200, 200, 0.42);
  border-color: var(--brand-mint-2);
  color: var(--brand-blue);
}

.status.demo {
  background: rgba(170, 165, 190, 0.28);
  border-color: var(--brand-lilac);
  color: var(--brand-navy);
}

.status.failed {
  background: #fee4e2;
  border-color: #fda29b;
  color: var(--danger);
}

.topbar .status {
  border-color: rgba(198, 218, 213, 0.42);
}

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

.result-limits {
  color: var(--muted);
  display: inline-flex;
  font-size: 13px;
  font-weight: 750;
  margin-left: 10px;
}

.metric {
  background: #ffffff;
  border: 1px solid var(--line);
  border-left: 4px solid var(--brand-mint);
  border-radius: 8px;
  min-width: 0;
  padding: 12px;
}

.metric span {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.metric strong {
  color: var(--brand-navy);
  display: block;
  font-size: 22px;
  font-weight: 850;
  line-height: 1.12;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.forecast {
  margin-bottom: 16px;
  min-width: 0;
}

.forecast h3 {
  color: var(--brand-navy);
  font-size: 15px;
  font-weight: 800;
  margin: 0 0 10px;
}

.forecast-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  min-width: 0;
}

.table-wrap {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
}

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

.forecast-table {
  min-width: 0;
}

.forecast-table th,
.forecast-table td {
  padding: 8px 9px;
}

.forecast-scenarios-table {
  table-layout: fixed;
}

.forecast-scenarios-table th:first-child,
.forecast-scenarios-table td:first-child {
  width: 42%;
}

.forecast-types-table {
  min-width: 940px;
}

.forecast-types-table th:first-child,
.forecast-types-table td:first-child {
  min-width: 210px;
  white-space: nowrap;
}

.results-table {
  min-width: 3900px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  padding: 10px 11px;
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--brand-navy);
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
  position: sticky;
  top: 0;
  z-index: 1;
}

.result-filters-row th {
  background: #eef5f3;
  border-bottom-color: var(--line-strong);
  padding: 6px;
  top: 38px;
  z-index: 2;
}

.result-filter-select {
  background: #ffffff;
  border-color: var(--line-strong);
  color: var(--brand-navy);
  font-size: 12px;
  font-weight: 650;
  height: 30px;
  min-width: 120px;
  padding: 4px 6px;
}

.sort-header {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  font-size: inherit;
  font-weight: inherit;
  gap: 6px;
  height: auto;
  justify-content: flex-start;
  line-height: 1.2;
  min-height: 0;
  padding: 0;
  text-align: left;
  white-space: normal;
  width: 100%;
}

.sort-header:hover,
.sort-header:focus {
  background: transparent;
  border: 0;
  color: var(--brand-pale);
  outline: none;
}

.sort-header:focus-visible {
  box-shadow: 0 0 0 2px rgba(198, 218, 213, 0.5);
}

.sort-header-num {
  justify-content: flex-end;
  text-align: right;
}

.sort-indicator {
  color: var(--brand-pale);
  flex: 0 0 auto;
  font-size: 12px;
  line-height: 1;
}

tbody tr:nth-child(even) {
  background: rgba(198, 218, 213, 0.16);
}

tbody tr:hover {
  background: rgba(165, 190, 190, 0.28);
}

td.num,
th.num {
  text-align: right;
}

.login {
  display: grid;
  min-height: 100vh;
  padding: 20px;
  place-items: center;
}

.semantic-page {
  margin: 0 auto;
  max-width: 1440px;
  padding: 24px;
}

.semantic-table-wrap {
  max-height: calc(100vh - 160px);
}

.semantic-table th {
  top: 0;
  z-index: 3;
}

.semantic-filters-row th {
  background: #eef5f3;
  border-bottom-color: var(--line-strong);
  padding: 6px;
  top: 38px;
  z-index: 4;
}

.semantic-filter-select {
  background: #ffffff;
  border-color: var(--line-strong);
  color: var(--brand-navy);
  font-size: 12px;
  font-weight: 650;
  height: 30px;
  min-width: 150px;
  padding: 4px 6px;
}

.semantic-edit-input {
  height: 30px;
  min-width: 180px;
  padding: 4px 6px;
}

.semantic-delete-button {
  background: #fee4e2;
  border-color: #fda29b;
  color: var(--danger);
  height: 30px;
  padding: 4px 9px;
}

.semantic-delete-button:hover,
.semantic-delete-button:focus {
  background: #fecdca;
  border-color: #f97066;
  color: var(--danger);
}

.login .panel {
  max-width: 420px;
  width: 100%;
}

.login .panel-header {
  background: var(--brand-navy);
  border-bottom: 1px solid rgba(198, 218, 213, 0.28);
  color: #ffffff;
  padding: 22px 24px;
}

.login .panel-header h1 {
  color: #ffffff;
  font-size: 28px;
}

.login .panel-header .muted {
  color: var(--brand-pale);
  display: block;
  margin-top: 4px;
  text-transform: uppercase;
}

.login .panel-body {
  padding: 22px 24px 24px;
}

.error {
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 6px;
  color: #9f1239;
  margin-bottom: 12px;
  padding: 10px;
}

.modal-backdrop {
  background: rgba(19, 15, 51, 0.46);
  bottom: 0;
  left: 0;
  position: fixed;
  right: 0;
  top: 0;
  z-index: 20;
}

.modal {
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 64px rgba(19, 15, 51, 0.26);
  left: 50%;
  max-height: min(76vh, 680px);
  max-width: min(720px, calc(100vw - 32px));
  overflow: auto;
  padding: 18px;
  position: fixed;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 620px;
  z-index: 21;
}

.modal-header {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: -2px 0 14px;
  padding-bottom: 12px;
}

.modal-header h2 {
  color: var(--brand-navy);
  font-size: 18px;
  margin: 0;
}

.modal-close {
  width: auto;
}

.model-table {
  min-width: 420px;
}

.model-input {
  height: 32px;
  max-width: 140px;
  text-align: right;
}

.modifier-select {
  background-color: #ffffff;
  border-color: var(--brand-mint);
  color: var(--brand-navy);
  font-size: 12px;
  font-weight: 750;
  height: 32px;
  min-width: 190px;
  padding: 5px 8px;
}

@media (max-width: 980px) {
  .content {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .forecast-grid {
    grid-template-columns: 1fr;
  }
}

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

  .topbar,
  .content {
    padding-left: 14px;
    padding-right: 14px;
  }

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

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

  button,
  .button {
    width: 100%;
  }
}
