/* Portfolio Optimization node (EX-03) — styles. Loaded globally by Dash from /assets, so every rule is scoped under
   .po-app. The page kit of the main app (assets/app_pages/pages_style.css: .pk-scope, .pk-card, .pk-pills) does most
   of the work; these rules lay out the node like Trading Range / Unconditional Statistics (rail + screens + tiles).
   Tokens: panels rgba(0,0,0,0.6), chips rgba(255,255,255,0.06), radius 10px, text #e8e8e8, muted #9fb3c8,
   headings #cfefff, accent #f0a030, good #3fbf7f, bad #e66767, blue #3987e5, teal #3fb6c9, purple #9085e9.
   Rule families: Markowitz #3987e5, hierarchical #199e70, risk measures #d95926, neural #d55181, 1/N #9fb3c8. */

.po-app { color: #e8e8e8; font-size: 13px; }
.po-app * { box-sizing: border-box; }

/* ---------- header (leave ~200px on the right for the app toolbar) ------------------ */
.po-top { display: flex; align-items: flex-end; gap: 18px; padding: 0 200px 10px 0; }
.po-brand h3 { margin: 0; font-size: 1.32rem; color: #cfefff; font-weight: 600; letter-spacing: .2px; }
.po-brand h3 span { color: #9fb3c8; font-weight: 400; font-size: .95rem; }
.po-brand > div { color: #9fb3c8; font-size: .78rem; max-width: 1060px; line-height: 1.45; }

/* ---------- main grid: rail + screens ------------------------------------------------- */
.po-main { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 14px; align-items: start; }
.po-rail { display: flex; flex-direction: column; min-width: 0; position: sticky; top: 0; }
.po-rail .pk-card { padding: 9px 11px; margin-bottom: 8px; }
.po-rail .pk-card-sub { font-size: .68rem; }
.po-k { color: #9fb3c8; font-size: .62rem; text-transform: uppercase; letter-spacing: .6px; margin: 6px 0 3px; }
.po-or { margin-top: 9px; }
.po-field { margin-bottom: 4px; }
.po-status { margin-top: 7px; font-size: .74rem; }
.po-ok { color: #bfe8c4; }
.po-ok i { color: #3fbf7f; }
.po-err { color: #ffd0cb; }
.po-err i { color: #e66767; }
.po-railnote { color: #7f93a6; font-size: .7rem; line-height: 1.45; padding: 2px 4px; }
.po-railnote i { color: #f0a030; }
.po-center { min-width: 0; }
.po-col { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.po-col > .pk-card { margin-bottom: 0; }
.po-app .po-presets label, .po-app .po-unc label { font-size: .72rem !important; padding: 2px 8px !important; }
.po-app .po-small-pills label { font-size: .74rem !important; padding: 3px 9px !important; }
.po-app .pfp-chip { width: 100%; }

/* screen tabs */
.po-tabs { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 0 0 12px; border-bottom: 1px solid rgba(255,255,255,0.07); }
.po-tabs label { display: inline-flex !important; margin: 0 !important; cursor: pointer; padding: 2px 0 8px;
                 color: #7f93a8; font-size: .98rem; font-weight: 600; border-bottom: 3px solid transparent;
                 transition: color .15s, border-color .15s; }
.po-tabs label:hover { color: #cfefff; }
.po-tabs label:has(input:checked) { color: #cfefff; border-bottom-color: #f0a030; }
.po-tabs input { display: none; }
.po-wait { color: #9fb3c8; padding: 40px 10px; text-align: center; }
.po-wait i { color: #f0a030; }

/* the Loading overlay of a long screen: spinner pinned near the top (it centres in the whole height otherwise),
   the old screen dimmed underneath */
.po-loadwrap { position: relative; min-height: 260px; }
.po-loadwrap > div:not(#po_screen) { align-items: flex-start !important; padding-top: 110px;
                                     background: rgba(5,10,16,0.45); border-radius: 10px; }
.po-loadwrap .dash-dot-spinner { transform: scale(1.7); }

/* progress strip (outside the Loading wrapper) */
.po-progwrap:empty { display: none; }
.po-progwrap { margin-bottom: 12px; }
.po-prog { background: rgba(0,0,0,0.6); border: 1px solid rgba(240,160,48,0.35); border-radius: 10px; padding: 12px 14px; }
.po-prog-t { color: #cfefff; font-weight: 600; font-size: .9rem; margin-bottom: 8px; }
.po-prog-t i { color: #f0a030; }
.po-prog-bar { height: 10px; border-radius: 10px; background: rgba(255,255,255,0.07); overflow: hidden; }
.po-prog-fill { height: 100%; border-radius: 10px; background: linear-gradient(90deg, #3987e5, #9085e9, #f0a030);
                box-shadow: 0 0 12px rgba(240,160,48,0.45); transition: width .6s ease; }
.po-prog-s { color: #9fb3c8; font-size: .74rem; margin-top: 7px; }
.po-nnchip { margin-top: 8px; padding: 8px 12px; border-radius: 10px; font-size: .78rem; color: #f6d3e3;
             background: rgba(213,81,129,0.12); border: 1px solid rgba(213,81,129,0.45); }
.po-nnchip i { color: #d55181; }
.po-nnchip.off { color: #c8d3dd; background: rgba(255,255,255,0.04); border-color: rgba(255,255,255,0.12); }
.po-nnchip.off i { color: #9fb3c8; }

/* ---------- headline + tiles ------------------------------------------------------------- */
.po-headline { background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.07); border-left: 4px solid #f0a030;
               border-radius: 10px; padding: 12px 15px; font-size: .93rem; color: #e8f4ff; line-height: 1.6; }
.po-headline > i { color: #f0a030; }
.po-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px; }
.po-tile { background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.08); border-radius: 10px;
           padding: 10px 12px 9px; transition: transform .15s, border-color .15s, box-shadow .15s; min-width: 0; cursor: default; }
.po-tile:hover { transform: translateY(-3px); border-color: rgba(240,160,48,0.6); box-shadow: 0 6px 18px rgba(0,0,0,0.35); }
.po-tl { color: #9fb3c8; font-size: .64rem; text-transform: uppercase; letter-spacing: .5px;
         white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.po-tv { color: #cfefff; font-size: 1.45rem; font-weight: 700; margin: 2px 0 2px; font-variant-numeric: tabular-nums;
         white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.po-ts { color: #7f93a6; font-size: .66rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.po-hero-tiles { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }

/* ---------- cards, grids ------------------------------------------------------------------- */
.po-card-h { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.po-grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.po-grid2 > .pk-card { margin-bottom: 0; }
.po-graph { width: 100%; }
.po-say { display: flex; gap: 8px; align-items: flex-start; margin-top: 6px; padding: 8px 11px; border-radius: 10px;
          background: rgba(255,255,255,0.04); color: #dfe7ee; font-size: .79rem; line-height: 1.5; }
.po-say i { color: #f0a030; margin-top: 3px; }
.po-note { color: #7f93a6; font-size: .7rem; line-height: 1.45; margin-top: 6px; }
.po-note.warn { color: #f5d6a3; }
.po-ctlrow { display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center; }
.po-badge { background: rgba(240,160,48,0.14); color: #f0a030; border: 1px solid rgba(240,160,48,0.45);
            border-radius: 10px; padding: 2px 9px; font-size: .72rem; font-weight: 600; white-space: nowrap; }
.po-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: -1px;
          box-shadow: 0 0 0 2px rgba(255,255,255,0.08); }
.po-rule { white-space: nowrap; }
.po-strong { font-weight: 700; color: #cfefff; }
.po-muted { color: #7f93a6; font-size: .72rem; }
.po-fam { display: inline-block; border: 1px solid; border-radius: 10px; padding: 0 7px; font-size: .64rem;
          letter-spacing: .3px; white-space: nowrap; background: rgba(255,255,255,0.03); }

/* tables */
.po-scroll { overflow-x: auto; }
.po-table { width: 100%; border-collapse: collapse; font-size: .77rem; }
.po-table th { color: #9fb3c8; font-weight: 500; font-size: .63rem; text-transform: uppercase; letter-spacing: .4px;
               text-align: right; padding: 5px 7px; border-bottom: 1px solid rgba(255,255,255,0.1); white-space: nowrap;
               vertical-align: bottom; }
.po-table td { padding: 5px 7px; border-bottom: 1px solid rgba(255,255,255,0.05); text-align: right;
               font-variant-numeric: tabular-nums; color: #e8e8e8; white-space: nowrap; }
.po-table th:first-child, .po-table td:first-child { text-align: left; }
.po-table tbody tr:hover td { background: rgba(255,255,255,0.035); }
.po-table td.po-neg { color: #f19a9a; }
.po-table td.po-strong { color: #f0a030; }

/* formulas box */
.po-formulas { background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.07); border-radius: 10px; }
.po-formulas summary { cursor: pointer; padding: 8px 12px; color: #cfefff; font-weight: 600; font-size: .82rem; }
.po-formulas summary i { color: #f0a030; }
.po-fbox { padding: 2px 12px 10px; }
.po-frow { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 10px; padding: 5px 0;
           border-top: 1px solid rgba(255,255,255,0.05); }
.po-fk { color: #9fb3c8; font-size: .74rem; }
.po-fv { color: #e8e8e8; font-size: .78rem; line-height: 1.5; font-family: "Cambria Math", Georgia, serif; }
.po-formula { font-family: "Cambria Math", Georgia, serif; color: #e8f4ff; font-size: .8rem; padding: 6px 9px;
              margin: 6px 0; border-radius: 8px; background: rgba(255,255,255,0.04); border-left: 3px solid rgba(240,160,48,0.6); }
.po-guide-line { color: #dfe7ee; font-size: .82rem; line-height: 1.5; }

/* mini weight bars (method guide, allocations) */
.po-mb { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.po-mb-row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 36px; gap: 6px; align-items: center; }
.po-mb-k { color: #9fb3c8; font-size: .68rem; font-weight: 600; }
.po-mb-bar { height: 8px; border-radius: 6px; background: rgba(255,255,255,0.06); overflow: hidden; }
.po-mb-bar > span { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, #2a78d6, #86b6ef); }
.po-mb-v { color: #e8e8e8; font-size: .68rem; text-align: right; font-variant-numeric: tabular-nums; }

/* method guide */
.po-g-block { display: flex; flex-direction: column; gap: 8px; }
.po-g-famh { border-bottom: 1px solid rgba(255,255,255,0.07); padding-bottom: 4px; }
.po-g-fam { font-weight: 700; font-size: .95rem; letter-spacing: .3px; }
.po-g-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.po-g-card { background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.08); border-top: 4px solid;
             border-radius: 10px; padding: 10px 12px; transition: transform .15s, box-shadow .15s; }
.po-g-card:hover { transform: translateY(-3px); box-shadow: 0 8px 22px rgba(0,0,0,0.4); }
.po-g-h { display: flex; align-items: center; }
.po-g-name { color: #cfefff; font-weight: 700; font-size: .88rem; }
.po-g-line { color: #b9c6d2; font-size: .76rem; line-height: 1.45; margin-top: 4px; min-height: 3.2em; }
.po-uses { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.po-use { font-size: .62rem; color: #cfefff; background: rgba(57,135,229,0.16); border: 1px solid rgba(57,135,229,0.4);
          border-radius: 10px; padding: 1px 7px; }

.po-foot { color: #6f8295; font-size: .68rem; line-height: 1.45; margin-top: 12px; padding-top: 8px;
           border-top: 1px solid rgba(255,255,255,0.06); }
.po-foot i { color: #9fb3c8; }

/* ---------- narrow screens ---------------------------------------------------------------- */
@media (max-width: 1250px) { .po-grid2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1000px) {
  .po-main { grid-template-columns: minmax(0, 1fr); }
  .po-rail { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 8px; }
  .po-top { padding-right: 120px; }
}
@media (max-width: 760px) { .po-hero-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .po-top { padding-right: 0; padding-top: 34px; }
  .po-brand > div { display: none; }
  .po-rail { grid-template-columns: minmax(0, 1fr); }
  .po-tabs { gap: 4px 14px; }
  .po-tabs label { font-size: .84rem; }
  .po-tv { font-size: 1.15rem; }
  .po-frow { grid-template-columns: minmax(0, 1fr); gap: 2px; }
}
