:root {
  --bg: #f4f7f7;
  --panel: #ffffff;
  --ink: #092033;
  --muted: #5c7182;
  --line: #cfe0e8;
  --blue: #1769d1;
  --green: #0b8065;
  --amber: #9a6700;
  --red: #b42318;
  --soft-blue: #e9f2ff;
  --soft-green: #e9f8f3;
  --soft-amber: #fff6db;
  --shadow: 0 10px 26px rgba(16, 38, 57, 0.09);
}

* {
  box-sizing: border-box;
}

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

button,
select,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  padding: 10px 14px;
  font-weight: 760;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(23, 105, 209, 0.18);
}

button.secondary {
  background: #eef5fb;
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
}

.button-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 10px 14px;
  border: 1px solid var(--blue);
  border-radius: 8px;
  background: var(--blue);
  color: #fff;
  font-weight: 760;
  text-decoration: none;
  box-shadow: 0 8px 16px rgba(23, 105, 209, 0.18);
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
.nav-link:focus-visible {
  outline: 3px solid #f1cf6d;
  outline-offset: 2px;
}

select,
input {
  min-width: 230px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  font-weight: 700;
}

input {
  min-height: 43px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 292px 1fr;
  grid-template-rows: 84px 1fr;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  background: #123f63;
  color: #fff;
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: #fff;
  color: #123f63;
  font-weight: 900;
  border: 3px solid #b9d7e8;
}

.brand-title {
  font-size: 20px;
  font-weight: 860;
}

.brand-subtitle {
  color: #d1e5f4;
  font-size: 13px;
  margin-top: 2px;
}

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

.profile-switch {
  display: grid;
  gap: 3px;
  color: #d1e5f4;
  font-size: 11px;
  font-weight: 760;
}

.profile-switch select {
  min-width: 210px;
}

.segmented {
  display: flex;
  padding: 4px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  gap: 4px;
  flex-wrap: wrap;
}

.segmented button {
  display: grid;
  gap: 2px;
  text-align: left;
  background: transparent;
  border-radius: 8px;
  box-shadow: none;
  color: #d9ebf7;
  padding: 8px 12px;
}

.segmented button.active {
  background: #fff;
  color: #113c60;
}

.segmented button.module-part2 {
  background: #dff3e8;
  color: #126149;
}

.segmented button.module-part2.active {
  background: #bfe5d1;
  color: #0d513d;
}

.segmented button.module-part3 {
  background: #f8dfe8;
  color: #8b3154;
}

.segmented button.module-part3.active {
  background: #f1bfd1;
  color: #71233f;
}

.segmented button span {
  font-size: 11px;
  text-transform: uppercase;
  opacity: 0.82;
}

.segmented button strong {
  font-size: 13px;
}

.view-tabs {
  display: flex;
  gap: 6px;
  position: relative;
  z-index: 2;
  padding-left: 10px;
  margin: 0;
}

.view-tab {
  min-height: 32px;
  padding: 0 12px;
  border-radius: 9px 9px 0 0;
  border-bottom: 0;
  background: #dceff5;
  color: #28566d;
  box-shadow: none;
  font-size: 12px;
  font-weight: 760;
}

.view-tab + .view-tab {
  margin-left: -2px;
}

.view-tab.active {
  border-color: var(--line);
  background: var(--panel);
  color: #123f63;
  box-shadow: 0 -2px 6px rgba(24, 73, 87, 0.06);
}

.market-tab-panel {
  min-height: 360px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0 8px 8px 8px;
  background: var(--panel);
  padding: 16px;
}

.market-tab-panel .card:last-child,
.market-tab-panel .grid .card {
  margin-bottom: 0;
}

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

.market-profile {
  display: grid;
  gap: 8px;
}

.market-profile-row {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f6faff;
}

.market-profile-row span {
  color: var(--muted);
  font-size: 12px;
}

