:root {
  --ink: #05080b;
  --panel: #081114;
  --panel-2: #0c1816;
  --line: rgba(94, 255, 186, 0.22);
  --line-strong: rgba(94, 255, 186, 0.48);
  --green: #3ef3a4;
  --green-2: #b8ffd8;
  --cyan: #6ae7ff;
  --gold: #d6ff4a;
  --text: #e8fff4;
  --muted: #8eaea0;
  --muted-2: #9eb8ab;
  --ink-paper: var(--text);
  --paper: var(--panel);
  --paper-2: #10201c;
  --ok: #8dffc3;
  --ok-bg: rgba(62, 243, 164, 0.14);
  --warn: #ffe08a;
  --warn-bg: rgba(255, 206, 92, 0.14);
  --bad: #ff9b9b;
  --bad-bg: rgba(255, 92, 92, 0.14);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  --sans: "Space Grotesk", "Segoe UI", sans-serif;
  color-scheme: dark;
  font-family: var(--sans);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  height: 100%;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(900px 480px at 8% -10%, rgba(62, 243, 164, 0.14), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(106, 231, 255, 0.12), transparent 50%),
    var(--ink);
  color: var(--text);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(106, 231, 255, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(106, 231, 255, 0.045) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at 50% 15%, #000 20%, transparent 78%);
}
body > * { position: relative; z-index: 1; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--cyan); }

.top {
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 16px 22px 10px;
}
.brand { display: flex; gap: 12px; align-items: center; flex: none; text-decoration: none; color: inherit; }
.brand .mark {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 12px;
  flex: none;
  border: 1px solid rgba(62, 243, 164, 0.45);
  box-shadow: 0 0 16px rgba(62, 243, 164, 0.28);
}
.intro {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 14px;
  padding: 24px;
  background:
    radial-gradient(520px 320px at 50% 42%, rgba(62, 243, 164, 0.16), transparent 70%),
    #05080b;
}
.intro img {
  width: min(320px, 78vw);
  height: auto;
  border-radius: 18px;
  border: 1px solid rgba(62, 243, 164, 0.45);
  box-shadow: 0 0 48px rgba(62, 243, 164, 0.22);
}
.intro-title {
  margin: 4px 0 0;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}
.intro-line {
  margin: 0;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.intro-line::after {
  content: "_";
  margin-left: 3px;
  animation: blink 1.15s steps(1) infinite;
}
.intro-track {
  width: min(320px, 78vw);
  height: 10px;
  border-radius: 99px;
  overflow: hidden;
  background: #0c1c18;
  border: 1px solid rgba(62, 243, 164, 0.35);
}
.intro-bar {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, #3ef3a4, #6ae7ff);
  box-shadow: 0 0 16px rgba(62, 243, 164, 0.65);
}
.intro.is-done {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  white-space: nowrap;
}
.brand p {
  margin: 2px 0 0;
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.brand p::after {
  content: "_";
  margin-left: 3px;
  animation: blink 1.15s steps(1) infinite;
}
.search { display: grid; gap: 8px; flex: 1; min-width: 0; }
.modes { display: flex; gap: 6px; }
.mode, .ghost, .go, .chip, .mini {
  border: 1px solid var(--line);
  background: rgba(8, 20, 18, 0.72);
  border-radius: 8px;
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.mode.is-on {
  background: rgba(62, 243, 164, 0.14);
  color: var(--green-2);
  border-color: var(--line-strong);
  box-shadow: inset 0 0 0 1px rgba(62, 243, 164, 0.18), 0 0 18px rgba(62, 243, 164, 0.12);
}
.bar { display: flex; gap: 8px; align-items: end; }
#fields { flex: 1; display: grid; grid-template-columns: 1.4fr 0.8fr 120px; gap: 8px; }
#fields.empresa, #fields.ligacao { grid-template-columns: 1fr 1fr; }
#fields.empresa { grid-template-columns: 1fr; }
label.field {
  display: grid;
  gap: 4px;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--cyan);
}
label.field input, label.field select, .filter {
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--mono);
  font-size: 0.95rem;
  color: var(--text);
  background: #06110f;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  width: 100%;
  caret-color: var(--green);
}
label.field input:focus, label.field select:focus, .filter:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(62, 243, 164, 0.16);
}
label.field select { color: var(--text); }
.go {
  background: var(--green);
  border-color: transparent;
  color: #042117;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 600;
  min-width: 132px;
  min-height: 44px;
  box-shadow: 0 0 24px rgba(62, 243, 164, 0.28);
}
.go:hover { background: #74ffc4; }
.go:disabled { opacity: 0.55; cursor: progress; box-shadow: none; }
.hint { margin: 0; color: var(--muted); font-family: var(--mono); font-size: 0.75rem; }
.history { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  color: var(--gold);
  background: rgba(214, 255, 74, 0.06);
  border-color: rgba(214, 255, 74, 0.28);
}

.status {
  min-height: 1.2em;
  margin: 0 22px 8px;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--green);
}
.status.is-bad { color: var(--bad); }
.status:empty { display: none; }
.status:not(:empty)::before { content: "> "; color: var(--cyan); }

