:root {
  --ink: #061335;
  --muted: #5b6478;
  --line: #d9dfec;
  --field: #f7f9fd;
  --soft: #f4f7fb;
  --accent: #0b49b5;
  --accent-dark: #073780;
  --accent-soft: #edf4ff;
  --success: #0b6b36;
  --success-soft: #edfff4;
  --warn: #a45b00;
  --error: #ad1d1d;
  --surface: #ffffff;
  --page: #eef3f8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

.is-embedded body {
  background: var(--page);
}

.is-embedded .topbar {
  position: static;
  min-height: auto;
  padding: 10px 0 14px;
  background: var(--page);
  border-bottom: 0;
}

.is-embedded .topnav {
  display: none;
}

.is-embedded .brand-logo {
  width: 140px;
}

.is-embedded .page-shell {
  width: 100%;
  padding: 0;
}

.is-embedded .hero {
  margin-top: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 78px;
  padding: 10px 32px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand-logo {
  width: 170px;
  max-height: 58px;
  object-fit: contain;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topnav a {
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
}

.language-control {
  position: relative;
}

.language-buttons {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.language-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 48px;
  min-height: 34px;
  padding: 6px 8px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.language-button:hover,
.language-button:focus-visible {
  background: rgba(0, 124, 140, 0.1);
  color: var(--ink);
  outline: none;
}

.language-button.is-active {
  background: var(--accent);
  color: #fff;
}

.language-select-fallback {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.6fr);
  align-items: center;
  gap: 24px;
  margin-bottom: 22px;
}

.hero.compact {
  grid-template-columns: 1fr;
}

.hero-compact {
  grid-template-columns: minmax(0, 0.95fr) minmax(280px, 0.42fr);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

h1 {
  max-width: 850px;
  margin: 0;
  font-size: 46px;
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 20px;
  font-size: 22px;
}

h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.hero-photo {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
}

.quote-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 0.42fr);
  gap: 24px;
  align-items: start;
  min-width: 0;
}

.quote-flow {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.quote-sidebar {
  position: sticky;
  top: 100px;
  display: grid;
  gap: 16px;
}

.admin-workspace {
  display: grid;
  gap: 24px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(320px, 0.48fr);
  gap: 24px;
  align-items: start;
}

.admin-sim-layout {
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.42fr);
}

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

.panel.narrow {
  max-width: 520px;
}

.form-section {
  display: grid;
  gap: 18px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.section-heading > div {
  min-width: 0;
}

.section-heading h2 {
  margin-bottom: 4px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.step-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

fieldset {
  display: grid;
  gap: 12px;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  font-weight: 800;
}

label {
  color: var(--ink);
  font-weight: 700;
}

.tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 6px;
  border: 1px solid #9eb9ef;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  vertical-align: text-top;
}

.tooltip::before,
.tooltip::after {
  position: absolute;
  left: 50%;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 120ms ease, transform 120ms ease;
}

.tooltip::before {
  content: "";
  bottom: calc(100% + 4px);
  border: 6px solid transparent;
  border-top-color: var(--ink);
}

.tooltip::after {
  content: attr(data-tooltip);
  bottom: calc(100% + 15px);
  width: min(280px, 70vw);
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  box-shadow: 0 10px 28px rgba(6, 19, 53, 0.18);
}

.tooltip:hover::before,
.tooltip:hover::after,
.tooltip:focus::before,
.tooltip:focus::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tooltip:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
}

input[type="radio"],
input[type="checkbox"] {
  width: auto;
  min-height: 0;
  margin-right: 8px;
}

input[type="range"] {
  min-width: 0;
  padding-right: 0;
  padding-left: 0;
}

.choice-group {
  gap: 10px;
}

.segmented-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.segmented-options.three-columns,
.field-grid.three-columns {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.segmented-option {
  position: relative;
  display: grid;
  gap: 4px;
  min-height: 86px;
  padding: 14px 14px 14px 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  cursor: pointer;
}

.segmented-option input {
  position: absolute;
  left: 16px;
  top: 18px;
}

.segmented-option span {
  font-weight: 800;
}

.segmented-option small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.segmented-option:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}

input[readonly],
input:disabled {
  color: var(--muted);
  background: #eceff6;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 0;
  min-width: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  min-width: 0;
}

.range-number {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 128px;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

output {
  color: var(--muted);
  font-weight: 700;
}

.help-text {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.mode-panel {
  display: grid;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  min-width: 0;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-width: 0;
}

.checkbox-grid label {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 46px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  font-weight: 700;
  min-width: 0;
  overflow-wrap: anywhere;
}

.checkbox-grid input {
  flex: 0 0 auto;
  margin-top: 4px;
  margin-right: 0;
}

.checkbox-grid label span[data-i18n] {
  flex: 1 1 160px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.is-disabled-option {
  color: var(--muted);
  background: #eef1f7 !important;
}

.is-disabled-option input {
  cursor: not-allowed;
}

.note {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--warn);
  background: #fff7e8;
  color: #633900;
}

.errors {
  margin: 14px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--error);
  background: #fff0f0;
  color: var(--error);
}

.summary {
  margin: 24px 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
}

.summary-panel {
  display: grid;
  gap: 18px;
}

.summary-panel h2 {
  margin-bottom: 0;
}

.disclaimer {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.disclaimer h2 {
  margin-bottom: 8px;
  font-size: 18px;
}

.disclaimer p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 14px;
}

.disclaimer p:last-child {
  margin-bottom: 0;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.summary-list div,
dl div {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.summary-list div {
  align-items: flex-start;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

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

.summary-status-row {
  display: grid !important;
  gap: 6px !important;
}

.summary-status-row dd {
  text-align: left;
}

.summary-status-card {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.summary-status-card span {
  color: var(--muted);
}

.summary-status-card strong {
  font-size: 14px;
  line-height: 1.35;
}

.highlight-row {
  padding: 14px;
  border: 1px solid #8bd7ad !important;
  border-radius: 8px;
  background: var(--success-soft);
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 800;
  text-align: right;
  overflow-wrap: anywhere;
}

.status-ok {
  color: var(--success);
}

.status-warn {
  color: var(--warn);
}

button,
.primary-button,
.button-link {
  min-height: 48px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--accent);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
}

button:hover,
.primary-button:hover,
.button-link:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
  color: #fff;
}

button:disabled,
.primary-button:disabled,
button:disabled:hover,
.primary-button:disabled:hover {
  border-color: var(--line);
  background: #eef1f7;
  color: var(--muted);
  cursor: not-allowed;
}

.danger-button {
  border-color: var(--error);
  color: var(--error);
}

.danger-button:hover {
  border-color: var(--error);
  background: var(--error);
  color: #fff;
}

.button-row,
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.button-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

#configEditor {
  min-height: 520px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 14px;
}

.versions-list {
  margin-top: 18px;
}

.version-card-list {
  display: grid;
  gap: 14px;
}

.version-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.version-card.is-active-version {
  border-color: #8bd7ad;
  background: var(--success-soft);
}

.version-card-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
}

.version-title-group {
  min-width: 0;
}

.version-title-group .eyebrow {
  margin-bottom: 4px;
}

.version-title-group h3 {
  margin: 0;
  overflow-wrap: anywhere;
}

.version-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.version-positioning {
  margin: -4px 0 0;
  color: var(--muted);
}

.version-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.version-metrics div {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.version-metrics dd {
  text-align: left;
}

.version-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding-top: 2px;
}

.version-meta div {
  justify-content: flex-start;
}

.version-meta dd {
  text-align: left;
  font-weight: 700;
}

.status-badge {
  display: inline-block;
  min-width: 82px;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f7f9fd;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.status-active {
  border-color: #8bd7ad;
  background: #edfff4;
  color: #0b6b36;
}

.status-draft {
  border-color: #d7b56a;
  background: #fff7e8;
  color: #633900;
}

.status-archived {
  background: #eef1f7;
}

.status-loaded {
  border-color: #9eb9ef;
  background: #edf4ff;
  color: var(--accent);
}

.version-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.version-actions button {
  min-height: 40px;
  padding: 0 14px;
}

.compact-action {
  width: auto;
}

.formula-doc {
  margin-bottom: 24px;
}

.formula-doc p {
  max-width: 980px;
  margin: 0 0 14px;
  color: var(--muted);
}

.formula-doc pre {
  margin: 14px 0 18px;
  padding: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fd;
  color: var(--ink);
}

.formula-doc code {
  font-family: Consolas, "Courier New", monospace;
}

.formula-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0 4px;
}

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

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

.formula-table td:first-child {
  width: 28%;
  font-weight: 700;
}

.hidden {
  display: none !important;
}

@media (max-width: 980px) {
  .topbar,
  .hero,
  .quote-layout,
  .admin-grid,
  .field-grid,
  .field-grid.three-columns,
  .range-number,
  .segmented-options,
  .segmented-options.three-columns,
  .checkbox-grid,
  .version-card-header,
  .version-metrics,
  .version-meta {
    grid-template-columns: 1fr;
  }

  .version-badges {
    justify-content: flex-start;
  }

  .quote-sidebar {
    position: static;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    padding: 12px 20px;
  }

  .topbar-actions {
    align-items: flex-start;
    justify-content: space-between;
    width: 100%;
  }

  .hero {
    gap: 18px;
  }

  h1 {
    font-size: 34px;
  }

  .page-shell {
    width: min(100% - 24px, 1360px);
    padding-top: 18px;
  }

  .hero-photo {
    max-height: 220px;
  }
}

@media (max-width: 560px) {
  .panel {
    padding: 18px;
  }

  h1 {
    font-size: 30px;
  }

  .section-heading {
    gap: 10px;
  }

  .segmented-option {
    min-height: 74px;
  }

  .tooltip::before {
    display: none;
  }

  .tooltip::after {
    position: fixed;
    right: 16px;
    bottom: 16px;
    left: 16px;
    width: auto;
    max-width: none;
    transform: translate(0, 8px);
  }

  .tooltip:hover::after,
  .tooltip:focus::after {
    transform: translate(0, 0);
  }
}
