/* CFO OS styles — the nav shell + new-tab components. Loaded AFTER styles.css so it reuses the
   ink palette (:root vars) and component classes (.card/.row/.chip/.num/.pos/.neg). Home's
   styles.css is never edited; this only adds. */

/* ---- layout: make room for the fixed nav ---- */
@media (min-width: 1024px) {
  body.has-nav { padding-left: 92px; }
}
@media (max-width: 1023px) {
  body.has-nav { padding-bottom: 66px; }
}

/* ---- desktop left rail ---- */
.cfo-rail {
  position: fixed; top: 0; left: 0; height: 100dvh; width: 92px; z-index: 30;
  background: linear-gradient(180deg, var(--panel-2), var(--ink-2));
  border-right: 1px solid var(--line-2);
  display: flex; flex-direction: column; align-items: stretch; padding: 14px 8px; gap: 2px;
  overflow-y: auto;
}
.cfo-rail .rail-brand {
  display: flex; flex-direction: column; align-items: center; gap: 5px; text-decoration: none;
  color: var(--text); font-family: var(--display); padding: 6px 0 14px;
}
.cfo-rail .rail-brand .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--emerald); box-shadow: 0 0 14px var(--emerald); }
.cfo-rail .rail-brand b { font-size: 13px; letter-spacing: 0.14em; }
.rail-grp { color: var(--faint); font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; padding: 12px 6px 4px; }
.rail-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px; text-decoration: none;
  color: var(--muted); padding: 9px 4px; border-radius: var(--r-sm); transition: background 0.14s, color 0.14s;
}
.rail-item:hover { background: var(--panel-hi); color: var(--text); }
.rail-item.active { background: var(--emerald-soft); color: var(--emerald); }
.rail-item .ri-ic { font-size: 19px; line-height: 1; }
.rail-item .ri-l { font-size: 10px; font-weight: 600; }
@media (max-width: 1023px) { .cfo-rail { display: none; } }

/* ---- mobile bottom bar ---- */
.cfo-bottom {
  position: fixed; bottom: 0; left: 0; right: 0; height: 64px; z-index: 30;
  background: linear-gradient(0deg, var(--ink), var(--ink-2));
  border-top: 1px solid var(--line-2);
  display: flex; align-items: stretch; justify-content: space-around; padding: 0 4px;
}
.cfo-bottom .bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--muted); font-size: 10px; min-width: 0;
}
.cfo-bottom .bn-item.active { color: var(--emerald); }
.cfo-bottom .bn-ic { font-size: 19px; line-height: 1; }
.cfo-bottom .bn-l { font-weight: 600; }
@media (min-width: 1024px) { .cfo-bottom { display: none; } }
.moresheet { display: grid; gap: 6px; }
.moresheet-item { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text);
  padding: 13px 14px; border: 1px solid var(--line); border-radius: var(--r-sm); font-weight: 600; }
.moresheet-item.active { border-color: var(--emerald); color: var(--emerald); }
.moresheet-item span { font-size: 18px; }

