:root {
  --bg: #071018;
  --bg-soft: #0a131d;
  --panel: rgba(15, 24, 35, 0.94);
  --panel-strong: #101a26;
  --border: #223142;
  --border-soft: #182536;
  --text: #d9e3ef;
  --muted: #8292a6;
  --muted-strong: #a8b5c5;
  --green: #42d392;
  --amber: #f2b84b;
  --orange: #ff8c42;
  --red: #ff5d69;
  --purple: #a98cff;
  --blue: #6aa9ff;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(52, 98, 138, 0.12), transparent 36rem),
    linear-gradient(180deg, #08111a 0%, var(--bg) 34%, #060d14 100%);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

.site-header {
  border-bottom: 1px solid var(--border-soft);
  background: rgba(7, 16, 24, 0.84);
  backdrop-filter: blur(14px);
}

.header-shell,
.dashboard-shell {
  width: min(1220px, calc(100% - 32px));
  margin: 0 auto;
}

.header-shell { padding: 30px 0 26px; }
.brand-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.eyebrow,
.section-kicker {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

h1, h2, p { margin: 0; }
h1 {
  margin-top: 7px;
  color: #f3f7fb;
  font-family: var(--mono);
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.1;
  letter-spacing: 0.08em;
}

.subtitle {
  max-width: 760px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(66, 211, 146, 0.3);
  border-radius: 999px;
  color: var(--green);
  background: rgba(66, 211, 146, 0.08);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 4px rgba(66, 211, 146, 0.09);
  animation: pulse 2s ease-in-out infinite;
}

.live-pill.is-offline {
  color: var(--red);
  border-color: rgba(255, 93, 105, 0.3);
  background: rgba(255, 93, 105, 0.08);
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.82); }
}

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

.metric-card {
  min-width: 0;
  padding: 15px 16px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(17, 28, 41, 0.96), rgba(11, 20, 30, 0.96));
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.018);
}

.metric-card small {
  display: block;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.metric-card span {
  display: block;
  margin-top: 7px;
  color: #f4f8fb;
  font-family: var(--mono);
  font-size: clamp(22px, 4vw, 30px);
  font-weight: 750;
  line-height: 1;
}

.dashboard-shell {
  display: grid;
  gap: 18px;
  padding: 22px 0 28px;
}

.panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.16);
}

.panel-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 17px 18px 14px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-heading h2 {
  margin-top: 5px;
  color: #eef4f9;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.panel-heading p {
  max-width: 570px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  text-align: right;
}
.compact-heading { align-items: center; }

.table-wrap { width: 100%; overflow: hidden; }
table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

th {
  padding: 10px 12px;
  color: #6f8196;
  border-bottom: 1px solid var(--border-soft);
  background: rgba(8, 16, 25, 0.52);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-align: left;
  text-transform: uppercase;
}

td {
  padding: 11px 12px;
  color: var(--muted-strong);
  border-bottom: 1px solid rgba(31, 45, 61, 0.62);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgba(255, 255, 255, 0.018); }
tr.new-hit td { animation: hit-flash 1.2s ease-out; }

@keyframes hit-flash {
  0% { background: rgba(255, 93, 105, 0.11); }
  100% { background: transparent; }
}

#live-table th:nth-child(1) { width: 74px; }
#live-table th:nth-child(2) { width: 128px; }
#live-table th:nth-child(3) { width: 180px; }
#live-table th:nth-child(4) { width: 160px; }
#live-table th:nth-child(5) { width: 210px; }
#live-table th:nth-child(6) { width: 135px; }
#live-table th:nth-child(7) { width: 116px; }

