:root {
    --bg: #0a0a0a;
    --bg2: #141414;
    --bg3: #1e1e1e;
    --border: #2a2a2a;
    --text: #e0e0e0;
    --text2: #888;
    --green: #22c55e;
    --green-dim: #166534;
    --blue: #3b82f6;
    --red: #ef4444;
    --yellow: #eab308;
    --purple: #a855f7;
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html, body {
    height: 100%;
    overflow: hidden;
    touch-action: manipulation;
}
body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 100;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    overflow: hidden;
}

.logo-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-wrap img {
    width: 28px;
    height: 28px;
}

.logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--green);
    letter-spacing: -0.5px;
}

/* BLE status icon */
.ble-status {
    font-size: 16px;
    transition: color var(--transition);
    display: flex;
    align-items: center;
}
.ble-status.disconnected { color: var(--red); }
.ble-status.connected { color: var(--blue); animation: ble-pulse 3s ease-in-out infinite; }
.ble-status.connecting {
    color: var(--yellow);
    animation: pulse-badge 1s ease-in-out infinite;
}

/* Header battery */
.header-battery {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    background: var(--bg3);
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    transition: all var(--transition);
}
.header-battery-icon {
    font-size: 16px;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}
.header-battery-pct {
    min-width: 28px;
    text-align: right;
}

/* Internet status icon */
.net-status {
    font-size: 14px;
    display: flex;
    align-items: center;
    transition: color var(--transition);
}
.net-status.online { color: var(--green); }
.net-status.offline { color: var(--text2); opacity: 0.5; }

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

@keyframes ble-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Last sync indicator */
.last-sync {
    font-size: 10px;
    color: var(--text2);
    padding: 4px 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 4px;
}
.last-sync .dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green);
    animation: ble-pulse 2s ease-in-out infinite;
}

.btn {
    padding: 6px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--green); color: #000; }
.btn-primary:hover:not(:disabled) { background: #16a34a; transform: translateY(-1px); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #dc2626; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Disconnected overlay — blur backdrop */
.disconnected-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s, visibility 0.4s;
}
.disconnected-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.disconnected-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px;
    max-width: 340px;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 49px 0 0 0;
    background: rgba(0,0,0,0.5);
    z-index: 89;
}
.sidebar-overlay.active { display: block; }

/* Layout */
.app {
    display: grid;
    grid-template-columns: 280px 1fr;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    background: var(--bg2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    -webkit-overflow-scrolling: touch;
}

/* Mobile toggle button */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        display: none !important;
        position: fixed;
        inset: 49px 0 0 0;
        z-index: 90;
        flex-direction: column;
        overflow-y: auto;
    }
    .sidebar.active {
        display: flex !important;
        animation: slideInLeft 0.25s ease-out;
    }
    .main { min-width: 0; min-height: 0; height: 100%; }
    .mobile-menu-btn { display: block; }
    .header .logo-wrap .logo { font-size: 15px; }
    .header { padding: 8px 12px; gap: 8px; }
    .header-left { gap: 6px; }
    .header-battery { padding: 2px 6px; font-size: 10px; }
    .header-battery-icon { font-size: 14px; }
    .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { padding: 10px 12px; font-size: 12px; white-space: nowrap; }
    .radio-grid, .radio-grid[style] { grid-template-columns: 1fr 1fr !important; gap: 8px; }
    .radio-card { padding: 12px; }
    .radio-card .value { font-size: 16px; }
    .chat-input { padding: 8px 12px; }
    .chat-input input { font-size: 16px; }
    .panel { padding: 12px; }
    .actions-row { gap: 6px; }
    .btn { padding: 8px 14px; font-size: 14px; }
    .btn-sm { padding: 6px 10px; font-size: 12px; }
    #tab-config input[type="text"],
    #tab-config input[type="number"],
    #tab-config select { font-size: 16px; }
    #nodesTable { font-size: 11px; }
    #nodesTable th, #nodesTable td { padding: 6px 4px; }
    #nodesTable .btn-sm { padding: 4px 6px; font-size: 10px; }
    /* Chat panel fills screen on mobile */
    .chat-panel.active { flex: 1; min-height: 0; overflow: hidden; }
    #chatView { min-height: 0; height: 100%; }
    .chat-messages { min-height: 0; flex: 1; }
    .panel.active { min-height: 0; }
}

@media (max-width: 400px) {
    .radio-grid, .radio-grid[style] { grid-template-columns: 1fr !important; }
    .header-left .logo-wrap .logo { display: none; }
}

