:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667085;
  --line: #d9e0e8;
  --brand: #176b87;
  --brand-dark: #0f4c5c;
  --accent: #d45b39;
  --green: #18794e;
  --red: #c0342b;
  --amber: #9a6700;
  --shadow: 0 18px 50px rgba(31, 45, 61, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 24px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 30;
  overflow-y: auto;
}

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

.mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: var(--brand);
  color: white;
  font-weight: 800;
  border-radius: 8px;
}

.brand h1,
.brand p,
.topbar h2,
.topbar p,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  line-height: 1.15;
}

.brand p,
.panel p,
.muted,
.metric-tile small,
.feed small {
  color: var(--muted);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span,
.label {
  color: #344054;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: #fbfcfe;
  color: var(--ink);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(23, 107, 135, 0.14);
}

.primary-btn {
  border: 0;
  background: var(--brand);
  color: #fff;
  min-height: 42px;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

.primary-btn:hover {
  background: var(--brand-dark);
}

.nav {
  display: grid;
  gap: 6px;
  padding-top: 8px;
}

.nav a,
.small-panel a {
  color: var(--brand-dark);
  text-decoration: none;
  font-weight: 700;
}

.nav a {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
}

.nav a:hover {
  background: #eef6f8;
}

.small-panel {
  margin-top: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 6px;
  background: #fbfcfe;
}

.selector-group {
  display: grid;
  gap: 8px;
  position: relative;
}

.selector-group .field {
  gap: 0;
}

.compact-field {
  margin-top: 2px;
  margin-bottom: 14px;
}

.compact-field select {
  min-height: 38px;
  padding: 8px 10px;
}

.combo {
  position: relative;
}

.combo input {
  padding-right: 46px;
}

.combo-toggle {
  position: absolute;
  right: 5px;
  top: 5px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 7px;
  background: #eef4f7;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
}

.combo-toggle:hover {
  background: #e2edf2;
}

.selected-card {
  display: grid;
  gap: 4px;
  border: 1px solid #dce6ee;
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  background: #f8fbfc;
  padding: 9px 11px;
  min-height: 48px;
}

.result-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.selected-card:empty {
  display: none;
}

.selected-card strong,
.result-item strong {
  display: block;
  color: #17202a;
  font-size: 13px;
  line-height: 1.25;
}

.selected-card span,
.result-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.combo-menu {
  display: none;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
  margin-top: 7px;
  padding: 8px;
  border: 1px solid #cfd9e3;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 14px 30px rgba(31, 45, 61, 0.12);
}

.combo-menu.open {
  display: grid;
}

.compact-results {
  max-height: 340px;
}

.result-item {
  width: 100%;
  display: grid;
  gap: 4px;
  text-align: left;
  border: 1px solid #e4ebf2;
  background: #ffffff;
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
}

.result-item:hover,
.result-item.active {
  border-color: rgba(23, 107, 135, 0.45);
  background: #f0f8fa;
}

.small-empty {
  padding: 10px;
  font-size: 12px;
}

.workspace {
  min-width: 0;
  width: min(100%, 1680px);
  margin: 0 auto;
  padding: 34px clamp(24px, 3.2vw, 52px) 52px;
  display: grid;
  gap: 24px;
}

.workspace > * {
  order: 20;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  order: 1;
}

.eyebrow {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.topbar h2 {
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.18;
}

.status-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e7f4ef;
  color: var(--green);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
}

.pill.neutral {
  background: #eef2f6;
  color: #344054;
}

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

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

.metric-tile {
  min-height: 116px;
  padding: 18px;
  display: grid;
  gap: 8px;
}

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

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

.positive {
  color: var(--green);
}

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

.market-stack {
  display: grid;
  gap: 24px;
  order: 3;
}

.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 24px;
}

.scenario-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  order: 4;
}

.news-insights {
  order: 7;
}

#financials {
  order: 8;
}

#events {
  order: 9;
}

