/* ============================================================================
   KING FAMILY HUB — FINANCES (bespoke premium rebuild)
   Scoped under .cc.fin so it inherits the redesign tokens + dark mode.
   Load AFTER redesign.css.  Pair with redesign-finances.js.
   ========================================================================== */

/* ---- page shell ---------------------------------------------------------- */
.fin { max-width: 1240px; }
.fin .fin-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.fin .fin-head h1 { font-family: var(--font-display); font-weight: 600; letter-spacing: -.015em; font-size: clamp(22px, 2.4vw, 30px); line-height: 1.02; color: var(--ink); }
.fin .fin-head .fh-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; font-weight: 500; }
.fin .fin-head .fh-spacer { flex: 1; }
.fin .fin-lock { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-soft); background: var(--surface); border: 1px solid var(--line); padding: 7px 13px; border-radius: var(--radius-pill); cursor: pointer; transition: all .14s; }
.fin .fin-lock:hover { color: var(--ink); border-color: var(--line-strong); }
.fin .fin-lock svg { width: 13px; height: 13px; }

/* ---- live status chip ---------------------------------------------------- */
.fin .fin-status { display: inline-flex; align-items: center; gap: 8px; font-size: 11.5px; font-weight: 600; color: var(--ink-soft); background: var(--surface-2); border: 1px solid var(--line); padding: 6px 12px; border-radius: var(--radius-pill); margin-bottom: 16px; }
.fin .fin-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-faint); }
.fin .fin-status.live .dot { background: var(--green); }
.fin .fin-status.err .dot { background: var(--red); }
.fin .fin-status a { color: var(--accent); font-weight: 700; margin-left: 2px; }

/* ============================================================================
   KPI HERO — replaces the navy "command bar"
   ========================================================================== */
.fin .kpi-hero { background: linear-gradient(150deg, var(--navy) 0%, #0a121c 72%); color: #fff; border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; position: relative; overflow: hidden; box-shadow: var(--shadow-md); }
.fin .kpi-hero::after { content: ""; position: absolute; right: -70px; top: -70px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, color-mix(in oklab, var(--accent) 55%, transparent), transparent 70%); opacity: .45; }
.fin .kpi-eyebrow { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: rgba(255,255,255,.6); margin-bottom: 16px; position: relative; }
.fin .kpi-eyebrow svg { width: 15px; height: 15px; }
.fin .kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: rgba(255,255,255,.1); border-radius: var(--radius-sm); overflow: hidden; position: relative; }
.fin .kpi { background: rgba(255,255,255,.04); padding: 14px 16px; }
.fin .kpi .k-label { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: rgba(255,255,255,.55); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.fin .kpi .k-label svg { width: 13px; height: 13px; opacity: .8; }
.fin .kpi .k-val { font-family: var(--font-mono); font-size: clamp(18px, 1.7vw, 23px); font-weight: 700; letter-spacing: -.02em; line-height: 1; }
.fin .kpi .k-sub { font-size: 10.5px; color: rgba(255,255,255,.5); margin-top: 5px; font-weight: 500; }
.fin .kpi .k-val.pos { color: oklch(0.82 0.13 150); } .fin .kpi .k-val.neg { color: oklch(0.78 0.12 25); }
.fin .kpi .k-val.warn { color: oklch(0.85 0.13 80); }

.fin .kpi-actions { margin-top: 14px; position: relative; display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; }
.fin .kpi-act { display: flex; align-items: flex-start; gap: 9px; padding: 10px 13px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); border-radius: var(--radius-sm); font-size: 12px; line-height: 1.4; color: rgba(255,255,255,.92); }
.fin .kpi-act .ka-dot { width: 6px; height: 6px; border-radius: 50%; background: oklch(0.85 0.13 80); flex-shrink: 0; margin-top: 5px; }
.fin .kpi-act b { color: #fff; font-weight: 700; }

/* ============================================================================
   TABS (segmented, reuse .cc .seg styling but full-width capable)
   ========================================================================== */
.fin .fin-tabs { display: inline-flex; gap: 3px; padding: 4px; background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-pill); margin-bottom: 18px; flex-wrap: wrap; }
.fin .fin-tabs button { padding: 8px 18px; border-radius: var(--radius-pill); font-weight: 600; font-size: 13px; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 7px; cursor: pointer; white-space: nowrap; transition: all .14s; border: none; background: none; }
.fin .fin-tabs button svg { width: 15px; height: 15px; }
.fin .fin-tabs button:hover { color: var(--ink); }
.fin .fin-tabs button.active { background: var(--accent); color: #fff; }
.fin .fin-tabs button.active svg { color: #fff; }

/* ============================================================================
   GENERIC CARDS / TILES (reuses .cc-card; finance extras)
   ========================================================================== */
.fin .fgrid { display: grid; gap: 14px; }
.fin .fgrid.c2 { grid-template-columns: 1fr 1fr; }
.fin .fgrid.c3 { grid-template-columns: repeat(3, 1fr); }
.fin .span2 { grid-column: span 2; }

/* big headline number */
.fin .headline { text-align: center; padding: 22px 0 6px; }
.fin .headline .h-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 8px; }
.fin .headline .h-num { font-family: var(--font-mono); font-size: clamp(34px, 4.5vw, 46px); font-weight: 700; letter-spacing: -.025em; line-height: 1; color: var(--ink); }
.fin .headline .h-chip-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 10px; }
.fin .headline .h-delta { font-family: var(--font-mono); font-size: 15px; font-weight: 700; }
.fin .headline .h-delta.up { color: var(--green); } .fin .headline .h-delta.down { color: var(--red); }
.fin .headline .h-pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: var(--radius-pill); }
.fin .headline .h-pill.up { background: var(--light-green); color: var(--green); } .fin .headline .h-pill.down { background: var(--light-red); color: var(--red); }
.fin .headline .h-asof { font-size: 11.5px; color: var(--ink-faint); margin-top: 8px; }

