:root {
  --bg: #0d1117; --panel: #161b22; --line: #30363d; --text: #e6edf3; --muted: #8b949e;
  --accent: #58a6ff; --err: #ff7b72; --ok: #3fb950; --warn: #d29922;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overflow-x: hidden; }
.hidden { display: none !important; }
.muted { color: var(--muted); } .small { font-size: 12px; } .err { color: var(--err); min-height: 1em; }
code { font-size: 12px; word-break: break-all; }
button, select, input { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 6px; padding: 7px 10px; min-height: 36px; }
button { cursor: pointer; background: #21262d; } button:hover { border-color: var(--accent); }
button.ghost { background: transparent; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
label.inline { flex-direction: row; align-items: center; margin: 0; gap: 6px; }
label.inline input { width: 70px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card h3 { font-size: 15px; margin: 18px 0 4px; }

.auth { display: flex; align-items: center; justify-content: center; min-height: 100%; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: 100%; max-width: 420px; }
.card.wide { max-width: 560px; margin: 16px auto; }
.card h1 { margin-top: 0; font-size: 20px; }

#main { display: flex; flex-direction: column; height: 100%; }
.top { display: flex; align-items: center; gap: 12px; padding: 8px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.brand-ic { width: 24px; height: 24px; flex: none; }
.auth-logo { display: block; margin: 0 auto 6px; filter: drop-shadow(0 0 10px rgba(56, 217, 255, .35)); }
#tabs { display: flex; gap: 4px; overflow-x: auto; flex: 1; min-width: 0; scrollbar-width: none; }
#tabs button { background: transparent; border-color: transparent; white-space: nowrap; }
#tabs button.active { border-color: var(--accent); color: var(--accent); }
.banner { background: #3b2e0a; color: #f2cc60; padding: 8px 16px; border-bottom: 1px solid var(--warn); }
.view { flex: 1; min-height: 0; overflow: auto; padding: 12px 16px; }
#view-map { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px 16px; }
#view-map .toolbar input#m-q { width: 170px; }

#map-wrap { position: relative; flex: 1; min-height: 300px; }
#map { position: absolute; inset: 0; background: #0a1520; }
.detail .tbl th, .detail .tbl td { white-space: normal; overflow-wrap: break-word; padding: 5px 4px; }
#map-wrap:fullscreen { background: var(--bg); }

/* live animation */
.pulse { pointer-events: none; }
.pulse::before, .pulse::after { content: ""; position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--c, #fff);
  box-shadow: 0 0 8px var(--c, #fff); }
.pulse::before { background: #fff; border-color: #fff; transform: scale(.3); animation: dot 2.4s ease-out forwards; }
.pulse::after { animation: ring 2.4s ease-out forwards; }
@keyframes ring { from { transform: scale(.3); opacity: 1; } to { transform: scale(3.2); opacity: 0; } }
@keyframes dot { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
.arc { animation: draw 4s ease-out forwards; filter: drop-shadow(0 0 4px currentColor) drop-shadow(0 0 1px currentColor); stroke-linecap: round; }
@keyframes draw { 0% { stroke-dashoffset: var(--len); opacity: 1; } 35% { stroke-dashoffset: 0; opacity: 1; }
  75% { stroke-dashoffset: 0; opacity: .9; } 100% { stroke-dashoffset: 0; opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pulse::after, .arc { animation-duration: .01s; } }

.legend, .ticker { background: rgba(13, 17, 23, .88); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
  color: var(--text); font-size: 12px; max-width: 290px; }
.legend summary { cursor: pointer; font-weight: 600; }
.lg-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.lg-row i { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.lg-sep { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 6px; }
.lg-row i.lg-arc { width: 18px; height: 8px; border-radius: 10px 10px 0 0; border: 2px solid #38d9ff; border-bottom: 0; background: none; }
.lg-row i.lg-pulse { background: none; border: 2px solid #ffa94d; }
.lg-note { margin-top: 6px; color: var(--muted); }
.lg-title { font-weight: 600; margin-top: 6px; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.lg-count { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }
label.lg-toggle { flex-direction: row; margin: 4px 0 0; cursor: pointer; }
.lg-toggle input { min-height: 0; margin: 0; width: 14px; height: 14px; }
#lg-arcs { max-height: 240px; overflow: auto; }
.lg-src { margin-top: 6px; font-weight: 600; font-size: 11px; }
.sensor { background: #e9ecef; transform: rotate(45deg); border: 1px solid #0d1117; box-shadow: 0 0 6px rgba(255,255,255,.6); }
.head { filter: drop-shadow(0 0 5px #fff); }
.top-panel { width: 230px; }
/* keep clear of the ticker in the bottom-right corner: scroll instead of running underneath it */
.top-panel[open] { max-height: calc(100vh - 500px); min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
/* the legend grows upwards from the bottom-left corner: stop below the zoom buttons and the Layers button (top left)
   and scroll instead of covering them */
.leaflet-bottom.leaflet-left .legend[open] { max-height: calc(100vh - 300px); min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.top-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pulse-late::before, .pulse-late::after { animation-delay: 1.2s; opacity: 0; }
.ticker { width: 300px; }
.tk-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.chip { font-weight: 700; font-size: 11px; letter-spacing: .05em; color: #69db7c; }
.chip::before { content: "● "; }
.chip-replay { color: #ffa94d; }
.small-btn { min-height: 26px; padding: 2px 8px; font-size: 12px; }
#tk-list { list-style: none; margin: 6px 0 0; padding: 0; }
#tk-list li { display: grid; grid-template-columns: 10px 38px 1fr; gap: 2px 6px; align-items: center; padding: 3px 0;
  border-top: 1px solid #21262d; cursor: pointer; animation: flash 1.5s; }
#tk-list li i { width: 8px; height: 8px; border-radius: 50%; }
.tk-t { color: var(--muted); } .tk-ip { font-family: ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-what { grid-column: 3; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail { position: absolute; top: 10px; right: 10px; bottom: 10px; width: 360px; max-width: calc(100% - 20px);
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow: auto; z-index: 1000; }
.detail .close { position: absolute; top: 6px; right: 6px; font-size: 20px; min-height: 32px; padding: 0 10px; }
.detail h3 { margin: 0 34px 6px 0; word-break: break-all; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 8px 0; }
.detail dt { color: var(--muted); } .detail dd { margin: 0; word-break: break-word; }
.score { display: inline-block; padding: 2px 8px; border-radius: 10px; font-weight: 600; }
.s-high { background: #5a1e1e; color: #ffa198; } .s-med { background: #4d3a0b; color: #f2cc60; } .s-low { background: #1c2d41; color: #a5d6ff; }
i.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.note { font-size: 12px; color: var(--muted); border-left: 3px solid var(--warn); padding-left: 8px; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th, .tbl td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl tr.click { cursor: pointer; } .tbl tr.click:hover { background: #1c2128; }
.tbl tr.new { animation: flash 1.5s; }
@keyframes flash { from { background: #1f3a5c; } to { background: transparent; } }

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.stat { font-size: 28px; font-weight: 700; }
.bar { display: grid; grid-template-columns: 140px 1fr 60px; gap: 8px; align-items: center; margin: 4px 0; }
.bar .fill { height: 10px; background: var(--accent); border-radius: 4px; min-width: 2px; }
.bar span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.src { margin-bottom: 12px; }
.src .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pill { padding: 1px 8px; border-radius: 10px; font-size: 12px; border: 1px solid var(--line); }
.st-ok { color: var(--ok); border-color: var(--ok); } .st-error, .st-stale, .st-degraded { color: var(--err); border-color: var(--err); }
.st-needs_key, .st-pending { color: var(--warn); border-color: var(--warn); } .st-disabled { color: var(--muted); }

@media (max-width: 767px) {
  .top { padding: 6px 12px; gap: 6px; }
  .brand .brand-name, .brand .ver { display: none; }   /* phones: the icon alone, to leave room for the tabs */
  /* the map credits wrap to two lines on phones: keep the Legend button above them */
  .leaflet-bottom.leaflet-left { bottom: 34px; }
  #tabs { order: 3; flex-basis: 100%; }
  .view { padding: 10px 12px; }
  .toolbar { padding: 6px 12px; }
  #view-map .toolbar input#m-q { width: 100%; flex-basis: 100%; }
  #view-map .toolbar select { flex: 1; min-width: 0; }
  /* bottom sheet */
  .detail { top: auto; left: 0; right: 0; bottom: 0; width: 100%; max-width: 100%; max-height: 60%;
    border-radius: 14px 14px 0 0; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .tbl th:nth-child(3), .tbl td:nth-child(3), .tbl th:nth-child(5), .tbl td:nth-child(5) { display: none; }
  /* live feed on phones: keep "what it's doing" / the attack name; drop country+category / count+source */
  .feed-ips th:nth-child(5), .feed-ips td:nth-child(5) { display: table-cell; }
  .feed-ips th:nth-child(4), .feed-ips td:nth-child(4) { display: none; }
  .feed-attacks th:nth-child(3), .feed-attacks td:nth-child(3) { display: table-cell; }
  .feed-attacks th:nth-child(6), .feed-attacks td:nth-child(6) { display: none; }
  .tbl { table-layout: fixed; }
  .tbl th, .tbl td { padding: 6px 4px; white-space: normal; overflow-wrap: anywhere; }
  #tabs button { padding: 6px 7px; }
  .detail .tbl { table-layout: auto; }
  .bar { grid-template-columns: 90px 1fr 48px; }
  .legend:not([open]) { padding: 4px 8px; }
  .legend, .ticker { max-width: calc(100vw - 24px); font-size: 11px; }
  .ticker { width: 190px; }
  #tk-list li:nth-child(n+3) { display: none; }
  .top-panel:not([open]) { width: auto; }
  .top-panel[open] { width: 210px; }
  #view-map .toolbar select { flex: 1 1 40%; }
  #view-map .toolbar label.inline { flex: 1; }
  .leaflet-bottom.leaflet-left .legend[open] { max-height: 55vh; overflow: auto; }
  .leaflet-bottom.leaflet-left .leaflet-control, .leaflet-bottom.leaflet-right .leaflet-control { margin-bottom: 8px; }
}

/* IP detail: activity, picker, badges */
.act-list { list-style: none; padding: 0; margin: 4px 0 8px; font-size: 13px; }
.act-list li { padding: 4px 0; border-bottom: 1px solid var(--border, #30363d); line-height: 1.4; }
.act-list li:last-child { border-bottom: 0; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 9px; border: 1px solid #484f58; color: #c9d1d9; margin: 0 4px 3px 0; white-space: nowrap; }
.badge.b-obs { border-color: #ff6b6b; color: #ff8787; }
.badge.b-rep { border-color: #74c0fc; color: #a5d8ff; }
.badge.b-ai { border-color: #e599f7; color: #f3c4fb; }
.badges { margin: 4px 0 8px; }
.comments .cmt { font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; color: #c9d1d9; overflow-wrap: anywhere; margin-top: 2px; }
.pick-list { list-style: none; padding: 0; margin: 6px 0; }
.pick { display: flex; gap: 8px; align-items: center; width: 100%; text-align: left; padding: 7px 6px; background: transparent; border: 0; border-bottom: 1px solid #30363d; border-radius: 0; color: inherit; cursor: pointer; min-height: 36px; }
.pick:hover, .pick:focus-visible { background: #1f2630; }
.pick-ip { font-family: ui-monospace, Consolas, monospace; min-width: 9em; }
.ex-row { display: flex; gap: 6px; align-items: baseline; font-size: 12px; padding: 2px 0; }
.ex-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ex-cve { font-family: ui-monospace, Consolas, monospace; font-size: 10.5px; color: #ffd43b; }

/* live feed */
.mono { font-family: ui-monospace, Consolas, monospace; }
.feed-tbl td { vertical-align: top; }
.feed-tbl .badge { margin-right: 6px; }
.feed-tbl td { white-space: normal; }
.feed-tbl td:first-child { white-space: nowrap; }
/* one attacker session on your sensor: a summary row that expands to every event */
.sess { margin-top: 4px; }
.sess summary { cursor: pointer; color: var(--muted); font-size: 11px; }
.sess-list { margin: 4px 0 0; padding-left: 32px; max-height: 260px; overflow: auto; overscroll-behavior: contain;
  font-family: ui-monospace, Consolas, monospace; font-size: 11px; overflow-wrap: anywhere; }
.ip-link { color: var(--accent, #58a6ff); text-decoration: underline; text-underline-offset: 2px; }
.arc-hit { cursor: pointer; }
.lk-box dd .badge { margin: 1px 3px 1px 0; }
.ver { font-weight: 400; font-size: 11px; color: var(--muted); margin-left: 4px; }
.upd-note { font-size: 12px; padding: 3px 10px; border-color: #d29922; color: #e3b341; background: transparent; }

/* Update card (Settings) */
.upd-card { display: flex; flex-direction: column; gap: 14px; }
.upd-head { display: flex; align-items: center; gap: 12px; }
.upd-logo { width: 34px; height: 34px; fill: none; stroke: #ff6b6b; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.upd-title { font-size: 20px; font-weight: 700; }
.upd-box { display: flex; gap: 10px; align-items: flex-start; border: 1px solid; border-radius: 10px; padding: 12px 14px; }
.upd-ico { width: 20px; height: 20px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #0d1117; margin-top: 1px; }
.upd-h { font-weight: 700; }
.upd-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.upd-green { border-color: #2ea043; background: rgba(46,160,67,.12); } .upd-green .upd-ico { background: #3fb950; }
.upd-amber { border-color: #bb8009; background: rgba(187,128,9,.12); } .upd-amber .upd-ico { background: #e3b341; }
.upd-blue { border-color: #1f6feb; background: rgba(31,111,235,.12); } .upd-blue .upd-ico { background: transparent; border: 2px solid #58a6ff; border-top-color: transparent; animation: upd-spin 0.9s linear infinite; }
.upd-red { border-color: #da3633; background: rgba(218,54,51,.12); } .upd-red .upd-ico { background: #ff7b72; }
.upd-grey { border-color: var(--line); background: rgba(139,148,158,.08); } .upd-grey .upd-ico { background: #8b949e; }
@keyframes upd-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .upd-blue .upd-ico { animation: none; } }
.upd-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 0; }
.upd-mode select { max-width: 360px; }
.upd-drop { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 26px 16px;
  border: 2px dashed var(--line); border-radius: 12px; cursor: pointer; }
.upd-drop:hover, .upd-drop:focus-visible, .upd-drop.over { border-color: #ff6b6b; background: rgba(255,107,107,.06); }
.upd-drop code { font-size: 12px; }
.upd-fico { width: 28px; height: 28px; fill: none; stroke: #ff6b6b; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.upd-log { max-height: 320px; overflow: auto; background: #010409; border: 1px solid var(--line); border-radius: 8px; padding: 10px;
  font-size: 12px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.upd-drop.disabled { opacity: .5; pointer-events: none; }
#u-msg:empty { display: none; }

/* settings sub-tabs */
.subtabs { display: flex; gap: 4px; overflow-x: auto; max-width: 560px; margin: 16px auto 0; padding: 0 2px; scrollbar-width: none; border-bottom: 1px solid var(--line); }
.subtabs button { background: transparent; border-color: transparent; border-radius: 6px 6px 0 0; white-space: nowrap; }
.subtabs button.active { border-color: var(--line); border-bottom-color: var(--panel); background: var(--panel); color: var(--accent); }
.stab.hidden { display: none; }
.tblwrap { overflow-x: auto; }
.sn-new { margin-top: 14px; padding: 12px; border: 1px solid var(--accent); border-radius: 8px; }
.sn-new pre { white-space: pre-wrap; word-break: break-all; }
.sn-st { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--muted); }
.sn-st.online { background: #3fb950; } .sn-st.offline { background: #d29922; }
.sn-acts button { padding: 2px 8px; margin: 0 2px 2px 0; font-size: 12px; }
#sn-tbl th, #sn-tbl td { white-space: normal; }
#sn-tbl .sn-acts { min-width: 150px; }

/* map layers control */
.layers { max-width: 260px; max-height: calc(100vh - 340px); min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.layers .lg-row { margin-top: 3px; }
.layers .lg-toggle { cursor: pointer; }
.layers .lg-title { font-weight: 600; margin-top: 8px; }
.ly-btns { display: flex; gap: 6px; flex-wrap: wrap; }
@media (max-width: 767px) { .layers { max-width: 220px; max-height: calc(100vh - 300px); } }
