:root {
  --bg: #0b1220;
  --panel: #111a2c;
  --panel-2: #16223a;
  --line: #22314f;
  --text: #e6ecf7;
  --muted: #8b9bb8;
  --accent: #4fd1a5;
  --accent-ink: #062018;
  --gold: #f5c451;
  --blue: #7aa7ff;
  --red: #ff6b6b;
  --orange: #ffa94d;
  --radius: 10px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
a { color: var(--blue); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: .2px; }
.logo { width: 22px; height: 22px; border-radius: 6px; background:
  linear-gradient(var(--accent),var(--accent)) 0 0/45% 45% no-repeat,
  linear-gradient(var(--gold),var(--gold)) 100% 0/45% 45% no-repeat,
  linear-gradient(var(--gold),var(--gold)) 0 100%/45% 45% no-repeat,
  linear-gradient(var(--blue),var(--blue)) 100% 100%/45% 45% no-repeat; }

/* login */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate-card { width: min(360px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; display: grid; gap: 14px; }

/* header */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 18px; padding: 10px 20px; background: rgba(11,18,32,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
#tabs { display: flex; gap: 4px; flex-wrap: wrap; }
#tabs button { background: none; border: 0; color: var(--muted); padding: 7px 12px; border-radius: 8px; cursor: pointer; font: inherit; }
#tabs button:hover { color: var(--text); background: var(--panel-2); }
#tabs button.active { color: var(--text); background: var(--panel-2); box-shadow: inset 0 -2px 0 var(--accent); }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
main { padding: 18px 20px 60px; max-width: 1400px; margin: 0 auto; }

.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: var(--radius); background: #3a2a10; border: 1px solid #6b4c16; color: #ffe0a3; }

/* bits */
.btn { font: inherit; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 7px 13px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #3a4f78; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--red); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.target { background: #1d2b4a; border-color: #2e4372; }
.btn.target.donutdrop { color: var(--gold); }
.btn.target.eldorado { color: var(--blue); }
.muted { color: var(--muted); }
.note { color: #ffe0a3; background: #2a2212; border: 1px solid #4d3c18; padding: 9px 11px; border-radius: 8px; font-size: 13px; }
.error { color: var(--red); margin: 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; background: var(--panel-2); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.online { color: var(--accent); }
.pill.connecting { color: var(--blue); }
.pill.linking { color: var(--gold); }
.pill.moving { color: var(--orange); }
.pill.offline { color: var(--muted); }
.pill.error { color: var(--red); }
.pill.plain::before { display: none; }

label { display: grid; gap: 5px; font-size: 12.5px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: #0d1526; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid #2d6b58; border-color: var(--accent); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.switch { display: flex; align-items: center; gap: 9px; color: var(--text); font-size: 14px; cursor: pointer; }
.switch input { width: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat b { display: block; font-size: 22px; }
.stat span { color: var(--muted); font-size: 12.5px; }

.toolbar { display: flex; align-items: center; gap: 10px; margin: 6px 0 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.search { max-width: 240px; }
.selection { display: flex; align-items: center; gap: 8px; background: var(--panel-2); border: 1px solid #2e4372; padding: 5px 8px 5px 12px; border-radius: 10px; flex-wrap: wrap; }
#move-buttons, #proxy-move-buttons { display: inline-flex; gap: 6px; }

.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; }
.grid th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 9px 12px; border-bottom: 1px solid var(--line); background: #0f1829; white-space: nowrap; }
.grid td { padding: 9px 12px; border-bottom: 1px solid #1a2742; vertical-align: middle; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr.selected td { background: #142340; }
.grid .check { width: 34px; }
.grid .right { text-align: right; }
.actions { display: flex; gap: 5px; justify-content: flex-end; flex-wrap: wrap; }
.who { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.who img { width: 28px; height: 28px; border-radius: 6px; image-rendering: pixelated; background: var(--panel-2); }
.who b { display: block; }
.who small { color: var(--muted); }
.sub { display: block; color: var(--muted); font-size: 12px; margin-top: 3px; max-width: 420px; }
.sub.err { color: #ff9b9b; }
.sub.warn { color: #ffd38a; }
.code-box { display: inline-flex; gap: 8px; align-items: center; margin-top: 6px; background: #2b2410; border: 1px solid #5a4818; padding: 5px 9px; border-radius: 8px; color: #ffe7a6; font-size: 12.5px; }
.code-box b { font-family: ui-monospace, Consolas, monospace; font-size: 15px; letter-spacing: 1px; color: #fff; }
.empty { color: var(--muted); padding: 26px; text-align: center; margin: 0; }
td select { padding: 5px 8px; min-width: 130px; }

.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; align-content: start; }
.card h3 { margin: 0; font-size: 15px; }
.card.narrow { max-width: 620px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row3 { display: grid; grid-template-columns: 110px 1fr 1fr; gap: 10px; }

.targets { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.target-card h3 { display: flex; align-items: center; gap: 10px; }
.target-card ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 560px; overflow: auto; }
.target-card li { display: flex; align-items: center; gap: 10px; padding: 7px 9px; background: #0f1829; border-radius: 8px; }
.target-card li img { width: 24px; height: 24px; border-radius: 5px; image-rendering: pixelated; }
.target-card li .grow { flex: 1; min-width: 0; }
.target-card li small { color: var(--muted); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.log { font-family: ui-monospace, Consolas, monospace; font-size: 12px; max-height: 620px; overflow: auto; display: grid; gap: 2px; }
.log div { padding: 2px 4px; border-radius: 4px; white-space: pre-wrap; word-break: break-word; }
.log .warn { color: #ffd38a; }
.log .error { color: #ff9b9b; }
.log time { color: var(--muted); margin-right: 8px; }

dialog { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--text); padding: 0; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(3,7,15,.7); }
.dialog { padding: 20px; display: grid; gap: 14px; }
.dialog h3 { margin: 0; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
.seg { display: flex; background: #0d1526; border: 1px solid var(--line); border-radius: 9px; padding: 3px; gap: 3px; }
.seg button { flex: 1; background: none; border: 0; color: var(--muted); padding: 7px; border-radius: 7px; cursor: pointer; font: inherit; }
.seg button.active { background: var(--panel-2); color: var(--text); }
.result { background: #0d1526; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: 13px; display: grid; gap: 4px; max-height: 240px; overflow: auto; }
.result .ok { color: var(--accent); }
.result .bad { color: #ff9b9b; }
.move-list { margin: 0; padding-left: 18px; max-height: 180px; overflow: auto; color: var(--text); }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: #1d2b4a; border: 1px solid #2e4372; color: var(--text); padding: 10px 16px; border-radius: 10px; z-index: 20; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.bad { border-color: #7a2e2e; background: #3a1717; }

@media (max-width: 860px) {
  .cols, .targets, .row2 { grid-template-columns: 1fr; }
  .row3 { grid-template-columns: 1fr 1fr; }
  main { padding: 14px 16px 60px; }
  .top { padding: 10px 16px; }
  .search { max-width: none; flex: 1 1 100%; }
}
.c-accent { color: var(--accent); }
.c-warn { color: var(--orange); }
