/* Ferron Log Atlas — forged steel, no chrome. */

:root {
  --bg: #0D1319;
  --bg-raise: #111A24;
  --panel: #131C27;
  --line: #1F2E3C;
  --line-strong: #31465A;
  --ink: #E7EEF4;
  --muted: #93A7B4;
  --faint: #5C7280;
  --accent: #FFB454;
  --accent-ink: #221302;

  --s2: #57C48C;
  --s3: #6FA8DC;
  --s4: #D0913C;
  --s5: #E15A64;

  --font-ui: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", "Cascadia Code", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background:
    radial-gradient(1100px 500px at 70% -200px, rgba(255, 180, 84, 0.06), transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

::selection { background: rgba(255, 180, 84, 0.3); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.mono, code { font-family: var(--font-mono); }

/* ---------- Header ---------- */

.top {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 26px 28px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 16px; }

.fe-tile {
  width: 46px;
  height: 46px;
  flex: none;
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  display: grid;
  place-items: center;
}
.fe-tile::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--accent);
}
.fe-symbol {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: -0.02em;
  margin-top: -3px;
}
.fe-number {
  position: absolute;
  top: 3px;
  right: 5px;
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--faint);
}

.brand-text h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.tagline {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

/* ---------- Buttons ---------- */

.btn {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 8px 14px;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.btn:hover { background: var(--bg-raise); border-color: var(--faint); }

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

.btn.select {
  padding: 7px 10px;
  appearance: none;
  -webkit-appearance: none;
}

.linklike {
  font: inherit;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linklike:hover { color: #ffca7e; }

/* ---------- Ledger column ---------- */

.ledger {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 0 28px 40px;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  flex: 1;
}

/* ---------- Intake ---------- */

.intake { padding-top: 8px; }

.intake-zone {
  border: 1px dashed var(--line-strong);
  padding: 44px 32px 36px;
  text-align: center;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.intake-zone.dragging {
  border-color: var(--accent);
  background: rgba(255, 180, 84, 0.05);
}

.intake-title { margin: 0; font-size: 22px; font-weight: 600; }
.intake-sub { margin: 6px 0 30px; color: var(--muted); }

.intake-formats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
  text-align: left;
  border-top: 1px solid var(--line);
}
.format {
  padding: 16px 20px 14px;
  border-right: 1px solid var(--line);
}
.format:last-child { border-right: none; }
.format h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
}
.format code {
  display: block;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--s3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 8px;
}
.format p { margin: 0; color: var(--faint); font-size: 11.5px; }

.paste-box { margin-top: 16px; }
.paste-box textarea {
  width: 100%;
  background: var(--bg-raise);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 12px;
  resize: vertical;
}
.paste-box textarea::placeholder { color: var(--faint); }
.paste-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }

.intake-note {
  margin: 14px 0 0;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}
.intake-note.error { color: var(--s5); }

/* ---------- Meta line & KPIs ---------- */

.report { padding-top: 24px; }

.meta-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.meta-right { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
#meta-methods { font-size: 11.5px; color: var(--faint); }
.range-label { font-size: 12px; color: var(--faint); display: flex; align-items: center; gap: 8px; }

.kpis {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  border-bottom: 1px solid var(--line);
}
.kpi {
  padding: 18px 16px 16px 0;
}
.kpi + .kpi { padding-left: 16px; border-left: 1px solid var(--line); }
.kpi .kpi-label { color: var(--faint); font-size: 11.5px; margin-bottom: 4px; }
.kpi .kpi-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  line-height: 1.1;
  white-space: nowrap;
}
.kpi .kpi-value small { font-size: 13px; color: var(--muted); font-weight: 400; }
.kpi .kpi-sub { color: var(--faint); font-size: 11px; margin-top: 3px; font-family: var(--font-mono); }
.kpi .kpi-value.bad { color: var(--s5); }

/* ---------- Panels ---------- */

.panel { padding: 22px 0 18px; border-bottom: 1px solid var(--line); min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); }
.grid-2 .panel, .grid-3 .panel { padding: 22px 20px 18px; }
.grid-2 .panel + .panel, .grid-3 .panel + .panel { border-left: 1px solid var(--line); }

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.panel h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 500;
}
.panel-sub { color: var(--faint); font-size: 11.5px; font-family: var(--font-mono); }

