:root {
  --bg: #020403;
  --panel: rgba(3, 10, 7, 0.84);
  --panel-strong: rgba(0, 0, 0, 0.72);
  --line: rgba(0, 255, 36, 0.28);
  --line-soft: rgba(180, 188, 184, 0.24);
  --neon: #00ff24;
  --neon-deep: #08a829;
  --text: #eef8f0;
  --muted: #93a99a;
  --danger: #ff4f7b;
  --radius: 8px;
  --shadow: 0 0 26px rgba(0, 255, 36, 0.24), inset 0 0 24px rgba(0, 255, 36, 0.05);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(rgba(0, 255, 36, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 36, 0.03) 1px, transparent 1px),
    radial-gradient(circle at 50% 0%, rgba(0, 255, 36, 0.14), transparent 32rem),
    #020403;
  background-size: 44px 44px, 44px 44px, auto, auto;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.035),
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px,
    transparent 4px
  );
  mix-blend-mode: screen;
  opacity: 0.26;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-shell {
  width: min(100%, 430px);
}

.login-panel,
.data-surface,
.status-card,
.module-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--panel), var(--panel-strong));
  box-shadow: var(--shadow);
}

.login-panel {
  position: relative;
  overflow: hidden;
  padding: 34px;
}

.login-panel::before {
  position: absolute;
  top: 104px;
  left: -12%;
  width: 124%;
  height: 4px;
  content: "";
  background: var(--neon);
  box-shadow: 0 0 18px var(--neon), 0 0 44px rgba(0, 255, 36, 0.62);
}

.brand-mark {
  display: grid;
  width: 118px;
  height: 92px;
  margin: 0 auto 24px;
  place-items: center;
  border: 1px solid var(--line-soft);
  background: #000;
  box-shadow: inset 0 0 22px rgba(0, 255, 36, 0.18), 0 0 22px rgba(0, 255, 36, 0.18);
}

.brand-mark img {
  width: 92px;
  height: 92px;
  object-fit: contain;
  filter: drop-shadow(0 0 9px var(--neon));
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--neon);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

.login-panel h1,
.topbar h1 {
  margin-bottom: 24px;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1;
  text-shadow: 0 0 18px rgba(0, 255, 36, 0.42);
}

.login-form {
  display: grid;
  gap: 18px;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field input,
.field select {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  color: var(--text);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  outline: none;
  background: rgba(0, 0, 0, 0.74);
  box-shadow: inset 0 0 16px rgba(0, 255, 36, 0.06);
}

.field select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--neon) 50%) calc(100% - 19px) 21px / 7px 7px no-repeat,
    linear-gradient(135deg, var(--neon) 50%, transparent 50%) calc(100% - 12px) 21px / 7px 7px no-repeat,
    rgba(0, 0, 0, 0.74);
}

.field input:focus,
.field select:focus {
  border-color: var(--neon);
  box-shadow: 0 0 0 3px rgba(0, 255, 36, 0.14), inset 0 0 18px rgba(0, 255, 36, 0.08);
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 56px;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--neon);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

.password-toggle {
  position: absolute;
  right: 5px;
  bottom: 4px;
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
}

.remember-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
}

.remember-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ios-switch {
  position: relative;
  flex: 0 0 auto;
  width: 54px;
  height: 31px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  transition: 0.18s ease;
}

.ios-switch::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 23px;
  height: 23px;
  content: "";
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.32);
  transition: 0.18s ease;
}

.remember-row input:checked + .ios-switch {
  border-color: var(--neon);
  background: var(--neon);
  box-shadow: 0 0 18px rgba(0, 255, 36, 0.42);
}

.remember-row input:checked + .ios-switch::after {
  transform: translateX(23px);
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--neon);
  border-radius: var(--radius);
  font-weight: 900;
  color: #001d05;
  background: var(--neon);
  box-shadow: 0 0 22px rgba(0, 255, 36, 0.4);
  cursor: pointer;
}

.ghost-button {
  color: var(--neon);
  background: rgba(0, 0, 0, 0.35);
}

.alert {
  margin-bottom: 18px;
  padding: 12px 14px;
  color: #ffdbe4;
  border: 1px solid rgba(255, 79, 123, 0.45);
  border-radius: var(--radius);
  background: rgba(255, 79, 123, 0.12);
}

.notice {
  margin-bottom: 18px;
  padding: 12px 14px;
  color: #dfffe5;
  border: 1px solid rgba(0, 255, 36, 0.42);
  border-radius: var(--radius);
  background: rgba(0, 255, 36, 0.1);
}

.app-frame {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 270px 1fr;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.58);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 36px;
  font-weight: 900;
}