.panel {
  min-width: 0;
  padding: 22px;
}

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

.panel h3 {
  font-size: 18px;
}

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f8fafc;
}

.segment {
  border: 0;
  background: transparent;
  color: var(--muted);
  min-height: 34px;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 800;
}

.segment.active {
  background: var(--brand);
  color: white;
}

.chart-wrap {
  position: relative;
}

.chart-readout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.chart-readout div {
  min-width: 0;
  border: 1px solid #e6ebf1;
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px 11px;
  display: grid;
  gap: 4px;
}

.chart-readout span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.chart-readout strong {
  color: #17202a;
  font-size: 15px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.chart-readout small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.chart-panel canvas {
  display: block;
  width: 100%;
  height: 430px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  cursor: crosshair;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 210px;
  max-width: 280px;
  border: 1px solid #cfd9e3;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 14px 34px rgba(31, 45, 61, 0.16);
  padding: 10px 11px;
  pointer-events: none;
  color: #17202a;
  font-size: 12px;
  line-height: 1.35;
}

.chart-tooltip strong {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.chart-tooltip dl {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 12px;
  margin: 0;
}

.chart-tooltip dt {
  color: var(--muted);
}

.chart-tooltip dd {
  margin: 0;
  text-align: right;
  font-weight: 800;
}

.chart-tooltip .event-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.chart-tooltip .event-tags span,
.chart-legend span {
  border-radius: 999px;
  padding: 3px 7px;
  background: #eef2f6;
  color: #344054;
  font-size: 11px;
  font-weight: 800;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  min-height: 26px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.scenario-panel .scenario-copy {
  color: #344054;
  line-height: 1.55;
  margin-bottom: 18px;
}

.scenario-panel .current-event-copy {
  color: #344054;
  line-height: 1.55;
  border: 1px solid #e6ebf1;
  background: #fbfcfe;
  border-radius: 8px;
  padding: 13px 14px;
  margin: 0 0 28px;
}

.current-event-copy:empty {
  display: none;
}

/* Clickable document cards (news / filings) */
.doc-card {
  cursor: pointer;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.doc-card:hover,
.doc-card:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 6px 18px rgba(23, 107, 135, 0.12);
  outline: none;
}

.doc-preview {
  color: var(--muted);
  line-height: 1.5;
  margin: 4px 0 0;
}

.doc-open-hint {
  display: inline-block;
  margin-top: 4px;
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
}

.doc-link-btn {
  margin-top: 14px;
  border: 1px solid var(--brand);
  background: #f1f8fa;
  color: var(--brand);
  font-weight: 700;
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  width: 100%;
}

.doc-link-btn:hover {
  background: #e3f1f5;
}

/* Earnings releases list */
.earnings-releases {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.press-release-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.earnings-release-row {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.4fr) auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: #fbfcfe;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font: inherit;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}

.earnings-release-row:hover,
.earnings-release-row:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 4px 12px rgba(23, 107, 135, 0.12);
  outline: none;
}

.erow-period {
  font-weight: 700;
  color: #17202a;
}

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

/* Document reader modal */
.doc-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.doc-modal.open {
  display: flex;
}

.doc-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 24, 32, 0.55);
  backdrop-filter: blur(2px);
}

.doc-modal-panel {
  position: relative;
  z-index: 1;
  width: min(1040px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(16, 24, 32, 0.35);
  overflow: hidden;
}

.doc-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 26px 16px;
  border-bottom: 1px solid var(--line);
}

.doc-modal-kind {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--brand);
}

.doc-modal-head h2 {
  margin: 6px 0 4px;
  font-size: 22px;
  line-height: 1.25;
}

.doc-modal-meta {
  color: var(--muted);
  font-size: 13px;
}

.doc-modal-close {
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fbfcfe;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #344054;
}

.doc-modal-close:hover {
  background: #eef2f6;
}

