:root {
  color-scheme: light;
  --bg: #f6f7f4;
  --panel: #ffffff;
  --ink: #18211f;
  --muted: #62706a;
  --line: #dbe1dc;
  --accent: #0f766e;
  --accent-dark: #0b4f4a;
  --amber: #b7791f;
  --red: #a33a2b;
  --blue: #315f99;
  --green-soft: #e6f3ef;
  --amber-soft: #fbf0dc;
  --red-soft: #f9e7e3;
  --shadow: 0 18px 45px rgba(24, 33, 31, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  overflow-x: hidden;
}

button,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px 28px;
  background: rgba(246, 247, 244, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
}

.topbar > div {
  max-width: 100%;
  min-width: 0;
}

.topbar > div:first-child {
  flex: 1 1 auto;
  width: auto;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.08;
  overflow-wrap: break-word;
}

h2 {
  font-size: 22px;
  letter-spacing: 0;
}

h3 {
  font-size: 18px;
  letter-spacing: 0;
}

main {
  width: min(1440px, calc(100% - 36px));
  margin: 24px auto 56px;
}

.eyebrow,
.section-label {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.asof {
  flex: 0 0 auto;
  min-width: 148px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  white-space: nowrap;
}

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

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

.thesis-panel {
  padding: 20px;
}

.summary-text {
  max-width: 850px;
  margin-top: 10px;
  color: #27332f;
  font-size: 17px;
  line-height: 1.55;
}

.metric-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 142px;
  padding: 18px;
}

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

.metric-panel strong {
  margin-top: 8px;
  color: var(--accent-dark);
  font-size: 34px;
  line-height: 1;
}

.metric-panel.warning strong {
  color: var(--amber);
}

.metric-panel p {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.disclaimer {
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 22px 0;
  max-width: 100%;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  min-height: 40px;
  padding: 0 14px;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.tab.active {
  color: #ffffff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin: 8px 0 16px;
}

.muted {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.filter-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

select {
  min-width: 150px;
  height: 38px;
  padding: 0 12px;
  color: var(--ink);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.holding-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 500px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ticker {
  font-size: 24px;
  font-weight: 800;
}

.name {
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
}

.weight {
  min-width: 64px;
  padding: 8px 10px;
  color: var(--accent-dark);
  background: var(--green-soft);
  border-radius: 8px;
  text-align: center;
  font-weight: 800;
}

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

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 5px 8px;
  color: var(--accent-dark);
  background: var(--green-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.meta-row span {
  padding: 5px 7px;
  background: #f1f3ef;
  border: 1px solid var(--line);
  border-radius: 999px;
}

.thesis {
  color: #27332f;
  font-size: 15px;
  line-height: 1.5;
}

.card-section-title {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

li {
  margin: 6px 0;
  line-height: 1.45;
}

.risk-list li {
  color: #4b3835;
}

.source-links {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.source-pill {
  padding: 6px 8px;
  background: #eef1ec;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.chart-panel {
  padding: 18px;
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 72px;
  align-items: center;
  gap: 12px;
  margin: 14px 0;
}

.bar-label {
  font-weight: 760;
}

.bar-track {
  height: 16px;
  overflow: hidden;
  background: #e8ede8;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-dark), var(--blue));
  border-radius: inherit;
}

.bar-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.bar-note {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 13px;
}

.allocation-grid,
.signal-grid,
.question-grid,
.source-list,
.claim-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.mini-card,
.signal-card,
.question-card,
.source-card,
.claim-card {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mini-card strong,
.signal-card strong,
.question-card strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
}

.severity {
  display: inline-block;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.severity.high {
  color: var(--red);
  background: var(--red-soft);
}

.severity.medium {
  color: var(--amber);
  background: var(--amber-soft);
}

.severity.info,
.severity.watch,
.severity.data-gap {
  color: var(--accent-dark);
  background: var(--green-soft);
}

.signal-card p,
.question-card p,
.source-card p,
.claim-card p {
  margin-top: 10px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.claims-head {
  margin-top: 28px;
}

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

.research-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.research-row .ticker {
  font-size: 28px;
}

.research-row p {
  color: #27332f;
  line-height: 1.55;
}

.source-card {
  min-height: 110px;
  overflow-wrap: anywhere;
}

.claim-card {
  min-height: 190px;
  overflow-wrap: anywhere;
}

.performance-panel {
  margin-bottom: 22px;
  padding: 18px;
}

.performance-head {
  margin-top: 0;
}

.portfolio-status {
  margin-top: 10px;
  padding: 12px 14px;
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.45;
}

.portfolio-status.ready {
  color: var(--accent-dark);
  background: var(--green-soft);
}

.portfolio-kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.portfolio-kpi {
  min-width: 0;
  padding: 12px;
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.portfolio-kpi span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.portfolio-kpi strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.positive {
  color: var(--accent-dark);
}

.negative {
  color: var(--red);
}

.portfolio-plot-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.portfolio-plot-grid figure {
  min-width: 0;
  margin: 0;
  padding: 12px;
  background: #f8faf8;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.portfolio-plot-grid figcaption {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.portfolio-plot-grid img,
.inline-chart {
  display: block;
  width: 100%;
  height: auto;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.portfolio-table-wrap {
  max-width: 100%;
  margin-top: 14px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.portfolio-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: var(--panel);
  font-size: 14px;
}

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

.portfolio-table th {
  color: var(--muted);
  background: #f8faf8;
  font-size: 12px;
  text-transform: uppercase;
}

.portfolio-table td span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.inline-bars {
  display: grid;
  gap: 8px;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.inline-bars > div {
  display: grid;
  grid-template-columns: 76px 1fr 92px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.inline-bars div div {
  height: 10px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.inline-bars i {
  display: block;
  height: 100%;
  background: var(--accent);
}

.empty-chart {
  padding: 30px;
  color: var(--muted);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 6px;
  text-align: center;
}

@media (max-width: 1040px) {
  .dashboard-grid,
  .holdings-grid,
  .allocation-grid,
  .signal-grid,
  .question-grid,
  .source-list,
  .claim-list,
  .portfolio-kpis,
  .portfolio-plot-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 880px) {
  h1 {
    font-size: 26px;
  }

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

  .asof {
    text-align: left;
  }

  main {
    width: calc(100% - 24px);
  }

  .dashboard-grid,
  .holdings-grid,
  .allocation-grid,
  .signal-grid,
  .question-grid,
  .source-list,
  .claim-list,
  .portfolio-kpis,
  .portfolio-plot-grid,
  .research-row {
    grid-template-columns: 1fr;
  }

  .holding-card {
    min-height: auto;
  }

  .bar-row {
    grid-template-columns: 92px 1fr 56px;
  }
}

@media (max-width: 560px) {
  .tabs {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .tab {
    flex: 1 1 calc(50% - 8px);
    padding: 0 10px;
    text-align: center;
  }
}
