* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0d1117; --card: #161b22; --card2: #1c2330; --border: #2d333b;
  --text: #e6edf3; --muted: #8b949e; --accent: #4f8cff; --accent2: #3fb950;
  --danger: #f85149; --warn: #d29922;
}
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.hidden { display: none !important; }

/* ---------- login ---------- */
.overlay {
  position: fixed; inset: 0; background: #0d1117;
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.login-card {
  background: var(--card); border: 1px solid var(--border); border-radius: 14px;
  padding: 34px 38px; width: 340px; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.login-logo { font-size: 44px; margin-bottom: 8px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card input {
  width: 100%; margin: 18px 0 10px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 14px;
}
.login-card input:focus { outline: none; border-color: var(--accent); }

/* ---------- topbar ---------- */
#topbar {
  display: flex; align-items: center; gap: 16px; padding: 10px 18px;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 15px; letter-spacing: .3px; }
#topbar nav { display: flex; gap: 6px; flex: 1; }
.nav-btn {
  background: transparent; border: none; color: var(--muted); padding: 7px 12px;
  border-radius: 8px; cursor: pointer; font-size: 14px;
}
.nav-btn:hover { color: var(--text); background: var(--card2); }
.nav-btn.active { color: #fff; background: var(--accent); }
.ws-status { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }
.dot.off { background: #666; }

/* ---------- layout ---------- */
main { max-width: 1080px; margin: 18px auto 80px; padding: 0 16px; }
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 18px 20px; margin-bottom: 14px;
}
.card h2 { font-size: 15px; margin-bottom: 12px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }

input, select, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; font-size: 13.5px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { width: 100%; min-height: 74px; resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }

button {
  border: none; border-radius: 8px; padding: 8px 14px; cursor: pointer;
  font-size: 13.5px; color: var(--text); background: var(--card2);
  transition: filter .15s;
}
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .5; cursor: default; }
.primary { background: var(--accent); color: #fff; }
.green { background: var(--accent2); color: #06220c; font-weight: 600; }
.ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.danger { background: transparent; color: var(--danger); border: 1px solid rgba(248,81,73,.4); }
.small { padding: 4px 9px; font-size: 12px; }
.wide { width: 100%; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: #9cdcfe; }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- victim rows ---------- */
.victim-row {
  display: flex; align-items: center; gap: 12px; background: var(--card);
  border: 1px solid var(--border); border-radius: 10px; padding: 12px 16px; margin-bottom: 8px;
}
.victim-row .vname { font-weight: 600; font-size: 14.5px; }
.victim-row .vmeta { color: var(--muted); font-size: 12px; margin-top: 3px; }
.status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.status-dot.on { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }
.status-dot.off { background: #555; }

.badge {
  display: inline-block; background: var(--card2); border: 1px solid var(--border);
  color: var(--muted); border-radius: 20px; padding: 1px 9px; font-size: 11px; vertical-align: middle;
}
.badge.on { color: var(--accent2); border-color: rgba(63,185,80,.4); }

/* ---------- misc ---------- */
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 12px; }
.flex { display: flex; align-items: center; gap: 8px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 8px; }
.pageurl {
  background: var(--card2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  word-break: break-all; margin-top: 10px;
}
.empty { text-align: center; color: var(--muted); padding: 26px 0; }
.kbd { background: var(--card2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }

#toast {
  position: fixed; bottom: 22px; right: 22px; z-index: 100; display: flex; flex-direction: column; gap: 8px;
}
.toast-item {
  background: var(--card2); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  color: var(--text); padding: 10px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: fadein .2s;
}
.toast-item.ok { border-left-color: var(--accent2); }
.toast-item.err { border-left-color: var(--danger); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.rules-table td input { width: 100%; }
ol, ul { margin: 8px 0 8px 20px; }
li { margin: 5px 0; }
code { background: var(--card2); padding: 1px 6px; border-radius: 5px; font-size: 12px; }
.staged-card { border: 1px dashed var(--accent); }
.staged-card table td { vertical-align: top; }
