:root {
  color-scheme: light;
  --ink: #16202a;
  --muted: #637083;
  --line: #dfe5ea;
  --panel: #ffffff;
  --soft: #f5f7f9;
  --navy: #10283b;
  --teal: #0f8b8d;
  --green: #2e9d67;
  --amber: #d58b1f;
  --red: #c44e43;
  --blue: #2962a8;
  --shadow: 0 18px 48px rgba(14, 31, 44, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

button,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: var(--navy);
  color: #f7fbfc;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.brand {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f0b547;
  color: #112331;
  font-weight: 800;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: rgba(247, 251, 252, 0.68);
  margin-top: 2px;
}

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

.nav-item {
  color: rgba(247, 251, 252, 0.78);
  text-decoration: none;
  border-radius: 8px;
  padding: 12px 14px;
  border: 1px solid transparent;
  transition: 160ms ease;
}

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

.sidebar-panel {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
}

.sidebar-panel span {
  color: rgba(247, 251, 252, 0.7);
  font-size: 0.84rem;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

.topbar h1 {
  max-width: 840px;
  margin: 4px 0 0;
  font-size: clamp(1.65rem, 3vw, 3rem);
  line-height: 1.04;
  letter-spacing: 0;
}

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

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

.primary-button,
.ghost-button,
.insight-actions button,
.segmented-control button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 700;
}

.primary-button {
  background: var(--teal);
  color: white;
}

.ghost-button {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.icon-button {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  place-items: center;
  gap: 4px;
  padding: 10px;
}

.icon-button span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--ink);
}

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

.content-grid {
  margin-top: 16px;
}

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

.health-panel {
  grid-column: span 2;
  min-height: 356px;
  padding: 22px;
}

.insight-panel {
  grid-column: span 2;
  min-height: 356px;
  padding: 24px;
  color: white;
  background:
    linear-gradient(135deg, rgba(16, 40, 59, 0.94), rgba(15, 139, 141, 0.82)),
    url("assets/portfolio-intelligence-preview.png");
  background-size: cover;
  background-position: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.insight-panel .eyebrow {
  color: #f6d483;
}

.insight-panel h2 {
  max-width: 660px;
  margin: 16px 0;
  font-size: clamp(1.6rem, 3vw, 2.8rem);
  line-height: 1.04;
  letter-spacing: 0;
}

.insight-panel p {
  max-width: 680px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 1rem;
  line-height: 1.6;
}

.insight-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.insight-actions button {
  color: #10283b;
  background: #ffffff;
}

.panel-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.section-heading.compact {
  margin-bottom: 14px;
}

h2 {
  margin: 4px 0 0;
  font-size: 1.16rem;
  letter-spacing: 0;
}

.health-panel h2 {
  font-size: 3.4rem;
  line-height: 0.95;
}

.health-panel h2 small {
  color: var(--muted);
  font-size: 1.1rem;
  margin-left: 3px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.status-pill.positive {
  color: #17633e;
  background: #dff4e9;
}

.status-pill.neutral {
  color: #704a10;
  background: #f9ead2;
}

.status-pill.warning {
  color: #8a3a32;
  background: #f8dfdc;
}

.score-ring {
  display: grid;
  place-items: center;
  position: relative;
  width: 190px;
  height: 190px;
  margin: 14px auto;
}

.score-ring svg {
  width: 190px;
  height: 190px;
  transform: rotate(-90deg);
}

.score-ring circle {
  fill: none;
  stroke-width: 16;
}

.ring-bg {
  stroke: #e8edf1;
}

.ring-value {
  stroke: var(--green);
  stroke-linecap: round;
  stroke-dasharray: 389;
  stroke-dashoffset: 70;
}

.score-ring div {
  position: absolute;
  text-align: center;
}

.score-ring strong,
.score-ring span {
  display: block;
}

.score-ring strong {
  font-size: 2rem;
}

.score-ring span {
  color: var(--muted);
  font-size: 0.8rem;
}

.trend-strip {
  height: 78px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 8px;
}

.trend-strip span,
.bar-chart span {
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--teal), #b8dad9);
}

.metric-card {
  min-height: 132px;
  padding: 18px;
  display: grid;
  align-content: space-between;
}

.metric-card span,
.metric-card small {
  color: var(--muted);
}

.metric-card strong {
  font-size: 2rem;
}

.metric-card small.up {
  color: var(--green);
}

.metric-card small.down {
  color: var(--red);
}

.wide-panel {
  grid-column: span 4;
  padding: 20px;
}

.panel {
  grid-column: span 2;
  padding: 20px;
  min-height: 330px;
}

.segmented-control {
  display: flex;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
}

.segmented-control button {
  min-height: 34px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
}

.segmented-control button.active {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.agent-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.agent-card {
  border: 1px solid var(--line);
  background: var(--soft);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 10px;
  min-height: 168px;
}

.agent-card strong {
  line-height: 1.25;
}

.agent-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.agent-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dbecef;
  color: var(--teal);
  font-weight: 800;
}

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

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

.risk-item header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.risk-item p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.probability {
  height: 8px;
  background: #e1e7ec;
  border-radius: 999px;
  overflow: hidden;
}

.probability i {
  display: block;
  height: 100%;
  background: var(--red);
}

.bar-chart {
  height: 168px;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  align-items: end;
  gap: 12px;
  padding-top: 20px;
  border-bottom: 1px solid var(--line);
}

.driver-list,
.capacity-list,
.report-timeline {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.driver-list div,
.report-timeline div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.driver-list span,
.report-timeline span,
.report-timeline small {
  color: var(--muted);
}

.report-timeline div {
  display: grid;
  grid-template-columns: 1.1fr 0.7fr 1.2fr;
  align-items: center;
}

.capacity-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) 48px;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.capacity-row div {
  height: 10px;
  border-radius: 999px;
  background: #e1e7ec;
  overflow: hidden;
}

.capacity-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 14px 16px;
  border-radius: 8px;
  background: #10283b;
  color: white;
  box-shadow: var(--shadow);
  transform: translateY(18px);
  opacity: 0;
  pointer-events: none;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

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

  .sidebar {
    position: fixed;
    z-index: 20;
    transform: translateX(-100%);
    transition: 180ms ease;
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .icon-button {
    display: grid;
  }

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

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

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

  .topbar {
    display: grid;
  }

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

  .health-panel,
  .insight-panel,
  .metric-card,
  .panel,
  .wide-panel {
    grid-column: span 4;
  }

  .agent-grid,
  .report-timeline div {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .section-heading {
    display: grid;
  }

  .capacity-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .workspace {
    padding: 14px;
  }

  .health-panel,
  .insight-panel,
  .panel,
  .wide-panel {
    padding: 16px;
  }

  .metric-card {
    min-height: 116px;
  }

  .segmented-control {
    width: 100%;
  }

  .segmented-control button {
    flex: 1;
    padding: 0 8px;
  }
}