.sidebar-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  background: #000;
  filter: drop-shadow(0 0 6px var(--neon));
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav-group {
  display: grid;
  gap: 6px;
}

.side-nav a {
  padding: 12px 14px;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
}

.side-nav-submenu {
  display: grid;
  gap: 6px;
  margin-left: 14px;
  padding-left: 12px;
  border-left: 1px solid var(--line-soft);
}

.side-nav-submenu a {
  padding: 10px 12px;
  font-size: 0.9rem;
}

.side-nav a:hover,
.side-nav .active {
  color: var(--neon);
  border-color: var(--line);
  background: rgba(0, 255, 36, 0.08);
}

.content {
  padding: 34px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 26px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.46);
}

.user-chip a {
  padding: 8px 12px;
  color: #001d05;
  border-radius: 6px;
  background: var(--neon);
  font-weight: 800;
}

.round-action,
.icon-action {
  display: inline-grid;
  place-items: center;
  color: var(--neon);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.42);
  box-shadow: inset 0 0 14px rgba(0, 255, 36, 0.06);
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.round-action {
  width: 48px;
  height: 48px;
}

.icon-action {
  width: 38px;
  height: 38px;
  padding: 0;
}

.round-action svg,
.icon-action svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.round-action:hover,
.icon-action:hover {
  border-color: var(--neon);
  box-shadow: 0 0 18px rgba(0, 255, 36, 0.25), inset 0 0 16px rgba(0, 255, 36, 0.08);
  transform: translateY(-1px);
}

.danger-action {
  color: var(--danger);
  border-color: rgba(255, 79, 123, 0.36);
}

.danger-action:hover {
  border-color: var(--danger);
  box-shadow: 0 0 18px rgba(255, 79, 123, 0.2), inset 0 0 16px rgba(255, 79, 123, 0.08);
}

.icon-action:disabled {
  color: rgba(147, 169, 154, 0.45);
  border-color: rgba(180, 188, 184, 0.12);
  cursor: not-allowed;
  opacity: 0.58;
  transform: none;
}

.status-grid,
.module-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.module-grid {
  margin-top: 18px;
}

.stats-summary {
  margin-top: 18px;
}

.status-card,
.module-card,
.data-surface {
  padding: 22px;
}

.status-card {
  display: grid;
  min-height: 150px;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

.status-card p,
.module-card p,
.surface-heading p {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.status-card h2,
.module-card h2,
.surface-heading h2 {
  margin-bottom: 0;
}

.status-card small {
  grid-column: 1 / -1;
  align-self: end;
  color: var(--muted);
}

.status-dot {
  width: 13px;
  height: 13px;
  border-radius: 999px;
  background: var(--danger);
  box-shadow: 0 0 14px var(--danger);
}

.is-online .status-dot {
  background: var(--neon);
  box-shadow: 0 0 14px var(--neon);
}

.module-card {
  display: block;
  min-height: 170px;
  transition: transform 0.18s ease, border-color 0.18s ease;
}

.module-card:hover {
  border-color: var(--neon);
  transform: translateY(-2px);
}

.module-card span,
.muted {
  color: var(--muted);
}

.data-surface {
  overflow-x: auto;
}

.filter-surface {
  margin-bottom: 18px;
}

.export-surface {
  margin-bottom: 18px;
}

.stats-filter,
.stats-export {
  display: grid;
  gap: 16px;
  align-items: end;
}

.stats-filter {
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, 1fr) minmax(160px, 1fr) auto;
}

.stats-export {
  grid-template-columns: minmax(220px, 1fr) auto;
}

.export-note {
  margin: 12px 0 0;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.chart-card {
  min-height: 480px;
}

.chart-span-2 {
  grid-column: span 2;
}

.map-section {
  margin-top: 18px;
}

.world-map {
  position: relative;
  width: 100%;
  min-height: 560px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background:
    linear-gradient(rgba(0, 255, 36, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 36, 0.045) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(0, 255, 36, 0.08), transparent 70%),
    rgba(0, 0, 0, 0.38);
  background-size: 36px 36px, 36px 36px, auto, auto;
}

.world-map.leaflet-container {
  background: #06100b;
  font-family: inherit;
}

.world-map > svg {
  display: block;
  width: 100%;
  height: 560px;
}

.world-map .leaflet-tile {
  filter: saturate(0.58) hue-rotate(72deg) brightness(1.08) contrast(0.94);
}

.world-map .leaflet-control-attribution,
.world-map .leaflet-control-zoom a {
  color: var(--muted);
  border-color: var(--line-soft);
  background: rgba(0, 0, 0, 0.72);
}

.world-map .leaflet-control-zoom a:hover {
  color: var(--neon);
  background: rgba(0, 0, 0, 0.9);
}

.world-map .leaflet-tooltip {
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.94);
  box-shadow: 0 0 22px rgba(0, 255, 36, 0.34);
  font-weight: 800;
  z-index: 1000;
}

.world-map .leaflet-tooltip strong {
  color: var(--neon);
}

.leaflet-neon-marker {
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
}

.leaflet-neon-marker span {
  display: block;
  min-width: 22px;
  min-height: 22px;
  border: 2px solid var(--neon);
  border-radius: 999px;
  background: rgba(0, 255, 36, 0.32);
  box-shadow:
    0 0 10px rgba(0, 255, 36, 0.96),
    0 0 26px rgba(0, 255, 36, 0.58),
    inset 0 0 10px rgba(255, 255, 255, 0.2);
}

.leaflet-neon-marker span::after {
  display: block;
  width: 100%;
  height: 100%;
  content: "";
  border-radius: inherit;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.76), transparent 42%);
  opacity: 0.72;
}