.toggle { display: flex; border: 1px solid var(--line-strong); }
.toggle-btn {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--muted);
  background: transparent;
  border: none;
  padding: 5px 12px;
  cursor: pointer;
}
.toggle-btn + .toggle-btn { border-left: 1px solid var(--line-strong); }
.toggle-btn.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

.chart-block { position: relative; }
.chart-block svg { display: block; }
.donut-block { display: flex; justify-content: center; }

/* ---------- Code list ---------- */

.code-list { margin-top: 14px; }
.code-row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-family: var(--font-mono);
  font-size: 12px;
}
.code-row .swatch { width: 9px; height: 9px; justify-self: start; }
.code-row .code-count { color: var(--muted); }
.code-track {
  height: 4px;
  background: var(--line);
  position: relative;
}
.code-track i {
  position: absolute; inset: 0 auto 0 0;
  display: block;
}

/* ---------- Bar lists ---------- */

.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { min-width: 0; }
.bar-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}
.bar-label {
  font-family: var(--font-mono);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bar-sub { color: var(--faint); font-size: 10.5px; flex: none; font-family: var(--font-mono); }
.bar-value { font-family: var(--font-mono); font-size: 12px; color: var(--muted); flex: none; }
.bar-track { height: 8px; background: var(--line); }
.bar-track i {
  display: block;
  height: 100%;
  background: var(--accent);
}
.bar-track i.s5 { background: var(--s5); }
.bar-track i.s4 { background: var(--s4); }

/* ---------- Busiest hours heatmap ---------- */

.heat-grid {
  display: grid;
  grid-template-columns: auto repeat(24, minmax(0, 1fr));
  gap: 2px;
  align-items: center;
}
.heat-day {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--faint);
  padding-right: 4px;
  white-space: nowrap;
}
.heat-cell {
  position: relative;
  aspect-ratio: 1;
  min-width: 0;
  background: var(--line);
  cursor: crosshair;
}
.heat-cell i {
  position: absolute;
  inset: 0;
  display: block;
  background: var(--accent);
  opacity: var(--heat, 0);
}
.heat-cell:hover { outline: 1px solid var(--muted); }
.heat-hour {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--faint);
  padding-top: 4px;
}

/* ---------- Clients & bots ---------- */

.clients-summary {
  margin: 0 0 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--faint);
}
.clients-summary .cs-n { color: var(--ink); }
.clients-summary .human-count { color: var(--s2); }
.clients-summary .bot-count { color: var(--s4); }

.clients-ref-title { margin-top: 18px; }
.ref-list { display: flex; flex-direction: column; }
.ref-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 5px 0;
  font-family: var(--font-mono);
  font-size: 12px;
}
.ref-row + .ref-row { border-top: 1px solid var(--line); }
.ref-name {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ref-count { color: var(--faint); flex: none; }

@media (max-width: 760px) {
  .heat-grid { grid-template-columns: auto repeat(24, minmax(0, 1fr)); gap: 1px; }
  .heat-day, .heat-hour { font-size: 9.5px; }
}

/* ---------- Application log ---------- */

.applog-list { display: flex; flex-direction: column; }
.applog-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12px;
}
.applog-row:first-child { border-top: none; }
.applog-time { color: var(--faint); flex: none; }
.applog-level { flex: none; width: 46px; }
.applog-level.ERROR { color: var(--s5); }
.applog-level.WARN { color: var(--s4); }
.applog-level.INFO { color: var(--s3); }
.applog-level.DEBUG { color: var(--faint); }
.applog-target { color: var(--faint); flex: none; }
.applog-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Errors right now ---------- */

