
:root{
  --bg:#0a0c10; --surface:#0e1218; --panel:#131a23; --edge:#1b2635;
  --ink:#e7ecf3; --muted:#9aa4b2; --accent:#86a8ff; --ok:#22c55e; --warn:#f59e0b;
}
*{box-sizing:border-box} html,body{height:100%}
body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.6 system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,Arial}
.container{max-width:980px;margin:28px auto;padding:0 16px}
h1{margin:0 0 12px;font-weight:700;font-size:22px}
.grid{display:block}
.card{background:var(--surface);border:1px solid var(--edge);border-radius:18px;padding:16px;margin:16px 0;box-shadow:0 0 0 1px rgba(0,0,0,0.2) inset}
.card h2{margin:0 0 6px;font-size:18px}
.card p.desc{margin:2px 0 12px;color:var(--muted);font-size:13px}

/* Help blocks */
details.help{margin-top:10px;border:1px dashed var(--edge);border-radius:12px;padding:10px}
details.help[open]{background:#0f141d}
details.help summary{cursor:pointer;list-style:none;color:var(--ink);font-weight:600}
details.help summary::marker{display:none}
details.help .help-body{color:var(--muted);font-size:13px;margin-top:8px}
details.help ul{margin:6px 0 0 18px;padding:0}
details.help li{margin:4px 0}

/* Inputs */
.inputs3{display:grid;grid-template-columns:repeat(3,minmax(220px,1fr));gap:12px}
.row{display:grid;gap:8px;grid-template-columns:160px 1fr;align-items:center}
.row>label{color:var(--muted);font-size:13px}
.row>input,.row>select{height:44px;padding:10px 12px;border-radius:12px;background:var(--panel);color:var(--ink);border:1.5px solid #2a3a50;outline:none;width:100%;font-size:16px}
.row>input::placeholder{color:#aab3c2}
.row>input:focus,.row>select:focus{border-color:#4a6a9b;box-shadow:0 0 0 3px rgba(134,168,255,.15)}
input[type=number]{appearance:textfield;-moz-appearance:textfield}
input[type=number]::-webkit-outer-spin-button,input[type=number]::-webkit-inner-spin-button{appearance:none;margin:0}

.stats{display:grid;grid-template-columns:repeat(3,1fr);gap:12px;margin-top:10px}
.stat{background:var(--panel);border:1px solid var(--edge);border-radius:12px;padding:12px}
.stat span{display:block;color:var(--muted);font-size:12px;margin-bottom:4px}

button{background:#0f172a;border:1px solid var(--edge);color:var(--ink);border-radius:12px;padding:10px 14px;cursor:pointer;font-size:15px}
button:hover{border-color:#2b3a50}

.table{width:100%;border-collapse:collapse;font-size:13px}
.table th,.table td{padding:10px;border-bottom:1px solid var(--edge);text-align:left}
.table th{color:var(--muted);font-weight:600}

/* Thresholds */
.thr{margin-top:12px;border:1px dashed var(--edge);border-radius:12px;padding:12px}
.thr h3{margin:0 0 8px;font-size:14px;color:var(--muted)}
.thrgrid{display:grid;grid-template-columns:repeat(4,minmax(160px,1fr));gap:12px}
.controls{display:flex;gap:12px;align-items:center;margin-top:10px}
.controls label{display:flex;gap:8px;align-items:center;color:var(--muted);font-size:13px}

/* R7 canvas */
canvas.plot{width:100%;height:240px;background:#0f141d;border:1px solid var(--edge);border-radius:14px}

/* Drawdown slider (ruler) + wheel */
.dd-flex{display:grid;grid-template-columns:1fr 200px;gap:16px;align-items:center}
.ruler{margin:8px 0 12px;position:relative}
.ruler input[type=range]{width:100%;height:6px;border-radius:999px;background:#1e2a3a;outline:none;-webkit-appearance:none}
.ruler input[type=range]::-webkit-slider-thumb{-webkit-appearance:none;height:18px;width:18px;border-radius:50%;background:var(--accent);border:1px solid #335;cursor:pointer}
.ruler .ticks{position:absolute;left:0;right:0;top:-8px;height:10px;display:flex;justify-content:space-between}
.ruler .ticks i{display:block;width:1px;height:10px;background:#2b3a50;opacity:.8}
.wheel{display:flex;gap:12px;align-items:center}
#dd_wheel{width:180px;height:180px;border-radius:50%;border:1px solid var(--edge);background:#0f141d}
.wheel .readout{min-width:110px}

/* Simple helpers */
.muted{color:var(--muted)}
.divider{height:1px;background:var(--edge);margin:10px 0}

/* 2-column subcards used in reference sections */
.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.subcard{background:var(--panel);border:1px solid var(--edge);border-radius:14px;padding:12px}
@media (max-width:980px){.grid2{grid-template-columns:1fr}}

ul.clean{list-style:none;padding-left:0;margin:10px 0}
ul.clean li{margin:8px 0}
.tagline{font-weight:700;margin:8px 0}
.callout{margin-top:10px;border:1px solid rgba(245,158,11,.25);background:rgba(245,158,11,.08);border-radius:12px;padding:10px;color:var(--ink)}

/* Sector spreads */
.spreads-controls{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:10px 0 12px}
.chk{display:flex;gap:8px;align-items:center;color:var(--muted);font-size:13px}

/* DCA table */
.table-wrap{overflow-x:auto}
.dca-toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin:10px 0 12px}
.dca-table input,.dca-table select{height:40px;padding:8px 10px;border-radius:12px;background:var(--panel);color:var(--ink);border:1.5px solid #2a3a50;outline:none;width:100%;font-size:14px}
.dca-table input:focus,.dca-table select:focus{border-color:#4a6a9b;box-shadow:0 0 0 3px rgba(134,168,255,.15)}


/* Sector regimes compact list */
ul.clean.compact li{margin:6px 0;}


/* Sector strength bars */
.bars{display:flex; flex-direction:column; gap:8px; margin-top:8px;}
.barRow{display:grid; grid-template-columns: 340px 1fr 64px; gap:10px; align-items:center;}
.barLabel{font-weight:600; letter-spacing:0.2px; white-space:nowrap; overflow:hidden; text-overflow:clip;flex-wrap:wrap;}
.barTrack{position:relative; height: 9px; border-radius:999px; background: rgba(255,255,255,0.06); overflow:hidden; border:1px solid rgba(255,255,255,0.08);}
.barFill{position:absolute; top:0; bottom:0; border-radius:999px;}
.barMid{position:absolute; top:-4px; bottom:-4px; left:50%; width:1px; background: rgba(255,255,255,0.10);}
.barVal{font-variant-numeric: tabular-nums; text-align:right; opacity:0.9;}
.select{padding:8px 10px; border-radius:10px; border:1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.04); color: inherit;}


/* Pills */
.pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:3px 9px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  font-size:11px;
  line-height:1;
  white-space:nowrap;
 color: rgba(255,255,255,0.92);}
.pill.rk-on{background: rgba(245,158,11,0.22); border-color: rgba(245,158,11,0.45); color: rgba(255,246,224,0.95);}
.pill.rk-mix{background: rgba(234,179,8,0.20); border-color: rgba(234,179,8,0.45); color: rgba(255,252,220,0.95);}
.pill.rk-off{background: rgba(59,130,246,0.20); border-color: rgba(59,130,246,0.45); color: rgba(230,242,255,0.95);}

/* How it works formatting */
.howtoBody{margin-top:10px; display:flex; flex-direction:column; gap:12px;}
.howtoBody p{margin:0; color: rgba(255,255,255,0.85); line-height:1.55;}
.howtoBody .hTitle{font-weight:700; letter-spacing:0.2px; color: rgba(255,255,255,0.92);}
.howtoBody ul{margin:0; padding-left:18px;}
.howtoBody li{margin:6px 0; color: rgba(255,255,255,0.85); line-height:1.5;}
.howtoBody code{background: rgba(255,255,255,0.06); border:1px solid rgba(255,255,255,0.10); padding:1px 6px; border-radius:8px;}

.barLabel .sym{white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width:260px; display:inline-block}

.barLabel .pill{flex:0 0 auto}

#strengthMeta{white-space:nowrap}


/* Risk regime pills (force colours) */
.pill.rk-on{background: rgba(245,158,11,0.22) !important; border-color: rgba(245,158,11,0.45) !important; color: rgba(255,246,224,0.95) !important;}
.pill.rk-mix{background: rgba(234,179,8,0.20) !important; border-color: rgba(234,179,8,0.45) !important; color: rgba(255,252,220,0.95) !important;}
.pill.rk-off{background: rgba(59,130,246,0.20) !important; border-color: rgba(59,130,246,0.45) !important; color: rgba(230,242,255,0.95) !important;}

.bench{font-weight:700; letter-spacing:0.2px;}

#strengthMeta{max-width:100%;}
#strengthMetaText{display:inline-block;max-width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}

/* Hard-disable drawdown wheel */
#dd_wheel, .wheel{display:none !important;}


/* Mobile polish */
@media (max-width: 520px){
  .card{padding:16px !important;}
  /* Drawdown */
  #dd .ddTop{grid-template-columns:1fr !important; gap:12px !important;}
  #dd .ddControls{grid-template-columns:1fr !important;}
  #dd input[type="range"]{width:100% !important;}
  #dd .ddStats{display:grid !important; grid-template-columns:1fr 1fr !important; gap:10px !important;}
  #dd .ddStat{padding:14px !important;}
  #dd .ddPct{margin-left:10px; font-weight:700; color:rgba(255,255,255,0.9);}
  /* Strength */
  .strengthRow{grid-template-columns:1fr 1fr 64px !important; column-gap:10px !important;}
  .barTrack{height:9px !important;}
  .barFill{height:9px !important;}
  .barVal{justify-self:end;}
  /* Spreads checklist */
  .spreadChecks{display:grid !important; grid-template-columns:1fr 1fr !important; gap:8px 12px !important;}
  .spreadChecks label{margin:0 !important;}
  .spreadControls{flex-wrap:wrap !important; gap:10px !important;}
  .miniSelectRow{display:flex; gap:10px; flex-wrap:wrap; margin-top:8px;}
  .miniSelectRow button{padding:8px 10px; border-radius:999px; font-size:13px;}
}

#dd_pct{width:86px; text-align:center; font-weight:700; color: rgba(255,255,255,.92); background: rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.12); border-radius:14px; padding:10px 12px;}
#dd .row{display:flex; align-items:center; gap:12px;}
#dd .row label{flex:1;}


/* =========================
   Mobile friendliness pass
   ========================= */

@media (max-width: 520px){
  body{font-size:16px;}
  .container{padding: 16px !important; max-width: 100% !important;}
  h1{font-size: 28px !important; line-height: 1.15 !important; margin-bottom: 14px !important;}
  h2{font-size: 22px !important; line-height: 1.2 !important;}
  .desc{font-size: 14px !important; line-height: 1.45 !important;}

  /* Cards */
  .card{padding: 16px !important; border-radius: 18px !important;}
  .grid{grid-template-columns: 1fr !important; gap: 14px !important;}

  /* Buttons / inputs hit targets */
  button, .btn{min-height: 40px;}
  input, select, textarea{min-height: 40px; font-size: 16px !important;} /* prevents iOS zoom */

  /* Drawdown */
  #dd .dd-flex{display:block !important;}
  #dd .stats{grid-template-columns: 1fr 1fr !important; gap: 10px !important;}
  #dd .ruler{margin-top: 10px !important;}
  #dd .ticks{display:none !important;} /* reduce clutter on small screens */
  #dd .table{font-size: 14px;}
  #dd .row{display:flex; align-items:center; gap: 10px;}
  #dd .row label{min-width: 110px;}

  /* Sector Strength */
  #sector-strength .row{gap: 10px !important;}
  #sector-strength select{width: 100% !important; max-width: 100% !important;}
  .bars{gap: 8px !important;}
  .barRow{grid-template-columns: 1fr 1fr 64px !important; gap: 10px !important;}
  .barLabel{max-width: 100% !important;}
  .barLabel .sym{max-width: 100% !important;}
  .barTrack{height: 9px !important;}
  .barVal{font-size: 14px !important;}

  /* Spreads */
  .spreads-controls{gap: 10px !important; flex-wrap: wrap !important;}
  .spreads-controls #spStatus{flex-basis: 100% !important; margin-left: 0 !important;}
  /* two-column checks (labels are inside spreads-controls in your build) */
  .spreads-controls .chk{width: calc(50% - 8px) !important; margin: 0 !important;}
  #spRefresh, #spClearCache{width: 100% !important;}

  /* DCA table */
  .table-wrap{overflow-x: auto !important; -webkit-overflow-scrolling: touch;}
  .dca-table{min-width: 760px;} /* keep columns readable */
  .dca-toolbar{gap: 10px !important;}
  .kpi{padding: 10px 0 !important;}
}
