/*
 * Stock Analysis pages: "How they make money" (money-flow diagram) and the one-period income
 * statement. Colours are tokens so the deep-blue skin ([data-theme="dark"]) only swaps values.
 */
.sa {
  --sa-card: #ffffff;
  --sa-border: #e3e8ee;
  --sa-text: #1f2d3d;
  --sa-muted: #6b7785;
  --sa-heading: #16406b;
  --sa-soft: #f4f6f9;
  --sa-rule: #d6dde5;
  --sa-good: #1f8a36;
  --sa-bad: #c0392b;
  --sa-accent: #0d6efd;

  /* Diagram */
  --flow-source: #3b4a5c;
  --flow-source-link: rgba(120, 130, 145, 0.45);
  --flow-revenue: #111827;
  --flow-profit: #2e9e44;
  --flow-profit-link: rgba(76, 175, 95, 0.42);
  --flow-cost: #d0021b;
  --flow-cost-link: rgba(229, 83, 83, 0.40);
  --flow-text: #1f2d3d;
  --flow-muted: #6b7785;
  --flow-good: #1f8a36;
  --flow-bad: #b3261e;

  max-width: 1400px;
  margin: 0 auto;
  color: var(--sa-text);
}
[data-theme="dark"] .sa {
  --sa-card: #0f1e36;
  --sa-border: #1d3454;
  --sa-text: #e6edf7;
  --sa-muted: #a9b6c8;
  --sa-heading: #8cc4ff;
  --sa-soft: #10223f;
  --sa-rule: #2a4466;
  --sa-good: #5ad27a;
  --sa-bad: #ff7b7b;
  --sa-accent: #4da3ff;

  --flow-source: #9fb0c6;
  --flow-source-link: rgba(148, 163, 184, 0.30);
  --flow-revenue: #e6edf7;
  --flow-profit: #3fbf5c;
  --flow-profit-link: rgba(63, 191, 92, 0.34);
  --flow-cost: #f05252;
  --flow-cost-link: rgba(240, 82, 82, 0.32);
  --flow-text: #e6edf7;
  --flow-muted: #a9b6c8;
  --flow-good: #5ad27a;
  --flow-bad: #ff8a8a;
}

.sa-card {
  background: var(--sa-card);
  border: 1px solid var(--sa-border);
  border-radius: 10px;
}
.sa-sub {
  color: var(--sa-muted);
}
[data-theme="dark"] .sa .sa-sub {
  color: var(--sa-muted) !important;
}

/* ---- Toolbar: ticker, annual / quarterly, period, and the view switch ---- */
.sa-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.sa-toolbar .sa-ticker {
  width: 150px;
  text-transform: uppercase;
  font-weight: 600;
}
.sa-toolbar .sa-period {
  width: auto;
  min-width: 190px;
}
.sa-toolbar .sa-spacer {
  flex: 1 1 auto;
}
.sa-seg {
  display: inline-flex;
  background: var(--sa-soft);
  border: 1px solid var(--sa-border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.sa-seg a {
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--sa-muted) !important;
  text-decoration: none;
  white-space: nowrap;
}
.sa-seg a:hover {
  color: var(--sa-text) !important;
}
.sa-seg a.active {
  background: var(--sa-card);
  color: var(--sa-text) !important;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
}
[data-theme="dark"] .sa-seg a.active {
  background: #1a3358;
}

/* ---- Empty / not-found state ---- */
.sa-empty {
  padding: 40px 20px;
  text-align: center;
}
.sa-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}
.sa-chips a {
  border: 1px solid var(--sa-border);
  border-radius: 999px;
  padding: 4px 14px;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--sa-text) !important;
  text-decoration: none;
  background: var(--sa-soft);
}
.sa-chips a:hover {
  border-color: var(--sa-accent);
}

