/* irr.css -- the IRR tab's own styles, SCOPED TO THE TAB.
 *
 * Ported from tools/irr-test-template.html, which styled a standalone page and
 * therefore styled `body`, `button`, `table`, `th` and `svg` globally. Injected
 * into the application unscoped, those rules would restyle every other tab --
 * a stylesheet leaking across a page is the same class of fault as a variable
 * leaking across a module, and it is harder to see.
 *
 * So every selector is prefixed with the tab's own id, and the rules the
 * application already provides (box-sizing, the page font and background, the
 * header) are removed rather than duplicated. The custom properties live on the
 * tab, so they cannot be read outside it either.
 *
 * Generated from the template once, by hand-checked transformation; the tab is
 * now the source and the template is not used at runtime.
 */
#tab-irr{--ink:#191714; --muted:#6b6459; --line:#ddd6c8; --bg:#fbf9f5; --card:#fff; --accent:#8a5a1c; --good:#1f6b3a; --warn:#8a3a12; --warnbg:#fdf3e3; margin:0;font:14px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;background:var(--bg);color:var(--ink)}

#tab-irr .wrap{max-width:1180px;margin:0 auto;padding:18px 20px 60px}
#tab-irr .banner{background:var(--warnbg);border:1px solid #e5c9a8;border-left:4px solid var(--accent);padding:10px 14px;border-radius:4px;font-size:12.5px;color:#4a3a24;margin-bottom:16px}
#tab-irr .grid{display:grid;grid-template-columns:380px 1fr;gap:18px;align-items:start}
@media (max-width:980px){
  #tab-irr .grid{grid-template-columns:1fr}
}
#tab-irr .card{background:var(--card);border:1px solid var(--line);border-radius:6px;padding:14px 16px;margin-bottom:14px}
#tab-irr .card h2{font-size:13px;text-transform:uppercase;letter-spacing:.6px;color:var(--muted);margin:0 0 10px;font-weight:600}
#tab-irr .card h3{font-size:12.5px;margin:14px 0 6px;color:var(--accent);font-weight:600}
#tab-irr label{display:block;font-size:12px;color:var(--muted);margin:8px 0 2px}
#tab-irr input,#tab-irr select{width:100%;padding:6px 8px;border:1px solid var(--line);border-radius:4px;font:inherit;background:#fff}
#tab-irr input:focus,#tab-irr select:focus{outline:2px solid #e8d9bd;border-color:var(--accent)}
#tab-irr .row{display:grid;grid-template-columns:1fr 1fr;gap:10px}
#tab-irr button{font:inherit;padding:8px 14px;border-radius:4px;border:1px solid var(--accent);background:var(--accent);color:#fff;cursor:pointer;font-weight:600}
#tab-irr button.ghost{background:#fff;color:var(--accent)}
#tab-irr button:hover{filter:brightness(1.06)}
#tab-irr .actions{display:flex;gap:8px;flex-wrap:wrap;margin:14px 0}
#tab-irr table{border-collapse:collapse;width:100%;font-size:12px}
#tab-irr th,#tab-irr td{padding:5px 7px;border-bottom:1px solid #eee7db;text-align:right;white-space:nowrap}
#tab-irr th:first-child,#tab-irr td:first-child{text-align:left}
#tab-irr thead th{background:#f4efe6;color:#5a5245;font-weight:600;position:sticky;top:0}
#tab-irr tbody tr:nth-child(even){background:#fdfcf9}
#tab-irr .kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px}
#tab-irr .kpi{background:#f8f4ec;border:1px solid var(--line);border-radius:5px;padding:10px 12px}
#tab-irr .kpi .lab{font-size:11px;color:var(--muted);text-transform:uppercase;letter-spacing:.4px}
#tab-irr .kpi .val{font-size:20px;font-weight:650;margin-top:2px}
#tab-irr .kpi .sub{font-size:11px;color:var(--muted);margin-top:2px}
#tab-irr .pos{color:var(--good)}
#tab-irr .neg{color:var(--warn)}
#tab-irr .warn{background:var(--warnbg);border:1px solid #e5c9a8;border-radius:5px;padding:10px 12px;margin:6px 0;font-size:12.5px;color:#4a3a24}
#tab-irr .warn ul{margin:6px 0 0 16px;padding:0}
#tab-irr .scroll{max-height:420px;overflow:auto;border:1px solid var(--line);border-radius:5px}
#tab-irr .muted{color:var(--muted);font-size:11.5px}
#tab-irr .pill{display:inline-block;padding:1px 7px;border-radius:10px;background:#f0e9dc;color:#6b5a3d;font-size:11px;margin-left:6px}
#tab-irr details{margin-top:10px}
#tab-irr summary{cursor:pointer;font-size:12.5px;color:var(--accent);font-weight:600}
#tab-irr svg{display:block;width:100%;height:auto}
#tab-irr .legend{font-size:11px;color:var(--muted);margin-top:4px}
#tab-irr .legend i{display:inline-block;width:10px;height:3px;vertical-align:middle;margin-right:4px}