/* metric tiles row */
.fin .tiles { display: grid; gap: 12px; }
.fin .tiles.t4 { grid-template-columns: repeat(4, 1fr); }
.fin .tiles.t3 { grid-template-columns: repeat(3, 1fr); }
.fin .tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px; box-shadow: var(--shadow-sm); position: relative; overflow: hidden; }
.fin .tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--c, var(--accent)); }
.fin .tile .t-label { font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 6px; }
.fin .tile .t-val { font-family: var(--font-mono); font-size: 19px; font-weight: 700; letter-spacing: -.02em; color: var(--c, var(--ink)); line-height: 1; }
.fin .tile .t-sub { font-size: 10.5px; color: var(--ink-soft); margin-top: 5px; }
.fin .tile.c-green { --c: var(--green); } .fin .tile.c-red { --c: var(--red); } .fin .tile.c-orange { --c: var(--orange); }
.fin .tile.c-teal { --c: var(--teal); } .fin .tile.c-purple { --c: var(--purple); } .fin .tile.c-blue { --c: var(--accent); }
.fin .tile.c-ink { --c: var(--ink-soft); }

/* callout boxes (insight / alert / good) */
.fin .callout { border-radius: var(--radius-sm); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); background: var(--cs, var(--surface-2)); padding: 13px 15px; }
.fin .callout .co-label { font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--c, var(--ink-soft)); margin-bottom: 7px; display: flex; align-items: center; gap: 7px; }
.fin .callout .co-label svg { width: 14px; height: 14px; }
.fin .callout p, .fin .callout .co-body { font-size: 12.5px; color: var(--ink-soft); line-height: 1.55; }
.fin .callout b, .fin .callout strong { color: var(--ink); font-weight: 700; }
.fin .callout.red { --c: var(--red); --cs: var(--light-red); }
.fin .callout.orange { --c: var(--orange); --cs: var(--light-orange); }
.fin .callout.green { --c: var(--green); --cs: var(--light-green); }
.fin .callout.blue { --c: var(--accent); --cs: var(--accent-soft); }

/* chart frame */
.fin .chart-frame { position: relative; height: 220px; }
.fin .chart-frame.tall { height: 260px; }
.fin .chart-note { font-size: 11px; color: var(--ink-faint); text-align: center; margin-top: 10px; line-height: 1.5; }

