:root {
  --bg: #0f1218; --panel: #161b24; --panel2: #1c2230; --line: #262e3d; --text: #d7dce5; --muted: #8590a3;
  --gold: #c9a24a; --gold2: #e3c272; --green: #3fbf7f; --red: #e0565b; --blue: #4e9bea; --amber: #e3a03a; --violet: #a07de8;
  --r: 8px; font-size: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: "Segoe UI", system-ui, sans-serif; }
a { color: var(--gold2); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
input, select, textarea, button { font: inherit; color: inherit; }
input, select, textarea { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; outline: none; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); }
textarea { width: 100%; resize: vertical; font-family: Consolas, monospace; font-size: 13px; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; }
label input, label select { color: var(--text); font-size: 14px; }

.btn { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--gold); }
.btn.primary { background: var(--gold); color: #17130a; border-color: var(--gold); font-weight: 600; }
.btn.primary:hover { background: var(--gold2); }
.btn.danger { border-color: #6b2a2d; color: #ff9a9e; }
.btn.danger:hover { background: #3a1719; }
.btn.ok { border-color: #1f6044; color: #7fe0ae; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: default; }

.login { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 30%, #1c2333, var(--bg)); }
.login-box { width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.err { color: var(--red); min-height: 1em; font-size: 13px; }

.brand { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 8px; padding: 18px 16px; }
.brand.big { font-size: 22px; justify-content: center; padding: 0 0 8px; }
.logo { background: var(--gold); color: #161a22; border-radius: 6px; padding: 1px 6px; font-weight: 800; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); margin-left: auto; }
.dot.on { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.off { background: var(--red); }
.dot.warn { background: var(--amber); }

#app { display: flex; height: 100%; }
.side { width: 220px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.side nav { flex: 1; overflow-y: auto; padding: 0 8px; }
.side nav a { display: flex; gap: 10px; padding: 8px 10px; border-radius: 6px; color: var(--text); }
.side nav a::before { content: attr(data-i); width: 18px; text-align: center; color: var(--muted); }
.side nav a:hover { background: var(--panel2); text-decoration: none; }
.side nav a.active { background: var(--panel2); color: var(--gold2); }
.side nav a.active::before { color: var(--gold2); }
.sep { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .08em; padding: 14px 10px 4px; }
.side-foot { padding: 12px 16px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.credits { color: var(--muted); font-size: 11px; margin-top: 6px; text-align: center; }
.side-foot .credits { text-align: left; }
.credits a { color: var(--muted); text-decoration: underline; }
.credits a:hover { color: var(--gold2); }

main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--panel); }
.top h1 { font-size: 17px; margin: 0; font-weight: 600; }
.quick { margin-left: auto; }
.quick input { width: 220px; }
.menu-btn { display: none; }
.jobbar { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; font-size: 12px; max-width: 520px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; }
.jobbar.run { border-color: var(--amber); }
#view { flex: 1; overflow: auto; padding: 20px; }
#view.full { padding: 0; overflow: hidden; }

.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card h3 .right { margin-left: auto; display: flex; gap: 6px; }
.stat .v { font-size: 26px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, monospace; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; background: var(--panel2); border: 1px solid var(--line); }
.pill.on { color: #7fe0ae; border-color: #1f6044; }
.pill.off { color: var(--muted); }
.pill.red { color: #ff9a9e; border-color: #6b2a2d; }
.pill.gold { color: var(--gold2); border-color: #6b5524; }
.pill.blue { color: #9cc8f5; border-color: #24496d; }
.grade { font-weight: 700; font-size: 11px; padding: 0 4px; border-radius: 3px; background: #2a3242; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: 12px; position: sticky; top: 0; background: var(--panel); cursor: default; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--panel2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; max-height: calc(100vh - 220px); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: none; border-bottom: 2px solid transparent; padding: 8px 12px; cursor: pointer; color: var(--muted); }
.tabs button.active { color: var(--gold2); border-bottom-color: var(--gold); }

.comp { display: grid; grid-template-columns: 14px 120px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.comp:last-child { border-bottom: none; }
.ports { display: flex; gap: 6px; flex-wrap: wrap; }
.joblog { background: #0b0e13; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-family: Consolas, monospace; font-size: 12px; height: 260px; overflow: auto; white-space: pre-wrap; }
.logview { background: #0b0e13; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-family: Consolas, monospace; font-size: 12px; height: calc(100vh - 250px); overflow: auto; white-space: pre-wrap; word-break: break-all; }
.bar { height: 6px; background: var(--panel2); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--gold); }
.bar.hp > i { background: var(--red); } .bar.mp > i { background: var(--blue); } .bar.cp > i { background: var(--amber); }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 2000; }
.modal-box { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; width: min(560px, 94vw); max-height: 90vh; overflow: auto; }
.modal-head { display: flex; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15px; flex: 1; }
#modalBody { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.suggest { border: 1px solid var(--line); border-radius: 6px; max-height: 220px; overflow: auto; }
.suggest div { padding: 6px 10px; cursor: pointer; display: flex; gap: 8px; }
.suggest div:hover, .suggest div.sel { background: var(--panel2); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 3000; }
.toast { background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--green); border-radius: 6px; padding: 10px 14px; max-width: 380px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.toast.err { border-left-color: var(--red); }

/* map */
.mapwrap { position: relative; height: 100%; }
#map { position: absolute; inset: 0; background: #0e1116; }
.map-panel { position: absolute; top: 12px; right: 12px; z-index: 1000; width: 280px; background: rgba(22,27,36,.94); border: 1px solid var(--line); border-radius: 8px; padding: 12px; display: flex; flex-direction: column; gap: 8px; max-height: calc(100% - 24px); overflow: auto; }
.map-coords { position: absolute; left: 12px; bottom: 12px; z-index: 1000; background: rgba(22,27,36,.9); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; font-family: Consolas, monospace; font-size: 12px; }
.plist div { display: flex; justify-content: space-between; padding: 4px 6px; border-radius: 4px; cursor: pointer; font-size: 13px; }
.plist div:hover { background: var(--panel2); }
.pmark { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; background: var(--green); box-shadow: 0 0 6px rgba(0,0,0,.8); }
.pmark.off { background: #6c7586; border-color: #aab; width: 9px; height: 9px; }
.pmark.gm { background: var(--violet); }
.pmark.pk { background: var(--red); }
.plabel { background: rgba(10,12,16,.75); border: none; color: #fff; font-size: 11px; padding: 0 4px; border-radius: 3px; box-shadow: none; }
.plabel::before { display: none; }
.bmark { font-size: 15px; line-height: 15px; text-shadow: 0 0 3px #000; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.leaflet-container { font: inherit; }
.leaflet-crosshair, .leaflet-crosshair .leaflet-interactive { cursor: crosshair !important; }

@media (max-width: 900px) {
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g2 { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 1500; height: 100%; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu-btn { display: inline-block; }
  .quick input { width: 140px; }
  #view { padding: 12px; }
  .comp { grid-template-columns: 14px 1fr; }
  .map-panel { width: calc(100% - 24px); max-height: 40%; top: auto; bottom: 12px; }
}
