body {
    margin: 0;
    background: #111;
    color: white;
    font-family: Arial, sans-serif;
    overflow: auto;
}

#header {
    min-height: 60px;
    height: auto;
    background: #222;
    border-bottom: 1px solid #444;
    display: flex;
    align-items: center;
    padding: 6px 20px;
    font-size: 20px;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}

/* Barra de herramientas */
#toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    background: #444;
    color: white;
    border: 1px solid #666;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: background 0.2s;
}

.btn:hover { background: #555; }
.btn.active { background: #f39c12; color: #111; border-color: #f39c12; font-weight: bold; }

#main {
    display: grid;
    grid-template-columns: 280px minmax(320px, 1fr) 320px;
    height: calc(100vh - 60px);
    position: relative;
}

#left {
    width: 280px;
    flex: 0 0 280px;
    background: #202020;
    overflow: auto;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #444;
}

#right {
    width: 320px;
    flex: 0 0 320px;
    background: #181b20;
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #2d333b;
}

#center {
    min-width: 320px;
    position: relative;
}

.title {
    background: #333;
    padding: 10px;
    font-weight: bold;
}

.panel-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8b949e;
    background: #1c2128;
    padding: 6px 12px;
    border-top: 1px solid #2d333b;
    border-bottom: 1px solid #2d333b;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tree, .prop {
    padding: 10px 12px;
    line-height: 22px;
    font-size: 13px;
}

/* Floor CSMA Card */
.floor-card {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(30, 27, 75, 0.4) 100%);
    border: 1px solid rgba(245, 158, 11, 0.35);
    border-radius: 6px;
    margin: 8px 10px;
    padding: 10px 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.floor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.floor-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #fbbf24;
}

.floor-badge {
    font-family: 'JetBrains Mono', monospace, Consolas, sans-serif;
    font-size: 11px;
    font-weight: 700;
    background: #78350f;
    color: #fef3c7;
    border: 1px solid #d97706;
    padding: 2px 8px;
    border-radius: 4px;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.3);
    transition: all 0.2s ease;
}

.floor-badge.active {
    background: #b45309;
    color: #fff;
    border-color: #f59e0b;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
}

.floor-phase-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
}

.floor-phase-tag {
    font-weight: 600;
    font-size: 10px;
    background: #1e293b;
    color: #38bdf8;
    border: 1px solid #334155;
    padding: 1px 6px;
    border-radius: 3px;
}

.floor-subtext {
    color: #94a3b8;
    font-size: 10px;
    font-style: italic;
}

/* Simulation Controls Card */
.sim-controls-card {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #1a1e24;
    border-bottom: 1px solid #2d333b;
}