.leaflet-empty-state,
.leaflet-map-summary {
  padding: 10px 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.78);
  font-weight: 800;
}

.leaflet-map-summary {
  color: var(--neon);
}

.map-land {
  fill: rgba(0, 255, 36, 0.13);
  stroke: rgba(0, 255, 36, 0.36);
  stroke-width: 1.6;
}

.map-bubble {
  cursor: pointer;
  fill: rgba(0, 255, 36, 0.58);
  stroke: var(--neon);
  stroke-width: 2;
  filter: drop-shadow(0 0 14px rgba(0, 255, 36, 0.78));
}

.map-label {
  fill: var(--text);
  font: 800 11px system-ui, sans-serif;
  pointer-events: none;
  text-anchor: middle;
  text-shadow: 0 0 8px #000;
}

.empty-map {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  font-weight: 800;
}

.pie-chart {
  display: block;
  width: 100%;
  max-width: 420px;
  height: auto;
  margin: 4px auto 18px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 0.78rem;
  font-weight: 700;
}

.legend-item i {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  box-shadow: 0 0 10px currentColor;
}

.legend-item strong {
  color: var(--text);
}

.chart-tooltip {
  position: fixed;
  z-index: 20;
  display: grid;
  gap: 3px;
  max-width: 240px;
  padding: 10px 12px;
  color: var(--text);
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.88);
  box-shadow: 0 0 18px rgba(0, 255, 36, 0.22);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.chart-tooltip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.chart-tooltip strong {
  color: var(--neon);
}

.chart-tooltip span {
  color: var(--muted);
  font-size: 0.84rem;
}

.user-form-surface {
  margin-bottom: 18px;
}

.user-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.user-form .primary-button,
.user-active-row {
  align-self: end;
}

.user-active-row {
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.38);
}

.surface-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.pulse-line {
  width: min(44vw, 420px);
  height: 4px;
  background: var(--neon);
  box-shadow: 0 0 18px var(--neon);
}

.neon-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
}

.neon-table th,
.neon-table td {
  padding: 14px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
}

.neon-table th {
  color: var(--neon);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.users-table th:last-child,
.users-table td:last-child {
  width: 120px;
  text-align: right;
}

.table-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.inline-form {
  display: inline;
  margin: 0;
}

.state-pill,
.current-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
}

.state-pill.is-active {
  color: #001d05;
  background: var(--neon);
  box-shadow: 0 0 14px rgba(0, 255, 36, 0.24);
}

.state-pill.is-disabled {
  color: #ffdbe4;
  background: rgba(255, 79, 123, 0.16);
  border: 1px solid rgba(255, 79, 123, 0.32);
}

.current-badge {
  margin-left: 8px;
  color: var(--neon);
  border: 1px solid var(--line);
  background: rgba(0, 255, 36, 0.08);
}

@media (max-width: 860px) {
  .app-frame {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 3;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-brand {
    margin-bottom: 16px;
  }

  .side-nav {
    grid-template-columns: repeat(4, minmax(max-content, 1fr));
    overflow-x: auto;
  }

  .side-nav-group,
  .side-nav-submenu {
    display: contents;
  }

  .content {
    padding: 24px;
  }

  .topbar,
  .surface-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .status-grid,
  .module-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-span-2 {
    grid-column: auto;
  }

  .user-form {
    grid-template-columns: 1fr;
  }

  .stats-filter,
  .stats-export {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .auth-page,
  .content,
  .sidebar {
    padding: 18px;
  }

  .login-panel {
    padding: 24px;
  }

  .side-nav {
    margin-right: -18px;
    padding-right: 18px;
  }
}
