:root {
  color-scheme: dark;
  --bg: #0b0f14;
  --bg-2: #10161d;
  --panel: #131a22;
  --line: #222c38;
  --line-2: #2c3845;
  --text: #dbe4ee;
  --muted: #8494a6;
  --faint: #56657a;
  --teal: #2dd4bf;
  --teal-dim: #1a7f73;
  --edge: #8aa0b8;
  --neg: #3a4655;
  --amber: #e0a74a;
  --red: #f0716b;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: radial-gradient(1200px 600px at 30% -10%, #12202a 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}
[hidden] { display: none !important; }

h1, h2, h3 { margin: 0; font-weight: 600; }
h1 { font-size: 18px; letter-spacing: .01em; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
h3 { font-size: 12px; color: var(--muted); margin: 14px 0 6px; font-weight: 500; }

/* header */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand svg { width: 30px; height: 30px; fill: none; stroke: var(--teal); stroke-width: 2.5; }
.sub { margin: 0; color: var(--muted); font-size: 12px; }
/* signed-in character */
.me { display: flex; align-items: center; gap: 8px; margin-left: auto; font-size: 12px; position: relative; }
.me-off { color: var(--faint); border: 1px dashed var(--line-2); border-radius: 8px; padding: 4px 10px; cursor: help; }
.me-err { color: var(--amber); font-weight: 700; }
.me-menu summary { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 8px 3px 3px; border: 1px solid var(--line-2); border-radius: 999px; background: var(--bg-2); }
.me-menu summary::-webkit-details-marker { display: none; }
.me-menu[open] summary, .me-menu summary:hover { border-color: var(--faint); }
.me-face { position: relative; display: inline-flex; }
.me-face img { border-radius: 50%; }
.me-dot { position: absolute; right: -1px; bottom: -1px; width: 9px; height: 9px; border-radius: 50%; background: var(--faint); border: 2px solid var(--bg-2); }
.me-dot.on { background: #4ade80; }
.me-who { display: flex; flex-direction: column; line-height: 1.2; }
.me-who small { color: var(--muted); }
.me-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; width: 320px; display: flex; flex-direction: column; gap: 10px;
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 12px; box-shadow: 0 12px 30px rgba(0,0,0,.5); }
.me-ship { color: var(--muted); }
.me-ship b { color: var(--text); }
.me-opt { display: grid; grid-template-columns: 18px 1fr; gap: 6px; align-items: start; cursor: pointer; }
.me-opt input { accent-color: var(--teal); margin-top: 2px; }
.me-opt span { display: flex; flex-direction: column; color: var(--text); }
.me-opt small { color: var(--faint); }
.me-opt.off { opacity: .55; cursor: not-allowed; }
.me-warn { color: var(--amber); font-size: 11.5px; }
.me-pop .btn { align-self: flex-start; }
input:disabled { opacity: .7; cursor: not-allowed; }
input.from-me { border-color: #a78bfa; }

/* page nav */
.pages { display: inline-flex; gap: 2px; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 2px; }
.pages a { color: var(--muted); text-decoration: none; font-size: 13px; padding: 5px 12px; border-radius: 6px; }
.pages a:hover { color: var(--text); }
.pages a[aria-current=page] { background: #16302e; color: var(--teal); font-weight: 600; }

.refresh { display: flex; align-items: center; gap: 12px; }
.status { color: var(--muted); font-size: 12px; text-align: right; }
.status.err { color: var(--amber); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text);
  padding: 7px 14px; border-radius: 8px; font: inherit; cursor: pointer;
}
.btn:hover { border-color: var(--faint); }
.btn:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #04201c; font-weight: 600; }
.btn.primary:hover { background: #5eead4; }
.btn.primary[disabled] { opacity: .6; cursor: progress; }
.btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.btn.loading svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }

/* controls */
.controls {
  display: flex; flex-wrap: wrap; gap: 12px 18px; padding: 12px 24px;
  border-bottom: 1px solid var(--line); background: rgba(16, 22, 29, .6);
}
.controls label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
select, input[type=number], input[type=search] {
  background: var(--bg); color: var(--text); border: 1px solid var(--line-2);
  border-radius: 7px; padding: 6px 8px; font: inherit; font-size: 13px;
}
.controls input[type=number] { width: 90px; }
label.inline { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
label.check input { accent-color: var(--teal); }

/* layout */
.layout {
  display: grid; gap: 16px; padding: 16px 24px 32px;
  grid-template-columns: minmax(0, 1fr) 360px;
  grid-template-areas: "graph side" "trips trips" "scan scan" "table table";
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; grid-template-areas: "graph" "side" "trips" "scan" "table"; padding: 12px; }
  .topbar, .controls { padding-left: 12px; padding-right: 12px; }
}
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.graph-panel { grid-area: graph; display: flex; flex-direction: column; }
.side { grid-area: side; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.table-panel { grid-area: table; min-width: 0; }

/* graph */
#graph { width: 100%; height: auto; max-height: 68vh; display: block; user-select: none; }
#graph .bg { fill: transparent; }
.node { cursor: pointer; }
.node circle { fill: #16202b; stroke: var(--line-2); stroke-width: 1.5; transition: stroke .15s, fill .15s; }
.node:hover circle { stroke: var(--faint); }
.node.src circle { stroke: var(--teal); stroke-width: 2.5; fill: #0f2a2a; }
.node.dst circle { stroke: var(--teal-dim); stroke-width: 2; }
.node.dim { opacity: .45; }
.node text.name { fill: var(--text); font-size: 14px; font-weight: 600; text-anchor: middle; }
.node text.region { fill: var(--muted); font-size: 10.5px; text-anchor: middle; }
.node:focus-visible circle { stroke: var(--teal); stroke-dasharray: 3 3; }
.node:focus { outline: none; }

.edge { fill: none; stroke-linecap: round; transition: opacity .15s; }
.edge.pos { stroke: var(--edge); }
.edge.best { stroke: var(--teal); filter: url(#glow); }
.edge.neg { stroke: var(--neg); stroke-width: 1.2; }
.edge.stale { stroke: var(--amber); stroke-dasharray: 5 5; stroke-width: 1.5; opacity: .7; }
.edge.faded { opacity: .1 !important; }
.edge-hit { stroke: transparent; stroke-width: 16; fill: none; }
.elabel rect { fill: #0b0f14; stroke: var(--line-2); }
.elabel text { fill: var(--text); font: 600 11px var(--mono); text-anchor: middle; dominant-baseline: central; }
.elabel.best rect { stroke: var(--teal); fill: #062522; }
.elabel.best text { fill: var(--teal); }
.elabel.stale text { fill: var(--amber); font-weight: 500; }

.focus { min-height: 44px; margin: 6px 4px 8px; font-size: 13px; color: var(--muted); }
.focus strong { color: var(--text); }
.focus .big { color: var(--teal); font: 600 15px var(--mono); }
.legend { list-style: none; padding: 10px 4px 0; margin: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 22px; height: 0; border-top: 3px solid; border-radius: 2px; }
.sw.best { border-color: var(--teal); }
.sw.pos { border-color: var(--edge); }
.sw.neg { border-color: var(--neg); border-top-width: 2px; }
.sw.stale { border-color: var(--amber); border-top-style: dashed; border-top-width: 2px; }

/* items */
.count { color: var(--faint); font-weight: 400; }
.picker { position: relative; margin: 10px 0; }
.picker input { width: 100%; }
.picker-results {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px);
  background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 8px;
  max-height: 340px; overflow-y: auto; box-shadow: 0 12px 30px rgba(0,0,0,.5);
}
.picker-results button {
  display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  padding: 7px 10px; font: inherit; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--line);
}
.picker-results button:hover, .picker-results button:focus-visible { background: #18222d; outline: none; }
.picker-results .path { display: block; color: var(--faint); font-size: 11px; }
.picker-results .msg { padding: 8px 10px; color: var(--muted); font-size: 12px; }
.picker-results .grp { color: var(--muted); }
.picker-results .grp::before { content: "▸ "; color: var(--faint); }
.picker-results .added { color: var(--faint); }

.item-list { list-style: none; margin: 0; padding: 0; }
.item-list li { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); }
.item-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-list .id { color: var(--faint); font: 11px var(--mono); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.ok { background: var(--teal); }
.dot.loading { background: var(--muted); animation: pulse 1s ease-in-out infinite; }
.dot.stale { background: var(--amber); }
.dot.error { background: var(--red); }
@keyframes pulse { 50% { opacity: .3; } }
.x { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 16px; line-height: 1; padding: 2px 4px; border-radius: 4px; }
.x:hover { color: var(--red); }
.item-list li.empty { color: var(--faint); font-size: 12.5px; }

/* watchlist items: icon linking to the EVE University wiki, and a Remove button */
.item-pic { display: inline-flex; flex: none; border-radius: 5px; line-height: 0; vertical-align: middle; margin-right: 8px; }
.item-pic img { border-radius: 5px; background: var(--bg); border: 1px solid var(--line); }
.item-pic:hover img { border-color: var(--teal); }
.item-pic:focus-visible { outline: 2px solid var(--teal); outline-offset: 1px; }
.item-list .item-pic { margin-right: 0; }
.del { display: inline-flex; align-items: center; gap: 5px; flex: none; background: none; border: 1px solid var(--line-2); color: var(--muted);
  border-radius: 6px; padding: 3px 8px; font: 12px system-ui, sans-serif; cursor: pointer; }
.del svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.del:hover { color: var(--red); border-color: rgba(240,113,107,.6); background: rgba(240,113,107,.08); }
.del:focus-visible { outline: 2px solid var(--red); outline-offset: 1px; }
.item-list .del { padding: 4px 6px; }
.item-list .del span { display: none; }   /* side panel: icon only */
/* Pictures only where there's room. */
@media (max-width: 700px) { .board .item-pic { display: none; } .board .del span { display: none; } }
@media (max-width: 420px) { .item-list .item-pic { display: none; } }

/* overrides */
details.panel summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::before { content: "▸"; color: var(--faint); transition: transform .15s; }
details[open].panel summary::before { transform: rotate(90deg); }
.hint { color: var(--faint); font-size: 12px; margin: 8px 0; }
.ov-table { width: 100%; border-collapse: collapse; margin-top: 8px; }
.ov-table th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 500; padding: 4px 4px; }
.ov-table td { padding: 3px 4px; }
.ov-table input, .ov-jumps input { width: 100%; font-family: var(--mono); font-size: 12px; padding: 5px 6px; }
.ov-table input:not(:placeholder-shown), .ov-jumps input:not(:placeholder-shown) { border-color: var(--amber); }
.ov-jumps { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px 10px; margin-bottom: 12px; }
.ov-jumps label { display: grid; grid-template-columns: 1fr 64px; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }

/* table */
.table-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.table-head .check { margin-left: auto; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; background: #0f2a2a; color: var(--teal); border: 1px solid var(--teal-dim); padding: 2px 4px 2px 10px; border-radius: 999px; }
.chip button { background: none; border: 0; color: inherit; cursor: pointer; padding: 0 4px; font-size: 14px; }
.table-wrap { overflow-x: auto; }
table.routes { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.routes th {
  text-align: right; font-size: 11px; font-weight: 500; color: var(--muted); padding: 8px 10px;
  border-bottom: 1px solid var(--line-2); white-space: nowrap; cursor: pointer; user-select: none;
}
.routes th.l, .routes td.l { text-align: left; }
.routes th:hover { color: var(--text); }
.routes th[aria-sort] { color: var(--teal); }
.routes th[aria-sort=descending]::after { content: " ↓"; }
.routes th[aria-sort=ascending]::after { content: " ↑"; }
.routes td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; font-family: var(--mono); font-size: 12.5px; }
.routes td.l { font-family: inherit; font-size: 13px; }
.routes tbody tr { cursor: pointer; }
.routes tbody tr:hover { background: #17212b; }
.routes tr.top { background: linear-gradient(90deg, rgba(45,212,191,.16), rgba(45,212,191,.03)); }
.routes tr.top td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
.routes tr.top .metric { color: var(--teal); font-weight: 700; }
.routes .neg { color: var(--red); }
.routes .muted { color: var(--faint); }
.arrow { color: var(--faint); padding: 0 4px; }
.badge { display: inline-block; font: 600 10px/1 system-ui; padding: 3px 5px; border-radius: 4px; margin-left: 6px; vertical-align: 1px; letter-spacing: .03em; }
.badge.stale { background: rgba(224,167,74,.15); color: var(--amber); }
.badge.ov { background: rgba(138,160,184,.15); color: var(--edge); }
.empty td { text-align: center; color: var(--muted); padding: 28px; font-family: inherit; }
.foot { margin-bottom: 0; }

/* graph header + star map */
.graph-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.tabs { display: inline-flex; background: var(--bg); border: 1px solid var(--line-2); border-radius: 8px; padding: 2px; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; padding: 5px 12px; border-radius: 6px; cursor: pointer; }
.tabs button[aria-selected=true] { background: #16302e; color: var(--teal); font-weight: 600; }
.tabs button:focus-visible { outline: 2px solid var(--teal); }
.map-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.map-tools select { padding: 4px 6px; font-size: 12px; }
.btn-group { display: inline-flex; gap: 4px; }
.btn-group .btn.small { min-width: 30px; justify-content: center; }
.map-view { position: relative; height: min(68vh, 640px); min-height: 360px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.map-view canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.map-tip {
  position: absolute; pointer-events: none; z-index: 2; max-width: 280px;
  background: rgba(11,15,20,.96); border: 1px solid var(--line-2); border-radius: 8px;
  padding: 7px 10px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.map-tip .sec { font: 600 12px var(--mono); margin-left: 4px; }
.map-tip .reg { color: var(--muted); }
.map-tip .hint { color: var(--faint); margin-top: 3px; }
.map-tip .on { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); color: var(--teal); font: 11px var(--mono); }
.map-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; padding: 20px; text-align: center; pointer-events: none; }
.sec-legend { gap: 6px; }
.secbar { display: inline-block; width: 90px; height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, #2fefef, #48f0c0, #00ef47, #00f000, #8fef2f, #efef00, #d77700, #f06000, #f04800, #d73000, #f00000, #da0636, #b6115f, #921981, #6e1f9e); }

/* whole-market scan */
.scan-panel { grid-area: scan; min-width: 0; }
.scan-status { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; }
.scan-status.warn { color: var(--amber); }
.progress { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin: -4px 0 10px; }
.progress i { display: block; height: 100%; width: 0; background: var(--teal); transition: width .3s; }
.scan-filters { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 12px; }
.scan-filters label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.scan-filters input, .scan-filters select { width: 120px; padding: 5px 7px; font-size: 12.5px; }
.scan-filters label.grow { flex: 1; min-width: 160px; }
.scan-filters label.grow input { width: 100%; }
.scan-table th { cursor: default; }
.scan-table td.item { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.scan-table .loc { line-height: 1.25; }
.scan-table .loc b { font-weight: 600; }
.scan-table .loc small { display: block; color: var(--faint); font-size: 10.5px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scan-table tr.picked { background: rgba(45,212,191,.1); box-shadow: inset 3px 0 0 var(--teal); }
.scan-table .rank { color: var(--faint); font-family: var(--mono); font-size: 11px; }
.star { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 15px; padding: 0 6px 0 0; vertical-align: -1px; }
.star:hover, .star.on { color: var(--amber); }
.warn-m { color: var(--amber); }
.scan-foot { display: flex; align-items: flex-start; gap: 12px; }
.scan-foot .hint { flex: 1; margin-bottom: 0; }

/* multi-stop routes */
.trips-panel { grid-area: trips; min-width: 0; }
.trips-panel .checks { display: flex; flex-direction: column; gap: 4px; justify-content: flex-end; }
.trips-panel .checks label.check { flex-direction: row; font-size: 12px; }
.scan-filters input[type=text]#tpStart { width: 140px; }
.scan-filters input.bad { border-color: var(--red); }
.scan-filters .sc-check { align-self: flex-end; padding-bottom: 7px; flex-direction: row; }
.trips-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.trips-body.has-detail { grid-template-columns: minmax(0, 1fr) 380px; }
@media (max-width: 1100px) { .trips-body.has-detail { grid-template-columns: minmax(0, 1fr); } }
.trips-table td.route { white-space: normal; font-family: inherit; font-size: 12.5px; line-height: 1.35; max-width: 520px; }
.trips-table td.route .sys { font-weight: 600; }
.trips-table td.route .itm { color: var(--muted); font-size: 11.5px; display: block; }
.trips-table tr.picked { background: rgba(167,139,250,.12); box-shadow: inset 3px 0 0 #a78bfa; }
.trips-table .metric { color: var(--teal); font-weight: 700; }
.trip-detail { border: 1px solid var(--line-2); border-radius: 8px; padding: 10px 12px; background: var(--bg-2); min-width: 0; }
.trip-detail .table-head { margin-bottom: 6px; }
.trip-detail h3 { margin: 0; flex: 1; }
.trip-stops { margin: 0; padding: 0; list-style: none; counter-reset: none; }
.trip-stops li { display: grid; grid-template-columns: 26px 1fr; gap: 2px 8px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.trip-stops li:first-child { border-top: 0; }
.trip-stops .n { grid-row: span 3; width: 22px; height: 22px; border-radius: 50%; background: #a78bfa; color: #140d2b; font: 700 11px/22px system-ui; text-align: center; }
.trip-stops .n.start { background: var(--line-2); color: var(--text); }
.trip-stops .where { font-weight: 600; }
.trip-stops .where small { color: var(--faint); font-weight: 400; margin-left: 4px; }
.trip-stops .act { color: var(--muted); }
.trip-stops .act b { color: var(--text); font-weight: 600; }
.trip-stops .act .up { color: var(--teal); }
.trip-stops .hop { color: var(--faint); font-size: 11px; }
