/* The Financial Profile (plan 32 §5.5): the snapshot card, the Financials part and the charts. Colours come from app.css tokens;
   the four chart-line colours are this file's own and are defined for both themes (the dataviz skill's validated categorical slots 1-4). */

:root {
  --fin-s1: #2a78d6;
  --fin-s2: #eb6834;
  --fin-s3: #1baf7a;
  --fin-s4: #eda100;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fin-s1: #3987e5;
    --fin-s2: #d95926;
    --fin-s3: #199e70;
    --fin-s4: #c98500;
  }
}
:root[data-theme="dark"] {
  --fin-s1: #3987e5;
  --fin-s2: #d95926;
  --fin-s3: #199e70;
  --fin-s4: #c98500;
}

/* -- the snapshot card ---------------------------------------------------------------------------------------------- */
.fin-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fin-card-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fin-card-h { font-size: 17px; font-weight: 600; }
.fin-big { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.fin-big small { font-size: 15px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 2px; }
.fin-stack { font-size: 14px; color: var(--ink-2); }
.fin-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 16px; margin: 0; }
.fin-facts > div { min-width: 0; }
.fin-facts dt { font-size: 13px; color: var(--muted); }
.fin-facts dd { margin: 0; font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.fin-facts dd.neg, .fin-tile .value.neg { color: var(--bad); }
.fin-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fin-from { font-size: 13px; color: var(--muted); }
.fin-said { margin: 0; padding-left: 18px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.fin-card .fin-said { padding-left: 0; list-style: none; }

/* -- the part ---------------------------------------------------------------------------------------------------------- */
.fin-part { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.fin-part > * { min-width: 0; }
.fin-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 16px; border-radius: 12px; background: var(--info-soft); color: var(--info-ink); border: 1px solid var(--line); }
.fin-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; }
.fin-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.fin-tile .value { white-space: normal; overflow-wrap: anywhere; font-size: 24px; font-variant-numeric: tabular-nums; }
.fin-tile .sub { font-size: 12px; color: var(--muted); }
.fin-src { font-size: 12px; color: var(--muted); }
.fin-section { display: flex; flex-direction: column; gap: 12px; }
.fin-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.fin-section-head h2 { font-size: 17px; }
.fin-links { display: flex; flex-wrap: wrap; gap: 8px; }

/* Where the money goes: a row per cost group, the bar drawn in an inline SVG with percentage widths. */
.fin-bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.fin-bar { display: grid; grid-template-columns: minmax(120px, 190px) minmax(0, 1fr) minmax(130px, auto); align-items: center; gap: 4px 14px; }
.fin-bar-name { grid-column: 1; grid-row: 1; font-size: 14px; overflow-wrap: anywhere; }
.fin-bar .fin-bar-svg { grid-column: 2; grid-row: 1; }
.fin-bar-val { grid-column: 3; grid-row: 1; font-size: 14px; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fin-bar-val span { color: var(--muted); margin-left: 2px; }
.fin-bar svg { display: block; width: 100%; height: 16px; }
.fin-bar-fill { fill: var(--accent); }
.fin-bar-track { fill: var(--track); opacity: 0.55; }

/* The line charts. The SVG is drawn at the width it has, so the text is never scaled down. */
.fin-chart { position: relative; min-width: 0; }
.fin-chart svg.fin-svg { display: block; width: 100%; height: auto; overflow: visible; touch-action: pan-y; }
.fin-svg text, .fin-bar-svg rect, .fin-hit { stroke: none; }  /* app.css gives every svg a currentColor stroke */
.fin-chart:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }
.fin-grid { stroke: var(--line-2); stroke-width: 1; fill: none; }
.fin-axis { stroke: var(--line-strong); stroke-width: 1; fill: none; }
.fin-tick { fill: var(--muted); font-size: 12px; font-family: var(--sans); }
.fin-line { fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.fin-dot { stroke: var(--surface); stroke-width: 2; }
.fin-cross { stroke: var(--line-strong); stroke-width: 1; }
.fin-endlabel { fill: var(--ink-2); font-size: 12px; font-family: var(--sans); }
.fin-hit { fill: transparent; }
.fin-line.s1 { stroke: var(--fin-s1); } .fin-line.s2 { stroke: var(--fin-s2); } .fin-line.s3 { stroke: var(--fin-s3); } .fin-line.s4 { stroke: var(--fin-s4); } .fin-line.s5 { stroke: var(--accent); }
.fin-dot.s1 { fill: var(--fin-s1); } .fin-dot.s2 { fill: var(--fin-s2); } .fin-dot.s3 { fill: var(--fin-s3); } .fin-dot.s4 { fill: var(--fin-s4); } .fin-dot.s5 { fill: var(--accent); }
.fin-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 13px; color: var(--ink-2); }
.fin-legend li { display: inline-flex; align-items: center; gap: 8px; }
.fin-key { display: inline-block; width: 18px; height: 0; border-top: 2px solid; border-radius: 1px; flex-shrink: 0; }
.fin-key.s1 { border-color: var(--fin-s1); } .fin-key.s2 { border-color: var(--fin-s2); } .fin-key.s3 { border-color: var(--fin-s3); } .fin-key.s4 { border-color: var(--fin-s4); } .fin-key.s5 { border-color: var(--accent); }
.fin-tip { position: absolute; z-index: 3; top: 0; min-width: 190px; max-width: 260px; padding: 10px 12px; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-pop); font-size: 13px; pointer-events: none; }
.fin-tip-year { font-weight: 600; margin-bottom: 4px; }
.fin-tip-row { display: flex; align-items: center; gap: 8px; }
.fin-tip-row b { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.fin-tip-row span.n { color: var(--ink-2); }
.fin-tablewrap { max-height: 460px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; }
.fin-tablewrap table { margin: 0; }
.fin-tablewrap th, .fin-tablewrap td { text-align: right; white-space: nowrap; }
.fin-tablewrap th:first-child, .fin-tablewrap td:first-child { text-align: left; }
.fin-tablewrap td { font-variant-numeric: tabular-nums; font-size: 13px; }

@media (max-width: 760px) {
  .fin-facts { grid-template-columns: minmax(0, 1fr); }
  .fin-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fin-tile .value { font-size: 20px; }
  .fin-bar { grid-template-columns: minmax(0, 1fr) auto; }
  .fin-bar .fin-bar-svg { grid-column: 1 / -1; grid-row: 2; }
  .fin-bar-val { grid-column: 2; }
  .fin-big { font-size: 30px; }
}
