/* Server Economy Planner (economy-planner.html). Loaded after tools.css; uses the site tokens.
   Chart colours: money in / money out are categorical slots 1 and 2, the three player kinds an ordinal blue ramp
   (checked with the dataviz palette validator against the card colours #fffdfb and #1d1718). */

.ep-tool {
  --ep-surface: var(--white);
  --ep-in: #2a78d6;
  --ep-out: #eb6834;
  --ep-p0: #86b6ef;
  --ep-p1: #2a78d6;
  --ep-p2: #104281;
  --ep-grid: rgba(23, 18, 18, 0.1);
  --ep-base: rgba(23, 18, 18, 0.28);
}
@media (prefers-color-scheme: dark) {
  .ep-tool {
    --ep-surface: #1d1718;
    --ep-in: #3987e5;
    --ep-out: #d95926;
    --ep-p0: #184f95;
    --ep-p1: #3987e5;
    --ep-p2: #9ec5f4;
    --ep-grid: rgba(245, 240, 236, 0.1);
    --ep-base: rgba(245, 240, 236, 0.28);
  }
}

.ep-grow { flex: 3 1 200px !important; }
.ep-curf { flex: 0 1 110px !important; }
.ep-actions { margin-top: 14px; align-items: center; }
.tool .ep-actions select { width: auto; padding: 6px 10px; font-size: 0.84rem; }
.ep-first { margin: -6px 0 12px; }
.ep-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; font-weight: 600; cursor: pointer; padding: 6px 0; }
.ep-check input { width: 18px; height: 18px; accent-color: var(--red-500); }
.ep-tool .tf > .seg { align-self: flex-start; max-width: 100%; }
.ep-tool input.ep-num { font-variant-numeric: tabular-nums; }
.tool.ep-tool .ep-rows input, .tool.ep-tool .ep-rows select, .tool.ep-tool .ep-profiles input { padding: 7px 9px; font-size: 0.88rem; }
.ep-rows .tf > span, .ep-profiles .tf > span { font-size: 0.76rem; }

