/* EVENTULIST stats dashboard - dark theme. */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0b1220;
  --panel: #111a2e;
  --panel2: #16213b;
  --line: #243353;
  --text: #e6edf7;
  --muted: #8ea0c4;
  --accent: #4d8dff;
  --accent2: #3b82f6;
  --green: #34d399;
  --red: #f87171;
  --amber: #fbbf24;
  --radius: 12px;
}
html, body { height: 100%; }
body {
  background: radial-gradient(1200px 600px at 70% -10%, #14203c 0%, var(--bg) 55%);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 12px; font-weight: 400; }
.err { color: var(--red); font-size: 13px; margin-top: 10px; }

/* ---------- sign-in ---------- */
#login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 34px 30px; width: 100%; max-width: 360px; text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .45);
}
.login-card h1 { font-size: 26px; letter-spacing: .5px; }
.login-card h1 span, .brand h1 span { color: var(--accent); }
.login-sub { color: var(--muted); margin: 6px 0 22px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 12px; margin-bottom: 12px;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
}
.login-card input:focus { outline: 2px solid var(--accent2); border-color: transparent; }
.login-card button {
  width: 100%; padding: 11px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent2); color: #fff; font-size: 14px; font-weight: 600;
}
.login-card button:hover { background: var(--accent); }
.login-card button:disabled { opacity: .6; cursor: wait; }

/* ---------- layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 22px;
  background: rgba(11, 18, 32, .86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand h1 { font-size: 19px; letter-spacing: .5px; }
.brand p { color: var(--muted); font-size: 12px; margin-top: 2px; }
.controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.seg button {
  background: transparent; color: var(--muted); border: 0; padding: 8px 13px;
  font-size: 13px; cursor: pointer; font-weight: 500;
}
.seg button:hover { color: var(--text); }
.seg button.active { background: var(--accent2); color: #fff; }

.check { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; cursor: pointer; user-select: none; }
.check input { accent-color: var(--accent2); }

.btn {
  background: var(--accent2); color: #fff; border: 0; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--accent); }
.btn.ghost { background: var(--panel); color: var(--muted); border: 1px solid var(--line); font-weight: 500; }
.btn.ghost:hover { color: var(--text); border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }

main { padding: 20px 22px 40px; max-width: 1500px; margin: 0 auto; display: grid; gap: 18px; }

/* ---------- totals strip (compact replacement for the old 8-card wall) ---------- */
.strip { display: flex; flex-wrap: wrap; gap: 10px; }
.strip .stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 16px; flex: 1 1 160px; max-width: 260px;
}
.strip .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; }
.strip .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
.strip .s { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ---------- cards / grids ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; min-width: 0;
}
.card h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: 2fr 2fr 1.6fr; }
.outbound-card { margin-top: 18px; }
.outbound-card .note { margin: -6px 0 10px; }
@media (max-width: 1100px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }

.chart { height: 260px; position: relative; }
.chart svg { width: 100%; height: 100%; display: block; }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 10.5px; }
.chart .area-visits { fill: url(#visitsGrad); }
.chart .line-visits { stroke: var(--accent); stroke-width: 1.8; fill: none; }
.chart .line-uniques { stroke: var(--green); stroke-width: 1.3; fill: none; }
.chart .hover-line { stroke: var(--muted); stroke-dasharray: 3 3; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 10px; font-size: 12px; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
}
.chart-tip b { color: var(--accent); }
.chart-tip .u { color: var(--green); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }

.map { height: 380px; border-radius: 10px; overflow: hidden; z-index: 0; }
.mapwrap { position: relative; }
.map .leaflet-control-attribution { font-size: 10px; background: rgba(17, 26, 46, .75); color: var(--muted); }
.map .leaflet-control-attribution a { color: var(--muted); }
.map .leaflet-control-zoom a { background: var(--panel2); color: var(--text); border-color: var(--line); }
.map .leaflet-control-zoom a:hover { background: var(--line); }

.map-fit {
  position: absolute; top: 10px; right: 10px; z-index: 500;
  padding: 6px 11px; font-size: 12px; border-radius: 8px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
}
.map-legend {
  position: absolute; right: 10px; bottom: 26px; z-index: 500;
  background: rgba(17, 26, 46, .92); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 10px; font-size: 11px; color: var(--muted);
  pointer-events: none; box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
}
.map-legend .grad {
  width: 130px; height: 8px; border-radius: 4px; margin: 4px 0 3px;
  background: linear-gradient(90deg, rgb(77,157,255), rgb(124,107,255), rgb(245,158,11));
}
.map-legend .lbl { display: flex; justify-content: space-between; font-size: 10px; }

/* dark Leaflet popups to match the theme */
.leaflet-popup-content-wrapper {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .5);
}
.leaflet-popup-tip { background: var(--panel2); border: 1px solid var(--line); }
.leaflet-popup-content { margin: 12px 14px; font-size: 13px; }
.leaflet-popup-close-button { color: var(--muted) !important; }
.mpop-title { font-weight: 700; font-size: 14px; }
.mpop-title small { color: var(--muted); font-weight: 400; font-size: 11px; }
.mpop-stat { color: var(--muted); font-size: 12px; margin: 3px 0 9px; }
.mpop-stat b { color: var(--accent); }
.mpop-list { margin: 0; padding: 0; list-style: none; font-size: 12px; max-height: 150px; overflow-y: auto; }
.mpop-list li {
  padding: 3px 0; border-bottom: 1px solid rgba(36, 51, 83, .5);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.mpop-list li .t { color: var(--muted); margin-right: 6px; font-variant-numeric: tabular-nums; }
.mpop-btn {
  margin-top: 9px; width: 100%; padding: 6px; cursor: pointer;
  background: rgba(77, 141, 255, .14); color: var(--accent);
  border: 1px solid rgba(77, 141, 255, .5); border-radius: 7px; font-size: 12px; font-weight: 600;
}
.mpop-btn:hover { background: rgba(77, 141, 255, .25); }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid rgba(36, 51, 83, .5);
  cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: rgba(77, 141, 255, .06); }
.row .n { width: 44px; text-align: right; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.row .name .sub { display: block; color: var(--muted); font-weight: 400; font-size: 11.5px; }
.row .cnt { font-weight: 700; font-variant-numeric: tabular-nums; }
.row .bar { height: 4px; border-radius: 2px; background: var(--accent2); opacity: .75; }
.row.active { background: rgba(77, 141, 255, .12); border-radius: 6px; }
.row .x { color: var(--red); font-size: 15px; padding: 0 4px; border: 0; background: none; cursor: pointer; display: none; }
.row.active .x { display: block; }
.empty { color: var(--muted); padding: 18px 2px; font-size: 13px; }

/* ---------- live feed ---------- */
.live-list { gap: 0; }
.live-item {
  display: flex; gap: 10px; align-items: baseline;
  padding: 6px 2px; border-bottom: 1px solid rgba(36, 51, 83, .5); font-size: 13px;
}
.live-item:first-child { border-top: 1px solid rgba(36, 51, 83, .5); }
.live-item .t { color: var(--muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.live-item .p { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.live-item .g { color: var(--muted); font-size: 12px; white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis; }
.live-item.new { animation: flash 1.6s ease-out; }
@keyframes flash { 0% { background: rgba(77, 141, 255, .25); } 100% { background: transparent; } }
.pulse {
  width: 8px; height: 8px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 0 0 rgba(52, 211, 153, .6); animation: ping 2s infinite;
  display: inline-block;
}
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .55); } 70% { box-shadow: 0 0 0 7px rgba(52, 211, 153, 0); } 100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); } }

/* ---------- visits table ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; min-height: 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--panel2); border: 1px solid var(--accent2); color: var(--text);
  border-radius: 20px; padding: 3px 6px 3px 11px; font-size: 12px;
}
.chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.chip button:hover { color: var(--red); }
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 11.5px; text-transform: uppercase; letter-spacing: .6px; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid rgba(36, 51, 83, .45); vertical-align: top; }
td.p { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td.g { color: var(--muted); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr:hover td { background: rgba(77, 141, 255, .05); }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 12px; color: var(--muted); font-size: 13px; }

/* ---------- all-pages table ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.toolbar input[type="search"] {
  width: 260px; max-width: 100%; padding: 8px 12px;
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
.toolbar input[type="search"]:focus { outline: 2px solid var(--accent2); border-color: transparent; }
#pagesTable td.cnt { font-weight: 700; font-variant-numeric: tabular-nums; }
.sharebar {
  height: 7px; max-width: 130px; border-radius: 4px;
  background: linear-gradient(90deg, rgb(77,157,255), rgb(124,107,255));
}
tr.active-row td { background: rgba(77, 141, 255, .12); }
#pagesTable tbody tr { cursor: pointer; }

/* Known visitors (data/known-visitors.json labels): the "Who" cell gets a
 * friendly name with a small star so people stand out from anonymous hits. */
.who { color: var(--muted); }
.who.known {
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}
.who.known::before {
  content: "★ ";
  color: var(--accent2);
  font-size: 11px;
}
#visitorsTable td.who.known, #visitsTable td.who.known, .live-item .who.known {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 6px 0 26px; }

