:root {
    --bg-color: #0b0f19;
    --text-main: #e2e8f0;
    --text-muted: #94a3b8;
    --accent-color: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --glass-bg: rgba(17, 24, 39, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-border-strong: rgba(255, 255, 255, 0.2);
    --glass-bg-hover: rgba(255, 255, 255, 0.05);
    --glass-bg-light: rgba(255, 255, 255, 0.08);
    --glass-bg-active: rgba(255, 255, 255, 0.15);
    --glass-bg-solid: rgba(15, 23, 42, 0.8);
    --shadow-main: rgba(0, 0, 0, 0.2);
    --shadow-strong: rgba(0, 0, 0, 0.4);
    --shadow-dark: rgba(0, 0, 0, 0.8);
    --grid-line: rgba(255, 255, 255, 0.05);
    --success: #10b981;
}



* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);

    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
}

#app-container, .app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--glass-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, #3b82f6, #8b5cf6);
    border-radius: 6px;
    box-shadow: 0 0 15px var(--accent-glow);
}

h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #ffffff;
}

.nav-links {
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    transition: color 0.3s ease, text-shadow 0.3s ease;
}

.nav-links a:hover, .nav-links a.active {
    color: #fff;
    text-shadow: 0 0 8px rgba(255,255,255,0.4);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--success);
}

.pulse {
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--success);
    animation: pulse-anim 2s infinite;
}

@keyframes pulse-anim {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.dashboard {
    display: flex;
    flex: 1;
    padding: 1.5rem;
    gap: 1.5rem;
    overflow: hidden;
}

.glass-panel {
    backdrop-filter: blur(50px);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    box-shadow: 0 8px 32px var(--shadow-main);
}

.overlay-stats {
    position: absolute;
    top: 1.5rem;
    left: 1.5rem;
    z-index: 10;
    width: auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 2rem;
    border-radius: 30px;
    pointer-events: auto;
}

.overlay-stats h2 {
    display: none;
}

.stat-card {
    background: transparent;
    padding: 0;
    border: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    opacity: 0.8;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    min-width: 0;
    overflow-x: hidden;
}

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.view-header h2 {
    font-size: 1.5rem;
}

.controls {
    display: flex;
    gap: 1rem;
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    border: none;
    transition: all 0.3s ease;
}

.btn.primary {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 4px 14px var(--accent-glow);
}

.btn.primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(59, 130, 246, 0.6);
}

.btn.table-header {
    padding: 1rem 1.5rem;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--glass-border);
}

/* Split Layout and Virtual Scroller Styles */
.split-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
    height: calc(100vh - 180px); /* Fill available space */
}
.split-left {
    flex: 1;
    min-width: 0;
    height: 100%;
    margin-right: 700px;
    transition: margin-right 0.3s ease;
}
.split-right {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 700px;
    background: rgba(17, 24, 39, 0.95);
    border-left: 1px solid var(--glass-border);
    box-shadow: -10px 0 30px rgba(0,0,0,0.5);
    transform: translateX(0);
    transition: transform 0.3s ease;
    z-index: 10;
}
.split-right.empty {
    transform: translateX(100%);
}
.detail-collapsed .split-left {
    margin-right: 0;
}
.panel-close-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    z-index: 20;
}
.panel-close-btn:hover {
    color: white;
}
tbody#packet-feed tr {
    border-bottom: 1px solid var(--glass-border);
    transition: background-color 0.2s;
}
tbody#packet-feed tr:hover {
    background-color: var(--glass-bg-hover);
}
tbody#packet-feed tr.selected {
    background-color: rgba(59, 130, 246, 0.2);
}
.detail-row {
    margin-bottom: 1rem;
}
.detail-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.2rem;
}
.detail-value {
    font-family: monospace;
    background: rgba(0,0,0,0.3);
    padding: 0.5rem;
    border-radius: 4px;
    word-break: break-all;
    font-size: 0.9rem;
}

.btn.secondary {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--glass-border);
}

.btn.secondary:hover {
    background: var(--glass-border);
}

.canvas-container {
    flex: 1;
    background: var(--shadow-main);
    border: 1px inset var(--glass-bg-hover);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 1.1rem;
    animation: fade-in-out 3s infinite ease-in-out;
}

