:root {
  --bg: #f5f7f4;
  --surface: #ffffff;
  --surface-2: #eef4f1;
  --ink: #17211d;
  --muted: #61706a;
  --line: #dce5df;
  --teal: #157a6e;
  --blue: #2e5eaa;
  --amber: #b7791f;
  --coral: #bd4b42;
  --green: #2f7d4f;
  --shadow: 0 18px 50px rgba(23, 33, 29, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--bg);
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px;
  color: #f9fffc;
  background: #18352e;
}

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

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 8px;
  color: #eff9f4;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
}

.brand-name,
.brand-note,
.principles p,
.metric-card p,
.topbar-note,
.eyebrow,
.as-of,
.muted {
  margin: 0;
}

.brand-name {
  font-weight: 800;
}

.brand-note {
  color: rgba(249, 255, 252, 0.72);
  font-size: 0.85rem;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  width: 100%;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  color: rgba(249, 255, 252, 0.72);
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
}

.nav-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 6px;
  color: #cde7dc;
  background: rgba(255, 255, 255, 0.09);
  font-size: 0.78rem;
  font-weight: 800;
}

.principles {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.principles p {
  color: rgba(249, 255, 252, 0.8);
  font-size: 0.88rem;
}

.workspace {
  min-width: 0;
  padding: 28px;
}

.topbar,
.section-head,
.panel-head,
.topbar-actions,
.callout-grid {
  display: flex;
  align-items: center;
}

.topbar,
.section-head {
  justify-content: space-between;
  gap: 20px;
}

.topbar {
  margin-bottom: 28px;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1.1;
}

h2 {
  font-size: 1.35rem;
}

h3 {
  font-size: 1rem;
}

.eyebrow {
  color: var(--teal);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.as-of,
.muted,
.topbar-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.topbar-note {
  margin-top: 8px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.icon-button,
.text-button,
.primary-button {
  border: 1px solid var(--line);
  border-radius: 8px;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--ink);
  background: var(--surface);
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.text-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--teal);
  background: var(--surface);
  font-weight: 700;
}

.topbar-actions .text-button {
  min-height: 40px;
}

.primary-button {
  min-height: 42px;
  color: #ffffff;
  background: var(--teal);
  border-color: var(--teal);
  font-weight: 800;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
}

.metric-grid,
.dashboard-grid,
.data-grid,
.advisor-grid,
.simulator-layout,
.watchlist-grid,
.analytics-grid {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 20px 0 16px;
}

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

.metric-card {
  min-height: 124px;
  padding: 18px;
}

.metric-card p,
.metric-card span {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric-card strong {
  display: block;
  margin: 12px 0 6px;
  font-size: 1.8rem;
}

.dashboard-grid {
  grid-template-columns: 1.3fr 1fr;
  align-items: start;
}

.data-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.data-table-panel {
  grid-column: span 2;
}

.allocation-panel {
  grid-row: span 2;
}

.panel,
.table-wrap {
  padding: 18px;
}

.panel-head {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 10px;
  color: #13463f;
  background: #dff0eb;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.is-stale {
  color: #7c4a03;
  background: #fff1cf;
}

.allocation-bars,
.provider-list,
.factor-list,
.scenario-results,
.exposure-list,
.evidence-list {
  display: grid;
  gap: 12px;
}

.allocation-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) 74px;
  align-items: center;
  gap: 12px;
}

.bar-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.advisor-summary {
  margin: 0 0 16px;
  color: #31423b;
  line-height: 1.55;
}

.evidence-list span,
.scenario-results div,
.exposure-list div,
.factor-row,
.watch-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.evidence-list span {
  padding: 10px 12px;
  color: var(--muted);
}

.exposure-list div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 12px;
}

.provider-row {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfb;
}

.provider-row span {
  color: var(--muted);
}

.table-wrap {
  margin-top: 18px;
  overflow-x: auto;
  padding: 0;
}

.json-panel {
  margin-top: 18px;
}

.json-panel textarea {
  width: 100%;
  min-height: 180px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 0.86rem;
  line-height: 1.5;
}

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

.compact-table table {
  min-width: 760px;
}

th,
td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.ticker {
  font-weight: 850;
}

