.network-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
}

.system-state,
.hub-state,
.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
}

.system-state {
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: .82rem;
}

.system-state.online,
.hub-state.online,
.connection-state {
  color: var(--green);
}

.system-state.degraded {
  color: var(--amber);
}

.system-state.offline,
.hub-state.offline {
  color: var(--red);
}

.system-state.checking {
  color: var(--muted);
}

.state-dot,
.node-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 12px currentColor;
}

.toolbar-actions,
.filter-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.refresh-label,
.filter-group label {
  color: var(--muted);
  font-size: .85rem;
  font-weight: 800;
}

select,
input[type="search"] {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
}

input[type="search"] {
  width: 150px;
}

.hub-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 18px;
  margin-bottom: 22px;
}

.summary-card {
  position: relative;
  overflow: hidden;
}

.summary-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--muted);
}

.summary-card.online::before {
  background: var(--green);
}

.summary-card.offline::before {
  background: var(--red);
}

.summary-top,
.table-heading,
.legacy-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.summary-top h2 {
  margin-bottom: 0;
}

.hub-state {
  padding: 8px 11px;
  border-radius: 999px;
  border: 1px solid currentColor;
}

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

.summary-metrics > div {
  padding: 15px;
  background: rgba(255,255,255,.035);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.summary-metrics strong {
  display: block;
  font-size: 1.4rem;
  margin-bottom: 3px;
}

.summary-metrics span {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 750;
}

.loading-card {
  min-height: 190px;
  background:
    linear-gradient(
      90deg,
      rgba(255,255,255,.03),
      rgba(255,255,255,.08),
      rgba(255,255,255,.03)
    );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  to { background-position: -200% 0; }
}

.link-table-card,
.combined-card {
  margin-bottom: 22px;
}

.table-heading {
  margin-bottom: 18px;
}

.responsive-table {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 13px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}

tbody tr:hover {
  background: rgba(39,167,255,.045);
}

.table-message {
  color: var(--muted);
  text-align: center;
  padding: 28px;
}

.hub-badge,
.direction,
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  font-weight: 900;
}

.hub-badge {
  color: var(--cyan);
  background: rgba(32,227,208,.08);
  border: 1px solid rgba(32,227,208,.2);
  padding: 6px 9px;
}

.direction {
  min-width: 48px;
  padding: 6px 9px;
}

.direction.in {
  color: var(--green);
  background: rgba(92,227,138,.08);
}

.direction.out {
  color: var(--blue);
  background: rgba(39,167,255,.10);
}

.node-number {
  color: var(--text);
  font-size: 1.05rem;
}

.count-pill {
  padding: 9px 13px;
  color: var(--blue);
  background: rgba(39,167,255,.10);
  border: 1px solid rgba(39,167,255,.25);
}

.network-node-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit,minmax(125px,1fr));
  gap: 10px;
}

.network-node {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255,255,255,.03);
}

.network-node .node-dot {
  color: var(--green);
}

.empty-state {
  color: var(--muted);
  text-align: center;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 14px;
}

.legacy-card {
  align-items: center;
}

@media (max-width: 850px) {
  .network-toolbar,
  .table-heading,
  .legacy-card {
    flex-direction: column;
    align-items: stretch;
  }

  .hub-summary-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .summary-metrics {
    grid-template-columns: 1fr;
  }

  .filter-group {
    align-items: stretch;
    flex-direction: column;
  }

  input[type="search"],
  select {
    width: 100%;
  }
}
.summary-card.is-keyed {
  border-color: rgba(92, 227, 138, .7);
  box-shadow: 0 0 32px rgba(92, 227, 138, .16);
}

.keyed-banner {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-top: 16px;
  padding: 13px 15px;
  border-radius: 13px;
  background: rgba(92, 227, 138, .11);
  border: 1px solid rgba(92, 227, 138, .35);
  color: var(--green);
}

.keyed-banner span {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 900;
}

.keyed-banner strong {
  text-align: right;
}

.activity {
  display: inline-flex;
  align-items: center;
}

.activity.keyed {
  color: var(--green);
  text-shadow: 0 0 12px rgba(92, 227, 138, .55);
}

.activity.idle {
  color: var(--muted);
}

.keyed-row {
  background: rgba(92, 227, 138, .10);
  box-shadow: inset 4px 0 0 var(--green);
}

.keyed-row:hover {
  background: rgba(92, 227, 138, .16);
}

.live-keyed {
  display: inline-flex;
  margin-left: 8px;
  padding: 4px 7px;
  border-radius: 999px;
  color: #06130b;
  background: var(--green);
  font-size: .66rem;
  font-weight: 1000;
  letter-spacing: .07em;
  vertical-align: middle;
  animation: keyedPulse 1s ease-in-out infinite;
}

.network-node.keyed {
  border-color: rgba(92, 227, 138, .65);
  background: rgba(92, 227, 138, .12);
  box-shadow: 0 0 18px rgba(92, 227, 138, .12);
}