.cell-time,
.cell-ip,
.cell-path,
.cell-model {
  font-family: var(--mono);
}
.cell-time { color: #73859a; }
.cell-ip { color: var(--green); font-weight: 650; }
.cell-source { color: #c5d1df; }
.cell-client,
.cell-path,
.cell-model {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cell-client { color: #c7d4e2; }
.cell-path { color: #9eb1c5; }
.cell-model { color: #8fa1b5; font-size: 11px; }

.trap-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
.trap-neutral { color: var(--amber); background: rgba(242,184,75,.08); border-color: rgba(242,184,75,.22); }
.trap-bait { color: var(--orange); background: rgba(255,140,66,.09); border-color: rgba(255,140,66,.25); }
.trap-warning { color: #ff7e72; background: rgba(255,93,105,.07); border-color: rgba(255,93,105,.32); }
.trap-deception { color: var(--purple); background: rgba(169,140,255,.09); border-color: rgba(169,140,255,.25); }
.trap-critical {
  color: #fff0f1;
  background: rgba(255, 65, 79, 0.2);
  border-color: rgba(255, 93, 105, 0.55);
  box-shadow: 0 0 0 1px rgba(255,93,105,.05), 0 0 18px rgba(255,65,79,.08);
}

.secondary-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(300px, .75fr);
  gap: 18px;
}

#wall-table th:nth-child(1) { width: 40%; }
#wall-table th:nth-child(2) { width: 18%; }
#wall-table td:first-child { color: var(--green); font-family: var(--mono); }
#wall-table td:nth-child(2) { color: #d9e4ef; font-family: var(--mono); }
#wall-table td:last-child { color: #8091a5; font-family: var(--mono); font-size: 11px; }

.source-chips {
  display: grid;
  gap: 8px;
  padding: 14px;
}
.source-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border-soft);
  border-radius: 9px;
  background: rgba(10, 19, 29, 0.72);
}
.source-chip-label {
  min-width: 0;
  overflow: hidden;
  color: #bfcddd;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.source-chip b {
  flex: 0 0 auto;
  color: var(--green);
  font-family: var(--mono);
  font-size: 11px;
}

.empty-state {
  padding: 24px 14px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 2px 16px 28px;
  color: #536274;
  font-family: var(--mono);
  font-size: 9px;
  text-align: center;
}

@media (max-width: 900px) {
  .secondary-grid { grid-template-columns: 1fr; }
  #live-table th:nth-child(5) { width: 160px; }
  .panel-heading { align-items: flex-start; }
}

@media (max-width: 760px) {
  .header-shell,
  .dashboard-shell {
    width: min(100% - 20px, 640px);
  }
  .header-shell { padding: 22px 0 20px; }
  .brand-row { align-items: center; }
  h1 { font-size: 21px; }
  .subtitle { font-size: 12px; line-height: 1.55; }
  .live-pill { min-height: 27px; padding: 0 9px; font-size: 9px; }

  .metric-grid { gap: 7px; margin-top: 18px; }
  .metric-card { padding: 11px 10px; border-radius: 10px; }
  .metric-card small { font-size: 8px; letter-spacing: 0.04em; }
  .metric-card span { margin-top: 6px; font-size: 20px; }

  .dashboard-shell { gap: 12px; padding-top: 12px; }
  .panel { border-radius: 12px; }
  .panel-heading {
    display: block;
    padding: 14px 13px 12px;
  }
  .panel-heading p {
    margin-top: 8px;
    max-width: none;
    font-size: 10px;
    line-height: 1.45;
    text-align: left;
  }

  .live-table-wrap { overflow: visible; }
  #live-table,
  #live-table tbody,
  #feed tr,
  #live-table td {
    display: block;
    width: 100%;
  }
  #live-table thead { display: none; }
  #live-table { padding: 10px; }
  #feed { display: grid; gap: 9px; }
  #feed tr {
    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "time ip trap"
      "source source source"
      "client client client"
      "path path path"
      "model model model";
    gap: 0;
    padding: 11px 12px 10px;
    border: 1px solid var(--border-soft);
    border-radius: 10px;
    background: rgba(9, 18, 28, 0.82);
  }
  #feed tr:hover td { background: transparent; }
  #live-table td {
    padding: 0;
    border: 0;
    white-space: normal;
  }
  #live-table td::before {
    display: inline-block;
    margin-right: 8px;
    color: #607287;
    font-family: var(--mono);
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    content: attr(data-label);
  }
  #live-table .cell-time,
  #live-table .cell-ip {
    display: inline;
    width: auto;
    font-size: 10px;
  }
  #live-table .cell-time { grid-area: time; margin-right: 8px; }
  #live-table .cell-time::before,
  #live-table .cell-ip::before,
  #live-table .cell-trap::before { display: none; }
  #live-table .cell-ip { grid-area: ip; margin-left: 8px; }
  #live-table .cell-source {
    grid-area: source;
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid var(--border-soft);
    font-size: 11px;
  }
  #live-table .cell-client { grid-area: client; margin-top: 7px; font-size: 11px; }
  #live-table .cell-path { grid-area: path; margin-top: 7px; font-size: 10px; word-break: break-word; }
  #live-table .cell-model { grid-area: model; margin-top: 7px; font-size: 10px; }
  #live-table .cell-model.is-empty { display: none; }
  #live-table .cell-trap {
    grid-area: trap;
    width: auto;
    justify-self: end;
  }
  .trap-badge { min-height: 22px; font-size: 8px; }

  .secondary-grid { gap: 12px; }
  .wall-wrap { overflow-x: visible; }
  #wall-table { table-layout: auto; font-size: 10px; }
  #wall-table th, #wall-table td { padding: 9px 8px; }
  #wall-table th:nth-child(1) { width: auto; }
  #wall-table th:nth-child(2) { width: 58px; }
  #wall-table th:nth-child(3) { width: 110px; }
  #wall-table td:last-child { font-size: 9px; }

  .source-chips { padding: 10px; }
  .source-chip { min-height: 36px; }
  footer { display: block; padding-bottom: 22px; line-height: 1.6; }
  .footer-sep { display: none; }
  footer span { display: block; }
}