@keyframes fade-in-out {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

.no-padding {
    padding: 0 !important;
}

.no-border {
    border: none !important;
    border-radius: 0 !important;
}

.bottom-nav {
    position: absolute;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    gap: 1rem;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    box-shadow: 0 10px 40px var(--shadow-strong);
    pointer-events: auto;
    background: rgb(39 43 51 / 85%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.95rem;
    border-radius: 30px;
    transition: all 0.3s ease;
}

.nav-item:hover {
    color: #fff;
    background: var(--glass-border);
}

.nav-item.active {
    color: #fff;
    background: var(--accent-color);
    box-shadow: 0 4px 14px var(--accent-glow);
}

.system-stats-bar {
    position: absolute;
    right: 1.5rem;
    z-index: 10;
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
    padding: 0.5rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.sys-stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sys-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sys-stat-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.sys-stat-divider {
    width: 1px;
    height: 20px;
    background: var(--glass-bg-active);
}

body.map-view-active .system-stats-bar.dark-overlay {
    border: 1px solid rgba(0, 0, 0, 0.2);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
body.map-view-active .system-stats-bar.dark-overlay .sys-stat-label {
    color: #4b5563;
}
body.map-view-active .system-stats-bar.dark-overlay .sys-stat-value {
    color: #111827;
}
body.map-view-active .system-stats-bar.dark-overlay .sys-stat-divider {
    background: rgba(0, 0, 0, 0.2);
}

#live-console {
    position: absolute;
    bottom: 100px;
    left: 1.5rem;
    height: 350px;
    width: 700px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    overflow-y: hidden;
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    font-size: 12px;
    padding: 5px;
    z-index: 10;
    pointer-events: auto;
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.console-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    line-height: 1.3;
}

.console-time {
    color: var(--text-muted);
    margin-right: 0.5rem;
}

#timeline-wrapper {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 60px;
    box-sizing: border-box;
    background: transparent;
    z-index: 10;
    pointer-events: auto;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

#timeline-controls {
    position: relative;
    z-index: 20;
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    height: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

#timeline-label {
    font-weight: bold;
    color: #fff;
}

#timeline-container {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    width: 100%;
    height: 40px;
    gap: 5px;
    cursor: pointer;
}

.timeline-bar {
    flex: 1;
    background: var(--accent-color);
    min-width: 1px;
    border-radius: 0;
    opacity: 0.6;
    transition: height 0.1s ease, opacity 0.1s ease, transform 0.1s ease;
    transform-origin: bottom;
}

.timeline-bar:hover, .timeline-bar.hovered, .timeline-bar.playing {
    opacity: 1;
    background: #fff;
    transform: scaleY(2.5);
    z-index: 2;
}

.timeline-bar.neighbor-1 {
    opacity: 0.9;
    transform: scaleY(1.8);
}

.timeline-bar.neighbor-2 {
    opacity: 0.8;
    transform: scaleY(1.4);
}

.resizer {
    position: absolute;
    right: 0;
    top: 20%;
    width: 2px;
    height: 60%;
    background: var(--glass-bg-active);
    cursor: col-resize;
    user-select: none;
    transition: background 0.2s, width 0.2s;
    border-radius: 2px;
}

.resizer:hover, .resizer:active {
    background: rgba(255,255,255,0.5);
    width: 4px;
}

.layer-btn, .toggle-btn {
    background: rgba(15, 23, 42, 0.7);
    color: #e2e8f0;
    border: 1px solid rgba(148, 163, 184, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px var(--shadow-main);
}

.layer-btn:hover, .toggle-btn:hover {
    background: rgba(15, 23, 42, 0.9);
    border-color: var(--accent-color);
    transform: translateY(-1px);
}

.layer-btn.active, .toggle-btn.active {
    background: var(--accent-color);
    color: #0f172a;
    border-color: var(--accent-color);
    font-weight: bold;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

.toggle-btn img {
    width: 24px;
    height: 24px;
    display: block;
    transition: filter 0.2s ease, opacity 0.2s ease;
}

.toggle-btn.active img {
    filter: brightness(0) !important; /* Black */
}

.toggle-btn:not(.active) img {
    filter: brightness(0) invert(1) !important; /* White */
    opacity: 0.7;
}

#node-popup {
    background: rgba(17, 24, 39, 0.6);
}

#map-legend {
    display: none;
    position: absolute;
    bottom: 465px;
    left: 1.5rem;
    width: max-content;
    z-index: 20;
    padding: 1.5rem;
    cursor: default;
}

#legend-content {
    font-size: 0.85rem;
    line-height: 1.4;
    color: #e2e8f0;
}

.legend-grid {
    display: grid;
    grid-template-columns: auto auto;
    column-gap: 16px;
    row-gap: 4px;
    align-items: center;
}

