:root {
  --bg: #06101f;
  --bg-deep: #020713;
  --surface: #0b1729;
  --surface-2: #10223a;
  --surface-3: #132b46;
  --line: #1f3b5c;
  --line-soft: rgba(126, 166, 204, 0.18);
  --text: #edf7ff;
  --muted: #8aa7c4;
  --muted-2: #5f7f9e;
  --cyan: #27d6e8;
  --cyan-soft: rgba(39, 214, 232, 0.16);
  --red: #ff5268;
  --red-soft: rgba(255, 82, 104, 0.14);
  --orange: #ffb14a;
  --orange-soft: rgba(255, 177, 74, 0.16);
  --green: #35d07f;
  --green-soft: rgba(53, 208, 127, 0.16);
  --violet: #9d7cff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 8px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(39, 214, 232, 0.12), transparent 28rem),
    linear-gradient(135deg, var(--bg-deep), var(--bg) 48%, #0c1020);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line-soft);
  background: rgba(5, 13, 26, 0.94);
  backdrop-filter: blur(20px);
  overflow-y: auto;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(39, 214, 232, 0.55);
  border-radius: var(--radius);
  color: var(--cyan);
  background: linear-gradient(145deg, rgba(39, 214, 232, 0.18), rgba(157, 124, 255, 0.1));
}

.brand strong {
  display: block;
  font-size: 15px;
  line-height: 1.25;
}

.brand span,
.target-box span,
.role-panel small,
.panel-header span,
.period-label,
.metric-card small,
.metric-card span,
.muted,
.posture-grid span,
.report-summary span {
  color: var(--muted);
}

.target-box,
.role-panel {
  margin-top: 22px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(16, 34, 58, 0.64);
}

.target-box span,
.role-panel label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.target-box a {
  display: block;
  overflow-wrap: anywhere;
  color: var(--cyan);
  font-weight: 700;
  text-decoration: none;
}

.nav-list {
  display: grid;
  gap: 8px;
  margin-top: 22px;
}

.nav-item,
.button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--text);
  background: transparent;
}

.nav-item {
  justify-content: flex-start;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--muted);
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  border-color: rgba(39, 214, 232, 0.36);
  color: var(--text);
  background: var(--cyan-soft);
}

.nav-item svg,
.button svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.role-panel select,
.filter-strip select,
.filter-strip input,
.control-stack select,
.control-stack input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: #08172a;
  outline: none;
}

.role-panel select,
.control-stack select,
.control-stack input,
.filter-strip input,
.filter-strip select {
  padding: 9px 10px;
}

.role-panel small {
  display: block;
  margin-top: 8px;
}

.main {
  min-width: 0;
  padding: 22px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 8px;
  font-size: clamp(26px, 3vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 2px;
  font-size: 16px;
  line-height: 1.25;
}

.topbar-actions,
.inline-actions,
.report-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid rgba(53, 208, 127, 0.44);
  border-radius: 999px;
  color: #c6ffe0;
  background: var(--green-soft);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 6px rgba(53, 208, 127, 0.16);
}

.button {
  gap: 8px;
  min-height: 40px;
  padding: 9px 12px;
  font-weight: 800;
  white-space: nowrap;
}

.button.secondary {
  border-color: rgba(39, 214, 232, 0.34);
  background: rgba(39, 214, 232, 0.1);
}

.button.ghost {
  align-self: end;
  border-color: var(--line-soft);
  background: rgba(255, 255, 255, 0.03);
}

.button.danger {
  border-color: rgba(255, 82, 104, 0.45);
  background: var(--red-soft);
}

.button.warning {
  border-color: rgba(255, 177, 74, 0.45);
  background: var(--orange-soft);
}

.button.safe {
  border-color: rgba(53, 208, 127, 0.45);
  background: var(--green-soft);
}

.button:disabled,
.icon-button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.icon-button {
  width: 38px;
  height: 38px;
  border-color: var(--line-soft);
  background: rgba(255, 255, 255, 0.04);
}

.filter-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr)) auto;
  gap: 12px;
  margin: 22px 0;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(8, 20, 36, 0.82);
}

.filter-strip label,
.control-stack label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.metric-card,
.panel,
.rule-tile {
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(16, 34, 58, 0.92), rgba(9, 20, 35, 0.9));
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.18);
}

.metric-card {
  position: relative;
  min-height: 154px;
  padding: 17px;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -42px;
  bottom: -42px;
  width: 120px;
  height: 120px;
  border: 1px solid rgba(39, 214, 232, 0.16);
  border-radius: 50%;
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-bottom: 14px;
  border-radius: var(--radius);
}

.metric-icon.danger {
  color: var(--red);
  background: var(--red-soft);
}

.metric-icon.warning {
  color: var(--orange);
  background: var(--orange-soft);
}

.metric-icon.safe {
  color: var(--green);
  background: var(--green-soft);
}

.metric-icon.cyan {
  color: var(--cyan);
  background: var(--cyan-soft);
}

.metric-card > span {
  display: block;
  min-height: 32px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 8px 0 4px;
  font-size: clamp(24px, 2.8vw, 36px);
  line-height: 1;
}

.score-card,
.status-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.score-ring {
  display: grid;
  place-items: center;
  align-self: flex-start;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #0b1729 58%, transparent 59%),
    conic-gradient(var(--green) 0deg, var(--green) 320deg, rgba(255, 255, 255, 0.1) 320deg);
}