.sidebar-section {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text2);
    margin-bottom: 8px;
}

/* Device Info Cards */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.info-item {
    background: var(--bg3);
    padding: 8px;
    border-radius: 6px;
    transition: background var(--transition);
}

.info-label {
    font-size: 10px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.info-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    word-break: break-all;
    transition: color var(--transition);
}

.info-item.full { grid-column: span 2; }

/* Battery bar */
.battery-bar {
    width: 100%;
    height: 6px;
    background: var(--bg);
    border-radius: 3px;
    margin-top: 4px;
    overflow: hidden;
}
.battery-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1), background 0.6s;
}

/* Contacts List */
.contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition);
}
.contact-item:hover { background: var(--bg3); }
.contact-item.selected { background: var(--green-dim); }

.contact-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
    transition: transform var(--transition);
}
.contact-item:hover .contact-avatar { transform: scale(1.1); }
.contact-avatar.chat { background: var(--blue); color: #fff; }
.contact-avatar.repeater { background: var(--purple); color: #fff; }
.contact-avatar.room { background: var(--yellow); color: #000; }
.contact-avatar.sensor { background: var(--green); color: #000; }
.contact-avatar.unknown { background: var(--text2); color: #fff; }

.contact-info { flex: 1; min-width: 0; position: relative; }

/* Unread badge */
.unread-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9px;
    background: var(--red);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
    animation: badgePop 0.3s ease-out;
}
@keyframes badgePop {
    0% { transform: scale(0); }
    60% { transform: scale(1.2); }
    100% { transform: scale(1); }
}
.contact-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.contact-meta {
    font-size: 11px;
    color: var(--text2);
}

/* Recent chats list */
.recent-chat-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background var(--transition);
    margin-bottom: 2px;
}
.recent-chat-item:hover { background: var(--bg3); }
.recent-chat-item .rc-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.recent-chat-item .rc-info { flex: 1; min-width: 0; }
.recent-chat-item .rc-name { font-size: 13px; font-weight: 500; }
.recent-chat-item .rc-preview {
    font-size: 11px; color: var(--text2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.recent-chat-item .rc-meta {
    display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0;
}
.recent-chat-item .rc-time { font-size: 10px; color: var(--text2); }
.recent-chat-item .rc-delete-btn {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text2); cursor: pointer;
    font-size: 14px; padding: 4px 6px; border-radius: 4px;
    opacity: 0; transition: opacity 0.15s, color 0.15s;
}
.recent-chat-item:hover .rc-delete-btn { opacity: 1; }
.recent-chat-item .rc-delete-btn:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* Main content area */
.main {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    height: 100%;
}

/* Chat view container — visibility controlled by JS inline style */
#chatView {
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    padding: 0 12px;
}

.tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text2);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all var(--transition);
    position: relative;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--green); border-bottom-color: var(--green); }

/* Content panels — animated */
.panel {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: none;
    min-height: 0;
}
.panel.active {
    display: block;
    opacity: 1;
    animation: fadeIn 0.3s ease-out;
}