/* list rows (accounts / debts / income) */
.fin .lrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.fin .lrow:last-child { border-bottom: none; }
.fin .lrow .lr-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.fin .lrow .lr-inst { font-size: 11px; color: var(--ink-faint); margin-top: 1px; }
.fin .lrow .lr-amt { font-family: var(--font-mono); font-size: 13px; font-weight: 700; white-space: nowrap; }
.fin .lr-amt.pos { color: var(--green); } .fin .lr-amt.neg { color: var(--red); } .fin .lr-amt.ink { color: var(--ink); }
.fin .lgroup-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); padding: 14px 0 4px; display: flex; align-items: center; gap: 7px; }
.fin .lgroup-label:first-child { padding-top: 2px; }
.fin .lr-rank { width: 24px; height: 24px; border-radius: 7px; flex-shrink: 0; display: grid; place-items: center; font-family: var(--font-mono); font-size: 12px; font-weight: 700; color: #fff; }

/* budget category bar */
.fin .bcat { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.fin .bcat .bc-ico { width: 30px; height: 30px; border-radius: 8px; background: var(--bg-2); display: grid; place-items: center; font-size: 15px; flex-shrink: 0; }
.fin .bcat .bc-main { flex: 1; min-width: 0; }
.fin .bcat .bc-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 7px; }
.fin .bcat .bc-name { font-size: 13px; font-weight: 600; color: var(--ink); line-height: 1.3; }
.fin .bcat .bc-amt { font-family: var(--font-mono); font-size: 11.5px; white-space: nowrap; color: var(--ink-soft); flex-shrink: 0; padding-top: 1px; }
.fin .bcat .bc-amt b { color: var(--ink); }
.fin .bcat .bc-amt .st-over { color: var(--red); font-weight: 700; }
.fin .bcat .bc-amt .st-ok { color: var(--green); }
.fin .bcat .bc-track { height: 7px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.fin .bcat .bc-fill { height: 100%; border-radius: 99px; transition: width .5s cubic-bezier(.4,0,.2,1); }
.fin .bcat-group-h { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-faint); margin: 16px 0 4px; display: flex; align-items: center; gap: 8px; }
.fin .bcat-group-h:first-child { margin-top: 4px; }
.fin .bcat-group-h .bgh-rule { flex: 1; height: 1px; background: var(--line); }
.fin .bcat-group-h .bgh-sum { font-family: var(--font-mono); font-size: 11px; color: var(--ink-soft); letter-spacing: 0; text-transform: none; white-space: nowrap; flex-shrink: 0; }

/* transaction row */
.fin .txrow { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.fin .txrow .tx-ico { width: 30px; text-align: center; font-size: 17px; flex-shrink: 0; }
.fin .txrow .tx-main { flex: 1; min-width: 0; }
.fin .txrow .tx-merch { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fin .txrow .tx-cat { font-size: 11px; color: var(--ink-faint); margin-top: 1px; }
.fin .txrow .tx-amt { font-family: var(--font-mono); font-size: 13px; font-weight: 700; text-align: right; }

/* collapsible */
.fin .fcollapse { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 12px; overflow: hidden; background: var(--surface-2); }
.fin .fcollapse > .fc-head { display: flex; align-items: center; gap: 9px; padding: 11px 14px; cursor: pointer; font-size: 12.5px; font-weight: 700; color: var(--ink); user-select: none; }
.fin .fcollapse > .fc-head .fc-chev { margin-left: auto; transition: transform .2s; color: var(--ink-faint); display: flex; }
.fin .fcollapse > .fc-head .fc-chev svg { width: 16px; height: 16px; }
.fin .fcollapse.open > .fc-head .fc-chev { transform: rotate(180deg); }
.fin .fcollapse > .fc-body { padding: 0 14px 12px; }
.fin .fcollapse:not(.open) > .fc-body { display: none; }

/* mini table */
.fin .ftable { width: 100%; border-collapse: collapse; font-size: 12px; }
.fin .ftable th { text-align: left; padding: 7px 6px; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-faint); border-bottom: 2px solid var(--line); }
.fin .ftable th.r, .fin .ftable td.r { text-align: right; }
.fin .ftable td { padding: 8px 6px; border-bottom: 1px solid var(--line); color: var(--ink-soft); }
.fin .ftable td .ft-name { font-weight: 600; color: var(--ink); }
.fin .ftable td .ft-sub { font-size: 10.5px; color: var(--ink-faint); margin-top: 1px; }
.fin .ftable .ft-mono { font-family: var(--font-mono); font-weight: 700; color: var(--ink); }
.fin .ftable tr.ft-total td { border-top: 2px solid var(--line-strong); background: var(--surface-2); font-weight: 800; }
.fin .ftable tr.ft-hi td { background: var(--accent-soft); }
.fin .pos { color: var(--green); } .fin .neg { color: var(--red); } .fin .muted { color: var(--ink-faint); }

/* investment idea card */
.fin .idea { border-radius: var(--radius-sm); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); background: var(--surface-2); padding: 13px 15px; }
.fin .idea .id-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 7px; }
.fin .idea .id-name { font-size: 13.5px; font-weight: 800; color: var(--ink); }
.fin .idea .id-ticker { font-family: var(--font-mono); font-size: 11px; font-weight: 700; color: var(--ink-soft); margin-left: 6px; }
.fin .idea .id-type { font-size: 10px; font-weight: 600; color: var(--ink-faint); background: var(--bg-2); border-radius: 99px; padding: 1px 8px; margin-left: 4px; }
.fin .idea .id-risk { text-align: right; flex-shrink: 0; }
.fin .idea .id-risk .ir-lvl { font-size: 10px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.fin .idea .id-risk .ir-alloc { font-size: 10px; color: var(--ink-faint); margin-top: 2px; }
.fin .idea .id-why { font-size: 12px; color: var(--ink-soft); line-height: 1.5; margin-bottom: 6px; }
.fin .idea .id-meta { font-size: 11px; color: var(--ink-faint); line-height: 1.5; margin-top: 3px; }
.fin .idea .id-meta b { color: var(--ink-soft); }
.fin .idea.low { --c: var(--green); } .fin .idea.medium { --c: var(--orange); } .fin .idea.high { --c: var(--red); }
.fin .id-risk .low { color: var(--green); } .fin .id-risk .medium { color: var(--orange); } .fin .id-risk .high { color: var(--red); }

/* sector chips */
.fin .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.fin .chip { font-size: 10.5px; font-weight: 600; padding: 3px 9px; border-radius: var(--radius-pill); background: var(--bg-2); color: var(--ink-soft); border: 1px solid var(--line); }
.fin .chip.accent { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }

/* funded progress bar */
.fin .funded { margin-top: 4px; }
.fin .funded .fu-meta { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-soft); margin-bottom: 6px; }
.fin .funded .fu-track { height: 11px; background: var(--bg-2); border-radius: 99px; overflow: hidden; }
.fin .funded .fu-fill { height: 100%; border-radius: 99px; }

