:root {
  --bg: #0e0e10; --panel: #18181b; --card: #1c1c1f; --line: #2d2d32; --line2: #3a3a40;
  --text: #e8e8ea; --muted: #9a9aa2; --blue: #4a9eff; --blue2: #2b6cb0; --red: #ef4444; --green: #34d399; --amber: #f5b942;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
a { color: var(--blue); text-decoration: none; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.sp { flex: 1; }
.top { display: flex; align-items: baseline; gap: 14px; padding: 16px 20px 8px; }
.top h1 { margin: 0; font-size: 26px; font-weight: 700; }
footer { padding: 18px 20px 30px; }

.layout { display: grid; grid-template-columns: 400px 1fr; gap: 18px; padding: 8px 20px; align-items: start; }
.layout.collapsed { grid-template-columns: 44px 1fr; }
#inputs { position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow-y: auto; padding-right: 4px; }
.ihead { display: flex; align-items: center; gap: 10px; margin: 6px 0 14px; }
.lbl { font: 600 12px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.lbl2 { margin: 10px 0 6px; }

.btn { background: #222226; color: var(--text); border: 1px solid var(--line2); border-radius: 7px; padding: 7px 13px; font: 600 13px var(--sans); cursor: pointer; }
.btn:hover { border-color: #55555d; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn.red { color: var(--red); border-color: var(--red); background: transparent; }
.btn.ghost { border: 0; background: transparent; font-size: 18px; }
.btn.warn { border-color: var(--amber); color: var(--amber); }
.col-btn { width: 40px; }
.x { background: none; border: 0; color: var(--muted); font-size: 18px; cursor: pointer; padding: 0 4px; }
.x:hover { color: var(--text); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; }
.card-h { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sum { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sum span { flex: 1; }
.card-b { margin-top: 14px; display: flex; flex-direction: column; gap: 12px; }
.info { color: var(--muted); cursor: help; font-size: 13px; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: #141416; border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.seg button { background: transparent; color: var(--muted); border: 1px solid transparent; border-radius: 6px; padding: 5px 11px; font: 13px var(--mono); cursor: pointer; }
.seg button.on { background: #2a2a2f; color: var(--text); border-color: var(--line2); }
.card-b > .seg:first-child button.on, .seg button.on[data-seg=wmode] { background: #12304f; color: #8cc4ff; border-color: var(--blue2); }

.tog { width: 44px; height: 26px; border-radius: 13px; background: #333338; border: 0; position: relative; cursor: pointer; flex: none; }
.tog span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #bbb; transition: .15s; }
.tog.on { background: #6b6b72; } .tog.on span { left: 21px; background: #111; box-shadow: 0 0 0 2px #ddd inset; }
.line { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.line input[type=number], .line select { width: 120px; }
.row { display: flex; align-items: center; } .row.gap { gap: 8px; flex-wrap: wrap; } .row.between { justify-content: space-between; gap: 8px; }

input, select, textarea { background: #141416; color: var(--text); border: 1px solid var(--line2); border-radius: 7px; padding: 7px 9px; font: 13px var(--sans); }
input:focus, select:focus, textarea:focus { outline: 1px solid var(--blue); border-color: var(--blue); }
textarea { width: 100%; font-family: var(--mono); }
.search { position: relative; }
.search input { width: 100%; padding-left: 32px; height: 40px; }
.search .mag { position: absolute; left: 11px; top: 9px; color: var(--muted); font-size: 16px; }
.sugg { position: absolute; z-index: 20; left: 0; right: 0; top: 42px; background: #1f1f23; border-radius: 8px; box-shadow: 0 8px 24px #000a; max-height: 260px; overflow: auto; }
.sugg button { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); padding: 7px 12px; cursor: pointer; }
.sugg button:hover { background: #2a2a30; }
.around { display: flex; justify-content: space-between; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #222; border: 1px solid var(--line2); border-radius: 14px; padding: 2px 4px 2px 10px; font-size: 12px; }
.chip button { background: none; border: 0; color: var(--muted); cursor: pointer; }
.slider { width: 100%; accent-color: var(--blue); }
.taxes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; max-height: 240px; overflow: auto; }
.mini { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.mini input { width: 64px; padding: 4px 6px; } .mini select { padding: 3px 4px; }

.pilot { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.pilot.off { opacity: .5; }
.pilot img { width: 28px; height: 28px; border-radius: 50%; }
.pilot .pname { flex: 1; min-width: 90px; }
input.pname { padding: 4px 6px; }
.cols { padding: 4px 0 8px 36px; display: flex; flex-direction: column; gap: 4px; }
.col { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.col span:nth-child(2) { flex: 1; }
.col select { padding: 2px 4px; font-size: 12px; }
.badge { font: 600 11px var(--mono); border: 1px solid var(--blue2); color: #8cc4ff; border-radius: 5px; padding: 1px 6px; background: transparent; }
.badge.cal { border-color: var(--green); color: var(--green); }
.badge.est { cursor: pointer; }
.badge.den { cursor: pointer; border-color: #5a4513; color: var(--amber); }

.ptable .ph, .ptable .prow { display: grid; grid-template-columns: 1fr 80px 70px 22px; gap: 8px; align-items: start; }
.ptable .ph { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.ptable .prow { margin-bottom: 10px; }
.ptable input { width: 100%; }
.pin { width: 100%; }
.sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.hrs { width: 64px; } .hrs.on { border-color: var(--blue); }
.more summary { cursor: pointer; font: 600 12px var(--mono); letter-spacing: .1em; text-transform: uppercase; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.more[open] { display: flex; flex-direction: column; gap: 8px; }
.plan { width: 100%; background: var(--blue); color: #fff; border: 0; border-radius: 9px; padding: 13px; font: 600 15px var(--sans); cursor: pointer; margin: 4px 0 24px; }
.plan:disabled { opacity: .7; cursor: wait; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 10px 14px; font: 600 13px var(--sans); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--blue); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }
.warn-box { border: 1px solid var(--amber); color: var(--amber); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }

.kpis { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.kpi { display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; }
.kpi img { width: 32px; height: 32px; } .kpi div { display: flex; flex-direction: column; } .kpi span { color: var(--muted); font-size: 12px; }
.econ-strip { display: flex; flex-wrap: wrap; gap: 18px; padding: 10px 12px; background: var(--panel); border-radius: 9px; margin-bottom: 8px; color: var(--muted); }
.econ-strip b { color: var(--text); margin-left: 4px; }
.pilots { display: grid; grid-template-columns: repeat(auto-fill, minmax(460px, 1fr)); gap: 12px; }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
.ph2 { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.ph2 img { width: 28px; height: 28px; border-radius: 50%; }
.colony { border-top: 1px solid var(--line); padding: 8px 0; }
.ch { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ch .t { color: var(--muted); font-size: 13px; }
.status { font: 600 11px var(--mono); text-transform: uppercase; border-radius: 5px; padding: 1px 6px; }
.st-new .status { background: #12304f; color: #8cc4ff; }
.st-keep .status { background: #123a2c; color: var(--green); }
.st-rebuild .status { background: #3d2e10; color: var(--amber); }
.st-remove .status { background: #3d1515; color: #ff9a9a; }
.st-remove { opacity: .7; }
.io { font-size: 13px; margin-top: 3px; } .io.in { color: var(--muted); }
.bars { display: flex; gap: 8px; margin-top: 6px; }
.bar { flex: 1; position: relative; height: 16px; background: #141416; border-radius: 4px; overflow: hidden; font: 10px var(--mono); }
.bar i { position: absolute; inset: 0 auto 0 0; background: #24496f; }
.bar.full i { background: #6f2424; }
.bar span { position: absolute; left: 6px; top: 1px; color: #cfd8e3; }
.pt { display: inline-block; width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 50%; font: 700 11px var(--mono); color: #111; margin-right: 2px; }
.pt-B { background: #b9a37e; } .pt-G { background: #e0c36a; } .pt-I { background: #bfe6ff; } .pt-L { background: #ff7a45; }
.pt-O { background: #3f8dff; } .pt-P { background: #d07cff; } .pt-S { background: #8aa3b8; } .pt-T { background: #6fd18a; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: flex; flex-direction: column; }
.tile span { color: var(--muted); font-size: 12px; } .tile b { font-size: 22px; }
.tbl { width: 100%; border-collapse: collapse; margin-bottom: 12px; }
.tbl th, .tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.tbl th { color: var(--muted); font-weight: 600; font-size: 12px; }
.tbl.sm td, .tbl.sm th { padding: 4px 6px; font-size: 13px; }
.tbl tr.tot td { font-weight: 700; }
.tbl tr.bad td { color: #ff9a9a; } .tbl tr.warn td { color: var(--amber); }
h3 { margin: 18px 0 8px; font-size: 15px; }
.check { display: flex; gap: 8px; padding: 5px 0; align-items: flex-start; cursor: pointer; }
.check.done { color: var(--muted); text-decoration: line-through; }
.todo li { margin: 4px 0; }

.flowwrap { overflow-x: auto; background: var(--panel); border-radius: 10px; padding: 8px; }
.flow { width: 100%; min-width: 900px; }
.flow .hdr { fill: var(--muted); font: 600 12px var(--mono); }
.flow rect { fill: #222228; stroke: #3a3a40; }
.flow rect.t4 { stroke: #d07cff; } .flow rect.t3 { stroke: #4a9eff; } .flow rect.t2 { stroke: #34d399; } .flow rect.t1 { stroke: #f5b942; }
.flow text { fill: var(--text); font: 11px var(--sans); } .flow text.q { fill: var(--muted); font-size: 10px; }
.flow .links path { fill: none; stroke: #4a9eff55; }
.chain { background: var(--panel); border-radius: 10px; padding: 10px; margin: 10px 0; }
.chain .tr { padding: 3px 0; }
.tier { font: 600 10px var(--mono); border-radius: 4px; padding: 1px 4px; background: #333; }
.tier.t4 { background: #4b2463; } .tier.t3 { background: #173e66; } .tier.t2 { background: #164d3a; } .tier.t1 { background: #5a4513; }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #222228; border: 1px solid var(--line2); border-radius: 8px; padding: 10px 14px; max-width: 380px; box-shadow: 0 8px 24px #000a; }
.toast.error { border-color: var(--red); }

@media (max-width: 900px) {
  .layout, .layout.collapsed { grid-template-columns: 1fr; }
  #inputs { position: static; max-height: none; }
  .pilots { grid-template-columns: 1fr; }
}