.sim-clock-display {
    background: #0f1318;
    border: 1px solid #2d333b;
    border-radius: 6px;
    padding: 6px 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.clock-label {
    font-size: 10px;
    font-weight: 700;
    color: #8b949e;
    letter-spacing: 0.5px;
}

.clock-val {
    font-family: 'JetBrains Mono', monospace, Consolas, sans-serif;
    font-size: 15px;
    font-weight: 700;
    color: #38bdf8;
    text-shadow: 0 0 6px rgba(56, 189, 248, 0.3);
}

.sim-btn-group {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.btn-ctrl {
    padding: 6px 4px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
}

.btn-ctrl:active {
    transform: scale(0.97);
}

.btn-play {
    background: #15803d;
    color: #fff;
    border: 1px solid #22c55e;
}

.btn-play:hover {
    background: #16a34a;
}

.btn-pause {
    background: #b45309;
    color: #fff;
    border: 1px solid #f59e0b;
}

.btn-pause:hover {
    background: #d97706;
}

.btn-step {
    background: #1e293b;
    color: #e2e8f0;
    border: 1px solid #475569;
}

.btn-step:hover {
    background: #334155;
}

.sim-speed-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #94a3b8;
}

.sim-speed-select {
    background: #0f1318;
    border: 1px solid #334155;
    color: #f1f5f9;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 11px;
    flex: 1;
}

.sim-status-pill {
    font-size: 10px;
    background: #1e293b;
    color: #10b981;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #059669;
    white-space: nowrap;
}

.sim-status-pill.error {
    background: #450a0a;
    color: #f87171;
    border-color: #ef4444;
}

.sim-counters {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #8b949e;
    padding-top: 4px;
    border-top: 1px dashed #2d333b;
}

/* Quick Traffic Card */
.quick-traffic-card {
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: #1a1e24;
    border-bottom: 1px solid #2d333b;
}

.btn-quick {
    width: 100%;
    background: #1f2937;
    color: #e5e7eb;
    border: 1px solid #374151;
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 500;
    border-radius: 5px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-quick:hover {
    background: #374151;
    border-color: #4b5563;
    color: #fff;
}

.quick-traffic-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.btn-flutter-app {
    background: linear-gradient(135deg, #0284c7 0%, #06b6d4 100%);
    border-color: #38bdf8;
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    text-align: center;
}

.btn-flutter-app:hover {
    background: linear-gradient(135deg, #0369a1 0%, #0891b2 100%);
    border-color: #7dd3fc;
    box-shadow: 0 3px 12px rgba(6, 182, 212, 0.4);
    color: #ffffff;
}

.btn-chat-quick {
    background: linear-gradient(90deg, #065f46 0%, #047857 100%);
    border-color: #10b981;
    color: #ecfdf5;
    font-weight: 600;
}

.btn-chat-quick:hover {
    background: linear-gradient(90deg, #047857 0%, #059669 100%);
}

/* Telemetry Grid */
.telemetry-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 10px 12px;
    background: #1a1e24;
    border-bottom: 1px solid #2d333b;
}

.telemetry-item {
    background: #0f1318;
    border: 1px solid #2d333b;
    border-radius: 5px;
    padding: 6px 8px;
}

.telemetry-label {
    font-size: 10px;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.telemetry-val {
    font-family: 'JetBrains Mono', monospace, Consolas, sans-serif;
    font-size: 15px;
    font-weight: 700;
    margin-top: 2px;
}

.empty-node-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px 10px;
    color: #64748b;
    font-size: 12px;
    gap: 6px;
}

/* RNS Routing Table inside Inspector */
.rns-table-container {
    margin-top: 8px;
    background: #0f172a;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 11px;
}

.rns-table-header {
    display: flex;
    justify-content: space-between;
    color: #94a3b8;
    font-weight: 600;
    margin-bottom: 4px;
    border-bottom: 1px solid #1e293b;
    padding-bottom: 3px;
}

.rns-route-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 3px 0;
    border-bottom: 1px dashed rgba(51, 65, 85, 0.4);
    font-family: 'JetBrains Mono', monospace, Consolas, sans-serif;
}

.rns-route-item:last-child {
    border-bottom: none;
}

.rns-dest-hash {
    color: #38bdf8;
    font-weight: 600;
}

.rns-target-hop {
    color: #10b981;
    font-weight: 600;
    background: #1e293b;
    padding: 1px 4px;
    border-radius: 3px;
}

.sim-events {
    padding: 8px 12px;
    color: #aaa;
    font-size: 11px;
    line-height: 16px;
    max-height: 250px;
    overflow-y: auto;
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

/* Menús Flotantes (Contextual y Selectores) */
#context-menu, #link-selector {
    display: none;
    position: absolute;
    background: #333;
    border: 1px solid #555;
    box-shadow: 2px 2px 10px rgba(0,0,0,0.7);
    z-index: 1000;
    border-radius: 4px;
    overflow: hidden;
}

#link-selector {
    padding: 12px;
    width: 180px;
}

#link-selector label {
    display: block;
    font-size: 12px;
    margin-bottom: 6px;
    color: #bbb;
}

#link-selector select {
    width: 100%;
    background: #222;
    color: white;
    border: 1px solid #555;
    padding: 5px;
    border-radius: 4px;
    margin-bottom: 10px;
}

#link-selector .actions {
    display: flex;
    gap: 5px;
    justify-content: flex-end;
}

.ctx-item {
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
}

.ctx-item:hover { background: #444; }

/* Input file oculto para importar */
#file-input { display: none; }

@media (max-width: 900px) {
    #main {
        min-width: 960px;
        overflow-x: auto;
    }
}