main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(340px, 440px) 1fr;
  gap: 14px;
  padding: 0 14px 14px;
}
.dossier, .stage {
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow), inset 0 1px 0 rgba(184, 255, 216, 0.12);
}
.dossier {
  background:
    linear-gradient(90deg, transparent, rgba(62, 243, 164, 0.75), transparent) top / 100% 1px no-repeat,
    var(--panel);
  color: var(--text);
  overflow: auto;
  padding: 22px;
}
.stage {
  position: relative;
  overflow: hidden;
  min-height: 480px;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 42%, rgba(62, 243, 164, 0.08), transparent 36%),
    linear-gradient(rgba(106, 231, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(106, 231, 255, 0.05) 1px, transparent 1px),
    #050c0e;
  background-size: auto, 28px 28px, 28px 28px, auto;
}
.stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 90px;
  top: -90px;
  background: linear-gradient(transparent, rgba(62, 243, 164, 0.07), transparent);
  animation: scan 8s linear infinite;
  pointer-events: none;
  z-index: 1;
}
.stage-bar, .legend {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  z-index: 2;
}
.stage-bar p, .legend {
  margin: 0;
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.stage-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.ghost { color: var(--green-2); background: rgba(5, 16, 14, 0.72); }
.ghost:hover { border-color: var(--line-strong); }
.ghost.is-on {
  color: #f4ffb0;
  border-color: rgba(232, 255, 106, 0.75);
  background: rgba(232, 255, 106, 0.14);
  box-shadow: 0 0 16px rgba(232, 255, 106, 0.16);
}
#board { flex: 1; width: 100%; min-height: 0; touch-action: none; cursor: grab; position: relative; z-index: 1; user-select: none; }
#board.is-draw { cursor: crosshair; }
#board.is-erase { cursor: none; }
.legend { position: absolute; left: 12px; bottom: 10px; padding: 0; text-transform: none; letter-spacing: 0; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 99px; margin: 0 4px 0 10px; }
.dot.company { background: var(--green); border-radius: 2px; box-shadow: 0 0 8px var(--green); }
.dot.person { background: var(--cyan); box-shadow: 0 0 8px var(--cyan); }
.board-empty {
  position: absolute;
  inset: 52px 28px 36px;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.86rem;
  pointer-events: none;
  z-index: 1;
}
.board-empty[hidden] { display: none; }

.kicker {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--green);
}
.dossier h2 { margin: 0; font-size: 1.85rem; line-height: 1.02; letter-spacing: -0.04em; }
.subhead { margin: 8px 0 0; color: var(--muted-2); }
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.pill {
  border-radius: 999px;
  padding: 4px 9px;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.03em;
  background: rgba(232, 255, 244, 0.06);
  color: var(--text);
  border: 1px solid var(--line);
}
.pill.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.pill.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.pill.muted { background: rgba(142, 174, 160, 0.1); color: var(--muted); border-color: transparent; }
.facts, .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin: 0; }
.facts div, .stats div { min-width: 0; }
dt {
  font-family: var(--mono);
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--cyan);
}
dd { margin: 4px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.block { margin-top: 18px; padding-top: 14px; border-top: 1px solid rgba(94, 255, 186, 0.12); }
.block h3 {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green-2);
}
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mini, .qsa-item, .row-btn {
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  color: var(--text);
  padding: 8px 10px;
  text-align: left;
  text-decoration: none;
}
.mini:hover, .qsa-item:hover { border-color: var(--line-strong); background: #143028; }
.qsa { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.qsa-item { width: 100%; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.qsa-item strong, .company-row strong { display: block; color: var(--text); font-weight: 600; }
.qsa-item span, .meta { color: var(--muted-2); font-size: 0.8rem; }
.filter { margin-bottom: 8px; }
.company-list { display: grid; gap: 8px; }
.company-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: rgba(16, 32, 28, 0.85); }
.company-row header { display: flex; justify-content: space-between; gap: 8px; align-items: start; }
.signals { display: grid; gap: 8px; }
.signal {
  background: rgba(106, 231, 255, 0.06);
  border-left: 3px solid var(--cyan);
  padding: 8px 10px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.8rem;
}
.steps { margin: 12px 0 0; padding-left: 18px; }
.steps li { margin: 6px 0; }
.welcome h2 { font-size: 2.15rem; }
.note { margin-top: 16px; font-size: 0.82rem; color: var(--muted); font-family: var(--mono); }
.path { display: grid; gap: 8px; }
.path-step { display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: center; }
.path-n {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: rgba(62, 243, 164, 0.16);
  color: var(--green);
  font-family: var(--mono);
  font-size: 0.75rem;
}
.footer {
  padding: 0 22px 14px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.72rem;
}
.node text { text-anchor: middle; pointer-events: none; }
.node-title { fill: #f3fff9; font-size: 12px; font-weight: 600; font-family: var(--sans); }
.node-sub { fill: #b7e7d4; font-size: 10px; font-family: var(--mono); }
.node.person .node-title { fill: #f2fdff; }
.node.person .node-sub { fill: #b7eef8; }
.node rect, .node circle { stroke-width: 1.6; }
.node.company rect { fill: #073228; stroke: var(--green); }
.node.person circle { fill: #06343d; stroke: var(--cyan); }
.node.is-on rect, .node.is-on circle { stroke: #f4ffe8; stroke-width: 3; filter: drop-shadow(0 0 6px rgba(244, 255, 232, 0.45)); }
#board line { stroke: rgba(106, 231, 255, 0.55); stroke-width: 1.4; }
.ink-cursor { fill: none; stroke: #e8ff6a; stroke-width: 1.5; }

@keyframes blink { 50% { opacity: 0; } }
@keyframes scan { to { top: 100%; } }

@media (prefers-reduced-motion: reduce) {
  .brand p::after, .stage::after { animation: none; }
}
@media (max-width: 980px) {
  body { height: auto; }
  .top { flex-direction: column; }
  main { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .stage { height: 68vh; }
  #fields, #fields.empresa, #fields.ligacao { grid-template-columns: 1fr; }
  .bar { flex-direction: column; align-items: stretch; }
  .go { min-height: 46px; }
}
@media print {
  body { background: white; color: black; }
  body::before, .stage::after, .intro { display: none; }
  .top, .stage, .status, .footer, .actions, .filter { display: none !important; }
  main { display: block; height: auto; padding: 0; }
  .dossier { box-shadow: none; overflow: visible; background: white; color: black; border: 0; }
  .dossier h2, .dossier strong, .dossier dd, .kicker, dt, .note, .meta, .signal { color: black; }
}