.chat-panel {
    flex: 1;
    display: none;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.chat-panel.active {
    display: flex;
    opacity: 1;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeSlideIn {
    from { opacity: 0; transform: translateX(-8px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Chat */
.chat-header {
    padding: 12px 16px;
    background: var(--bg2);
    border-bottom: 1px solid var(--border);
    font-weight: 500;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.msg-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
    animation: msgAppear 0.25s ease-out both;
}
@keyframes msgAppear {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.msg-bubble.incoming {
    background: var(--bg3);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}
.msg-bubble.outgoing {
    background: var(--green-dim);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}
.msg-meta {
    font-size: 10px;
    color: var(--text2);
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

/* Message status indicators */
.msg-status {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    font-weight: 500;
    padding: 1px 6px;
    border-radius: 3px;
    transition: all 0.3s ease;
}
.msg-status.sending {
    color: var(--text2);
    background: rgba(255,255,255,0.05);
}
.msg-status.sending::before {
    content: '';
    width: 6px; height: 6px;
    border: 1.5px solid var(--text2);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}
.msg-status.waiting-ack {
    color: var(--yellow);
    background: rgba(234,179,8,0.1);
}
.msg-status.waiting-ack::before {
    content: '';
    width: 6px; height: 6px;
    border: 1.5px solid var(--yellow);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}
.msg-status.sent-flood {
    color: var(--blue);
    background: rgba(59,130,246,0.1);
}
.msg-status.delivered {
    color: var(--green);
    background: rgba(34,197,94,0.1);
    animation: statusPop 0.3s ease-out;
}
.msg-status.timeout {
    color: var(--red);
    background: rgba(239,68,68,0.1);
}
.msg-status.failed {
    color: var(--red);
    background: rgba(239,68,68,0.1);
}

@keyframes statusPop {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

/* Timeout countdown */
.msg-timeout-bar {
    height: 2px;
    background: var(--yellow);
    border-radius: 1px;
    margin-top: 3px;
    transition: width 0.5s linear;
    opacity: 0.6;
}

.chat-input {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg2);
    border-top: 1px solid var(--border);
}

.chat-input input {
    flex: 1;
    padding: 8px 12px;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color var(--transition);
}
.chat-input input:focus { border-color: var(--green); }

/* Welcome/empty state */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text2);
    gap: 8px;
    padding: 40px;
    text-align: center;
}

/* Radio info panel */
.radio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.radio-card {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    transition: border-color var(--transition), transform var(--transition);
}
.radio-card:hover { border-color: #3a3a3a; transform: translateY(-1px); }

.radio-card .label {
    font-size: 11px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.radio-card .value {
    font-size: 20px;
    font-weight: 700;
    color: var(--green);
    margin-top: 4px;
    transition: color var(--transition);
}

.radio-card .unit {
    font-size: 12px;
    color: var(--text2);
    font-weight: 400;
}

/* Action buttons row */
.actions-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

/* Log panel */
.log-container {
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    max-height: 100%;
    overflow-y: auto;
}

.log-entry {
    padding: 2px 0;
    color: var(--text2);
    border-bottom: 1px solid #1a1a1a;
    animation: fadeSlideIn 0.15s ease-out both;
}

.log-entry .time { color: var(--text2); margin-right: 8px; }
.log-entry .msg { color: var(--text); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text2); }

/* No BLE warning */
.no-ble-warning {
    background: #7f1d1d;
    color: #fca5a5;
    padding: 12px 20px;
    font-size: 13px;
    text-align: center;
}

/* ===== Connecting Overlay ===== */
.connecting-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease-out forwards;
}

.connecting-overlay.hiding {
    animation: fadeOut 0.3s ease-in forwards;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.connecting-spinner {
    width: 56px;
    height: 56px;
    position: relative;
    margin-bottom: 20px;
}

.connecting-spinner .ring {
    position: absolute;
    inset: 0;
    border: 3px solid transparent;
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.connecting-spinner .ring:nth-child(2) {
    inset: 6px;
    border-top-color: transparent;
    border-right-color: var(--green);
    opacity: 0.6;
    animation-duration: 1.5s;
    animation-direction: reverse;
}

.connecting-spinner .ring:nth-child(3) {
    inset: 12px;
    border-top-color: transparent;
    border-bottom-color: var(--green);
    opacity: 0.3;
    animation-duration: 2s;
}

.connecting-spinner .logo-center {
    position: absolute;
    inset: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.connecting-spinner .logo-center img {
    width: 20px;
    height: 20px;
    animation: pulse-logo 1.5s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes pulse-logo {
    0%, 100% { opacity: 0.7; transform: scale(0.9); }
    50% { opacity: 1; transform: scale(1.1); }
}

.connecting-text {
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 6px;
}

.connecting-sub {
    color: var(--text2);
    font-size: 12px;
}

.connecting-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* ===== Advert items animated ===== */
.advert-item {
    display: flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 4px;
    margin-bottom: 2px;
    font-size: 11px;
    transition: background var(--transition);
}
.advert-item:hover { background: var(--bg3); }

.advert-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.advert-dot.saved { background: var(--green); }
.advert-dot.new {
    background: var(--yellow);
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.4); }
    50% { box-shadow: 0 0 0 4px rgba(234, 179, 8, 0); }
}

/* ===== Channel items ===== */
.channel-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 6px;
    cursor: pointer;
    transition: all var(--transition);
}
.channel-item:hover { background: var(--bg3); border-color: #3a3a3a; }

/* ===== Mesh Tab Layout ===== */
.mesh-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
}
.mesh-col {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.mesh-col-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border);
}
.mesh-col-head i { color: var(--green); font-size: 13px; }
.mesh-scroll-list {
    flex: 1;
    overflow-y: auto;
    max-height: 380px;
    min-height: 120px;
}
.mesh-empty {
    padding: 20px 12px;
    text-align: center;
    color: var(--text2);
    font-size: 11px;
}
.mesh-stat {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 10px;
}
.mesh-stat-val { font-size: 16px; font-weight: 700; color: var(--green); }
.mesh-stat-lbl { font-size: 10px; color: var(--text2); }

/* Node card in list */
.mesh-node-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    margin-bottom: 3px;
    transition: background 0.15s;
    font-size: 12px;
}
.mesh-node-card:hover { background: var(--bg3); }
.mesh-node-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1.5px solid rgba(255,255,255,0.3);
}
.mesh-node-info { flex: 1; min-width: 0; }
.mesh-node-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
.mesh-node-meta { font-size: 9px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mesh-node-actions { display: flex; gap: 2px; flex-shrink: 0; }
.mesh-node-actions button {
    background: none; border: none; color: var(--text2); cursor: pointer;
    padding: 2px 4px; font-size: 12px; border-radius: 4px; transition: all 0.15s;
}
.mesh-node-actions button:hover { color: var(--text); background: var(--bg3); }

.mesh-btn-label { display: inline; }

/* Radar scan loading animation */
.radar-scan-anim {
    width: 48px;
    height: 48px;
    position: relative;
}
.radar-scan-ring {
    position: absolute;
    inset: 0;
    border: 1.5px solid rgba(34, 197, 94, 0.3);
    border-radius: 50%;
    animation: radarPing 2s ease-out infinite;
}
.radar-scan-ring.r2 {
    animation-delay: 1s;
}
.radar-scan-dot {
    position: absolute;
    top: 50%; left: 50%;
    width: 6px; height: 6px;
    margin: -3px 0 0 -3px;
    background: #22c55e;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.6);
}
@keyframes radarPing {
    0% { transform: scale(0.3); opacity: 1; border-color: rgba(34,197,94,0.6); }
    100% { transform: scale(1.8); opacity: 0; border-color: rgba(34,197,94,0); }
}

/* Mesh loading overlay */
.mesh-loading {
    position: absolute;
    inset: 0;
    background: rgba(10,10,10,0.85);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: opacity 0.3s;
}
.mesh-loading.hidden {
    opacity: 0;
    pointer-events: none;
}
.mesh-loading-inner {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text2);
    font-size: 13px;
}
.mesh-loading-spin {
    font-size: 16px;
    color: var(--green);
    animation: spin 1s linear infinite;
}

@media (max-width: 768px) {
    .mesh-grid { grid-template-columns: 1fr; }
    .mesh-scroll-list { max-height: 250px; }
    .mesh-btn-label { display: none; }
}
@media (min-width: 769px) and (max-width: 1100px) {
    .mesh-grid { grid-template-columns: 1fr 1fr; }
    .mesh-grid .mesh-col:first-child { grid-column: span 2; }
}

/* ===== Map ===== */
#tab-map.active {
    display: flex;
    flex-direction: column;
    padding: 0;
}
#mapContainer {
    flex: 1;
    min-height: 0;
    z-index: 1;
}
/* Dark theme for leaflet tiles */
.leaflet-tile-pane { filter: none; }
.leaflet-control-zoom a {
    background: var(--bg2) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}
.leaflet-control-attribution {
    background: rgba(10,10,10,0.7) !important;
    color: var(--text2) !important;
    font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--text2) !important; }
.leaflet-popup-content-wrapper {
    background: var(--bg2) !important;
    color: var(--text) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5) !important;
}
.leaflet-popup-tip { background: var(--bg2) !important; }
.leaflet-popup-content { font-size: 12px; margin: 10px 14px; }
.map-node-label {
    background: none !important; border: none !important;
    width: auto !important; height: auto !important;
    transform: translateX(-50%);
}
.map-node-label span {
    display: inline-block;
    background: rgba(0,0,0,0.82);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 3px;
    white-space: nowrap;
    line-height: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.5);
    pointer-events: none;
}

.map-style-opt {
    display: block; width: 100%; text-align: left;
    background: none; border: none; color: var(--text);
    padding: 6px 10px; border-radius: 5px; cursor: pointer;
    font-size: 12px; font-weight: 500;
}
.map-style-opt:hover { background: var(--bg2); }

/* ===== Realtime value update flash ===== */
.value-updated {
    animation: flashGreen 0.8s ease-out;
}

@keyframes flashGreen {
    0% { color: #4ade80; text-shadow: 0 0 6px rgba(74, 222, 128, 0.5); }
    100% { color: inherit; text-shadow: none; }
}
