:root {
  --bg: #0e141b; --panel: #16202b; --panel2: #1c2836; --line: #2a3a4c; --text: #e6edf3; --muted: #93a4b8;
  --accent: #5aa9ff; --accent2: #2f7fd8; --bad: #ff6b6b; --good: #4cd38a; --warn: #f0b429;
  --mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}
:root[data-theme="light"] {
  --bg: #f3f6f9; --panel: #ffffff; --panel2: #eef2f6; --line: #d5dde6; --text: #15202b; --muted: #5b6b7c;
  --accent: #1f6fd1; --accent2: #1a5fb4;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 18px; margin: 0; letter-spacing: .02em; }
h2 { font-size: 16px; margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error { color: var(--bad); min-height: 1.2em; }
.note { background: var(--panel2); border: 1px solid var(--line); padding: 10px 12px; border-radius: 8px; }
code { font-family: var(--mono); }

button { background: var(--accent2); color: #fff; border: 0; border-radius: 6px; padding: 8px 14px; cursor: pointer;
  font: inherit; font-weight: 600; }
button:hover { filter: brightness(1.1); }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); font-weight: 500; }
button.small { padding: 4px 10px; font-size: 12px; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; cursor: pointer; }
input, select { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 9px; font: inherit; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input[type=checkbox] { width: auto; margin: 0 6px 0 0; }
label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label > input, label > select, label > details, label > .row { color: var(--text); font-size: 14px; }
.check { display: inline-flex; align-items: center; font-size: 12px; color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; }

/* header */
.top { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--panel);
  border-bottom: 1px solid var(--line); flex-wrap: wrap; position: sticky; top: 0; z-index: 1000; }