.network-node.keyed .node-dot {
  animation: keyedPulse 1s ease-in-out infinite;
}

@keyframes keyedPulse {
  0%, 100% { opacity: .65; }
  50% { opacity: 1; box-shadow: 0 0 18px var(--green); }
}
.node-identity {
  display: grid;
  grid-template-columns: auto minmax(140px, 1fr) auto;
  align-items: center;
  gap: 4px 12px;
  min-width: 330px;
}

.node-number {
  color: var(--text);
  font-size: 1.08rem;
}

.node-name {
  color: var(--cyan);
  font-weight: 850;
}

.source-hub {
  grid-column: 1 / 3;
  color: var(--muted);
  font-size: .72rem;
}

.network-node {
  align-items: center;
}

.network-node-text {
  min-width: 0;
  flex: 1;
}

.network-node-text strong,
.network-node-text span {
  display: block;
}

.network-node-text span {
  margin-top: 3px;
  color: var(--muted);
  font-size: .76rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 680px) {
  .node-identity {
    min-width: 260px;
    grid-template-columns: 1fr;
  }

  .source-hub {
    grid-column: auto;
  }
}

/* Highlight a node while it is actively keyed */
.direct-links-table tbody tr.keyed-row {
    background: rgba(255, 193, 7, 0.22);
    box-shadow: inset 5px 0 0 #ffc107;
    animation: keyed-row-pulse 1.2s ease-in-out infinite;
}

.direct-links-table tbody tr.keyed-row td {
    background: transparent;
}

.direct-links-table tbody tr.keyed-row .node-number,
.direct-links-table tbody tr.keyed-row .node-name,
.direct-links-table tbody tr.keyed-row .received-cell {
    font-weight: 700;
}

.direct-links-table tbody tr.keyed-row .received-cell {
    color: #ffd75e;
}

.direct-links-table tbody tr.keyed-row .live-keyed {
    display: inline-block;
    margin-left: 8px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #ffc107;
    color: #111;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    animation: keyed-badge-pulse 0.8s ease-in-out infinite;
}

@keyframes keyed-row-pulse {
    0%, 100% {
        background: rgba(255, 193, 7, 0.15);
    }

    50% {
        background: rgba(255, 193, 7, 0.38);
    }
}

@keyframes keyed-badge-pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.08);
        opacity: 0.72;
    }
}

/* Fixed Last Heard display */
.last-heard-box {
    display: inline-flex;
    min-width: 118px;
    padding: 7px 10px;
    border: 1px solid rgba(90, 180, 255, 0.45);
    border-radius: 9px;
    background: rgba(20, 38, 58, 0.88);
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.03),
        0 3px 10px rgba(0, 0, 0, 0.18);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.15;
    white-space: nowrap;
}

.last-heard-box span {
    margin-bottom: 3px;
    color: #8fabc4;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.last-heard-box strong {
    color: #eaf6ff;
    font-size: 0.95rem;
    font-weight: 800;
}

.last-heard-box small {
    margin-top: 3px;
    color: #9fb4c6;
    font-size: 0.68rem;
}

.last-heard-box.never {
    border-color: rgba(150, 160, 170, 0.3);
    background: rgba(45, 49, 54, 0.72);
}

.last-heard-box.never strong {
    color: #aeb8c1;
}

/* Keep the box visible while a station is keyed */
.direct-links-table tbody tr.keyed-row .last-heard-box {
    border-color: #ffc107;
    background: rgba(90, 65, 5, 0.88);
}

.direct-links-table tbody tr.keyed-row .last-heard-box strong {
    color: #ffe38a;
}

/* Compact Last Heard override */
.received-cell {
    white-space: nowrap;
    vertical-align: middle;
}

.last-heard-box {
    display: inline-flex !important;
    min-width: 0 !important;
    padding: 5px 9px !important;
    border: 1px solid rgba(90, 180, 255, 0.38) !important;
    border-radius: 7px !important;
    background: rgba(20, 38, 58, 0.78) !important;
    box-shadow: none !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 7px !important;
    line-height: 1 !important;
    white-space: nowrap !important;
}

.last-heard-box span {
    display: none !important;
}

.last-heard-box strong {
    color: #eaf6ff !important;
    font-size: 0.86rem !important;
    font-weight: 700 !important;
}

.last-heard-box small {
    margin: 0 !important;
    color: #9fb4c6 !important;
    font-size: 0.72rem !important;
}

.last-heard-box.never {
    color: #aeb8c1 !important;
    font-size: 0.82rem !important;
    border-color: rgba(150, 160, 170, 0.25) !important;
    background: rgba(45, 49, 54, 0.55) !important;
}

.direct-links-table tbody tr.keyed-row .last-heard-box {
    border-color: #ffc107 !important;
    background: rgba(90, 65, 5, 0.75) !important;
}
