/* ==========================================================================
   statements.css — Financial Statement Analysis.
   Extends styles.css; every colour comes from its tokens so the two pages
   stay one system. Nothing here redefines a palette.
   ========================================================================== */

.fsa-hero {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; padding: 16px 0 14px;
  border-bottom: 1px solid var(--kimi-color-border);
}
.fsa-controls { display: flex; align-items: center; gap: 10px; }
.fsa-status {
  font-size: 12.5px; color: var(--kimi-color-text-tertiary);
  padding: 18px 0; margin: 0;
}
.fsa-section { margin-top: 16px; }
.section-head { margin-bottom: 14px; }
.section-head h2 { font-size: 15px; font-weight: 600; margin: 0 0 5px; }
.section-blurb {
  font-size: 12.5px; line-height: 1.6; color: var(--kimi-color-text-secondary);
  max-inline-size: 78ch; margin: 0;
}
.scroll-x { overflow-x: auto; }

/* ---- the decomposition strip ----
   Reads left to right as an equation, because that is what it is. */
.dupont-flow {
  display: flex; align-items: stretch; gap: 10px; flex-wrap: wrap;
  padding: 4px 0 2px;
}
.dp-term {
  flex: 1 1 150px; min-inline-size: 140px;
  border: 1px solid var(--kimi-color-border); border-radius: 10px;
  background: var(--page-bg); padding: 12px 14px 11px;
}
.dp-term.dp-result { border-color: var(--rt-gold-border); background: var(--rt-gold-tint); }
.dp-op {
  flex: 0 0 auto; align-self: center;
  font-family: var(--rt-font-mono); font-size: 19px; font-weight: 600;
  color: var(--kimi-color-text-tertiary); padding: 0 2px;
}
.dp-term .dp-label {
  font-size: 10px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--kimi-color-text-tertiary);
  display: block; margin-bottom: 5px;
}
.dp-term .dp-value {
  font-family: var(--rt-font-mono); font-size: 21px; font-weight: 600;
  line-height: 1.1; font-variant-numeric: tabular-nums; display: block;
}
.dp-term.dp-result .dp-value { color: var(--rt-gold); }
.dp-term .dp-note {
  font-size: 11px; line-height: 1.45; color: var(--kimi-color-text-tertiary);
  margin-top: 5px; display: block;
}
.dupont-reading {
  font-size: 12.5px; line-height: 1.6; color: var(--kimi-color-text-primary);
  margin: 14px 0 0; padding-top: 12px;
  border-top: 1px solid var(--kimi-color-surface-muted);
  max-inline-size: 82ch;
}
.dupont-reading strong { color: var(--rt-gold); font-weight: 600; }

/* ---- KPI groups ---- */
.kpi-group { margin-top: 16px; }
.kpi-group > h2 {
  font-size: 13px; font-weight: 600; margin: 0 0 3px;
}
.kpi-group > .group-blurb {
  font-size: 12px; line-height: 1.55; color: var(--kimi-color-text-tertiary);
  max-inline-size: 80ch; margin: 0 0 10px;
}
.kpi-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
}

/* A card is a button so the definition is reachable by keyboard, not just
   by hovering — the same information must not be mouse-only. */
.mcard {
  text-align: start; font: inherit; cursor: help;
  border: 1px solid var(--kimi-color-border); border-radius: 10px;
  background: var(--kimi-color-surface); padding: 12px 14px 11px;
  display: flex; flex-direction: column; gap: 2px;
}
.mcard:hover { border-color: var(--kimi-color-border-strong); }
.mcard:focus-visible { outline: 2px solid var(--rt-focus); outline-offset: 2px; }
.mcard .m-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--kimi-color-text-tertiary);
  display: flex; align-items: center; gap: 5px;
}
/* The dotted underline is the long-standing convention for "there is a
   definition behind this word". */
.mcard .m-label span { border-bottom: 1px dotted var(--kimi-color-text-quaternary); }
.mcard .m-value {
  font-family: var(--rt-font-mono); font-size: 20px; font-weight: 600;
  line-height: 1.15; margin-top: 4px; font-variant-numeric: tabular-nums;
}
.mcard .m-value.na { color: var(--kimi-color-text-tertiary); font-size: 15px; }
.mcard .m-trend {
  font-size: 11px; font-variant-numeric: tabular-nums;
  color: var(--kimi-color-text-tertiary); margin-top: 2px;
}
.mcard .m-trend.up { color: var(--kimi-color-positive); }
.mcard .m-trend.down { color: var(--kimi-color-danger); }
/* The one-line commentary that sits on the card itself, so the card says
   something without needing a hover at all. */
.mcard .m-gloss {
  font-size: 11.5px; line-height: 1.5; color: var(--kimi-color-text-secondary);
  margin-top: 7px; padding-top: 7px;
  border-top: 1px solid var(--kimi-color-surface-muted);
}
.mcard .m-flag {
  font-size: 10px; font-weight: 600; letter-spacing: .03em;
  border-radius: 4px; padding: 1px 6px; align-self: flex-start; margin-top: 6px;
}
.mcard .m-flag.warn { background: var(--rt-gold-tint); color: var(--rt-gold); }