.brand { display: flex; gap: 10px; align-items: center; }
.logo { width: 38px; height: 38px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; }
.tab { background: transparent; color: var(--muted); border: 1px solid transparent; font-weight: 600; }
.tab.active { color: var(--text); border-color: var(--line); background: var(--panel2); }
.right { margin-left: auto; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.tz { flex-direction: row; align-items: center; gap: 6px; }
.tz select { width: auto; padding: 4px 6px; }

main { padding: 16px; max-width: 1800px; margin: 0 auto; }
.pane { display: none; }
.pane.active { display: block; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; margin-bottom: 14px; }

/* filters */
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.grid .wide { grid-column: span 2; }
.checks { display: flex; gap: 16px; align-items: flex-end; grid-column: span 2; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
details.multi { position: relative; }
details.multi summary { list-style: none; background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
details.multi summary::after { content: "▾"; float: right; color: var(--muted); }
details.multi > div { position: absolute; z-index: 1100; top: 100%; left: 0; min-width: 280px; max-height: 360px;
  overflow: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.tgroup { margin-bottom: 6px; }
.tgroup b { display: block; font-size: 11px; color: var(--muted); margin: 4px 0; letter-spacing: .05em; }
.tgroup label { flex-direction: row; align-items: center; color: var(--text); font-size: 13px; padding: 2px 0; }

/* results */
.results-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px;
  flex-wrap: wrap; }
.pager { display: flex; gap: 8px; align-items: center; }
.table-wrap { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { position: sticky; top: 0; background: var(--panel2); font-size: 12px; color: var(--muted); z-index: 1; }
th[data-s] { cursor: pointer; }
th.sorted { color: var(--text); }
th.sorted::after { content: attr(data-dir); margin-left: 4px; }
tbody tr:hover { background: var(--panel2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td .id { font-family: var(--mono); font-size: 12px; }
tr.raw td { white-space: pre-wrap; font-family: var(--mono); font-size: 12px; color: var(--muted); background: var(--panel2); }
.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700;
  background: var(--panel2); border: 1px solid var(--line); }
.t-MOVE { color: #7cc4ff; } .t-HIT, .t-DEATH, .t-KILL { color: #ff8a8a; } .t-BUY, .t-SELL, .t-P2P, .t-BANK, .t-CASINO { color: #f0c36b; }
.t-ADMIN { color: #d29bff; } .t-CHAT { color: #9be0b8; } .t-CONNECT, .t-DISCONNECT { color: #b8c4d2; }

/* map */
#map { height: calc(100vh - 220px); min-height: 420px; border-radius: 10px; border: 1px solid var(--line); background: #1e2a33; }
.map-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.leaflet-popup-content { font-size: 12px; }
.leaflet-container { font: inherit; }

/* player */
.row-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row-form label { min-width: 260px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.card h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; }
.card .big { font-size: 22px; font-weight: 700; }
.kv { display: grid; grid-template-columns: auto auto; gap: 3px 12px; font-size: 13px; }
.kv span:nth-child(odd) { color: var(--muted); }
.kv span:nth-child(even) { text-align: right; font-variant-numeric: tabular-nums; }
.quick { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 24px;
  width: 100%; max-width: 420px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.login-card h1 { font-size: 22px; }
.qr { background: #fff; padding: 8px; border-radius: 8px; width: 220px; }
.qr svg { width: 100%; height: auto; display: block; }
.key code { word-break: break-all; }
.steps { padding-left: 18px; margin: 0; color: var(--muted); }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  max-width: min(900px, 95vw); max-height: 85vh; }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog form { margin-top: 12px; text-align: right; }

@media (max-width: 1100px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; } .grid .wide, .checks { grid-column: auto; }
  .top { gap: 10px; } .right { margin-left: 0; } main { padding: 10px; }
}

/* overview */
.ov-head { display: flex; align-items: baseline; gap: 12px; margin: 4px 0 12px; }
.ov-head h2 { margin: 0; font-size: 20px; }
.ov-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(280px, 1fr); gap: 14px; margin-top: 14px; }
.stat .big { font-size: 28px; font-weight: 800; }
.stat .muted { font-size: 12px; }
.live { color: var(--good); }
.ov-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 14px; }
.ov-row .panel { margin-bottom: 0; }
.ov-row + .panel { margin-top: 14px; }
.ov-row .quick { margin: 0; }
@media (max-width: 900px) { .ov-grid, .ov-row { grid-template-columns: 1fr; } }
.linkbtn { display: inline-block; padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--text); text-decoration: none; font-size: 12px; }
.linkbtn:hover { background: var(--panel2); }
/* cftools */
.cf-banner { border-color: var(--warn); }
button.danger { color: var(--bad); border-color: rgba(255,107,107,.5); }
.cf-form { margin-bottom: 4px; }
.cf-form.row input { flex: 1; }
#status { max-width: 380px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab { padding: 8px 11px; }
#ov-cf + .quick { margin: 10px 0 0; }
/* settings + confirm */
.set-grid { columns: 2; column-gap: 14px; }   /* boxes flow down two columns, no gaps */
.set-grid > .panel { break-inside: avoid; margin: 0 0 14px; display: block; }
.set-grid > form.panel { display: flex; }
.set-form { display: flex; flex-direction: column; gap: 12px; }
.set-row .set-label { color: var(--text); font-size: 13px; font-weight: 600; }
textarea { width: 100%; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 6px;
  padding: 7px 9px; font: 13px var(--mono); resize: vertical; }
.test-out { background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; padding: 10px; font: 12px/1.5 var(--mono);
  white-space: pre-wrap; margin: 0; }
dialog form.ask { text-align: left; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 360px; }
dialog form.ask h2 { margin: 0; }
button.danger-solid { background: #c93c3c; }
@media (max-width: 1100px) { .set-grid { columns: 1; } }

/* cftools map */
#cfmap { height: calc(100vh - 190px); min-height: 420px; border-radius: 10px; border: 1px solid var(--line); background: #1e2a33; }
.cf-dot-label { background: rgba(14,20,27,.82); color: #e6edf3; border: 0; box-shadow: none; font-size: 11px; padding: 1px 5px; }
.cf-dot-label::before { display: none; }
.cf-dot-label.hit { background: #f0b429; color: #111; font-weight: 700; }
#status { max-width: 300px; }
.tab { padding: 8px 9px; }
.map-head .check { flex-direction: row; gap: 4px; }
.cf-dot { background: #4cd38a; border: 2px solid #0e141b; border-radius: 50%; box-sizing: border-box; }
.cf-dot.hit { background: #f0b429; }
.leaflet-marker-draggable.cf-dot { cursor: grab; }

/* territories */
#tmap { height: calc(100vh - 260px); min-height: 420px; border-radius: 10px; border: 1px solid var(--line); background: #1e2a33; }
.terr-label { background: rgba(14,20,27,.82); color: #e6edf3; border: 0; box-shadow: none; font-size: 11px; padding: 1px 5px; }
.terr-label::before { display: none; }

.flag-dot{display:inline-block;width:10px;height:10px;border-radius:50%;border:1px solid #cfd6df;vertical-align:middle}

/* drag-to-resize columns */
th { position: sticky; }
th .col-grip { position: absolute; top: 0; right: -3px; width: 7px; height: 100%; cursor: col-resize; z-index: 2; }
th .col-grip:hover, body.col-resizing th .col-grip { background: rgba(90,169,255,.35); }
body.col-resizing { cursor: col-resize; user-select: none; }
table.fixed-cols { table-layout: fixed; }
table.fixed-cols td { overflow: hidden; text-overflow: ellipsis; }
