/*
 * NYXIEYES 2.0 :: painel web (radar).
 *
 * Alvo: navegador moderno, 320px ate 2560px. Sem framework, sem CDN.
 *
 * Direcao visual: console de interceptacao. Fundo quase preto, linhas de
 * 1px, tipografia monoespacada nos numeros, acido lima apenas para o que
 * esta vivo. Sem cartao arredondado com sombra difusa, sem gradiente
 * decorativo, sem emoji.
 */

:root {
  --bg: #0a0d10;
  --bg-elev: #0e1317;
  --surface: #11171c;
  --surface-2: #161d23;
  --surface-3: #1b232a;
  --line: #1d262e;
  --line-2: #2b3742;
  --text: #dde5ec;
  --text-2: #9aa8b4;
  --text-3: #6b7a87;
  --accent: #b8f04a;
  --accent-2: #d8ff7a;
  --accent-ink: #0a0d10;
  --danger: #ff6b6b;
  --ok: #4fd1c5;
  --warn: #f2b544;
  --violet: #a78bfa;
  --blue: #5aa9f7;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --t-micro: 11px;
  --t-label: 12px;
  --t-body: 13.5px;
  --t-table: 13px;
  --t-title: 15px;
  --t-stat: 22px;

  --rail-w: 208px;
  --rail-h: 38px;
  --drawer-w: 420px;
  --top-h: 52px;
  --radius: 2px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(184, 240, 74, 0.25);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* ─── tipografia utilitaria ─────────────────────────────────────────────── */

.eyebrow {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.mono {
  font-family: var(--font-mono);
  font-size: var(--t-table);
}

.dim {
  color: var(--text-3);
}

.mid {
  color: var(--text-2);
}

/* ─── gate de senha ─────────────────────────────────────────────────────── */

.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(var(--line) 1px, transparent 1px) 0 0 / 100% 48px,
    linear-gradient(90deg, var(--line) 1px, transparent 1px) 0 0 / 48px 100%,
    var(--bg);
}

.gate__box {
  width: min(380px, 100%);
  background: var(--bg-elev);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
}

.gate__head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.gate__mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.gate__title {
  margin: 0;
  font-size: var(--t-title);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.gate__sub {
  margin: 0;
  font-size: var(--t-label);
  color: var(--text-3);
}

.gate__form {
  padding: 18px 20px 20px;
  display: grid;
  gap: 14px;
}

.gate__row {
  display: grid;
  gap: 6px;
}

.gate__error {
  min-height: 16px;
  font-size: var(--t-label);
  font-family: var(--font-mono);
  color: var(--danger);
}

.gate__hint {
  font-size: var(--t-label);
  color: var(--text-3);
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.gate__hint code {
  font-family: var(--font-mono);
  color: var(--text-2);
}

/* ─── campos ────────────────────────────────────────────────────────────── */

.field {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--t-table);
  padding: 8px 10px;
  transition: border-color 120ms ease, background 120ms ease;
}

.field:hover {
  border-color: var(--line-2);
  background: #080b0d;
}

.field:focus {
  outline: none;
  border-color: var(--accent);
  background: #080b0d;
}

.field::placeholder {
  color: var(--text-3);
}

select.field {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 26px;
  cursor: pointer;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--t-label);
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 7px 12px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:hover {
  background: var(--surface-3);
  border-color: var(--text-3);
}

.btn:active {
  transform: translateY(0.5px);
}

.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.btn--primary:hover {
  background: var(--accent-2);
  border-color: var(--accent-2);
}

.btn--ghost {
  background: transparent;
}

.btn--sm {
  padding: 4px 8px;
  font-size: var(--t-label);
}

.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ─── estrutura ─────────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) 0px;
  grid-template-rows: var(--top-h) minmax(0, 1fr);
  grid-template-areas:
    "top top top"
    "rail main drawer";
  height: 100vh;
  transition: grid-template-columns 160ms ease;
}

.shell.is-drawer {
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--drawer-w);
}

/* ─── barra superior ────────────────────────────────────────────────────── */

.top {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg-elev);
}

.top__mark {
  display: flex;
  align-items: center;
  gap: 9px;
  width: calc(var(--rail-w) - 16px);
  flex: none;
}

.top__word {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--text);
}

.top__ver {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--text-3);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  padding: 1px 4px;
}

.top__stats {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-left: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.top__stat {
  padding: 4px 11px;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 0;
  min-width: 62px;
}

.top__stat:last-child {
  border-right: 0;
}

.top__stat b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
}