/* ---- the definition popup ---- */
.metric-pop {
  position: absolute; z-index: 60; max-inline-size: 380px;
  background: var(--kimi-color-surface-raised);
  border: 1px solid var(--rt-gold-border); border-radius: 10px;
  padding: 14px 16px 13px;
  box-shadow: 0 12px 32px rgba(0,0,0,.55);
  font-size: 12.5px; line-height: 1.6;
  color: var(--kimi-color-text-secondary);
}
.metric-pop h4 {
  font-size: 13px; font-weight: 600; color: var(--kimi-color-text-primary);
  margin: 0 0 2px;
}
.metric-pop .pop-formula {
  font-family: var(--rt-font-mono); font-size: 11.5px;
  color: var(--rt-gold); margin: 0 0 9px;
}
.metric-pop p { margin: 0 0 9px; }
.metric-pop p:last-child { margin-bottom: 0; }
.metric-pop .pop-tag {
  font-size: 10px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--kimi-color-text-tertiary);
  display: block; margin-bottom: 2px;
}
.metric-pop .pop-watch { color: var(--kimi-color-text-primary); }

/* ---- statement tables ---- */
.stmt-controls { margin-bottom: 10px; }
table.stmt { font-size: 12px; min-inline-size: 520px; }
table.stmt th:first-child, table.stmt td:first-child {
  position: sticky; inset-inline-start: 0;
  background: var(--kimi-color-surface); z-index: 1;
  min-inline-size: 190px;
}
table.stmt tr.total td {
  font-weight: 600; color: var(--kimi-color-text-primary);
  border-top: 1px solid var(--kimi-color-border-strong);
}
table.stmt tr.total td:first-child { color: var(--kimi-color-text-primary); }
table.stmt tr.spacer td { padding: 5px 0; border: 0; }
table.stmt td.derived-cell::after {
  content: "*"; color: var(--kimi-color-text-quaternary); margin-inline-start: 2px;
}

/* ---- earnings quality ---- */
.quality-grid {
  display: grid; gap: 14px; align-items: start;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
}
.quality-verdict {
  border: 1px solid var(--kimi-color-border); border-radius: 10px;
  padding: 14px 16px; background: var(--page-bg);
}
.quality-verdict .qv-head {
  font-size: 10px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--kimi-color-text-tertiary);
}
.quality-verdict .qv-value {
  font-family: var(--rt-font-mono); font-size: 22px; font-weight: 600;
  margin-top: 5px; display: block;
}
.quality-verdict .qv-note {
  font-size: 12px; line-height: 1.55; color: var(--kimi-color-text-secondary);
  margin-top: 7px;
}

@media (max-width: 900px) {
  /* The decomposition is an equation and has to keep reading as one.
     Wrapped into a 2x2 grid with the operators hidden it became four
     unrelated boxes, so at narrow widths it stacks into a single column
     and the operators stay, turning it into a vertical equation. */
  .dupont-flow { flex-direction: column; align-items: stretch; gap: 6px; }
  .dp-term { flex: 1 1 auto; min-inline-size: 0; }
  .dp-op { align-self: center; padding: 1px 0; font-size: 16px; }
  .dp-term .dp-value { font-size: 19px; }
}
@media (max-width: 680px) {
  .fsa-hero { flex-direction: column; align-items: stretch; gap: 12px; }
  .fsa-controls { justify-content: space-between; }
  .fsa-controls .seg { flex: 1 1 auto; }
  .fsa-controls .seg button { flex: 1 1 auto; }
  .section-head h2 { font-size: 14px; }
  .kpi-grid { grid-template-columns: 1fr; }
  /* A popup anchored to a card would sit half off a phone screen, so at
     this width it becomes a sheet pinned to the bottom of the viewport
     with its own scroll. */
  .metric-pop {
    position: fixed; inset-inline: 8px; inset-block-end: 8px;
    inset-block-start: auto; max-inline-size: none;
    max-block-size: 62vh; overflow-y: auto;
  }
  #refresh-btn { min-block-size: 42px; }
  table.stmt th:first-child, table.stmt td:first-child { min-inline-size: 150px; }
  .quality-grid { grid-template-columns: 1fr; }
}

/* period-over-period change column */
.stmt td.delta { font-size: 11px; }
.stmt td.delta.pos { color: #59b87a; }
.stmt td.delta.neg { color: #d4756b; }
#reading-body p {
  font-size: 12.5px; line-height: 1.65; color: var(--kimi-color-text-secondary);
  margin: 0 0 12px; max-inline-size: 88ch;
}
#reading-body p strong { color: var(--kimi-color-text-primary); }
#reading-body .reading-head {
  font-size: 10px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--kimi-color-text-tertiary);
  margin: 16px 0 6px;
}
#reading-body .reading-head:first-child { margin-top: 0; }

#analyst-note-body p {
  font-size: 13px; line-height: 1.7; color: var(--kimi-color-text-secondary);
  margin: 0 0 13px; max-inline-size: 86ch;
}
#analyst-note-body .note-meta {
  font-size: 10.5px; color: var(--kimi-color-text-quaternary);
  font-family: var(--rt-font-mono); margin-top: 4px;
}
#t-variance td.flag { color: #d4a13c; font-weight: 600; }

/* period end beneath each column label */
.stmt th .th-end, .grid th .th-end {
  display: block; font-weight: 400; font-size: 9.5px; letter-spacing: 0;
  text-transform: none; color: var(--kimi-color-text-quaternary); margin-top: 2px;
}
/* a figure revised by a later filing */
sup.restated {
  font-size: 8.5px; color: #d4a13c; margin-inline-start: 2px; cursor: help;
  font-family: var(--rt-font-mono);
}