/* SS timing cards */
.fin .ss-card { border-radius: var(--radius-sm); padding: 14px 16px; border: 1px solid var(--line); background: var(--surface-2); }
.fin .ss-card .ss-h { font-size: 11.5px; font-weight: 700; margin-bottom: 8px; }
.fin .ss-card .ss-amt { font-family: var(--font-mono); font-size: 24px; font-weight: 700; color: var(--ink); letter-spacing: -.02em; }
.fin .ss-card .ss-amt small { font-size: 12px; font-weight: 500; color: var(--ink-faint); font-family: var(--font-ui); }
.fin .ss-card .ss-note { font-size: 11px; margin-top: 6px; line-height: 1.4; }

.fin .footer-links { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.fin .footer-links a { font-size: 12px; font-weight: 600; color: var(--accent); display: inline-flex; align-items: center; gap: 5px; padding: 7px 14px; border-radius: var(--radius-pill); border: 1px solid var(--line); background: var(--surface); transition: all .14s; }
.fin .footer-links a:hover { background: var(--accent-soft); border-color: transparent; }

/* gate */
.fin-gate { min-height: 70vh; display: grid; place-items: center; padding: 24px; }
.fin-gate .gate-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 30px 28px; text-align: center; }
.fin-gate .gate-ico { width: 52px; height: 52px; border-radius: 14px; background: var(--navy); color: #fff; display: grid; place-items: center; margin: 0 auto 16px; }
.fin-gate .gate-ico svg { width: 24px; height: 24px; }
.fin-gate h2 { font-family: var(--font-display); font-size: 20px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.fin-gate p { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 18px; }
.fin-gate input { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 15px; box-sizing: border-box; margin-bottom: 10px; background: var(--surface-2); color: var(--ink); font-family: var(--font-ui); }
.fin-gate input:focus { outline: none; border-color: var(--accent); }
.fin-gate .gate-err { color: var(--red); font-size: 12.5px; min-height: 18px; margin-bottom: 8px; font-weight: 500; }
.fin-gate button.gate-btn { width: 100%; padding: 11px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm); font-size: 15px; font-weight: 700; cursor: pointer; transition: filter .14s; }
.fin-gate button.gate-btn:hover { filter: brightness(1.08); }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 900px) {
  .fin .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .fin .fgrid.c2, .fin .fgrid.c3 { grid-template-columns: 1fr; }
  .fin .span2 { grid-column: auto; }
  .fin .tiles.t4 { grid-template-columns: repeat(2, 1fr); }
  .fin .tiles.t3 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .fin .kpi-grid { grid-template-columns: 1fr 1fr; }
  .fin .tiles.t4 { grid-template-columns: 1fr 1fr; }
}