.score-ring strong {
  margin: 0;
  font-size: 28px;
}

.score-ring small {
  margin-top: -24px;
  font-size: 11px;
}

.status-card strong {
  color: var(--green);
}

.dashboard-grid,
.rules-layout,
.report-layout,
.split-layout {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.dashboard-grid {
  grid-template-columns: 1.4fr 1fr;
}

.rules-layout,
.report-layout,
.split-layout {
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.65fr);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel-wide {
  grid-column: 1 / -1;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-header svg {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  color: var(--cyan);
}

.chart-box {
  position: relative;
  height: 320px;
  min-height: 260px;
}

.chart-box.tall {
  height: 360px;
}

.panel-alerts {
  grid-column: 1 / -1;
}

.alert-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.alert-item {
  display: grid;
  gap: 8px;
  padding: 13px;
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--orange);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.alert-item.critical {
  border-left-color: var(--red);
}

.alert-item.high {
  border-left-color: var(--orange);
}

.alert-item.medium {
  border-left-color: var(--cyan);
}

.alert-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 800;
}

.alert-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.attack-map {
  height: 650px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: #07111f;
  overflow: hidden;
}

.leaflet-container {
  background: #07111f;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: #0b1729;
  color: var(--text);
  border: 1px solid var(--line-soft);
}

.map-popup {
  min-width: 210px;
}

.map-popup strong {
  display: block;
  margin-bottom: 6px;
  color: var(--cyan);
}

.map-popup span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.table-wrap.compact {
  max-height: 650px;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.compact table {
  min-width: 620px;
}

th,
td {
  padding: 12px 13px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #bed8f0;
  background: #0b182d;
  font-size: 12px;
  text-transform: uppercase;
  white-space: nowrap;
}

td {
  color: #d7eaff;
  font-size: 13px;
}

tbody tr:hover {
  background: rgba(39, 214, 232, 0.055);
}

.ip-link {
  border: 0;
  padding: 0;
  color: var(--cyan);
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag.blocked,
.tag.safe {
  color: #bfffe0;
  background: var(--green-soft);
}

.tag.allowed {
  color: #beeaff;
  background: var(--cyan-soft);
}

.tag.suspicious,
.tag.medium {
  color: #fff1c8;
  background: var(--orange-soft);
}

.tag.high,
.tag.warning {
  color: #ffdca9;
  background: var(--orange-soft);
}

.tag.critical,
.tag.danger {
  color: #ffd0d7;
  background: var(--red-soft);
}

.page-label {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

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

.rule-tile {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 92px;
  padding: 14px;
}

.rule-tile strong {
  display: block;
  margin-bottom: 5px;
}

.rule-tile span {
  color: var(--muted);
  font-size: 13px;
}

.switch {
  position: relative;
  display: inline-flex;
  width: 50px;
  height: 28px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #07111f;
  transition: 0.2s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--muted);
  transition: 0.2s ease;
}

.switch input:checked + span {
  border-color: rgba(53, 208, 127, 0.6);
  background: var(--green-soft);
}

.switch input:checked + span::after {
  transform: translateX(22px);
  background: var(--green);
}

.control-stack {
  display: grid;
  gap: 14px;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.range-value {
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
}

.policy-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.policy-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
}

.report-actions {
  margin-bottom: 16px;
}

.report-summary,
.posture-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.report-summary div,
.posture-grid div {
  min-height: 88px;
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.report-summary strong,
.posture-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.55);
}

.drawer.open {
  display: flex;
}

.drawer-panel {
  position: relative;
  width: min(720px, 100%);
  height: 100%;
  padding: 24px;
  border-left: 1px solid var(--line-soft);
  background: #07111f;
  box-shadow: var(--shadow);
  overflow-y: auto;
}

.drawer-close {
  position: absolute;
  top: 18px;
  right: 18px;
}

.drawer-head {
  padding-right: 54px;
}

.drawer-head h2 {
  margin-bottom: 8px;
  font-size: 28px;
}

.drawer-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 16px 0;
}

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

.detail-grid div {
  padding: 14px;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
}

.detail-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 20px;
}

.toast-container {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 10px;
  width: min(420px, calc(100vw - 36px));
}

.toast {
  padding: 13px 14px;
  border: 1px solid rgba(39, 214, 232, 0.3);
  border-left: 3px solid var(--cyan);
  border-radius: var(--radius);
  background: rgba(9, 20, 35, 0.98);
  box-shadow: var(--shadow);
}

.toast strong {
  display: block;
  margin-bottom: 4px;
}

.toast span {
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1260px) {
  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .dashboard-grid,
  .rules-layout,
  .report-layout,
  .split-layout {
    grid-template-columns: 1fr;
  }

  .alert-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filter-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .main,
  .sidebar,
  .drawer-panel {
    padding: 16px;
  }

  .nav-list,
  .metric-grid,
  .rules-grid,
  .report-summary,
  .posture-grid,
  .detail-grid,
  .alert-list,
  .filter-strip {
    grid-template-columns: 1fr;
  }

  .nav-item {
    min-height: 42px;
  }

  .input-action {
    grid-template-columns: 1fr;
  }

  .attack-map {
    height: 520px;
  }

  table {
    min-width: 900px;
  }
}
