/* C4 Missions tool — full graph-editor styling (sage-editor dark aesthetic). */
:root {
  --bg: #0e1116; --panel: #161b22; --panel2: #1c232c; --line: #2a323d;
  --ink: #d7dee7; --dim: #8b97a6; --accent: #6ea8fe; --accent2: #b48cff;
  --pos: #4ec98a; --neg: #f0726a; --warn: #e8b552; --mid: #d8c45a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body.tool { background: var(--bg); color: var(--ink); overflow: hidden; font: 14px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif; }
canvas { position: fixed; inset: 0; display: block; cursor: grab; }
body.tool.panning canvas { cursor: grabbing; }

/* toolbar */
.toolbar { position: fixed; top: 12px; left: 12px; right: 12px; z-index: 10; display: flex; align-items: center; gap: 10px;
  background: rgba(22,27,34,.92); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; backdrop-filter: blur(6px); }
.brand { font-size: 15px; letter-spacing: .3px; color: var(--dim); } .brand b { color: var(--ink); }
.tb { background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 7px; padding: 5px 11px; font-size: 12.5px; cursor: pointer; }
.tb:hover { border-color: var(--accent); color: #fff; }
.tb-hint { margin-left: auto; color: var(--dim); font-size: 11px; }

/* side panel */
.side-panel { position: fixed; top: 0; right: 0; width: 384px; height: 100%; z-index: 20; background: var(--panel); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .16s ease; overflow-y: auto; box-shadow: -8px 0 24px #0006; }
.side-panel.open { transform: none; }
.sp-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 12px 15px;
  background: var(--panel2); border-bottom: 1px solid var(--line); font-weight: 600; }
.sp-head .x { background: none; border: none; color: var(--dim); font-size: 20px; line-height: 1; cursor: pointer; } .sp-head .x:hover { color: #fff; }
.sp-body { padding: 12px 15px 40px; }

/* mini fields (legacy) */
.pfield { display: flex; justify-content: space-between; padding: 6px 2px; border-bottom: 1px solid var(--line); font-size: 12.5px; }
.pfield span { color: var(--dim); }

/* section headers + form rows */
.sec-h { margin: 16px 0 7px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--accent); border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.sec-h:first-child { margin-top: 2px; }
.frow { margin-bottom: 8px; }
.frow > label { display: block; color: var(--dim); font-size: 11.5px; margin-bottom: 3px; }
.frow input[type=text], .frow input[type=number], .frow select, .frow textarea {
  width: 100%; background: var(--panel2); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 12.5px; font-family: inherit; }
.frow textarea { resize: vertical; }
.frow.inline { display: flex; align-items: center; gap: 8px; } .frow.inline > label { margin: 0; flex: 1; color: var(--ink); }
.frow.inline input[type=checkbox] { width: auto; accent-color: var(--accent); }
.frow.range .rr { display: flex; align-items: center; gap: 8px; }
.frow.range input[type=range] { flex: 1; accent-color: var(--accent); }
.frow.range .val { min-width: 56px; text-align: right; color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; }

/* loot cards */
.loot-card { border: 1px solid var(--line); border-radius: 7px; padding: 6px; margin-bottom: 6px; background: var(--panel2); }
.lc-row { display: flex; gap: 5px; margin-bottom: 5px; } .lc-row:last-child { margin-bottom: 0; }
.lc-row input, .lc-row select { flex: 1; min-width: 0; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 5px; padding: 3px 5px; font-size: 11px; }
.lc-row .rm { flex: 0 0 auto; background: none; border: none; color: var(--neg); cursor: pointer; font-size: 15px; padding: 0 4px; }
.addbtn { background: var(--panel2); border: 1px dashed var(--line); color: var(--accent); border-radius: 6px; padding: 5px 9px; font-size: 11.5px; cursor: pointer; width: 100%; margin: 4px 0 6px; }
.addbtn:hover { border-color: var(--accent); }
.prev-crew { padding: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; margin-bottom: 6px; }
.pvh { font-size: 11px; color: var(--dim); text-transform: uppercase; letter-spacing: .5px; margin: 12px 0 5px; }

.pos { color: var(--pos); } .neg { color: var(--neg); } .zero { color: var(--dim); } .warn { color: var(--warn); }
.muted { color: var(--dim); } .small { font-size: 11.5px; }

/* previewer components */
.gauge { position: relative; height: 32px; background: var(--panel2); border-radius: 7px; overflow: hidden; border: 1px solid var(--line); }
.gauge-fill { height: 100%; transition: width .12s ease; }
.gauge-fill.great { background: linear-gradient(90deg, #2f8f63, var(--pos)); }
.gauge-fill.ok { background: linear-gradient(90deg, #3a7bbf, var(--accent)); }
.gauge-fill.mid { background: linear-gradient(90deg, #9a8a36, var(--mid)); }
.gauge-fill.bad { background: linear-gradient(90deg, #a94640, var(--neg)); }
.gauge-num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-weight: 700; text-shadow: 0 1px 3px #000a; }
table { width: 100%; border-collapse: collapse; }
table.breakdown td, table.kv td { padding: 4px 4px; border-bottom: 1px solid var(--line); font-size: 12px; }
table.breakdown td:last-child, table.kv td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
tr.sum td { border-top: 2px solid var(--line); border-bottom: none; padding-top: 7px; }
.badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.badge { font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); }
.badge.ok { color: var(--pos); border-color: #2f6b4d; background: #122a1f; }
.badge.bad { color: var(--neg); border-color: #6b332f; background: #2a1513; }
.badge.warn { color: var(--warn); border-color: #6b5a2f; background: #2a2413; }
.truebar { display: flex; height: 28px; border-radius: 7px; overflow: hidden; border: 1px solid var(--line); margin-bottom: 8px; font-size: 11px; }
.truebar .seg { display: flex; align-items: center; justify-content: center; white-space: nowrap; color: #06121b; font-weight: 600; }
.seg.stake { background: linear-gradient(90deg, #7aa7e0, var(--accent)); }
.seg.forgone { background: linear-gradient(90deg, #9a7ae0, var(--accent2)); }

/* tuning modal */
.modal-overlay { position: fixed; inset: 0; z-index: 50; background: #0009; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; }
.modal-card { width: 470px; max-width: 100%; max-height: 86vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 48px #000a; }
.modal-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; background: var(--panel2); border-bottom: 1px solid var(--line); font-weight: 600; }
.modal-head .x { background: none; border: none; color: var(--dim); font-size: 22px; line-height: 1; cursor: pointer; } .modal-head .x:hover { color: #fff; }
.modal-body { padding: 14px 16px 22px; }