/* ---------------------------------------------------------------- modes --
   The mode switch, and the hybrid pane.

   SCOPED TO THE TAB like everything else here: an unscoped `button` rule would
   restyle every button on every other tab, which is the fault this file's own
   header warns about. */
#tab-irr .modeswitch{display:flex;gap:6px;margin:0 0 14px;padding:4px;
  background:var(--sunk,#EDEFEA);border-radius:8px;width:max-content}
#tab-irr .modeswitch button{background:transparent;border:0;border-radius:6px;
  padding:7px 14px;font:inherit;font-weight:600;color:var(--ink2,#5A6461);cursor:pointer}
#tab-irr .modeswitch button.active{background:var(--surface,#FBFBF9);color:var(--ink,#15191A);
  box-shadow:0 1px 2px rgba(21,25,26,.08)}
#tab-irr .modeswitch button:hover:not(.active){color:var(--ink,#15191A)}
/* The hybrid pane reuses the tab's own grid, cards and rows, so a developer
   meets the same layout in both modes. These two are the only additions. */
#tab-irr #irrHybridMode .warn{margin-top:10px}
#tab-irr #hyInfraManualRow{gap:10px}

/*  The read-only studio table must be allowed to WRAP.
 *
 *  Every other table in this tab is a wide grid in the right-hand column and
 *  `white-space:nowrap` keeps its numbers on one line, which is what you want.
 *  This one is different: it sits in the 380px LEFT column, next to a 32px card
 *  padding, so it has 348px to work with -- and it carries the scenario name,
 *  "Best mix -- the studio's recommendation", which is 38 characters on its own.
 *  A table cannot shrink below its min-content width, and nowrap forbids the one
 *  thing that would shrink it, so the table grew past the card and EVERY row's
 *  value fell outside the box (RK, 11 October: 'third_party' outside the box).
 *  Columns are shared across rows, so one long row pushes all of them out.
 *
 *  Scoped by the tbody's own id, so no markup change and nothing else moves. */
#tab-irr #hyStudioRates td{white-space:normal;overflow-wrap:anywhere;vertical-align:top}
#tab-irr #hyStudioRates td:first-child{width:45%;color:var(--muted)}

/*  `hidden` MUST ACTUALLY HIDE.
 *
 *  `#tab-irr .grid` and `#tab-irr .row` set `display`, and an AUTHOR rule beats
 *  the user agent's `[hidden]{display:none}` no matter how much less specific it
 *  is -- origin outranks specificity. So the attribute did nothing on any element
 *  carrying one of those classes, and the tab had three of them:
 *
 *    #irrSingleMode      class="grid"  -- so switching to Hybrid never hid it
 *    #irrHybridMode      class="grid"  -- so it was visible from the start
 *    #hyInfraManualRow   class="row"   -- so the manual shares showed on pro-rata
 *
 *  The visible result was the whole tab as one long page: the single-project
 *  controls, then the hybrid pane's cards beneath them, with the mode switch
 *  changing nothing but a button's colour. RK reported exactly that, and asked
 *  whether the sections belonged to one mode -- they do not, and this is why it
 *  looked as though they did.
 *
 *  This is the third time the same trap has been sprung in this project: see
 *  `.rw-help-float[hidden]` and `.rw-banner[hidden]` in style.css, both patched
 *  the same way. Patching per-selector is what let it happen a third time, so
 *  this one rule covers EVERY hidden element inside the tab, and `!important` is
 *  used deliberately: the whole point is that no later `display` rule may
 *  out-rank it, and style.css already uses the same tool three times. */
#tab-irr [hidden]{display:none !important}