/* ---------- StatCounter-style header: date-range dropdown ---------- */
.range { position: relative; }
#rangeBtn {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; font-size: 13px; font-weight: 600;
}
#rangeBtn .cal { opacity: .8; }
#rangeBtn .caret { font-size: 10px; opacity: .7; }
#rangeBtn #rangeDate { font-weight: 400; }
.range-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 1200;
  min-width: 190px; padding: 6px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, .5);
  display: flex; flex-direction: column;
}
.range-menu .range-item {
  text-align: left; background: transparent; color: var(--text); border: 0;
  border-radius: 7px; padding: 8px 12px; font-size: 13px; cursor: pointer;
}
.range-menu .range-item:hover { background: rgba(77, 141, 255, .14); color: #fff; }
.range-menu .range-item.active { background: var(--accent2); color: #fff; font-weight: 600; }

/* ---------- StatCounter-style visitor activity rows ---------- */
#visitorsTable { table-layout: fixed; }
#visitorsTable th.vnumh { width: 44px; text-align: right; padding-right: 10px; }
#visitorsTable th:nth-child(2) { width: 54%; }
#visitorsTable td.vnum {
  width: 44px; text-align: right; padding-right: 10px;
  color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums;
}
#visitorsTable tbody tr { cursor: pointer; }
#visitorsTable td.va-left, #visitorsTable td.va-right { padding: 10px 14px; }
#visitorsTable td.va-left { border-right: 1px solid rgba(36, 51, 83, .45); }
.vwho { font-size: 13.5px; font-weight: 600; margin-bottom: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vwho.known { color: var(--accent); }
.vwho.known::before { content: "★ "; font-size: 12px; }
.vdl { display: grid; grid-template-columns: 150px 1fr; row-gap: 3px; margin: 0; }
.vdl dt { color: var(--muted); font-size: 11px; font-weight: 500; }
.vdl dd { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
@media (max-width: 900px) {
  #visitorsTable { table-layout: auto; }
  #visitorsTable th:first-child { width: auto; }
  #visitorsTable td.va-left, #visitorsTable td.va-right { display: block; border-right: 0; }
  .vdl { grid-template-columns: 120px 1fr; }
}

/* ---------- automated-traffic badge (cloud/proxy/hosting IPs) ---------- */
.vwho-row { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; flex-wrap: wrap; }
.vwho-row .vwho { margin-bottom: 0; }
.abadge {
  display: inline-block; padding: 1px 7px; margin-left: 2px;
  border-radius: 20px; font-size: 10.5px; font-weight: 700; letter-spacing: .3px;
  background: rgba(245, 158, 11, .14); color: var(--amber);
  border: 1px solid rgba(245, 158, 11, .5); white-space: nowrap; vertical-align: 1px;
  cursor: help;
}
.abadge.mini { font-size: 9.5px; padding: 0 5px; }
.abadge.good { background: rgba(52, 211, 153, .12); color: var(--green); border-color: rgba(52, 211, 153, .45); }
.abadge.warm { background: rgba(245, 158, 11, .14); color: var(--amber); border-color: rgba(245, 158, 11, .5); }
.abadge.hostile {
  background: rgba(248, 113, 113, .14); color: var(--red);
  border-color: rgba(248, 113, 113, .55);
}

/* ---------- expanded visitor detail (click a visitor row) ---------- */
#visitorsTable tr.visitor-detail td { padding: 0; border-bottom: 1px solid var(--line); background: rgba(77, 141, 255, .04); }
#visitorsTable tr.visitor-row.active-row td { background: rgba(77, 141, 255, .12); }
.vd-grid { display: grid; grid-template-columns: 1fr 1.7fr; gap: 20px; padding: 16px 18px; }
@media (max-width: 900px) { .vd-grid { grid-template-columns: 1fr; } }
.vd-card { min-width: 0; }
.vd-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.vd-head .vwho { margin-bottom: 0; }
.vd-sub { color: var(--muted); font-size: 11.5px; }
.vd-actions { margin-top: 12px; }
.vd-list { display: flex; flex-direction: column; max-height: 330px; overflow-y: auto; }
.vd-v { display: flex; gap: 10px; align-items: baseline; padding: 5px 2px; border-bottom: 1px solid rgba(36, 51, 83, .45); font-size: 12.5px; }
.vd-v:last-child { border-bottom: 0; }
.vd-v .t { color: var(--muted); font-size: 11.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.vd-v .p { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vd-v .g { color: var(--muted); font-size: 12px; white-space: nowrap; max-width: 24%; overflow: hidden; text-overflow: ellipsis; }
.vd-empty { color: var(--muted); padding: 12px 2px; font-size: 13px; }

/* ---------- collapsible "Overview & other reports" ---------- */
details#overview { border: 1px solid var(--line); border-radius: var(--radius); background: transparent; }
details#overview > summary {
  cursor: pointer; list-style: none; padding: 13px 18px;
  color: var(--muted); font-size: 13px; font-weight: 600; user-select: none;
  display: flex; align-items: center; gap: 8px;
}
details#overview > summary::-webkit-details-marker { display: none; }
details#overview > summary::before {
  content: "▸"; color: var(--accent); font-size: 11px; transition: transform .15s ease;
}
details#overview[open] > summary::before { transform: rotate(90deg); }
details#overview > summary:hover { color: var(--text); }
details#overview > summary span.arrow { color: var(--accent); }
.details-inner { padding: 4px 18px 20px; display: grid; gap: 18px; }
