/* NoantriDX — console giallorossa. Base calda quasi nera con
   sottotono rosso; il giallo è la luce (frequenze, numeri, tasti),
   il rosso è la struttura (righe, stati, energia). */

:root {
  --bg: #150a0b;
  --panel: #1f1113;
  --panel-2: #271518;
  --line: #45222a;
  --text: #f0e3cf;
  --dim: #a98d7c;
  --amber: #ffc21a;        /* giallo primario */
  --amber-dim: #d19a12;
  --red: #ef3b2f;          /* rosso primario */
  --red-deep: #8e1f1f;
  --ok: #3ddc84;
  --err: #ff5d5d;
  --grad: linear-gradient(90deg, var(--amber), var(--red));
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono",
          Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { height: 100%; }
body { height: auto; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--mono); font-size: 13px; line-height: 1.45;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: var(--amber); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 1px; }

/* ---------- barra superiore ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 10px 16px;
  border-bottom: 2px solid transparent;
  border-image: var(--grad) 1;
  background: linear-gradient(180deg, #2a1114 0%, var(--bg) 100%);
}
.brand { display: flex; flex-direction: column; line-height: 1.15; gap: 3px; }
.brand-logo {
  width: 236px; height: 40px; display: block;
  filter: drop-shadow(0 0 12px rgba(255,140,0,.28));
}
.brand-sub {
  font-size: 10px; letter-spacing: .32em; text-transform: uppercase;
  font-weight: 700; align-self: center;
  background: linear-gradient(90deg,
    var(--amber), #fff2c2, var(--red), var(--amber));
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--amber);
  animation: brandsweep 6s linear infinite;
}
@keyframes brandsweep {
  from { background-position: 300% 0; }
  to   { background-position: 0% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .brand-sub { animation: none; }
}

.nodes { display: flex; gap: 10px; flex: 0 1 auto; flex-wrap: wrap; }
.node {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 3px; padding: 2px 8px;
  background: var(--panel);
}
.node .led {
  width: 7px; height: 7px; border-radius: 50%; background: var(--err);
  box-shadow: 0 0 6px var(--err);
}
.node.on { color: var(--text); }
.node.on .led { background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.node b { color: var(--amber-dim); font-weight: 600; }
.clock { display: flex; align-items: baseline; gap: 6px; }
#utc-clock {
  font-size: 17px; color: var(--amber); letter-spacing: .06em;
  text-shadow: 0 0 10px rgba(255,194,26,.35);
}
.clock-label { font-size: 9px; color: var(--dim); letter-spacing: .2em; }
.ws-dot {
  width: 8px; height: 8px; border-radius: 50%; margin-left: 8px;
  background: var(--err); align-self: center; transition: background .3s;
}
.ws-dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* ---------- striscia bande (firma) ---------- */
.bandstrip {
  display: flex; gap: 2px; padding: 8px 16px 6px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.bseg {
  flex: 1; min-width: 0; border: none; cursor: pointer;
  background: var(--panel); border-radius: 2px; padding: 5px 2px 4px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--dim); transition: transform .1s;
  border-bottom: 3px solid transparent;
}
.bseg:hover { transform: translateY(-1px); color: var(--text); }
.bseg .bar {
  width: 100%; height: 26px; display: flex; align-items: flex-end;
}
.bseg .fill {
  width: 100%; min-height: 2px; border-radius: 1px 1px 0 0;
  opacity: .85; transition: height .6s ease;
}
.bseg .bname { font-size: 10px; letter-spacing: .04em; }
.bseg .bcount { font-size: 9px; color: var(--dim); }
.bseg.active { border-bottom-color: var(--red); color: var(--text); }
.bseg.active .bname { color: var(--amber); }

/* ---------- filtri ---------- */
.filters {
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px;
  padding: 8px 16px; border-bottom: 1px solid var(--line);
}
.chipgroup { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.chiplabel {
  font-family: var(--sans); font-size: 9px; text-transform: uppercase;
  letter-spacing: .18em; color: var(--dim); margin-right: 2px;
}
.chip {
  background: var(--panel); color: var(--dim); border: 1px solid var(--line);
  border-radius: 3px; padding: 3px 9px; font-size: 11px; cursor: pointer;
}
.chip:hover { color: var(--text); border-color: #6a3440; }
.chip.active {
  color: #1c0e04; background: var(--amber); border-color: var(--amber);
  font-weight: 700;
}
.searchbox { margin-left: auto; display: flex; gap: 6px; }
.searchbox input {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  font-family: var(--mono); font-size: 12px; padding: 4px 10px;
  border-radius: 3px; width: 190px; text-transform: uppercase;
}
.searchbox input::placeholder { color: var(--dim); text-transform: none; }
#clear-filters {
  background: none; border: 1px solid var(--line); color: var(--dim);
  border-radius: 3px; padding: 4px 10px; font-size: 11px; cursor: pointer;
}
#clear-filters:hover { color: var(--red); border-color: var(--red); }

/* ---------- layout principale ---------- */
.layout {
  flex: 1 0 auto; display: grid; grid-template-columns: minmax(560px, 58%) 1fr;
  gap: 10px; padding: 10px 16px; min-height: 0;
}
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 4px;
  display: flex; flex-direction: column; min-height: 0; overflow: hidden;
}
.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.panel-head h2 {
  margin: 0; font-family: var(--sans); font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .22em; color: var(--dim);
}
.counter { font-size: 11px; color: var(--dim); }
.counter b { color: var(--amber); font-weight: 600; }