.top__stat span {
  font-size: var(--t-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.live__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  flex: none;
}

.live.is-on {
  color: var(--accent);
}

.live.is-on .live__dot {
  background: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}

.live.is-down {
  color: var(--danger);
}

.live.is-down .live__dot {
  background: var(--danger);
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

@media (prefers-reduced-motion: reduce) {
  .live.is-on .live__dot {
    animation: none;
  }
  * {
    transition-duration: 1ms !important;
  }
}

/* ─── rail ──────────────────────────────────────────────────────────────── */

.rail {
  grid-area: rail;
  border-right: 1px solid var(--line);
  background: var(--bg-elev);
  padding: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.rail__label {
  padding: 6px 16px 8px;
}

.rail__item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 16px;
  background: none;
  border: 0;
  border-left: 2px solid transparent;
  color: var(--text-2);
  font-family: var(--font-ui);
  font-size: var(--t-body);
  text-align: left;
  cursor: pointer;
  transition: background 100ms ease, color 100ms ease;
}

.rail__item:hover {
  background: var(--surface);
  color: var(--text);
}

.rail__item.is-active {
  background: var(--surface);
  border-left-color: var(--accent);
  color: var(--text);
}

.rail__key {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--text-3);
}

.rail__count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-label);
  color: var(--text-3);
}

.rail__spacer {
  flex: 1;
}

.rail__foot {
  padding: 12px 16px 0;
  border-top: 1px solid var(--line);
  margin-top: 10px;
  display: grid;
  gap: 6px;
}

/* ─── area principal ────────────────────────────────────────────────────── */

.main {
  grid-area: main;
  overflow: auto;
  min-width: 0;
}

.view {
  display: none;
  flex-direction: column;
  min-height: 100%;
}

.view.is-active {
  display: flex;
}

.view__head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  gap: 14px;
  padding: 14px 18px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}

.view__titles {
  display: grid;
  gap: 2px;
}

.view__title {
  margin: 0;
  font-size: var(--t-title);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.view__desc {
  margin: 0;
  font-size: var(--t-label);
  color: var(--text-3);
}

.view__tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.view__tools .field {
  width: 230px;
}

.search {
  position: relative;
}

.search .field {
  padding-left: 28px;
}

.search__icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  display: flex;
}

/* ─── grade de indicadores ──────────────────────────────────────────────── */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  border-bottom: 1px solid var(--line);
}

.kpi {
  padding: 12px 18px;
  border-right: 1px solid var(--line);
  display: grid;
  gap: 2px;
}

.kpi:last-child {
  border-right: 0;
}

.kpi b {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-stat);
  font-weight: 500;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi span {
  font-size: var(--t-micro);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.kpi--alert b {
  color: var(--danger);
}

.kpi--accent b {
  color: var(--accent);
}

/* ─── tabela ────────────────────────────────────────────────────────────── */

.tablewrap {
  flex: 1;
  overflow: auto;
}

table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-table);
}

table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--line-2);
  text-align: left;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 12px;
  white-space: nowrap;
}

table.grid tbody td {
  border-bottom: 1px solid var(--line);
  padding: 7px 12px;
  vertical-align: middle;
  white-space: nowrap;
}

table.grid tbody tr {
  cursor: pointer;
  transition: background 90ms ease;
}

table.grid tbody tr:hover {
  background: var(--surface);
}

table.grid tbody tr.is-selected {
  background: var(--surface-2);
  box-shadow: inset 2px 0 0 var(--accent);
}

table.grid tbody tr.is-new {
  animation: flash 1.6s ease-out 1;
}

@keyframes flash {
  from {
    background: rgba(184, 240, 74, 0.16);
  }
  to {
    background: transparent;
  }
}