/* ---- Money-flow diagram ---- */
.flow-card {
  padding: 20px 20px 12px;
}
.flow-title {
  text-align: center;
  font-size: clamp(1.2rem, 1.9vw, 1.65rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0 0 4px;
  color: var(--sa-heading) !important;
}
.flow-note {
  text-align: center;
  font-size: 0.85rem;
  color: var(--sa-muted);
  margin-bottom: 4px;
}
.flow-scroll {
  overflow-x: auto;
}
.flow-svg {
  display: block;
  width: 100%;
  min-width: 880px;
  height: auto;
  font-family: inherit;
}
.flow-svg .flow-label {
  font-size: 13px;
  fill: var(--flow-text);
}
.flow-svg .flow-name {
  font-weight: 700;
}
.flow-svg .flow-value {
  font-weight: 600;
}
.flow-svg .flow-sub {
  font-size: 11.5px;
  fill: var(--flow-muted);
}
.flow-svg .flow-good {
  fill: var(--flow-good);
}
.flow-svg .flow-bad {
  fill: var(--flow-bad);
}
.flow-svg .flow-link {
  transition: opacity 0.15s;
}
.flow-svg .flow-link:hover {
  opacity: 0.7;
}
.flow-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--sa-border);
  margin-top: 6px;
  padding-top: 10px;
  font-size: 0.8rem;
  color: var(--sa-muted);
}
.flow-legend {
  display: inline-flex;
  gap: 14px;
  flex-wrap: wrap;
}
.flow-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}

/* ---- Income statement ---- */
.is-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 16px;
  margin-bottom: 12px;
}
.is-head h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0;
  color: var(--sa-heading) !important;
}
.is-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.is-kpi {
  padding: 12px 14px;
}
.is-kpi .k-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sa-muted);
  font-weight: 600;
}
.is-kpi .k-value {
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1.2;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
}
.is-kpi .k-change {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sa-muted);
}
.sa .is-good {
  color: var(--sa-good) !important;
}
.sa .is-bad {
  color: var(--sa-bad) !important;
}

/* ---- Income statement charts ---- */
.chart-card {
  padding: 14px 16px 10px;
  margin-bottom: 16px;
}
.chart-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 4px 16px;
  margin-bottom: 4px;
}
.chart-head h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  color: var(--sa-heading) !important;
}
.chart-legend {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--sa-muted);
}
.chart-legend i {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 5px;
  vertical-align: -1px;
}
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 0 16px;
}
@media (max-width: 520px) {
  .chart-grid {
    grid-template-columns: 1fr;
  }
}
.chart-body {
  overflow-x: auto;
}
.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  font-family: inherit;
}
#isWaterfall .chart-svg {
  min-width: 760px;
}
.sa {
  --chart-gross: #2e9e44;
  --chart-operating: #2563eb;
  --chart-net: #d97706;
}
[data-theme="dark"] .sa {
  --chart-gross: #3fbf5c;
  --chart-operating: #60a5fa;
  --chart-net: #fbbf24;
}
.chart-svg .chart-grid {
  stroke: var(--sa-border);
  stroke-width: 1;
}
.chart-svg .chart-zero {
  stroke: var(--sa-muted);
  stroke-width: 1;
}
.chart-svg .chart-connector {
  stroke: var(--sa-muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
.chart-svg .chart-tick {
  font-size: 11px;
  fill: var(--sa-muted);
}
.chart-svg .chart-value {
  font-size: 12.5px;
  font-weight: 700;
  fill: var(--sa-text);
}
.chart-svg .chart-cat {
  font-size: 12px;
  fill: var(--sa-text);
}
.chart-svg .chart-cat-total {
  font-weight: 700;
}
.chart-svg .is-good-fill {
  fill: var(--sa-good);
}
.chart-svg .is-bad-fill {
  fill: var(--sa-bad);
}
.chart-svg .chart-bar {
  transition: opacity 0.15s;
}
.chart-svg .chart-bar:hover {
  opacity: 0.8;
}
.chart-svg .chart-bar:not(.is-selected) {
  opacity: 0.72;
}
#isWaterfall .chart-svg .chart-bar {
  opacity: 1;
}

/* ---- Valuation: share price against the discounted-cash-flow value ---- */
.sa {
  --val-under: #2ec27e;
  --val-right: #efb21f;
  --val-over: #3b2a2c;
  --val-under-text: #1f9d61;
  --val-right-text: #c78f00;
  --val-over-text: #d64545;
  --val-bar: rgba(22, 27, 34, 0.92);
  --val-bar-fair: rgba(22, 27, 34, 0.62);
  --val-bracket: #2ec27e;
}
[data-theme="dark"] .sa {
  --val-under-text: #3fd68f;
  --val-right-text: #f3c445;
  --val-over-text: #ff6b6b;
  --val-over: #3a2729;
}
.val-card {
  padding: 18px 20px;
  margin-bottom: 16px;
}
.val-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--sa-heading);
  margin-bottom: 6px;
}
.val-num {
  color: var(--sa-muted);
  font-weight: 400;
  margin-right: 6px;
}
.val-lead {
  color: var(--sa-text);
  max-width: 900px;
}
.val-sub {
  font-size: 1rem;
  font-weight: 600;
  color: var(--sa-heading);
  margin-bottom: 8px;
}
.val-unavailable {
  background: var(--sa-soft);
  border: 1px dashed var(--sa-rule);
  border-radius: 8px;
  padding: 14px 16px;
}

