﻿/* Costs Simulator styles — bespoke revenue/cost viz.
   Chrome neutrals (page / surface / text / border / grid) are aligned to the
   dashboard palette (dashboard.css html[data-theme]); the series/status colours
   are kept from the original pool-revenue simulator. Theme follows the
   dashboard's data-theme attribute (set by the head bootstrap), NOT
   prefers-color-scheme, so this sheet obeys the dashboard light/dark toggle. */
  :root {
    /* neutrals — dashboard light */
    --surface-1: #ddd8ce;
    --page: #ece9e1;
    --text-primary: #202020;
    --text-secondary: #454545;
    --text-muted: #545454;
    --grid: #bdb8ae;
    --baseline: #9f9a91;
    --border: rgba(11,11,11,0.14);
    --tooltip-bg: #f3f1eb;
    /* series / status — original simulator (light) */
    --series-rev: #2a78d6;      /* owner revenue curve */
    --series-avg: #8a8a8a;      /* gross P&L reference line — muted, secondary */
    --series-margin: #1baf7a;   /* margin curve */
    --series-mr: #eda100;       /* marginal revenue */
    --cost: #ec835a;            /* cost line */
    --good: #0ca30c;
    --bad: #d03b3b;
    --wash-good: rgba(12,163,12,0.10);
    --wash-bad: rgba(208,59,59,0.10);
  }
  html[data-theme="dark"] {
    /* neutrals — dashboard dark */
    --surface-1: #272727;
    --page: #1c1c1c;
    --text-primary: #e6e6e6;
    --text-secondary: #c2c2c2;
    --text-muted: #a6a6a6;
    --grid: #363636;
    --baseline: #4a4a4a;
    --border: rgba(255,255,255,0.12);
    --tooltip-bg: #202020;
    /* series / status — original simulator (dark) */
    --series-rev: #3987e5;
    --series-avg: #8f8f8f;
    --series-margin: #199e70;
    --series-mr: #c98500;
    --cost: #ec835a;
    --good: #0ca30c;
    --bad: #d03b3b;
    --wash-good: rgba(12,163,12,0.14);
    --wash-bad: rgba(208,59,59,0.14);
  }

  /* page shell — back link to the dashboard */
  .sim-nav { margin: 0 0 10px; font-size: 12.5px; }
  .sim-nav a { color: var(--series-rev); text-decoration: none; }
  .sim-nav a:hover { text-decoration: underline; }
  * { box-sizing: border-box; margin: 0; padding: 0; }
  body {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--page);
    color: var(--text-primary);
    padding: 24px clamp(14px, 2.5vw, 36px) 40px;
  }
  h1 { font-size: 19px; font-weight: 650; letter-spacing: -0.01em; }
  .intro { color: var(--text-secondary); font-size: 13.5px; line-height: 1.5; margin-top: 8px; max-width: none; }
  .subtitle { color: var(--text-muted); font-size: 11.5px; margin-top: 10px; max-width: 980px; }
  .subtitle code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px; background: var(--surface-1);
    border: 1px solid var(--border); border-radius: 4px; padding: 1px 5px;
  }

  .layout { display: grid; grid-template-columns: 330px 1fr; gap: 16px; margin-top: 16px; align-items: start; }
  @media (max-width: 1080px) { .layout { grid-template-columns: 1fr; } }

  /* ---- sidebar ---- */
  .sidebar {
    background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 16px 16px;
  }
  .group { padding: 10px 0 12px; }
  .group + .group { border-top: 1px solid var(--border); }
  .group h3 {
    font-size: 10.5px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--text-muted); margin-bottom: 10px;
  }
  .ctl { display: flex; flex-direction: column; gap: 5px; margin-bottom: 11px; }
  .ctl:last-child { margin-bottom: 0; }
  .ctl > label, .ctl > .lbl { font-size: 12px; color: var(--text-secondary); display: flex; justify-content: space-between; gap: 8px; }
  .ctl output { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
  select, input[type=number] {
    font: inherit; font-size: 13px; color: var(--text-primary); width: 100%;
    background: var(--page); border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px;
  }
  .two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  input[type=range] {
    -webkit-appearance: none; appearance: none; width: 100%;
    height: 4px; border-radius: 2px; background: var(--grid); outline-offset: 2px;
  }
  input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 15px; height: 15px; border-radius: 50%;
    background: var(--series-rev); border: 2px solid var(--surface-1);
    box-shadow: 0 0 0 1px var(--border); cursor: pointer;
  }
  input[type=range]::-moz-range-thumb {
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--series-rev); border: 2px solid var(--surface-1);
    box-shadow: 0 0 0 1px var(--border); cursor: pointer;
  }
  .seg { display: flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: 100%; }
  .seg button {
    font: inherit; font-size: 12px; padding: 5px 4px; cursor: pointer; flex: 1;
    background: transparent; color: var(--text-secondary); border: none; white-space: nowrap;
  }
  .seg button + button { border-left: 1px solid var(--border); }
  .seg button[aria-pressed="true"] { background: var(--series-rev); color: #fff; font-weight: 600; }
  .seg button:disabled { opacity: 0.35; cursor: not-allowed; }
  input[type="range"]:disabled { opacity: 0.35; cursor: not-allowed; }

  details.adv { margin-top: 4px; }
  details.adv summary { font-size: 11.5px; color: var(--text-muted); cursor: pointer; user-select: none; margin-bottom: 8px; }

  .vol-group .ctl > label { font-size: 13px; color: var(--text-primary); font-weight: 600; }
  .vol-group output { font-size: 15px; }

  .ctl .warn { display: none; font-size: 11px; line-height: 1.35; color: var(--cost); margin-top: 4px; }
  .ctl .warn.on { display: block; }

  .help {
    display: inline-flex; align-items: center; justify-content: center;
    width: 14px; height: 14px; border-radius: 50%; flex: none;
    border: 1px solid var(--baseline); color: var(--text-muted);
    font-size: 9.5px; font-weight: 650; cursor: help; user-select: none;
    vertical-align: 1px; margin-left: 2px;
  }
  .helptip {
    position: fixed; z-index: 20; max-width: 250px; display: none; pointer-events: none;
    background: var(--tooltip-bg); border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 11px; font-size: 11.5px; line-height: 1.45; color: var(--text-secondary); white-space: pre-line;
    box-shadow: 0 4px 16px rgba(0,0,0,0.14);
  }

  /* ---- right column ---- */
  /* gas-cost formula readout hidden from the retail view; JS still populates
     the (now invisible) node, so the element stays in the DOM. */
  .gas-readout {
    display: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px; color: var(--text-muted); line-height: 1.5; word-break: break-word;
    margin-bottom: 12px; padding: 8px 12px;
    background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  }
  .gas-readout b { color: var(--text-secondary); font-weight: 600; }

  .tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
  .tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: 10px; padding: 11px 13px; }
  .tile .lbl { font-size: 11px; color: var(--text-secondary); }
  .tile .val { font-size: 21px; font-weight: 650; margin-top: 3px; letter-spacing: -0.01em; }
  .tile .sub { font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }

  .card {
    background: var(--surface-1); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 16px 8px; position: relative;
  }
  .card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
  .card h2 { font-size: 13px; font-weight: 600; }
  .card .desc { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
  .scale-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
  .scale-seg button {
    font: inherit; font-size: 12px; padding: 4px 12px; cursor: pointer;
    background: transparent; color: var(--text-secondary); border: none;
  }
  .scale-seg button + button { border-left: 1px solid var(--border); }
  .scale-seg button[aria-pressed="true"] { background: var(--series-rev); color: #fff; font-weight: 600; }
  .legend { display: flex; gap: 14px; margin: 7px 0 3px; flex-wrap: wrap; }
  .legend .lg { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-secondary); }
  .legend .lg .key-line { width: 16px; height: 0; border-top: 2.5px solid var(--series-rev); border-radius: 2px; }
  .legend .lg .key-dash { width: 16px; height: 0; border-top: 2.5px dashed var(--cost); }
  .legend .lg .key-rect { width: 11px; height: 11px; border-radius: 3px; border: 1px solid var(--border); }
  svg { display: block; width: 100%; height: auto; }
  svg text { font-family: system-ui, -apple-system, "Segoe UI", sans-serif; }
  .tick { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
  .dlabel { fill: var(--text-secondary); font-size: 11px; font-weight: 600; }

  details.margins { margin-top: 14px; }
  details.margins > summary {
    font-size: 12px; color: var(--text-secondary); cursor: pointer; user-select: none;
    padding: 8px 12px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px;
  }
  .margin-grid { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 12px; }
  @media (min-width: 1400px) { .margin-grid { grid-template-columns: 1fr 1fr; } }

  .tooltip {
    position: fixed; pointer-events: none; z-index: 10;
    background: var(--tooltip-bg); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.14);
    font-size: 12px; display: none; min-width: 170px;
  }
  .tooltip .tt-x { color: var(--text-muted); font-size: 11px; margin-bottom: 4px; }
  .tooltip .tt-row { display: flex; align-items: center; gap: 7px; margin-top: 3px; }
  .tooltip .tt-key { width: 12px; height: 0; border-top: 2.5px solid; border-radius: 2px; flex: none; }
  .tooltip .tt-val { font-weight: 650; font-variant-numeric: tabular-nums; }
  .tooltip .tt-name { color: var(--text-secondary); }

  .foot { margin-top: 14px; font-size: 11.5px; color: var(--text-muted); max-width: 980px; line-height: 1.55; }
  .foot p + p { margin-top: 8px; }
  .foot b { color: var(--text-secondary); font-weight: 600; }