td.n,
th.n {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

td.host {
  font-family: var(--font-mono);
  color: var(--text);
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
}

td.wrap {
  white-space: normal;
  max-width: 420px;
}

.empty {
  padding: 44px 18px;
  text-align: center;
  color: var(--text-3);
  font-size: var(--t-body);
}

.empty b {
  display: block;
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 4px;
}

/* ─── badges e medidores ────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono);
  font-size: var(--t-label);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--o, var(--text-2));
  border: 1px solid color-mix(in srgb, var(--o, var(--line-2)) 42%, transparent);
  border-radius: var(--radius);
  padding: 1px 6px;
  white-space: nowrap;
}

.badge__dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--o, var(--text-3));
  flex: none;
}

[data-origin="operator"] {
  --o: var(--ok);
}
[data-origin="friend"] {
  --o: var(--warn);
}
[data-origin="clone"] {
  --o: var(--danger);
}
[data-origin="legacy"] {
  --o: var(--violet);
}
[data-origin="scanner"] {
  --o: var(--blue);
}
[data-origin="unknown"] {
  --o: var(--text-3);
}

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

.meter__track {
  width: 46px;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
  flex: none;
}

.meter__fill {
  height: 100%;
  background: var(--o, var(--text-2));
}

.meter__val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text-2);
  min-width: 30px;
  text-align: right;
}

.chip {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 5px;
  margin: 0 3px 3px 0;
}

/* ─── drawer ────────────────────────────────────────────────────────────── */

.drawer {
  grid-area: drawer;
  border-left: 1px solid var(--line);
  background: var(--bg-elev);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.shell:not(.is-drawer) .drawer {
  border-left-width: 0;
}

.drawer__head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.drawer__titles {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.drawer__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  word-break: break-all;
}

.drawer__body {
  overflow: auto;
  padding: 14px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.drawer__close {
  flex: none;
}

.block {
  display: grid;
  gap: 8px;
}

.block__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.block__title {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}

.kv {
  display: grid;
  grid-template-columns: 108px minmax(0, 1fr);
  gap: 4px 10px;
  font-size: var(--t-table);
}

.kv dt {
  font-family: var(--font-mono);
  font-size: var(--t-micro);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  padding-top: 2px;
}

.kv dd {
  margin: 0;
  font-family: var(--font-mono);
  word-break: break-word;
  color: var(--text);
}

.timeline {
  border-left: 1px solid var(--line-2);
  margin-left: 4px;
  padding-left: 12px;
  display: grid;
  gap: 12px;
}

.tl {
  position: relative;
  display: grid;
  gap: 3px;
}

.tl::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 5px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
}

.tl__top {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.tl__event {
  font-family: var(--font-mono);
  font-size: var(--t-table);
  color: var(--text);
}

.tl__time {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-label);
  color: var(--text-3);
}

.tl__meta {
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--text-3);
  word-break: break-all;
}

.formrow {
  display: flex;
  gap: 8px;
  align-items: center;
}

.formrow .field {
  flex: 1;
  min-width: 0;
}

.notice {
  font-size: var(--t-label);
  color: var(--text-3);
  border-left: 2px solid var(--line-2);
  padding-left: 10px;
}

.notice--err {
  color: var(--danger);
  border-left-color: var(--danger);
}

.notice--ok {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* ─── exportacao ────────────────────────────────────────────────────────── */

.formgrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.formgrid .field {
  margin-top: 4px;
}

/* ─── rodape de status ──────────────────────────────────────────────────── */

.status {
  border-top: 1px solid var(--line);
  padding: 7px 18px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: var(--t-label);
  color: var(--text-3);
  flex: none;
}

.status b {
  color: var(--text-2);
  font-weight: 500;
}

/* ─── responsivo ────────────────────────────────────────────────────────── */

/* O drawer vira overlay. Um véu cobre o conteudo e devolve o clique para
   fechar o painel de detalhe: sem ele, o drawer prende a tela. */
@media (max-width: 1180px) {
  .shell.is-drawer {
    grid-template-columns: var(--rail-w) minmax(0, 1fr) 0px;
  }

  .shell.is-drawer::before {
    content: "";
    position: fixed;
    inset: var(--top-h) 0 0 0;
    background: rgba(4, 7, 9, 0.62);
    z-index: 19;
  }

  /* A navegacao fica acima do veu: com o drawer aberto, trocar de secao
     continua possivel em vez de o painel prender a tela. */
  .rail {
    position: relative;
    z-index: 21;
  }

  .shell.is-drawer .drawer {
    position: fixed;
    top: var(--top-h);
    right: 0;
    bottom: 0;
    width: min(var(--drawer-w), 92vw);
    z-index: 20;
    border-left: 1px solid var(--line-2);
  }

  .shell:not(.is-drawer) .drawer {
    display: none;
  }
}

@media (max-width: 860px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--top-h) auto minmax(0, 1fr);
    grid-template-areas:
      "top"
      "rail"
      "main";
  }

  /* A faixa de navegacao continua visivel e clicavel com o drawer aberto:
     no celular o detalhe sobe de baixo, em vez de cobrir a tela inteira. */
  .shell.is-drawer::before {
    inset: var(--top-h) 0 0 0;
  }

  .shell.is-drawer .drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: min(72vh, 620px);
    border-left: 0;
    border-top: 1px solid var(--line-2);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: 0 -18px 40px rgba(0, 0, 0, 0.42);
  }

  .rail {
    flex-direction: row;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0;
    height: var(--rail-h);
  }

  .rail__label,
  .rail__spacer,
  .rail__foot {
    display: none;
  }

  .rail__item {
    border-left: 0;
    border-bottom: 2px solid transparent;
    width: auto;
    white-space: nowrap;
  }

  .rail__item.is-active {
    border-left: 0;
    border-bottom-color: var(--accent);
  }

  .top__mark {
    width: auto;
  }

  .top__stats .top__stat:nth-child(n + 3) {
    display: none;
  }

  .view__head {
    flex-wrap: wrap;
  }

  .view__tools {
    margin-left: 0;
    width: 100%;
  }

  .view__tools .field {
    width: 100%;
  }
}