/* The chart: three bands across the full width, two bars laid over them. */
.val-chart-wrap {
  margin-top: 8px;
}
.val-chart {
  position: relative;
  padding-bottom: 78px; /* room for the rotated band labels */
}
.val-headline-row {
  position: relative;
  height: 74px;
}
.val-headline {
  position: absolute;
  bottom: 14px;
  white-space: nowrap;
  line-height: 1.1;
}
.val-headline-pct {
  font-size: 1.9rem;
  font-weight: 700;
}
.val-headline-label {
  font-size: 1.05rem;
  font-weight: 600;
}
.val-chart.is-under .val-headline { color: var(--val-under-text); }
.val-chart.is-right .val-headline { color: var(--val-right-text); }
.val-chart.is-over .val-headline { color: var(--val-over-text); }
.val-bracket {
  position: absolute;
  bottom: 0;
  height: 12px;
  border: 2px solid var(--val-bracket);
  border-bottom: none;
  min-width: 2px;
}
.val-chart.is-right .val-bracket { border-color: var(--val-right-text); }
.val-chart.is-over .val-bracket { border-color: var(--val-over-text); }

.val-plot {
  position: relative;
  height: 290px;
  overflow: hidden;
  border-radius: 2px;
}
.val-band {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
}
.val-band-under { background: var(--val-under); }
.val-band-right { background: var(--val-right); }
.val-band-over { background: var(--val-over); }
.val-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(255, 255, 255, 0.55);
}
.val-bar {
  position: absolute;
  left: 0;
  height: 100px;
  min-width: 150px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  color: #ffffff;
}
.val-bar-price {
  top: 30px;
  background: var(--val-bar);
  border-right: 3px solid #f7f3e3;
}
.val-bar-fair {
  top: 160px;
  background: linear-gradient(90deg, rgba(22, 27, 34, 0.25), var(--val-bar-fair));
  border-right: 3px solid #ffffff;
}
.val-bar-text {
  text-align: right;
  padding-right: 16px;
}
.val-bar-label {
  font-size: 1.05rem;
  font-weight: 600;
}
.val-bar-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.15;
}
.val-axis {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 78px;
}
.val-tick {
  position: absolute;
  top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  transform: translateX(-100%) rotate(-35deg);
  transform-origin: 100% 0;
}
.val-tick.is-under { color: var(--val-under-text); }
.val-tick.is-right { color: var(--val-right-text); }
.val-tick.is-over { color: var(--val-over-text); }
.val-verdict {
  margin: 4px 0 0;
  font-size: 1.02rem;
}

/* Multiples */
.val-multiples {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.val-multiple {
  background: var(--sa-soft);
  border: 1px solid var(--sa-border);
  border-radius: 8px;
  padding: 10px 12px;
}
.val-multiple .k-label {
  font-size: 0.8rem;
  color: var(--sa-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.val-multiple .k-value {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--sa-text);
}

/* Model tables */
.val-two {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 24px;
}
.val-table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--sa-text);
  margin-bottom: 0;
}
.val-table th, .val-table td {
  border-color: var(--sa-rule);
  vertical-align: top;
}
.val-table th[scope="row"] {
  font-weight: 500;
}
.val-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.val-sum .val-total th, .val-sum .val-total td {
  font-weight: 700;
  border-top: 2px solid var(--sa-rule);
}
.val-years .val-base td {
  color: var(--sa-muted);
}

@media (max-width: 900px) {
  .val-two { grid-template-columns: 1fr; }
  .val-plot { height: 230px; }
  .val-bar { height: 80px; min-width: 120px; }
  .val-bar-price { top: 22px; }
  .val-bar-fair { top: 126px; }
  .val-bar-value { font-size: 1.3rem; }
  .val-bar-label { font-size: 0.9rem; }
  .val-headline-pct { font-size: 1.5rem; }
}