/* players */
.ep-profiles { display: flex; flex-direction: column; gap: 8px; }
.ep-prof { display: grid; grid-template-columns: 12px minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.ep-phead { font-size: 0.76rem; font-weight: 700; margin-bottom: -4px; }
.ep-dot { width: 12px; height: 12px; border-radius: 3px; }
.ep-dot.p0, .ep-key i.p0, #alegend i.p0 { background: var(--ep-p0); }
.ep-dot.p1, .ep-key i.p1, #alegend i.p1 { background: var(--ep-p1); }
.ep-dot.p2, .ep-key i.p2, #alegend i.p2 { background: var(--ep-p2); }

/* income, sinks, boosts */
.ep-rows { display: flex; flex-direction: column; gap: 10px; margin-bottom: 4px; }
.ep-row { padding: 12px; box-shadow: inset 0 0 0 1px var(--rule-paper); min-width: 0; }
.ep-row-top { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: start; }
.ep-row-top > .ep-del { align-self: end; }
.tool.ep-tool .ep-rows select { height: 2.45rem; }
.tool.ep-tool .ep-rows input { height: 2.45rem; }
.ep-row-top.two { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr) auto; }
.ep-row-top .tf { margin-bottom: 0; }
.ep-del { flex: none; padding: 9px 12px !important; }
.ep-rates { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.ep-rates.n4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ep-rates.n2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.ep-rates .tf { margin-bottom: 0; }
.ep-rates .tf > span { min-height: 2.6em; line-height: 1.25; align-items: flex-end; }
.ep-boost { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.ep-boost .tf { margin-bottom: 0; flex: 1 1 110px; }
.ep-boostopts { margin-bottom: 12px; align-items: center; }
.ep-bout { margin-top: 12px; }
.ep-bout .thint { margin-top: 8px; }

/* results */
.ep-tiles { margin-top: 0; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.ep-tiles .tile strong { font-size: 1.4rem; overflow-wrap: anywhere; }
.tile.bad { box-shadow: inset 3px 0 0 var(--red-500), inset 0 0 0 1px var(--rule-paper); }
#status { margin-top: 12px; }
.ep-h3 { margin: 18px 0 6px; font-size: 0.95rem; font-weight: 800; }
.ep-legend { display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0 0 8px; font-size: 0.84rem; color: var(--on-paper-soft); }
.ep-legend .key i { border-radius: 2px; }
.ep-legend .key i.in { background: var(--ep-in); }
.ep-legend .key i.out { background: var(--ep-out); }
.ep-warnf { max-width: 260px; margin-top: 14px; }
.ep-scroll { overflow-x: auto; }
.ep-scroll .ttable { min-width: 380px; }
#atable td small { display: block; font-size: 0.72rem; }
#atable th, #ptable th { letter-spacing: 0.04em; }
#atable td.n { white-space: nowrap; }
#atable td:first-child, #ptable td:first-child { overflow-wrap: normal; min-width: 7.5rem; }
.ep-key { display: inline-flex; align-items: center; gap: 8px; }
.ep-key i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.ep-chartbar { justify-content: space-between; align-items: center; margin-top: 14px; }
.ep-chartbar .ep-legend { margin: 0; }

/* charts: horizontal bars, 4px rounded data end, square at the baseline, hairline grid */
.ep-chart { margin-top: 4px; }
.ep-plot { position: relative; display: flex; flex-direction: column; gap: 6px; --lab: 8.5rem; }
.ep-gridlines { position: absolute; top: 0; bottom: 22px; left: calc(var(--lab) + 10px); right: 0; pointer-events: none; }
.ep-gridlines i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--ep-grid); }
.ep-gridlines i:first-child { background: var(--ep-base); }
.ep-group { margin: 6px 0 0; font-family: var(--sans); font-variant-numeric: tabular-nums; font-weight: 650; font-stretch: 112%; font-size: 0.78rem; letter-spacing: 0; color: var(--on-paper-soft); }
.ep-brow, .ep-agroup { position: relative; display: grid; grid-template-columns: var(--lab) minmax(0, 1fr); gap: 10px; align-items: center; min-height: 22px; }
.ep-brow:focus-visible, .ep-agroup:focus-visible { outline: 2px solid var(--red-400); outline-offset: 2px; }
.ep-blab { font-size: 0.8rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ep-track { position: relative; height: 18px; }
.ep-bar { position: absolute; left: 0; top: 0; bottom: 0; min-width: 0; border-radius: 0 4px 4px 0; }
.ep-bar.in { background: var(--ep-in); }
.ep-bar.out { background: var(--ep-out); }
.ep-val { position: absolute; top: 50%; transform: translateY(-50%); font-family: var(--mono); font-size: 0.72rem; white-space: nowrap; color: var(--on-paper-soft); font-variant-numeric: tabular-nums; }
.ep-val.inside { left: auto; right: 6px; color: #fff; }
.ep-abars { display: flex; flex-direction: column; gap: 2px; padding: 2px 0; }
.ep-abar { display: block; height: 7px; min-width: 0; border-radius: 0 4px 4px 0; }
.ep-abar.p0 { background: var(--ep-p0); }
.ep-abar.p1 { background: var(--ep-p1); }
.ep-abar.p2 { background: var(--ep-p2); }
.ep-axrow { min-height: 18px; }
.ep-axis { position: relative; height: 16px; }
.ep-axis span { position: absolute; top: 0; transform: translateX(-50%); font-family: var(--mono); font-size: 0.68rem; color: var(--on-paper-soft); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ep-axis span:first-child { transform: none; }
.ep-axis span:last-child { transform: translateX(-100%); }

.ep-vtip {
  position: fixed; z-index: 70; max-width: min(320px, calc(100vw - 16px));
  padding: 7px 10px; background: var(--ink); color: #fff;
  font-size: 0.8rem; line-height: 1.4; white-space: pre-line; pointer-events: none;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}
.ep-vtip[hidden] { display: none; }
@media (prefers-color-scheme: dark) { .ep-vtip { background: #f5f0ec; color: #171212; } }

/* price helper */
.ep-helper { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 10px; }
.ep-helper .tf { margin-bottom: 0; }
.ep-hout { margin-top: 12px; }
.ep-sug { margin: 8px 0 0; padding-left: 1.3em; font-size: 0.9rem; line-height: 1.6; }

.ep-export { margin-top: clamp(16px, 2.5vw, 32px); }
.ep-export .out { margin-top: 10px; }

@media (max-width: 620px) {
  .ep-prof { grid-template-columns: 12px minmax(0, 1.2fr) minmax(0, 0.9fr) minmax(0, 0.9fr); gap: 6px; }
  .ep-plot { --lab: 6rem; }
  .ep-axis span:nth-child(even):not(:last-child) { display: none; }
  .ep-row-top, .ep-row-top.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
  .ep-row-top > .tf:first-child { grid-column: 1 / 3; }
  .ep-row-top > .ep-del { grid-column: 3; grid-row: 1; }
  .ep-rates, .ep-rates.n4 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