.spot-list { display: flex; flex-direction: column; }
.spot-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 6px 0;
  font-family: var(--font-mono);
  font-size: 12px;
}
.spot-row + .spot-row { border-top: 1px solid var(--line); }
.spot-status { flex: none; width: 40px; }
.spot-status.s4 { color: var(--s4); }
.spot-status.s5 { color: var(--s5); }
.spot-path {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spot-count { flex: none; color: var(--muted); }
.spot-last { flex: none; color: var(--faint); }

/* ---------- Table ---------- */

.table-head { gap: 16px; }
.table-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.search { width: 260px; }

.table-scroll { max-height: 480px; overflow: auto; border: 1px solid var(--line); }
.table-scroll table { width: 100%; border-collapse: collapse; font-family: var(--font-mono); font-size: 12px; }
.table-scroll th {
  text-align: left;
  font-weight: 500;
  font-size: 10.5px;
  color: var(--faint);
  padding: 8px 12px;
  border-bottom: 1px solid var(--line-strong);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}
.table-scroll td {
  padding: 5px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table-scroll tr:hover td { background: var(--bg-raise); }
td.c-time { color: var(--faint); }
td.c-path { overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
td.c-status.s2 { color: var(--s2); }
td.c-status.s3 { color: var(--s3); }
td.c-status.s4 { color: var(--s4); }
td.c-status.s5 { color: var(--s5); }
td.c-dur { color: var(--muted); }
td.c-size, td.c-client { color: var(--muted); }

.client-btn {
  font: inherit;
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-underline-offset: 3px;
}
.client-btn:hover { color: var(--ink); background: var(--bg-raise); text-decoration: underline; }

.table-note { margin: 10px 0 0; color: var(--faint); font-size: 11.5px; font-family: var(--font-mono); }

/* ---------- Live badge ---------- */

.live-badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--s2);
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 4px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.live-badge:hover { background: var(--bg-raise); }
.live-badge.paused { color: var(--faint); }

.live-badge .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--s2);
  animation: pulse 1.8s ease-in-out infinite;
}
.live-badge .dot.off {
  background: var(--faint);
  animation: none;
}
.live-badge.paused .dot {
  background: var(--faint);
  animation: none;
}

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

@media (prefers-reduced-motion: reduce) {
  .live-badge .dot { animation: none; }
}

/* ---------- World map ---------- */

.map-wrap {
  display: flex;
  gap: 24px;
  align-items: stretch;
}
.map-block {
  flex: 1 1 auto;
  min-width: 0;
}
.map-block svg {
  width: 100%;
  height: auto;
  display: block;
}
.map-land {
  fill: #16202B;
  stroke: #2C4050;
  stroke-width: 0.5;
}
.map-dot {
  fill: var(--accent);
  cursor: crosshair;
}
.map-dot-halo {
  fill: var(--accent);
  fill-opacity: 0.07;
  cursor: crosshair;
}
.map-origin {
  fill: var(--s5);
}
.map-origin-halo {
  fill: none;
  stroke: var(--s5);
  stroke-width: 1;
  fill-opacity: 1;
  animation: origin-breathe 2.4s ease-in-out infinite;
}
@keyframes origin-breathe {
  0%, 100% { fill-opacity: 0.8; }
  50% { fill-opacity: 0.15; }
}
.map-side {
  flex: 1 1 340px;
  min-width: 0;
}
.world-block { min-width: 0; }
.map-stack {
  position: relative;
  flex: 1 1 60%;
  min-width: 0;
  align-self: center;
}
/* effects layer: a sibling of the rebuilt base map, so live re-renders
   never detach in-flight arcs (detaching resets CSS animations) */
.fx-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.zoom-block { max-height: 340px; }
.zoom-block svg { max-height: 300px; }
svg .zoom-note { fill: var(--faint); font-family: var(--font-mono); font-size: 3.2px; }
.side-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--faint);
}
.top-countries-title { margin-top: 18px; }
.countries-list .bar-label { font-family: var(--font-ui); }

