:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #071019;
  --panel: rgba(13, 28, 41, 0.9);
  --panel-strong: #10283a;
  --line: rgba(144, 190, 216, 0.2);
  --text: #eaf7ff;
  --muted: #9cb6c7;
  --green: #44e29a;
  --cyan: #49c8f5;
  --yellow: #ffd166;
  --red: #ff6b7a;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 10% -10%, rgba(73, 200, 245, 0.17), transparent 32rem),
    radial-gradient(circle at 100% 15%, rgba(68, 226, 154, 0.12), transparent 30rem),
    var(--bg);
}

button, input, select { font: inherit; }
a { color: inherit; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 1.1rem clamp(1rem, 3vw, 3rem);
  border-bottom: 1px solid var(--line);
  background: rgba(7, 16, 25, 0.88);
  backdrop-filter: blur(18px);
}
.topbar h1 { margin: 0.1rem 0; font-size: clamp(1.45rem, 2.5vw, 2.3rem); }
.topbar p { margin: 0; color: var(--muted); }
.kicker { color: var(--cyan) !important; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; }
.top-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 0.65rem; }
.top-actions a, .top-actions button, button {
  border: 1px solid rgba(73, 200, 245, 0.32);
  border-radius: 0.72rem;
  padding: 0.68rem 0.92rem;
  color: var(--text);
  background: #15374d;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 150ms ease, transform 150ms ease, background 150ms ease;
}
button:hover:not(:disabled), .top-actions a:hover { transform: translateY(-1px); border-color: var(--cyan); background: #1b4862; }
button:disabled { cursor: not-allowed; opacity: 0.42; }
.danger-button { background: rgba(161, 38, 55, 0.64); border-color: rgba(255, 107, 122, 0.5); }
.secondary-button { background: transparent; }

main { width: min(1800px, 100%); margin: 0 auto; padding: clamp(1rem, 2.5vw, 2.4rem); }
.status-banner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  min-height: 5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.status-banner strong, .status-banner span { display: block; }
.status-banner div span, #next-refresh { margin-top: 0.2rem; color: var(--muted); }
.status-banner.healthy { border-color: rgba(68, 226, 154, 0.44); }
.status-banner.attention { border-color: rgba(255, 107, 122, 0.5); }
.pulse { width: 0.85rem; height: 0.85rem; border-radius: 999px; background: var(--yellow); box-shadow: 0 0 0 0 rgba(255, 209, 102, 0.5); animation: pulse 1.8s infinite; }
.healthy .pulse { background: var(--green); }
.attention .pulse { background: var(--red); }
@keyframes pulse { 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

.metric-grid { display: grid; grid-template-columns: repeat(8, minmax(140px, 1fr)); gap: 0.85rem; margin: 1rem 0; }
.metric-grid article, .site-card {
  min-width: 0;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: linear-gradient(145deg, rgba(19, 48, 68, 0.86), rgba(10, 26, 39, 0.93));
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.metric-grid span, .metric-grid small { display: block; color: var(--muted); }
.metric-grid strong { display: block; margin: 0.38rem 0 0.22rem; font-size: clamp(1.5rem, 2.6vw, 2.3rem); color: var(--green); }
.metric-grid .danger-metric strong { color: var(--red); }
.wireguard-grid { display: grid; grid-template-columns: repeat(6, minmax(160px, 1fr)); gap: 0.85rem; margin: 0.8rem 0 1rem; }
.wireguard-grid article { min-width: 0; padding: 0.95rem; border: 1px solid var(--line); border-radius: 0.95rem; background: linear-gradient(145deg, rgba(19, 48, 68, 0.86), rgba(10, 26, 39, 0.93)); }
.wireguard-grid span, .wireguard-grid small { display: block; color: var(--muted); }
.wireguard-grid strong { display: block; margin: 0.38rem 0 0.2rem; font-size: clamp(1.25rem, 2.2vw, 1.85rem); color: var(--cyan); }

.panel { margin-top: 1rem; padding: clamp(1rem, 2vw, 1.4rem); border: 1px solid var(--line); border-radius: 1rem; background: var(--panel); box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-heading h2 { margin: 0.18rem 0 0; font-size: clamp(1.15rem, 2vw, 1.55rem); }
.panel-heading p { margin: 0; }
.panel-status { color: var(--muted); text-align: right; }
.plain-help, .privacy-note { color: var(--muted); line-height: 1.55; }
.plain-help { padding: 0.8rem 1rem; border-left: 3px solid var(--cyan); background: rgba(73, 200, 245, 0.07); }
.privacy-note { margin: 1rem 0 0; font-size: 0.86rem; }
.control-row { display: flex; align-items: end; flex-wrap: wrap; gap: 0.7rem; }
.control-row form { display: flex; align-items: end; flex-wrap: wrap; gap: 0.5rem; padding-left: 0.7rem; border-left: 1px solid var(--line); }
.control-row label { display: grid; gap: 0.28rem; color: var(--muted); font-size: 0.82rem; }
input, select { border: 1px solid var(--line); border-radius: 0.62rem; padding: 0.65rem 0.72rem; color: var(--text); background: #081722; }

.site-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.site-card { position: relative; overflow: hidden; }
.site-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--green); }
.site-card.attention::before { background: var(--yellow); }
.site-card h3 { margin: 0; }
.site-card .domains { min-height: 2.5rem; margin: 0.45rem 0 0.9rem; color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
.site-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.6rem; }
.site-metrics span { display: grid; gap: 0.2rem; padding: 0.6rem; border-radius: 0.7rem; background: rgba(4, 13, 21, 0.52); }
.site-metrics small { color: var(--muted); }
.site-metrics strong { font-size: 1.35rem; }

.attack-map-layout { display: grid; grid-template-columns: minmax(0, 1.75fr) minmax(250px, 0.55fr); gap: 1rem; align-items: stretch; }
.attack-map-frame { position: relative; min-width: 0; overflow: hidden; border: 1px solid rgba(73, 200, 245, 0.22); border-radius: 1rem; background: #07131f; }
#attack-world-map { display: block; width: 100%; height: auto; min-height: 320px; }
.map-ocean { fill: url(#map-ocean); }
.map-grid path { fill: none; stroke: rgba(126, 184, 211, 0.09); stroke-width: 1; stroke-dasharray: 3 8; }
.map-land path { fill: rgba(51, 105, 131, 0.48); stroke: rgba(120, 188, 218, 0.28); stroke-width: 1.4; vector-effect: non-scaling-stroke; }
.attack-route { fill: none; stroke-width: 1.8; stroke-dasharray: 5 8; vector-effect: non-scaling-stroke; animation: attack-route-flow 6s linear infinite; }
.attack-route.detected { stroke: var(--yellow); }
.attack-route.banned { stroke: var(--red); }
@keyframes attack-route-flow { to { stroke-dashoffset: -52; } }
.marker-halo { opacity: 0.16; transform-box: fill-box; transform-origin: center; animation: marker-pulse 2.6s ease-out infinite; }
.marker-halo.detected, .marker-core.detected { fill: var(--yellow); }
.marker-halo.banned, .marker-core.banned { fill: var(--red); }
.marker-core { stroke: rgba(255,255,255,0.82); stroke-width: 1.2; vector-effect: non-scaling-stroke; filter: url(#map-glow); }
.marker-label { fill: #071019; font-size: 9px; font-weight: 900; text-anchor: middle; pointer-events: none; }
.attack-map-marker:focus { outline: none; }
.attack-map-marker:focus .marker-core { stroke: white; stroke-width: 3; }
@keyframes marker-pulse { 0% { transform: scale(0.82); opacity: 0.26; } 75%,100% { transform: scale(1.32); opacity: 0; } }
.server-beacon circle:first-child { fill: rgba(73, 200, 245, 0.2); stroke: var(--cyan); stroke-width: 1.6; animation: marker-pulse 2s ease-out infinite; transform-box: fill-box; transform-origin: center; }
.server-beacon circle:nth-child(2) { fill: var(--cyan); filter: url(#map-glow); }
.server-beacon text { fill: var(--text); font-size: 10px; font-weight: 900; letter-spacing: 0.04em; }
.server-beacon text:last-child { fill: var(--muted); font-size: 9px; font-weight: 600; }
.attack-map-legend { position: absolute; left: 0.8rem; bottom: 0.7rem; display: flex; flex-wrap: wrap; gap: 0.8rem; padding: 0.48rem 0.65rem; border: 1px solid var(--line); border-radius: 0.65rem; color: var(--muted); background: rgba(7, 16, 25, 0.82); backdrop-filter: blur(8px); font-size: 0.72rem; }
.attack-map-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.map-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; }
.map-dot.detected { background: var(--yellow); }
.map-dot.banned { background: var(--red); }
.map-dot.server { background: var(--cyan); }
.attack-map-sidebar { display: grid; align-content: start; gap: 1rem; padding: 1rem; border: 1px solid var(--line); border-radius: 1rem; background: linear-gradient(145deg, rgba(19, 48, 68, 0.68), rgba(8, 22, 33, 0.92)); }
.attack-map-sidebar h3 { margin: 0.15rem 0 0; font-size: 0.95rem; }
.attack-map-metrics { display: grid; grid-template-columns: 1fr; gap: 0.55rem; }
.attack-map-metrics article { display: flex; align-items: center; justify-content: space-between; gap: 0.8rem; padding: 0.7rem 0.8rem; border-radius: 0.7rem; background: rgba(4, 13, 21, 0.52); }
.attack-map-metrics span { color: var(--muted); font-size: 0.78rem; }
.attack-map-metrics strong { color: var(--cyan); font-size: 1.25rem; }
.attack-map-ranking { display: grid; gap: 0.62rem; margin: 0; padding: 0; list-style: none; }
.attack-map-ranking li { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.3rem 0.6rem; padding-bottom: 0.42rem; overflow: hidden; }
.attack-map-ranking span { min-width: 0; overflow: hidden; color: #cbe7f5; font-size: 0.8rem; text-overflow: ellipsis; white-space: nowrap; }
.attack-map-ranking strong { color: var(--text); font-size: 0.78rem; }
.attack-map-ranking i { grid-column: 1 / -1; display: block; width: 100%; height: 3px; border-radius: 99px; background: rgba(144, 190, 216, 0.12); }
.attack-map-ranking i::after { content: ""; display: block; width: var(--attack-share); height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--yellow), var(--red)); }
.attack-map-ranking .empty-ranking { display: block; color: var(--muted); line-height: 1.5; }

.two-column { display: grid; grid-template-columns: 1.25fr 0.75fr; gap: 1rem; }
.two-column .panel { min-width: 0; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: 0.78rem; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.72rem 0.8rem; border-bottom: 1px solid rgba(144, 190, 216, 0.12); text-align: left; vertical-align: top; }
th { position: sticky; top: 0; z-index: 1; color: var(--muted); background: #102637; font-size: 0.75rem; letter-spacing: 0.04em; text-transform: uppercase; }
td { font-size: 0.9rem; }
tr:last-child td { border-bottom: 0; }
.empty-cell { padding: 1.4rem; color: var(--muted); text-align: center; }
.wide-table { max-height: 34rem; }
.wide-table th { top: 0; }
.path-cell { max-width: 32rem; color: #c8e9f8; overflow-wrap: anywhere; }
.ip-cell { white-space: nowrap; }
.status-pill { display: inline-block; border-radius: 999px; padding: 0.26rem 0.52rem; font-size: 0.75rem; font-weight: 800; }
.status-pill.blocked { color: #071a12; background: var(--green); }
.status-pill.detected { color: #2b2102; background: var(--yellow); }
.event-banned { color: var(--red); font-weight: 800; }
.event-unbanned { color: var(--green); font-weight: 800; }
.event-detected { color: var(--yellow); font-weight: 800; }
.event-heading { align-items: end; }
.event-heading label { display: grid; gap: 0.3rem; color: var(--muted); font-size: 0.82rem; }
.legend { display: flex; flex-wrap: wrap; gap: 1rem; margin: -0.2rem 0 0.9rem; color: var(--muted); font-size: 0.82rem; }
.legend span { display: flex; align-items: center; gap: 0.4rem; }
.dot { width: 0.6rem; height: 0.6rem; border-radius: 50%; }
.dot.blocked { background: var(--green); }
.dot.detected { background: var(--yellow); }

.login-wall { max-width: 42rem; margin: 10vh auto; padding: 2rem; border: 1px solid var(--line); border-radius: 1rem; background: var(--panel); box-shadow: var(--shadow); text-align: center; }
.login-wall a { display: inline-block; margin-top: 1rem; padding: 0.75rem 1rem; border-radius: 0.7rem; background: #15374d; text-decoration: none; }

@media (max-width: 1500px) { .metric-grid { grid-template-columns: repeat(4, minmax(150px, 1fr)); } }
@media (max-width: 1500px) { .wireguard-grid { grid-template-columns: repeat(3, minmax(160px, 1fr)); } }
@media (max-width: 1000px) { .topbar { position: static; align-items: flex-start; flex-direction: column; } .top-actions { justify-content: flex-start; } .site-grid, .two-column, .attack-map-layout { grid-template-columns: 1fr; } .attack-map-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); } .attack-map-metrics article { align-items: flex-start; flex-direction: column; } }
@media (max-width: 650px) { main { padding: 0.7rem; } .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .wireguard-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .status-banner { grid-template-columns: auto 1fr; } #next-refresh { grid-column: 2; } .panel-heading { flex-direction: column; } .panel-status { text-align: left; } .site-metrics, .attack-map-metrics { grid-template-columns: 1fr; } .attack-map-metrics article { align-items: center; flex-direction: row; } #attack-world-map { min-height: 240px; } .attack-map-legend { position: static; border-width: 1px 0 0; border-radius: 0; background: rgba(7, 16, 25, 0.96); } .control-row, .control-row form { align-items: stretch; flex-direction: column; width: 100%; } .control-row form { padding: 0.8rem 0 0; border-left: 0; border-top: 1px solid var(--line); } }

.security-agents-panel .plain-help { margin-bottom: 1rem; }
.security-agent-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.security-agent-card { display: flex; align-items: center; gap: .75rem; min-width: 0; padding: .8rem .9rem; border: 1px solid var(--line); border-radius: .8rem; background: linear-gradient(145deg, rgba(19, 48, 68, .68), rgba(8, 22, 33, .88)); }
.security-agent-dot { width: .7rem; height: .7rem; flex: 0 0 auto; border-radius: 50%; background: var(--muted); box-shadow: 0 0 0 4px rgba(156, 182, 199, .12); }
.security-agent-dot.ok, .security-agent-dot.running { background: var(--green); box-shadow: 0 0 0 4px rgba(68, 226, 154, .12); }
.security-agent-dot.warning { background: var(--yellow); box-shadow: 0 0 0 4px rgba(255, 209, 102, .12); }
.security-agent-dot.critical { background: var(--red); box-shadow: 0 0 0 4px rgba(255, 107, 122, .12); }
.security-agent-copy { display: grid; gap: .18rem; min-width: 0; }.security-agent-copy strong { overflow: hidden; color: var(--text); text-overflow: ellipsis; white-space: nowrap; }.security-agent-copy small { overflow: hidden; color: var(--muted); text-overflow: ellipsis; white-space: nowrap; }.security-agent-state { margin-left: auto; flex: 0 0 auto; color: var(--muted); font-size: .75rem; font-weight: 800; }.security-agent-state.ok, .security-agent-state.running { color: var(--green); }.security-agent-state.warning { color: var(--yellow); }.security-agent-state.critical { color: var(--red); }
@media (max-width: 650px) { .security-agent-grid { grid-template-columns: 1fr; } }