.advisor-grid {
  grid-template-columns: 1fr 1fr;
  margin-top: 18px;
}

.recommendation-card p {
  color: #31423b;
  line-height: 1.55;
}

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

.scorecard-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
}

.scorecard-item span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.scorecard-item strong {
  display: block;
  margin-top: 4px;
  color: var(--ink);
  font-size: 1rem;
}

.callout-grid {
  align-items: stretch;
  gap: 12px;
  flex-wrap: wrap;
}

.callout-grid div {
  flex: 1 1 220px;
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}

.callout-grid span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.callout-grid ul {
  margin: 0;
  padding-left: 18px;
}

.callout-grid li {
  margin-bottom: 8px;
  line-height: 1.35;
}

.factor-row {
  padding: 12px;
}

.factor-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.factor-row p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.factor-detail {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 8px 12px;
  margin: 12px 0 0;
  color: #33463f;
  font-size: 0.86rem;
}

.factor-detail dt {
  color: var(--muted);
  font-weight: 800;
}

.factor-detail dd {
  margin: 0;
}

.feature-records {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.feature-record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
}

.feature-record strong,
.feature-record span {
  display: block;
}

.feature-record span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.feature-record > div:last-child {
  text-align: right;
}

.simulator-layout {
  grid-template-columns: 360px minmax(0, 1fr);
  align-items: start;
  margin-top: 18px;
}

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

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

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

.chip-input {
  width: 96px;
}

.scenario-results div {
  display: grid;
  gap: 5px;
  padding: 12px;
}

.scenario-results span {
  color: var(--muted);
  font-size: 0.86rem;
}

.watchlist-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.analytics-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 18px;
}

.analytics-grid .panel:first-child {
  grid-column: span 2;
}

.analytics-list,
.history-list,
.risk-list {
  display: grid;
  gap: 12px;
}

.analytics-row,
.history-row,
.risk-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  padding: 12px;
}

.analytics-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) 86px;
  align-items: center;
  gap: 12px;
}

.history-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.history-row span,
.risk-row p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.risk-row header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.risk-row p {
  margin-top: 8px;
}

.watch-card {
  min-height: 170px;
  padding: 16px;
}

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

.watch-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.watch-card > strong {
  display: block;
  margin-bottom: 8px;
}

.score-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  padding: 0 9px;
  color: #ffffff;
  background: var(--blue);
  font-size: 0.8rem;
  font-weight: 800;
}

.accent-blue {
  background: var(--blue);
}

.accent-amber {
  background: var(--amber);
}

.accent-coral {
  background: var(--coral);
}

.accent-green {
  background: var(--green);
}

.accent-purple {
  background: #6d5bd0;
}

.accent-slate {
  background: #64748b;
}

.is-error {
  color: #8a1f17;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 4;
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    padding: 16px;
  }

  .nav-list {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    overflow-x: auto;
  }

  .principles {
    display: none;
  }

  .metric-grid,
  .watchlist-grid,
  .analytics-grid,
  .data-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 780px) {
  .workspace {
    padding: 18px;
  }

  .topbar,
  .section-head,
  .advisor-grid,
  .dashboard-grid,
  .data-grid,
  .simulator-layout,
  .metric-grid,
  .watchlist-grid,
  .analytics-grid {
    grid-template-columns: 1fr;
  }

  .topbar,
  .section-head {
    align-items: flex-start;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .nav-list {
    grid-template-columns: repeat(7, 132px);
  }

  .allocation-row {
    grid-template-columns: 78px minmax(0, 1fr) 58px;
  }

  .callout-grid {
    display: grid;
  }

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

  .factor-detail {
    grid-template-columns: 1fr;
  }

  .feature-record {
    grid-template-columns: 1fr;
  }

  .feature-record > div:last-child {
    text-align: left;
  }

  .analytics-grid .panel:first-child {
    grid-column: auto;
  }

  .data-table-panel {
    grid-column: auto;
  }

  .analytics-row,
  .history-row {
    display: grid;
    grid-template-columns: 1fr;
    align-items: stretch;
  }
}

@media (max-width: 460px) {
  h1 {
    font-size: 1.55rem;
  }

  .brand {
    align-items: flex-start;
  }

  .metric-card,
  .panel {
    padding: 14px;
  }
}