/* live effects */
.arc-fly {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.3;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: arc-draw 2.2s ease-out forwards;
  opacity: 0.9;
}
@keyframes arc-draw {
  0% { stroke-dashoffset: 100; }
  55% { opacity: 0.9; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}
.pulse-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  animation: pulse-expand 1.6s ease-out forwards;
}
@keyframes pulse-expand {
  from { r: 4; fill-opacity: 0.6; stroke-opacity: 0.9; }
  to { r: 18; fill-opacity: 0; stroke-opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .arc-fly, .pulse-ring, .map-origin-halo { animation: none; }
  .arc-fly, .pulse-ring { display: none; }
}

@media (max-width: 760px) {
  .map-wrap { flex-direction: column; gap: 18px; }
  .map-side { flex: 1 1 auto; }
}

/* ---------- SVG text ---------- */

svg .axis { fill: var(--faint); font-family: var(--font-mono); font-size: 10px; }
svg .donut-num { fill: var(--ink); font-family: var(--font-mono); font-size: 22px; font-weight: 500; }
svg .donut-cap { fill: var(--faint); font-family: var(--font-mono); font-size: 10px; }

.empty {
  color: var(--faint);
  font-size: 12px;
  font-family: var(--font-mono);
  margin: 8px 0;
}

/* ---------- Client inspector ---------- */

.inspector {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw - 24px);
  padding: 20px;
  background: var(--panel);
  border-left: 1px solid var(--line-strong);
  overflow-y: auto;
  z-index: 8;
}
/* page dim, behind the card */
.inspector::before {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: -2;
}
/* the card surface, above the dim (fixed so it stays put while the card scrolls) */
.inspector::after {
  content: "";
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw - 24px);
  background: var(--panel);
  z-index: -1;
}
.inspector-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line-strong);
}
.inspector-head h2 {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.inspector-close {
  flex: none;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--ink);
  background: transparent;
  border: 1px solid var(--line-strong);
  padding: 8px 14px;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.inspector-close:hover { background: var(--bg-raise); border-color: var(--faint); }

.insp-rows { display: flex; flex-direction: column; }
.insp-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 5px 0;
  font-family: var(--font-mono);
  font-size: 12px;
}
.insp-row + .insp-row { border-top: 1px solid var(--line); }
.insp-label { flex: none; color: var(--faint); }
.insp-value {
  min-width: 0;
  color: var(--ink);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insp-section { margin-top: 18px; }
.insp-filter { margin-top: 20px; }

@media (max-width: 760px) {
  .inspector { padding: 16px; }
}

/* ---------- Tooltip ---------- */

.tooltip {
  position: fixed;
  z-index: 10;
  pointer-events: none;
  background: #0A0F14;
  border: 1px solid var(--line-strong);
  padding: 8px 11px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  max-width: 320px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.5);
}
.tooltip .tt-title { color: var(--accent); margin-bottom: 2px; }
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 16px; }
.tooltip .tt-row span:last-child { color: var(--muted); }
.tooltip .sw { display: inline-block; width: 8px; height: 8px; margin-right: 6px; }

/* ---------- Footer ---------- */

.foot {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 18px 28px 26px;
  color: var(--faint);
  font-size: 12px;
}

/* ---------- Responsive ---------- */

@media (max-width: 1000px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-3 .panel + .panel + .panel { border-left: none; border-top: 1px solid var(--line); }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kpi:nth-child(4) { border-left: none; border-top: 1px solid var(--line); }
  .kpi:nth-child(5), .kpi:nth-child(6) { border-top: 1px solid var(--line); }
  .kpi:nth-child(7) { border-left: none; border-top: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .top, .ledger, .foot { padding-left: 16px; padding-right: 16px; }
  .ledger { border-left: none; border-right: none; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-2 .panel + .panel, .grid-3 .panel + .panel { border-left: none; border-top: 1px solid var(--line); }
  .intake-formats { grid-template-columns: 1fr; }
  .format { border-right: none; border-top: 1px solid var(--line); }
  .format:first-child { border-top: none; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(odd) { border-left: none; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .search { width: 100%; flex: 1; }
  td.c-path { max-width: 180px; }
}