.sidebar {
  grid-row: 2;
  padding: 16px 12px;
  background: #eef5f7;
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.nav-group {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  padding: 10px;
  margin-bottom: 12px;
}

.nav-label {
  font-size: 12px;
  font-weight: 850;
  color: #486275;
  text-transform: uppercase;
  margin: 2px 8px 8px;
}

.nav-link {
  min-height: 42px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  color: var(--ink);
  text-decoration: none;
  border-radius: 8px;
}

.nav-link span {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid #b8d2e0;
  background: #fff;
  font-weight: 850;
  color: #1769d1;
}

.nav-link strong {
  font-size: 14px;
}

.nav-link.active {
  background: var(--soft-blue);
  outline: 1px solid #b4d4ff;
}

.main {
  grid-column: 2;
  grid-row: 2;
  overflow: auto;
}

.context {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.context > div {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.view {
  padding: 24px;
}

.view-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.12;
}

h2 {
  font-size: 17px;
}

p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.company-banner {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 16px;
  border: 1px solid #a7cce2;
  border-radius: 8px;
  overflow: hidden;
  background: #a7cce2;
}

.company-banner > div {
  display: grid;
  gap: 4px;
  min-height: 76px;
  padding: 14px 16px;
  background: #f8fcff;
}

.company-banner span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.company-banner strong {
  font-size: 16px;
}

.scenario-identity {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.scenario-parties {
  margin-bottom: 16px;
}

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

.metric {
  min-height: 112px;
  padding: 18px;
  display: grid;
  align-content: center;
  gap: 6px;
  border-top: 4px solid var(--blue);
}

.metric span,
.metric small {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  font-size: 28px;
  line-height: 1;
}

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

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

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

.card {
  overflow: hidden;
  margin-bottom: 16px;
}

.card-pad {
  padding: 18px;
}

.muted-card {
  padding: 22px;
  background: #fbfcfd;
}

.section-title {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 820;
}

.badge.blue {
  background: var(--soft-blue);
  border-color: #b4d4ff;
  color: #073d8f;
}

.badge.green {
  background: var(--soft-green);
  border-color: #9bd9c9;
  color: var(--green);
}

.badge.warn {
  background: var(--soft-amber);
  border-color: #f1cf6d;
  color: var(--amber);
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
  font-size: 13px;
}

th {
  color: #60788b;
  background: #f7fafc;
  font-size: 12px;
  text-transform: uppercase;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.status {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.status.ok {
  background: var(--soft-green);
  color: var(--green);
}

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

.status.danger {
  background: #fee4e2;
  color: var(--red);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 0;
}

.scope-filters {
  align-items: end;
  padding-top: 0;
}

.scope-filters .field {
  min-width: 260px;
}

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

.policy-settings {
  display: grid;
  gap: 16px;
}

.policy-settings .card {
  margin-bottom: 0;
}

.policy-ceilings {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.field select,
.field input {
  min-width: 0;
  width: 100%;
}

.field input[readonly] {
  background: #f7fafc;
  color: #486275;
}

.form-note {
  margin: 0;
  padding: 0 16px 16px;
  font-size: 13px;
}

.policy-actions {
  padding: 0 16px 16px;
}

.policy-note {
  display: grid;
  gap: 4px;
  margin: 14px 16px 0;
  padding: 12px 14px;
  border: 1px solid #b4d4ff;
  border-radius: 8px;
  background: var(--soft-blue);
  color: #073d8f;
  font-size: 13px;
}

.policy-note span {
  color: #355d85;
}

.form-message {
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 750;
}

.form-message.success {
  border-color: #9bd9c9;
  background: var(--soft-green);
  color: var(--green);
}

.form-message.error {
  border-color: #f7b4ad;
  background: #fff2f1;
  color: var(--red);
}

.surrender-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0 16px;
  border: 1px solid var(--line);
  background: var(--line);
}

.surrender-summary span {
  display: grid;
  gap: 4px;
  padding: 12px;
  color: var(--muted);
  background: #f8fcff;
  font-size: 12px;
  font-weight: 740;
}

.surrender-summary strong {
  color: var(--ink);
  font-size: 16px;
}

.validation-card {
  display: grid;
  gap: 8px;
  margin: 0 16px 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}

.validation-card > div {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.validation-card.valid {
  border-color: #9bd9c9;
  background: var(--soft-green);
  color: var(--green);
}

.validation-card.invalid {
  border-color: #f7b4ad;
  background: #fff2f1;
  color: var(--red);
}

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

.scenario-selector {
  align-items: end;
}

.scenario-description {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 70px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fcff;
  color: var(--muted);
  font-size: 13px;
}

.scenario-description strong {
  color: var(--ink);
}

.scenario-progress {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 12px;
  margin-top: 14px;
  padding: 10px 12px;
  border-left: 3px solid #2878b8;
  background: #f8fcff;
  color: var(--muted);
  font-size: 12px;
}

.scenario-progress strong {
  color: var(--ink);
}

.scenario-progress small {
  grid-column: 1 / -1;
}

.flow {
  display: grid;
  grid-template-columns: repeat(6, minmax(110px, 1fr));
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.flow-title {
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.flow-step {
  min-height: 64px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-content: center;
  gap: 2px 8px;
  padding: 9px 10px;
  border: 1px solid #a7cce2;
  border-radius: 8px;
  background: #f8fcff;
  border-left: 3px solid #2878b8;
}

.flow-number {
  grid-row: span 2;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #1769aa;
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}

.flow-step strong {
  align-self: end;
  color: var(--ink);
  font-size: 12px;
}

.flow-step small {
  align-self: start;
  color: var(--muted);
  font-size: 11px;
}

.empty {
  padding: 18px;
  color: var(--muted);
  background: #fbfcfd;
}

.events {
  display: grid;
}

.event {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr) 210px;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  align-items: start;
}

.event span,
.event small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
}

@media (max-width: 1100px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
  }

  .topbar,
  .context,
  .view-header {
    align-items: stretch;
    flex-direction: column;
  }

  .switches {
    justify-content: flex-start;
  }

  .sidebar {
    grid-row: 2;
    grid-column: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    max-height: none;
  }

  .main {
    grid-column: 1;
    grid-row: 3;
  }

  .metrics,
  .grid.two,
  .cards,
  .company-banner,
  .form-grid,
  .policy-ceilings,
  .surrender-summary {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 640px) {
  .view {
    padding: 14px;
  }

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

  .segmented,
  .sidebar {
    grid-template-columns: 1fr;
  }

  .segmented button {
    flex: 1 1 150px;
  }

  .profile-switch select,
  .switches > select {
    min-width: 0;
    width: 100%;
  }

  .flow {
    grid-template-columns: repeat(6, 150px);
  }
}