/* ---- page shell for new tabs (mirrors Home's .wrap/.topbar) ---- */
.cfo-wrap { max-width: 1180px; margin: 0 auto; padding: clamp(18px, 3vw, 34px) clamp(14px, 3vw, 30px) 80px; }
.cfo-top { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.cfo-top h1 { font-family: var(--display); font-weight: 500; font-size: clamp(22px, 3.4vw, 30px); margin: 0; }
.cfo-top .sub { color: var(--muted); font-size: 13px; }
.cfo-sec { margin-top: clamp(20px, 3vw, 30px); }
.cfo-sec > h2 { font-size: 13px; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; text-transform: uppercase;
  border-bottom: 1px solid var(--line); padding-bottom: 9px; margin: 0 0 14px; }
.ai-note { margin-top: 14px; padding: 13px 16px; border: 1px solid var(--line); border-left: 3px solid var(--emerald);
  border-radius: var(--r-sm); background: rgba(61,220,151,0.04); color: var(--text); font-size: 13.5px; line-height: 1.5; }
.ai-note b { color: var(--emerald); }
.loading-ph { color: var(--faint); padding: 20px; text-align: center; }
.bandtext.good { color: var(--emerald); } .bandtext.warn { color: var(--gold); } .bandtext.bad { color: var(--coral); }

/* ---- KPI tiles ---- */
.kpi-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); }
.kpi-tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; position: relative; }
.kpi-tile .kpi-k { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.kpi-tile .kpi-k i { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.kpi-tile .kpi-v { font-size: clamp(20px, 2.8vw, 26px); margin-top: 8px; }
.kpi-tile .kpi-delta { font-size: 12px; color: var(--faint); margin-top: 2px; }
.kpi-tile .kpi-delta.up { color: var(--emerald); } .kpi-tile .kpi-delta.down { color: var(--coral); }
.kpi-tile .kpi-spark { height: 32px; margin-top: 8px; }

/* ---- score gauges ---- */
.gauge-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
@media (max-width: 720px) { .gauge-row { grid-template-columns: repeat(3, 1fr); } }
.gauge { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 10px; text-align: center; }
.gauge-arc {
  width: 84px; height: 84px; border-radius: 50%; margin: 0 auto; display: grid; place-items: center;
  background: radial-gradient(closest-side, var(--panel) 70%, transparent 71% 100%),
              conic-gradient(var(--c) calc(var(--v) * 1%), var(--line-2) 0);
}
.gauge-num { font-size: 25px; color: var(--text); }
.gauge-l { margin-top: 9px; font-size: 11.5px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }

/* ---- ranking / data tables ---- */
.ctable { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.ctable th { text-align: right; color: var(--faint); font-weight: 600; font-size: 11px; letter-spacing: 0.05em;
  text-transform: uppercase; padding: 8px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.ctable th:first-child, .ctable td:first-child { text-align: left; }
.ctable td { text-align: right; padding: 13px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ctable tbody tr { transition: background 0.12s; }
.ctable tbody tr.clickable { cursor: pointer; }
.ctable tbody tr.clickable:hover { background: var(--panel-hi); }
.ctable .nm { font-weight: 600; color: var(--text); }
.ctable .num { font-family: var(--display); }
.ctable .rk { color: var(--faint); width: 26px; }
.dotcol i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-left: 2px; }

/* ---- best/worst hero pair ---- */
.bw { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .bw { grid-template-columns: 1fr; } }
.bw .card { padding: 18px 20px; }
.bw .lbl { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint); }
.bw .bw-name { font-family: var(--display); font-size: 22px; margin-top: 6px; }
.bw .bw-big { font-size: 26px; margin-top: 10px; }
.bw .bw-meta { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.bw.best .card { border-color: rgba(61,220,151,0.3); }
.bw.worst .card { border-color: rgba(240,135,105,0.3); }

/* ---- generic two-col + chartbox reuse ---- */
.cfo-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 820px) { .cfo-two { grid-template-columns: 1fr; } }
.cfo-chartbox { position: relative; height: clamp(220px, 34vw, 300px); }
.cfo-chartbox.sm { height: clamp(170px, 26vw, 220px); }

/* ---- verdict banner (expansion) ---- */
.verdict { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-radius: var(--r); border: 1px solid var(--line-2); font-weight: 600; }
.verdict .vbig { font-family: var(--display); font-size: 18px; }
.verdict.go { background: var(--emerald-soft); border-color: rgba(61,220,151,0.35); color: var(--emerald); }
.verdict.caution { background: rgba(230,181,74,0.1); border-color: rgba(230,181,74,0.35); color: var(--amber); }
.verdict.notyet { background: var(--coral-soft); border-color: rgba(240,135,105,0.35); color: var(--coral); }

/* ---- funding thermometer / progress bars ---- */
.thermo { height: 16px; border-radius: 999px; background: var(--panel-hi); overflow: hidden; border: 1px solid var(--line); }
.thermo > i { display: block; height: 100%; background: linear-gradient(90deg, var(--emerald-2), var(--emerald)); }

/* ---- scenario table cells with pass/fail ---- */
.scn td.pass { color: var(--emerald); } .scn td.fail { color: var(--coral); }

/* ---- wins/risks columns + checklist ---- */
.wr { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .wr { grid-template-columns: 1fr; } }
.wr ul { list-style: none; margin: 0; padding: 0; }
.wr li { padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; line-height: 1.45; display: flex; gap: 9px; }
.wr li:last-child { border-bottom: none; }
.wr .ic { flex: none; }
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: 11px; padding: 12px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.checklist a { margin-left: auto; color: var(--emerald); text-decoration: none; font-size: 12px; white-space: nowrap; }
.checklist .box { width: 16px; height: 16px; border: 1.5px solid var(--line-2); border-radius: 4px; flex: none; }

/* clickable By-Category rows on Home (drill-down to transactions) */
.catrow.clickable { cursor: pointer; border-radius: 8px; transition: background 0.12s; }
.catrow.clickable:hover { background: var(--panel-hi); }

/* ---- info tooltips: the ⓘ next to a metric + its Vietnamese popover ---- */
.cfo-info {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 14px; height: 14px; margin-left: 5px; vertical-align: middle;
  border: 1px solid var(--line-2); border-radius: 50%;
  color: var(--faint); background: transparent;
  font-family: var(--display); font-style: normal; font-weight: 600; font-size: 9.5px; line-height: 1;
  text-transform: none; letter-spacing: 0; cursor: help; user-select: none;
  transition: color 0.14s, border-color 0.14s;
}
.cfo-info:hover, .cfo-info:focus { color: var(--emerald); border-color: var(--emerald); outline: none; }
.kpi-k .cfo-info { margin-left: 0; } /* .kpi-k is flex with its own gap */

.cfo-pop {
  position: absolute; z-index: 60; max-width: 320px; width: max-content;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  transition: opacity 0.13s, transform 0.13s;
}
.cfo-pop.open { opacity: 1; transform: translateY(0); pointer-events: auto; }
.cfo-pop-term { font-family: var(--display); font-size: 14.5px; color: var(--text); margin-bottom: 6px; }
.cfo-pop-body { font-size: 12.5px; line-height: 1.55; color: var(--muted); }
.cfo-pop-scrim { display: none; }

@media (max-width: 720px) {
  .cfo-pop {
    position: fixed; left: 12px !important; right: 12px; bottom: 12px; top: auto !important;
    width: auto !important; max-width: none; padding: 16px 18px; transform: translateY(14px);
  }
  .cfo-pop.open { transform: translateY(0); }
  .cfo-pop-term { font-size: 16px; }
  .cfo-pop-body { font-size: 13.5px; }
  .cfo-pop-scrim {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(0, 0, 0, 0.5); opacity: 0; pointer-events: none; transition: opacity 0.13s;
  }
  .cfo-pop-scrim.open { opacity: 1; pointer-events: auto; }
}

/* ---- Debt Center: estimate badges, provenance sub-line, edit pencil + loan editor form ---- */
.estbadge {
  display: inline-block; margin-left: 5px; padding: 0 4px; vertical-align: middle;
  font-size: 9px; font-family: var(--display); letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--faint); border: 1px solid var(--line-2); border-radius: 4px; cursor: help;
}
.prov { color: var(--faint); font-size: 10.5px; margin-top: 2px; }
.prov.live { color: var(--emerald); } .prov.est { color: var(--gold); }
.iconbtn {
  background: transparent; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--muted); cursor: pointer; padding: 4px 8px; font-size: 13px; transition: color 0.14s, border-color 0.14s;
}
.iconbtn:hover { color: var(--emerald); border-color: var(--emerald); }

.lform { display: flex; flex-direction: column; gap: 12px; }
.lform .efield { display: flex; flex-direction: column; gap: 5px; }
.lform .efield > span { color: var(--muted); font-size: 12px; }
.lform input, .lform select {
  background: var(--ink-2); border: 1px solid var(--line-2); border-radius: var(--r-sm);
  color: var(--text); padding: 9px 11px; font-size: 14px; font-family: var(--body); width: 100%;
}
.lform input:focus, .lform select:focus { outline: none; border-color: var(--emerald); }
.lform .ehint { color: var(--faint); font-size: 11.5px; line-height: 1.4; }
.lform .esec { color: var(--faint); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.lform-actions { display: flex; gap: 10px; margin-top: 6px; }
.lform .btn { flex: 1; padding: 11px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  background: var(--panel-hi); color: var(--text); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.lform .btn.primary { background: var(--emerald-soft); border-color: rgba(61,220,151,0.35); color: var(--emerald); }
.lform .btn:disabled { opacity: 0.5; cursor: default; }
.lform .emsg { font-size: 12.5px; min-height: 16px; }
.lform .emsg.ok { color: var(--emerald); } .lform .emsg.err { color: var(--coral); }