@media (max-width: 390px) {
  .metric-card small { min-height: 20px; }
  .metric-card span { font-size: 18px; }
  #wall-table th:nth-child(3) { width: 96px; }
  #wall-table td:last-child { font-size: 8px; }
}

/* Persistent signal history */
.signal-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(138px, 1fr));
  gap: 9px;
  padding: 14px 18px 12px;
}

.signal-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: 11px;
  background: rgba(8, 17, 26, 0.72);
}
.signal-card-top {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 22px;
}
.signal-icon { font-size: 13px; }
.signal-name {
  overflow: hidden;
  color: var(--muted-strong);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-transform: uppercase;
}
.signal-card strong {
  display: block;
  margin-top: 8px;
  color: #f2f7fb;
  font-family: var(--mono);
  font-size: 24px;
  line-height: 1;
}
.signal-card-meta {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  color: #6f8195;
  font-family: var(--mono);
  font-size: 8px;
}
.signal-critical {
  border-color: rgba(255, 93, 105, 0.38);
  background: linear-gradient(180deg, rgba(255, 65, 79, 0.10), rgba(15, 20, 29, 0.82));
  box-shadow: inset 0 1px 0 rgba(255, 130, 140, 0.06);
}
.signal-critical strong { color: #ff818b; }
.signal-bait strong { color: var(--orange); }
.signal-warning strong { color: #ff8a7e; }
.signal-deception strong { color: var(--purple); }

.signal-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 2px 18px 13px;
  border-bottom: 1px solid var(--border-soft);
}
.signal-filter {
  min-height: 30px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: #8292a6;
  background: rgba(9, 18, 27, 0.75);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  cursor: pointer;
}
.signal-filter:hover,
.signal-filter.is-active {
  color: #e7eef6;
  border-color: #3a5068;
  background: rgba(33, 52, 71, 0.66);
}

.signal-events {
  display: grid;
  gap: 8px;
  padding: 12px 18px 16px;
}
.signal-event {
  padding: 11px 12px;
  border: 1px solid var(--border-soft);
  border-left-width: 3px;
  border-radius: 10px;
  background: rgba(8, 17, 26, 0.66);
}
.signal-event-neutral { border-left-color: var(--amber); }
.signal-event-bait { border-left-color: var(--orange); }
.signal-event-warning { border-left-color: var(--red); }
.signal-event-deception { border-left-color: var(--purple); }
.signal-event-critical {
  border-color: rgba(255, 93, 105, 0.28);
  border-left-color: var(--red);
  background: linear-gradient(90deg, rgba(255, 65, 79, 0.07), rgba(8, 17, 26, 0.70) 30%);
}
.signal-event-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.signal-event-title {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.signal-event-title time,
.signal-event-ip,
.signal-model,
.signal-path {
  font-family: var(--mono);
}
.signal-event-title time { color: #718399; font-size: 9px; }
.signal-event-ip { color: var(--green); font-size: 10px; }
.signal-event-body {
  display: grid;
  grid-template-columns: minmax(145px, .9fr) minmax(145px, .9fr) minmax(180px, 1.35fr) minmax(120px, .85fr);
  gap: 8px 14px;
  margin-top: 9px;
  color: #9fb0c2;
  font-size: 10px;
}
.signal-event-body > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.signal-path { color: #bcc9d7; }
.signal-model { color: #8799ae; }

@media (max-width: 760px) {
  .signal-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 10px 10px 9px;
  }
  .signal-card { padding: 10px; }
  .signal-card strong { font-size: 21px; }
  .signal-toolbar { padding: 2px 10px 10px; gap: 6px; }
  .signal-filter { min-height: 29px; font-size: 8px; }
  .signal-events { padding: 9px 10px 11px; }
  .signal-event { padding: 10px; }
  .signal-event-head { align-items: flex-start; }
  .signal-event-body {
    grid-template-columns: 1fr;
    gap: 5px;
    margin-top: 9px;
  }
  .signal-event-body > span { white-space: normal; overflow-wrap: anywhere; }
}

@media (max-width: 390px) {
  .signal-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .signal-card { padding: 9px; }
  .signal-name { font-size: 8px; }
  .signal-event-head { display: grid; gap: 7px; }
  .signal-event-ip { justify-self: start; }
}

/* Final UX polish */
.live-status-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex: 0 0 auto;
}

.last-updated {
  color: #63758a;
  font-family: var(--mono);
  font-size: 8px;
  line-height: 1.25;
  text-align: right;
  white-space: nowrap;
}

.live-pill.is-stale:not(.is-offline) {
  color: var(--amber);
  border-color: rgba(242, 184, 75, 0.34);
  background: rgba(242, 184, 75, 0.08);
}

.signal-filter:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.signal-filter {
  transition: border-color 140ms ease, background-color 140ms ease, color 140ms ease, transform 140ms ease;
}
.signal-filter:active { transform: translateY(1px); }

.loading-state,
.error-state {
  grid-column: 1 / -1;
  width: 100%;
}
.error-state { color: #c79086; }

@media (max-width: 760px) {
  .live-status-wrap { gap: 4px; }
  .last-updated { font-size: 7px; }
  .signal-filter { min-height: 34px; padding-inline: 11px; }
  #feed tr { overflow: hidden; }
  #live-table .cell-source,
  #live-table .cell-client,
  #live-table .cell-path,
  #live-table .cell-model { overflow-wrap: anywhere; }
}

@media (max-width: 340px) {
  .header-shell,
  .dashboard-shell { width: calc(100% - 16px); }
  .brand-row { gap: 10px; }
  h1 { font-size: 18px; letter-spacing: 0.055em; }
  .eyebrow { font-size: 8px; letter-spacing: 0.12em; }
  .live-pill { padding-inline: 8px; }
  .last-updated { max-width: 100px; white-space: normal; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-card:last-child { grid-column: 1 / -1; }
  .metric-card small { min-height: 0; }
  .signal-summary-grid { gap: 6px; padding-inline: 8px; }
  .signal-card-meta { font-size: 7px; }
  .signal-toolbar { padding-inline: 8px; }
  .signal-events { padding-inline: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
