/* RC1-clean styling */
:root{
  --bg:#0b1220;
  --card:#ffffff;
  --muted:#5b6473;
  --text:#0f172a;
  --line:#e7eaf0;
  --shadow: 0 10px 30px rgba(15,23,42,0.10);
  --radius:14px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial;
}
*{box-sizing:border-box}
body{
  margin:0;
  font-family:var(--sans);
  color:var(--text);
  background: linear-gradient(180deg, #0b1220, #0b1220 120px, #f6f7fb 120px);
}
.topbar{
  height:120px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:22px 26px;
  color:#fff;
}
.brand{display:flex; gap:14px; align-items:flex-start;}
.brand-mark{
  width:42px; height:42px; border-radius:12px;
  background: rgba(255,255,255,0.12);
  display:flex; align-items:center; justify-content:center;
  font-weight:800;
}
.brand-name{font-size:28px; font-weight:900; line-height:1.1;}
.brand-sub{font-size:13px; color:rgba(255,255,255,0.72); max-width:820px; margin-top:6px; line-height:1.35;}
.build-badge{
  font-family: var(--mono);
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.90);
}
.wrap{padding:22px 18px 26px;}
.grid{display:grid; grid-template-columns: 1.05fr 0.95fr; gap:16px; align-items:start;}
@media (max-width: 850px){
  .grid{grid-template-columns:1fr;}
  .topbar{height:auto}
}
.card{
  background:var(--card);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  padding:16px 16px 18px;
  border: 1px solid var(--line);
}
.card-head{display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap;}
.card-title{margin:0 0 12px; font-size:16px; letter-spacing:0.02em; text-transform:uppercase; color:#0f172a;}
.row{display:grid; grid-template-columns: 1fr 1fr; gap:12px; margin-top:12px;}
@media (max-width: 700px){ .row{grid-template-columns:1fr;} }
.field label{display:block; font-size:12px; font-weight:800; margin-bottom:6px;}
.field input, .field select{
  width:100%;
  padding:11px 12px;
  border-radius:12px;
  border:1px solid #d8dde8;
  background:#fff;
  font-size:14px;
  outline:none;
}
.field input:focus, .field select:focus{
  border-color: rgba(11,111,255,0.55);
  box-shadow: 0 0 0 4px rgba(11,111,255,0.12);
}
.help{font-size:12px; color:var(--muted); margin-top:6px; line-height:1.35;}
.inline{display:flex; gap:10px; align-items:center;}
.w-50{flex:1 1 50%;}
.sep{border:0; border-top:1px solid var(--line); margin:16px 0;}
.panel{
  border:1px solid var(--line);
  border-radius:14px;
  padding:12px;
  background:#fbfcff;
}
.panel-accent{background:#f3f8ff; border-color: rgba(11,111,255,0.25);}
.panel-title{font-weight:900; font-size:12px; letter-spacing:0.04em; text-transform:uppercase; margin-bottom:10px;}
.subhead{font-size:13px; text-transform:uppercase; letter-spacing:0.04em; margin:18px 0 10px; color:#0f172a;}
.advanced{margin-top:14px; padding-top:10px; border-top:1px dashed rgba(15,23,42,0.16);}
.btn{
  border:1px solid rgba(11,111,255,0.35);
  background: rgba(11,111,255,0.08);
  color: #0b3a9b;
  padding:10px 12px;
  border-radius:12px;
  font-weight:900;
  cursor:pointer;
}
.btn:hover{background: rgba(11,111,255,0.12);}
.tiles{display:grid; grid-template-columns:1fr 1fr 1fr; gap:12px; margin-top:12px;}
@media (max-width: 900px){ .tiles{grid-template-columns:1fr;} }
.tile{border:1px solid var(--line); border-radius:14px; padding:12px; background:#fff;}
.tile-delta{background:#f7fbff; border-color: rgba(14,165,233,0.25);}
.tile-kicker{font-size:12px; font-weight:900; letter-spacing:0.04em; text-transform:uppercase; color:#334155;}
.tile-value{font-size:34px; font-weight:950; margin-top:6px; line-height:1.05;}
.tile-sub{font-size:12px; color:var(--muted); margin-top:8px;}
.status{
  margin-top:12px; padding:10px 12px;
  border-radius:12px; border:1px solid var(--line);
  background:#fbfcff; font-size:13px; color:#334155;
}
.status.status-error{
  border-color: rgba(180,35,24,0.35);
  background: rgba(180,35,24,0.06);
  color: #7a1b13;
}
.invalid{
  border-color: rgba(180,35,24,0.55) !important;
  box-shadow: 0 0 0 4px rgba(180,35,24,0.10) !important;
}
.footer{margin-top:14px; color:#475569; font-size:12px; text-align:center;}
/* pill */
.pill{display:flex;border:1px solid rgba(15,23,42,0.16);border-radius:999px;padding:2px;background:#fff;}
.pill-btn{border:0;background:transparent;color:#0f172a;padding:8px 12px;border-radius:999px;font-weight:900;cursor:pointer;font-size:13px;}
.pill-btn.is-active{background:#0b1220;color:#fff;}
/* sticky results on desktop */
@media (min-width: 851px){
  .grid > .card:nth-child(2){ position: sticky; top:16px; align-self:start; }
}
/* assumptions accordion */
.assumptions{margin-top:12px;}
.assumptions-summary{
  list-style:none; cursor:pointer; user-select:none;
  font-weight:900; letter-spacing:0.02em; text-transform:uppercase;
  font-size:13px; color:#0f172a;
  padding:10px 12px; border:1px solid rgba(15,23,42,0.12);
  border-radius:14px; background:#fff;
  position:relative; padding-right:34px;
}
.assumptions-summary::-webkit-details-marker{display:none;}
.assumptions-summary::after{
  content:"▸"; position:absolute; right:14px; top:50%; transform:translateY(-50%);
  font-size:16px; color: rgba(15,23,42,0.65);
}
.assumptions[open] .assumptions-summary::after{content:"▾";}
.assumptions .breakdown{
  border:1px solid rgba(15,23,42,0.12); border-top:0;
  border-bottom-left-radius:14px; border-bottom-right-radius:14px;
  padding:12px; background:#fff;
}
.table-wrap{overflow:auto; border:1px solid var(--line); border-radius:14px; background:#fff;}
.table{width:100%; border-collapse:collapse; font-size:13px;}
.table td{padding:10px 12px; border-top:1px solid var(--line);}
.table tr:first-child td{border-top:0;}
.table td.key{color:#334155; font-weight:900; width:55%;}
.table td.val{font-family:var(--mono); color:#0f172a; text-align:right; white-space:nowrap;}
/* toggle switch */
.switch{position:relative; display:inline-block; width:44px; height:26px; flex:0 0 auto;}
.switch input{opacity:0; width:0; height:0;}
.slider{position:absolute; cursor:pointer; top:0; left:0; right:0; bottom:0; background: rgba(15,23,42,0.16); transition:.2s; border-radius:999px;}
.slider:before{position:absolute; content:""; height:20px; width:20px; left:3px; bottom:3px; background:white; transition:.2s; border-radius:999px; box-shadow:0 6px 16px rgba(15,23,42,0.18);}
.switch input:checked + .slider{ background: rgba(11,111,255,0.55); }
.switch input:checked + .slider:before{ transform: translateX(18px); }
/* loss toggle UI */
body.loss-breakdown-off #lossAggField{display:block;}
body:not(.loss-breakdown-off) #lossAggField{display:none;}
body.loss-breakdown-off #lossComponentsRow,
body.loss-breakdown-off #lossComponentsRow2{display:none;}