#live-console.dark-overlay,
#node-popup.dark-overlay,
#map-legend.dark-overlay {
    background: rgba(10, 15, 25, 0.65) !important;
}

/* Nodes and Channels Layout */
.split-layout {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}
.panel-left {
    flex: 1;
    background: rgba(17, 24, 39, 0.4);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
}
.panel-right {
    flex: 1;
    background: rgba(17, 24, 39, 0.6);
    overflow-y: auto;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}
.data-table th {
    text-align: left;
    padding: 15px 20px;
    border-bottom: 1px solid var(--glass-border);
    color: var(--text-muted);
    font-weight: 600;
    position: sticky;
    top: 0;
    background: rgba(17, 24, 39, 0.9);
    backdrop-filter: blur(5px);
    z-index: 5;
}
.data-table td {
    padding: 12px 20px;
    border-bottom: 1px solid var(--glass-bg-hover);
}
.data-table tr.interactive-row:hover {
    background: var(--glass-bg-hover);
    cursor: pointer;
}
.role-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
}

/* Channels */
.channel-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--glass-bg-hover);
    cursor: pointer;
    transition: background 0.2s;
}
.channel-item:hover, .channel-item.active {
    background: rgba(59, 130, 246, 0.15);
}
.channel-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 0.9rem;
}
.chat-message {
    display: flex;
    gap: 15px;
    max-width: 800px;
}
.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #111827;
    font-size: 1.1rem;
    flex-shrink: 0;
}
.chat-content {
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.chat-header {
    display: flex;
    gap: 10px;
    align-items: baseline;
}
.chat-header .mono {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-family: monospace;
}
.chat-bubble {
    background: var(--glass-bg-light);
    padding: 12px 16px;
    border-radius: 0 16px 16px 16px;
    line-height: 1.5;
    font-size: 0.95rem;
}
.chat-footer {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Cluster UI */
.cluster-marker {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 10;
}

.cluster-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(30, 41, 59, 0.95);
    border: 2px solid rgba(148, 163, 184, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-weight: 700;
    font-size: 1.4rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.5);
    z-index: 12;
}

.cluster-badges {
    display: flex;
    gap: 2px;
    justify-content: center;
    margin-bottom: -6px; /* overlap slightly under circle */
    z-index: 13; /* above the circle */
}

.cluster-badge {
    font-size: 0.65rem;
    font-weight: 600;
    color: #fff;
    padding: 2px 5px;
    border-radius: 3px;
    min-width: 14px;
    text-align: center;
    box-shadow: 0 2px 4px var(--shadow-strong);
}

.badge-r { background: #52525b; }
.badge-c { background: #3b82f6; }
.badge-s { background: #22c55e; }
.badge-o { background: #ea580c; }

/* Packets Page specific styles */
.packets-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.packets-section {
    padding: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.packets-header {
    flex-shrink: 0;
}

.packets-title {
    margin: 0;
}

.packets-controls {
    display: flex;
    gap: 15px;
    align-items: center;
}

.btn-pause {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    cursor: pointer;
    border: 1px solid var(--glass-border-strong);
    background: var(--shadow-strong);
    color: white;
    border-radius: 4px;
}

.btn-pause .material-symbols-outlined {
    font-size: 1.2rem;
}

.missed-badge {
    background: #ef4444;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: bold;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.5);
}

.search-input {
    padding: 8px 12px;
    width: 250px;
    background: var(--shadow-strong);
    border: 1px solid var(--glass-border-strong);
    color: white;
    border-radius: 4px;
}

.vscroll-viewport-custom {
    height: 100%;
    overflow-y: auto;
    overflow-x: auto;
    position: relative;
}

.vscroll-spacer {
    width: 1px;
    opacity: 0;
}

.packets-table {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.95rem;
}

.packets-table thead {
    position: sticky;
    top: 0;
    z-index: 5;
}

.packets-table-header-row {
    border-bottom: 2px solid var(--glass-border);
    color: var(--text-muted);
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(8px);
}

.packets-th {
    padding: 15px 20px;
    font-weight: 600;
    white-space: nowrap;
    position: relative;
    cursor: pointer;
    user-select: none;
}

.console-entry {
    color: var(--text-light);
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
    display: flex;
    justify-content: space-between;
}
.console-entry > div:first-child {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
}

.console-time-ago {
    white-space: nowrap;
    color: var(--text-main);
    margin-left: 10px;
    font-size: 1.0em;
    flex-shrink: 0;
    flex-grow: 0;
    min-width: 30px;
    text-align: right;
    padding-right: 12px;
}

.sort-icon {
    color: var(--accent-color);
    font-size: 0.8em;
}

.packets-td {
    padding: 12px 20px;
    white-space: nowrap;
    font-size: 0.95rem;
    border-bottom: 1px solid var(--glass-bg-hover);
    overflow: hidden;
    text-overflow: ellipsis;
}

.packets-td-path {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

.packets-td-details {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px;
    color: var(--text-muted);
}

.packets-td-center {
    text-align: center;
}

/* Javascript Generated Formatters */
.pkt-fmt-channel {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
    border: 1px solid rgba(34,197,94,0.4);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-right: 0.4rem;
}

.pkt-fmt-enc {
    background: var(--glass-border);
    color: #a1a1aa;
    border: 1px solid var(--glass-border-strong);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-right: 0.4rem;
}

.pkt-fmt-adv {
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
    border: 1px solid rgba(56,189,248,0.4);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    margin-right: 0.4rem;
}

.pkt-fmt-type {
    color: #fff;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    white-space: nowrap;
}

.pkt-fmt-repeats-empty {
    color: var(--text-muted);
}

.pkt-fmt-repeats {
    background: var(--accent-color);
    color: white;
    padding: 0.3rem 0.8rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: bold;
    box-shadow: 0 0 8px var(--accent-glow);
}

.pkt-fmt-path-node {
    background: var(--glass-border);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-right: 4px;
    display: inline-block;
    margin-bottom: 2px;
    border: 2px solid transparent;
}

.pkt-fmt-path-ambiguous {
    border: 1px dashed #ffffff;
}

.pkt-fmt-path-arrow {
    color: var(--text-muted);
    margin-right: 4px;
}

/* Custom Dark Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--shadow-main);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--glass-bg-active);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--glass-bg-light);
}

/* Analytics UI Extensions */
:root {
    --accent: var(--accent-color);
    --border: var(--glass-border);
    --status-green: #22c55e;
    --status-yellow: #eab308;
    --status-red: #ef4444;
}

.analytics-header { margin-bottom: 2rem; }
.analytics-header h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.analytics-filters { display: flex; gap: 1rem; margin: 1rem 0; }
.analytics-time-window-select { padding: 0.5rem; border-radius: 6px; background: rgba(0,0,0,0.3); color: white; border: 1px solid var(--glass-border); }
.analytics-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1rem; border-bottom: 1px solid var(--glass-border); padding-bottom: 1rem; }
.tab-btn { padding: 0.5rem 1rem; background: var(--glass-bg-hover); color: var(--text-muted); border: 1px solid var(--glass-border); border-radius: 6px; cursor: pointer; transition: 0.2s; font-weight: 500; }
.tab-btn:hover { background: var(--glass-border); }
.tab-btn.active { background: var(--accent-color); color: white; border-color: var(--accent-color); box-shadow: 0 0 10px var(--accent-glow); }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem; position: relative; z-index: 50; }
.stat-card { background: rgba(15, 23, 42, 0.7); border: 1px solid var(--glass-border); border-radius: 12px; padding: 1.5rem; display: flex; flex-direction: column; align-items: center; text-align: center; }
.stat-value { font-size: 2.5rem; font-weight: 700; color: white; margin-bottom: 0.5rem; }
.stat-label { color: var(--text-muted); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-detail { color: rgba(255,255,255,0.5); font-size: 0.8rem; margin-top: 0.5rem; }
.analytics-row { display: flex; flex-wrap: wrap; gap: 1.5rem; margin-bottom: 1.5rem; }
.analytics-card { background: rgba(15, 23, 42, 0.7); border: 1px solid var(--glass-border); border-radius: 12px; padding: 1.5rem; flex: 1; min-width: 300px; }
.analytics-card h3 { margin-bottom: 0.5rem; color: white; border-bottom: 1px solid var(--glass-border); padding-bottom: 0.5rem; }
.rf-stats { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 1rem; margin-top: 1rem; font-size: 0.9rem; color: var(--text-muted); background: var(--shadow-main); padding: 0.75rem; border-radius: 6px; }
.rf-stats strong { color: white; }
.analytics-table { width: 100%; border-collapse: collapse; margin-top: 1rem; font-size: 0.9rem; }
.analytics-table th, .analytics-table td { padding: 0.75rem; border-bottom: 1px solid var(--glass-border); text-align: left; }
.analytics-table th { color: var(--text-muted); font-weight: 600; }
.hash-bar-track { background: var(--glass-border); border-radius: 4px; overflow: hidden; height: 8px; flex-grow: 1; }
.hash-bar-fill { height: 100%; border-radius: 4px; }
.payload-bars { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
.payload-bar-row { display: flex; align-items: center; gap: 1rem; }
.payload-bar-label { width: 120px; color: white; display: flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; }
.payload-bar-value { width: 100px; text-align: right; font-size: 0.9rem; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.repeater-row { display: flex; align-items: center; gap: 1rem; padding: 0.5rem 0; border-bottom: 1px solid var(--glass-bg-hover); }
.repeater-name { width: 150px; color: white; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 0.9rem; }
.repeater-bar { flex: 1; }
.repeater-count { width: 80px; text-align: right; color: var(--text-muted); font-size: 0.9rem; }
.mono { font-family: monospace; color: var(--accent-color); }
.reach-rings { display: flex; flex-direction: column; gap: 1rem; margin-top: 1rem; }
.reach-ring { display: flex; flex-wrap: wrap; align-items: baseline; gap: 1rem; padding: 1rem; background: var(--shadow-main); border-radius: 8px; border-left: 3px solid var(--accent-color); }
.reach-hop { font-weight: 700; color: white; width: 60px; }
.reach-nodes { flex: 1; color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }
.reach-count { color: var(--accent-color); font-weight: 600; font-size: 0.9rem; }
.analytics-link { color: var(--accent-color); text-decoration: none; }
.analytics-link:hover { text-decoration: underline; }
.timeline-legend { display: flex; gap: 1.5rem; justify-content: center; margin-top: 1rem; font-size: 0.8rem; color: var(--text-muted); }
.timeline-legend span { display: flex; align-items: center; gap: 0.5rem; }

/* Map Legend Styles */
.legend-section {
    margin-bottom: 1.2rem;
}
.legend-section:last-child {
    margin-bottom: 0;
}
.legend-header {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin: 0 0 0.5rem 0;
    font-weight: 600;
}
.legend-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.4rem;
}
.legend-item:last-child {
    margin-bottom: 0;
}
.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 14px; /* compensate for smaller dot to align text */
    flex-shrink: 0;
}

.legend-icon {
    width: 16px;
    height: 16px;
    margin-right: 10px;
    flex-shrink: 0;
    object-fit: contain;
    filter: drop-shadow(0 0 2px var(--glass-bg-light));
}

@keyframes ambiguous-pulse {
    0%   { background: #000; box-shadow: 0 0 0 #000; }
    10%  { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
    20%  { background: #000; box-shadow: 0 0 0 #000; }
    30%  { background: #3b82f6; box-shadow: 0 0 6px #3b82f6; }
    40%  { background: #000; box-shadow: 0 0 0 #000; }
    50%  { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
    60%  { background: #000; box-shadow: 0 0 0 #000; }
    70%  { background: #a855f7; box-shadow: 0 0 6px #a855f7; }
    80%  { background: #000; box-shadow: 0 0 0 #000; }
    90%  { background: #06b6d4; box-shadow: 0 0 6px #06b6d4; }
    100% { background: #000; box-shadow: 0 0 0 #000; }
}

.ambiguous-dot {
    animation: ambiguous-pulse 3s infinite;
    width: 10px;
    height: 10px;
    margin-right: 12px;
}
.legend-shape {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 10px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.8);
    background: var(--glass-border);
}
.shape-circle {
    border-radius: 50%;
}
.shape-square {
    border-radius: 2px;
}
.shape-hexagon {
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
    border-radius: 0;
}
.shape-triangle {
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    border-radius: 0;
}
.shape-diamond {
    transform: rotate(45deg) scale(0.8);
}
.marker-bright {
    border-color: rgba(255,255,255,1);
    border-width: 2px;
}
.marker-faded {
    border-color: rgba(255,255,255,0.4);
}

/* Fullscreen Transition Helpers */
.slide-transition {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Tooltip Styles */
.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    color: var(--accent);
    margin-left: 6px;
}
.info-tooltip .tooltip-text {
    visibility: hidden;
    width: 280px;
    background-color: rgba(15, 23, 42, 0.95);
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 10px;
    position: absolute;
    z-index: 100;
    top: 150%;
    left: 50%;
    margin-left: -140px;
    opacity: 0;
    transition: opacity 0.3s;
    font-size: 0.85rem;
    border: 1px solid var(--glass-border);
    font-weight: normal;
    line-height: 1.4;
    pointer-events: none;
}
.info-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.bottom-nav.slide-up { transform: translate(-50%, -100px); }