.doc-modal-body {
  overflow-y: auto;
  padding: 22px 26px;
  /* A readable measure, like a filing/article page */
}

.doc-modal-body p {
  color: #2d3a47;
  line-height: 1.7;
  margin: 0 0 14px;
  font-size: 15px;
}

.doc-modal-body h3 {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin: 22px 0 8px;
}

.doc-modal-body .filing-section {
  margin-bottom: 8px;
}

.doc-modal-body table.filing-figures {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0 18px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.doc-modal-body table.filing-figures td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  color: #2d3a47;
}

.doc-modal-body table.filing-figures td.fig-val {
  text-align: right;
  font-weight: 700;
  white-space: nowrap;
}

.doc-modal-body table.filing-figures td.fig-note {
  text-align: right;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.doc-modal-body table.filing-figures tr.fig-section td {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 11px;
  color: var(--muted);
  border-bottom: 2px solid var(--line);
  padding-top: 12px;
}

.doc-modal-footer {
  padding: 12px 26px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

body.modal-open {
  overflow: hidden;
}

.scenario-meta {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.scenario-meta div {
  border: 1px solid #e6ebf1;
  background: #fbfcfe;
  border-radius: 8px;
  padding: 11px;
}

.scenario-meta span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
  text-transform: uppercase;
}

.scenario-meta strong {
  display: block;
  line-height: 1.35;
}

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

.fact-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.42fr) minmax(0, 1fr);
  gap: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf1f5;
  align-items: start;
}

.fact-row.wide {
  grid-column: 1 / -1;
  border-bottom: 0;
  padding-bottom: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  grid-template-columns: 1fr;
  gap: 7px;
  padding: 14px;
}

.fact-row span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.fact-row strong {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.fact-row.wide strong {
  text-align: left;
  line-height: 1.45;
}

.feed {
  display: grid;
  gap: 12px;
}

.feed-item {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}

.feed-item h4,
.signal-box h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.feed-item p,
.signal-box p {
  margin: 6px 0 0;
  color: #344054;
  line-height: 1.45;
}

.feed-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.feed-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  background: #eef2f6;
  color: #344054;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 800;
}

.feed-tag.positive {
  background: #e7f4ef;
  color: var(--green);
}

.feed-tag.negative {
  background: #fff1f0;
  color: var(--red);
}

.feed-tag.neutral {
  background: #eef2f6;
  color: #344054;
}

.compact {
  margin-bottom: 14px;
}

.signal-box {
  display: grid;
  gap: 12px;
}

.signal-card {
  border: 1px solid var(--line);
  background: #fbfcfe;
  border-radius: 8px;
  padding: 14px;
}

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

.signal-metrics div {
  background: white;
  border: 1px solid #e6ebf1;
  border-radius: 8px;
  padding: 10px;
}

.signal-metrics span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid #edf1f5;
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  background: #fff;
}

th {
  background: #f8fafc;
  color: #344054;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

.timeline {
  position: relative;
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.timeline-date {
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.timeline-card {
  border-left: 4px solid var(--brand);
  background: #fbfcfe;
  border-radius: 8px;
  border-top: 1px solid var(--line);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.timeline-card strong {
  display: block;
  margin-bottom: 5px;
}

.field.full {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  max-width: min(420px, calc(100vw - 44px));
  background: #17202a;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: 0 18px 40px rgba(23, 32, 42, 0.2);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

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

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fbfcfe;
}

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

  .sidebar {
    position: static;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-grid,
  .market-stack,
  .two-col {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
  }

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

  .nav a {
    text-align: center;
  }
}

@media (max-width: 640px) {
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .panel-head {
    flex-direction: column;
  }

  .summary-grid {
    gap: 10px;
  }

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

  .nav a {
    padding: 8px 6px;
  }

  .scenario-meta,
  .chart-readout,
  .facts-list {
    grid-template-columns: 1fr;
  }

  .combo-menu {
    max-height: 260px;
  }
}