/* tabella spot */
.tablewrap { overflow-y: auto; flex: 1; min-height: 300px; max-height: 540px; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; background: var(--panel-2); z-index: 2;
  font-family: var(--sans); font-size: 9px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .16em; color: var(--dim);
  text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line);
}
tbody td {
  padding: 4px 8px; border-bottom: 1px solid #2c171b;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
tbody tr:hover { background: #2b1519; }
tr.fresh { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: rgba(255,194,26,.14); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) {
  tr.fresh { animation: none; }
  .bseg .fill { transition: none; }
}
.c-time { width: 46px; color: var(--dim); }
.c-freq { width: 84px; }
td.c-freq { color: var(--amber); text-align: right; letter-spacing: .03em; }
th.c-freq { text-align: right; }
.c-dx { width: 96px; font-weight: 700; }
td.c-dx a { color: var(--text); }
td.c-dx a:hover { color: var(--amber); }
.c-mode { width: 52px; }
.mode-tag {
  display: inline-block; font-size: 10px; padding: 1px 5px; border-radius: 2px;
  border: 1px solid var(--line); color: var(--dim);
}
.c-dxcc { max-width: 140px; color: var(--dim); }
.c-dxcc .cont { color: var(--amber-dim); font-size: 10px; margin-left: 4px; }
.c-spotter { width: 92px; color: var(--dim); }
.c-comment { max-width: 220px; color: #c5a893; font-size: 12px; }
.bandmark {
  display: inline-block; width: 4px; height: 12px; border-radius: 1px;
  margin-right: 6px; vertical-align: -2px;
}
tr.empty td { text-align: center; color: var(--dim); padding: 30px 0; }

/* mappa */
#map { flex: 1; min-height: 320px; background: #100708; }
.leaflet-container { font-family: var(--mono); }
.leaflet-popup-content-wrapper {
  background: var(--panel-2); color: var(--text); border-radius: 4px;
  border: 1px solid var(--line);
}
.leaflet-popup-tip { background: var(--panel-2); }
.popup-call { font-size: 15px; font-weight: 700; color: var(--amber); }
.popup-row { font-size: 12px; color: var(--text); margin-top: 2px; }
.popup-row span { color: var(--dim); }
.popup-links { margin-top: 6px; font-size: 12px; }

.stats-row {
  display: flex; border-top: 1px solid var(--line);
}
.stat {
  flex: 1; padding: 8px 6px; text-align: center;
  border-right: 1px solid var(--line);
}
.stat:last-child { border-right: none; }
.stat b { display: block; font-size: 16px; color: var(--amber); }
.stat span {
  font-family: var(--sans); font-size: 9px; text-transform: uppercase;
  letter-spacing: .16em; color: var(--dim);
}

.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 8px 16px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--dim);
}

/* ---------- mobile ---------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .tablewrap { max-height: 46vh; }
  #map { min-height: 260px; }
  .bandstrip { overflow-x: auto; }
  .bseg { min-width: 44px; }
  .searchbox { margin-left: 0; width: 100%; }
  .searchbox input { flex: 1; }
  .c-comment, .c-dxcc { max-width: 110px; }
  .topbar { flex-wrap: wrap; }
}

/* ---------- tasti memoria (8 link, nella barra del titolo) ---------- */
.memkeys {
  display: flex; flex-wrap: wrap; gap: 6px; flex: 1;
  justify-content: center; min-width: 0;
}
.memkey {
  position: relative; display: inline-flex; align-items: center;
  gap: 6px; padding: 5px 10px; border-radius: 5px;
  font-size: 11px; font-weight: 700; letter-spacing: .05em;
  color: var(--text); text-decoration: none; white-space: nowrap;
  background: linear-gradient(180deg, #2c1518, #1d0f11);
  border: 1px solid #52262e; border-bottom-width: 2px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
  transition: transform .08s, box-shadow .2s, border-color .2s;
  overflow: hidden;
}
.memkey::before {           /* retroilluminazione giallorossa */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(80% 140% at 50% 130%,
              rgba(239,59,47,.25), rgba(255,194,26,.07) 55%, transparent);
  opacity: 0; transition: opacity .25s;
}
.memkey:hover { transform: translateY(-1px); border-color: var(--amber);
  box-shadow: 0 3px 14px rgba(239,59,47,.3), inset 0 1px 0 rgba(255,255,255,.07);
  text-decoration: none; }
.memkey:hover::before { opacity: 1; }
.memkey:active { transform: translateY(1px); border-bottom-width: 1px; }
.memkey::after {                /* lampo che percorre i tasti in sequenza */
  content: ""; position: absolute; top: 0; bottom: 0; width: 45%;
  left: -60%; transform: skewX(-18deg);
  background: linear-gradient(90deg, transparent,
              rgba(255,214,80,.28), rgba(239,59,47,.18), transparent);
  animation: keysheen 9s linear infinite;
  pointer-events: none;
}
.memkey:nth-child(1)::after { animation-delay: 0s; }
.memkey:nth-child(2)::after { animation-delay: .35s; }
.memkey:nth-child(3)::after { animation-delay: .7s; }
.memkey:nth-child(4)::after { animation-delay: 1.05s; }
.memkey:nth-child(5)::after { animation-delay: 1.4s; }
.memkey:nth-child(6)::after { animation-delay: 1.75s; }
.memkey:nth-child(7)::after { animation-delay: 2.1s; }
.memkey:nth-child(8)::after { animation-delay: 2.45s; }
.memkey:nth-child(9)::after { animation-delay: 2.8s; }
.memkey:nth-child(10)::after { animation-delay: 3.15s; }
@keyframes keysheen {
  0%   { left: -60%; opacity: 0; }
  4%   { opacity: 1; }
  12%  { left: 115%; opacity: 0; }
  100% { left: 115%; opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .memkey::after { animation: none; opacity: 0; }
}
.memkey-n {
  font-size: 8px; color: #1c0e04; background: var(--grad);
  border-radius: 3px; padding: 1px 4px; font-weight: 800;
}
.memkey.off { opacity: .45; cursor: default; }
.memkey.off:hover { transform: none; border-color: #52262e;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05); }
.memkey.off:hover::before { opacity: 0; }

/* ---------- griglia statistiche ---------- */
.statsgrid {
  display: grid; gap: 10px; padding: 0 16px 10px;
  grid-template-columns: repeat(2, 1fr);
}
.statsgrid .slinks, .statsgrid .smonthly { grid-column: 1 / -1; }
.schart .bars, .srank .rank { padding: 12px; }

/* grafici a barre verticali (mensile + orario) */
.bars-v {
  display: flex; align-items: flex-end; gap: 4px; height: 170px;
}
.bars-v .vb {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  align-items: center; gap: 5px; height: 100%; justify-content: flex-end;
}
.bars-v .vb .vfill {
  width: 100%; border-radius: 3px 3px 0 0; min-height: 2px;
  background: linear-gradient(180deg, var(--amber), var(--red) 90%);
  box-shadow: 0 0 10px rgba(239,59,47,.25);
  transition: height .7s cubic-bezier(.2,.8,.2,1);
}
.bars-v .vb .vlabel {
  font-size: 9px; color: var(--dim); letter-spacing: .02em;
  white-space: nowrap;
}
.bars-v .vb .vcount { font-size: 9px; color: var(--amber-dim); }
.bars-v .vb:hover .vfill { box-shadow: 0 0 16px rgba(255,194,26,.5); }
@media (prefers-reduced-motion: reduce) { .bars-v .vb .vfill { transition: none; } }

/* classifiche */
.rank { list-style: none; margin: 0; overflow-y: auto; max-height: 280px; }
.rank li {
  display: grid; grid-template-columns: 26px 110px 1fr 64px;
  align-items: center; gap: 8px; padding: 5px 2px;
  border-bottom: 1px solid #2c171b; font-size: 12px;
}
.rank li:last-child { border-bottom: none; }
.rank .pos {
  font-size: 10px; font-weight: 800; text-align: center;
  color: var(--dim);
}
.rank li:nth-child(1) .pos { color: var(--amber); text-shadow: 0 0 8px rgba(255,194,26,.6); }
.rank li:nth-child(2) .pos,
.rank li:nth-child(3) .pos { color: var(--red); }
.rank .rcall { font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.rank .rcall small { display: block; font-weight: 400; font-size: 9px; color: var(--dim); }
.rank .rbar { height: 8px; border-radius: 4px; background: #2c171b; overflow: hidden; }
.rank .rbar i { display: block; height: 100%; background: var(--grad); border-radius: 4px; }
.rank .rn { text-align: right; color: var(--amber); font-weight: 700; }
.rank .rn small { color: var(--dim); font-weight: 400; }
.rank .loading, .bars .loading { color: var(--dim); font-size: 12px; }

/* nodi collegati (output 'links') */
.linksout {
  margin: 0; padding: 12px; overflow: auto; max-height: 300px;
  font-size: 11.5px; line-height: 1.5; color: var(--text);
  white-space: pre; background: #170b0d;
}
.linksout .lnode { color: var(--amber); font-weight: 700; }

@media (max-width: 980px) {
  .memkeys { order: 10; flex-basis: 100%; justify-content: flex-start; }
  .statsgrid { grid-template-columns: 1fr; }
  .rank li { grid-template-columns: 22px 96px 1fr 56px; }
}

/* ---------- bandierine DXCC ---------- */
.flag {
  width: 20px; height: 15px; border-radius: 2px;
  vertical-align: -3px; margin-right: 6px;
  box-shadow: 0 0 0 1px rgba(0,0,0,.45);
  object-fit: cover;
}
.popup-row .flag { vertical-align: -2px; }
