:root {
    --bg-main: #121212;
    --bg-panel: #1e1e1e;
    --bg-header: #2d2d2d;
    --text-main: #e0e0e0;
    --text-muted: #888;
    --accent-1: #ff6b6b;
    --accent-2: #4ecdc4;
    --accent-3: #f7b731;
    --accent-4: #45b7d1;
    --border: #333;
    --font-ui: 'Inter', sans-serif;
    --font-code: 'JetBrains Mono', monospace;
}

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

body {
    font-family: var(--font-ui);
    background-color: var(--bg-main);
    color: var(--text-main);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.topbar {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 6px 15px;
    background-color: var(--bg-header);
    border-bottom: 1px solid var(--border);
    gap: 0;
    flex-shrink: 0;
}

.topbar-sep {
    width: 1px;
    height: 22px;
    background: var(--border);
    margin: 0 10px;
    flex-shrink: 0;
}

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

.branding h1 {
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}

.badge {
    display: none;
}

.controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.controls label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.controls select {
    background-color: #333;
    color: #fff;
    border: 1px solid #555;
    padding: 3px 6px;
    border-radius: 4px;
    font-family: var(--font-ui);
    font-size: 11px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.2s;
}

.controls select:focus,
.controls select:hover {
    border-color: #667eea;
}

/* Toggle Switch */
.linker-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #252526;
    padding: 3px 10px;
    border-radius: 14px;
    border: 1px solid #444;
}

.linker-toggle label,
.linker-toggle .linked-lbl {
    cursor: pointer;
    transition: color 0.3s;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.linker-toggle .active {
    color: var(--accent-2) !important;
}

.linker-toggle b {
    color: #fff;
}

.switch {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 18px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #555;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: #4ecdc4;
}

input:checked+.slider:before {
    transform: translateX(18px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

.linked-lbl {
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.3s;
}

#lbl-obj.active b {
    color: #f7b731;
}

#lbl-exe.active b {
    color: #4ecdc4;
}

.dashboard-grid {
    display: flex;
    flex: 1;
    gap: 10px;
    padding: 10px;
    overflow: hidden;
    min-height: 0;
}

.column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
    min-height: 0;
}

.panel {
    background-color: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0 14px 14px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.panel-top {
    flex: 6;
    min-height: 0;
}

.panel-bottom {
    flex: 4;
    min-height: 0;
}

.panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 14px 14px;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.panel-title {
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #333;
    padding: 10px 0 6px;
    position: sticky;
    top: 0;
    background: var(--bg-panel);
    z-index: 2;
    flex-shrink: 0;
}

p.hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
    line-height: 1.4;
}

.code-panel {
    font-family: var(--font-code);
    font-size: 13px;
    line-height: 1.6;
}

.code-line {
    display: flex;
    align-items: center;
    padding: 2px 5px;
    border-radius: 4px;
    position: relative;
    cursor: default;
    transition: background 0.2s;
}

.code-line:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Global highlight class triggers everywhere */
.highlight-active {
    background: rgba(255, 255, 255, 0.12) !important;
    box-shadow: inset 3px 0 0 #fff;
    color: #fff;
}

.line-number {
    color: #666;
    width: 25px;
    text-align: right;
    margin-right: 15px;
    user-select: none;
}

.code-content {
    flex: 1;
}

.keyword {
    color: #c586c0;
}

.string {
    color: #ce9178;
}

.number {
    color: #b5cea8;
}

.comment {
    color: #6a9955;
}

.function {
    color: #dcdcaa;
}

.variable {
    color: #9cdcfe;
    cursor: pointer;
    border-bottom: 1px dashed #555;
    transition: color 0.2s;
}

.variable:hover {
    color: #fff;
    border-bottom-color: #fff;
}

.color-bar {
    display: inline-block;
    width: 4px;
    height: 16px;
    margin-right: 10px;
    border-radius: 2px;
    vertical-align: middle;
}

.asm-color-1 {
    background: var(--accent-1);
}

.asm-color-2 {
    background: var(--accent-2);
}

.asm-color-3 {
    background: var(--accent-3);
}

.asm-color-4 {
    background: #666;
}

.asm-color-5 {
    background: #5f27cd;
}

.asm-color-6 {
    background: #28a745;
}

.legend {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    font-size: 12px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #bbb;
    padding: 2px 6px;
    border-radius: 4px;
}

.symbol-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-code);
    font-size: 13px;
}

.symbol-table th {
    background: #2a2d32;
    color: #fff;
    padding: 10px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #444;
}

.symbol-table td {
    padding: 10px;
    border-bottom: 1px solid #333;
    color: #ccc;
    transition: background 0.2s;
}

.machine-code-item {
    display: flex;
    background: #252526;
    padding: 8px 12px;
    margin-bottom: 8px;
    border-radius: 6px;
    font-family: var(--font-code);
    font-size: 13px;
    align-items: center;
    gap: 15px;
    transition: background 0.2s;
}

.mc-addr {
    color: #666;
    width: 70px;
}

.mc-asm {
    flex: 1;
    color: #dcdcaa;
}

.mc-hex {
    color: #ce9178;
    letter-spacing: 1px;
}

.memory-viz {
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: var(--font-code);
    font-size: 13px;
}

.memory-row {
    display: flex;
    background: #252526;
    border-radius: 4px;
    overflow: hidden;
    transition: background 0.2s;
}

.mem-addr {
    padding: 8px 12px;
    background: #333;
    color: #999;
    width: 105px;
    border-right: 1px solid #444;
}

.mem-data {
    padding: 8px 12px;
    flex: 1;
    display: flex;
    justify-content: space-between;
    position: relative;
}

.mem-data.seg-header {
    border-left: 3px solid #f7b731;
}

.mem-data.seg-text {
    border-left: 3px solid #5f27cd;
}

.mem-data.seg-rodata {
    border-left: 3px solid #2980b9;
}

.mem-data.seg-data {
    border-left: 3px solid #4ecdc4;
}

.mem-data.seg-idata {
    border-left: 3px solid #27ae60;
}

.val-box {
    color: #fff;
    font-weight: bold;
}

.var-label {
    color: #888;
    transform: translateY(-1px);
    display: inline-block;
    font-size: 11px;
}

.editable-value input {
    background: #1e1e1e;
    color: #b5cea8;
    border: 1px solid #569cd6;
    padding: 2px 4px;
    font-family: var(--font-code);
    font-size: 14px;
    width: 65px;
    text-align: center;
    border-radius: 4px;
    font-weight: bold;
    transition: all 0.2s;
}

.editable-value input:focus {
    outline: none;
    border-color: #dcdcaa;
    box-shadow: 0 0 8px rgba(220, 220, 170, 0.3);
    background: #252526;
    color: #fff;
}

.editable-value input:-webkit-autofill {
    -webkit-text-fill-color: #b5cea8;
    transition: background-color 5000s ease-in-out 0s;
}

@media (max-width: 1200px) {
    .dashboard-grid {
        flex-direction: column;
        overflow-y: auto;
        height: auto;
    }

    body {
        height: auto;
        overflow: auto;
    }
}

/* Ripristino per funzionalità Hex Dump e Rilocazione */
.mem-data.hex-container { flex-direction: column; justify-content: flex-start; }
.hex-dump { font-family: var(--font-code); font-size: 13px; color: #dcdcaa; letter-spacing: 1px; line-height: 1.8; word-break: break-all; margin-top: 6px; display: block; width: 100%; white-space: pre-wrap; margin-bottom: 2px;}
.hex-dump-alt { color: #ce9178; }
.hex-dump-dim { color: #666; }
.var-label { margin-bottom: 2px; }

/* Stili specifici per il File Oggetto (Rilocazioni) */
.reloc-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 13px;
    text-align: left;
    background: #1e1e1e;
}
.reloc-table th {
    padding: 6px;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
    font-weight: 600;
}
.reloc-table td {
    padding: 6px;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    font-family: var(--font-code);
}
.reloc-empty {
    padding: 15px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    background: rgba(30, 30, 30, 0.5);
    border: 1px dashed var(--border);
    border-radius: 4px;
}
.obj-section {
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 1px dashed #444;
}
.obj-title {
    font-weight: bold;
    color: var(--accent-3);
    margin-bottom: 8px;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== STACK FRAME VISUALIZATION ===== */
.stack-viz {
    display: flex;
    flex-direction: column;
    gap: 0;
    font-family: var(--font-code);
    font-size: 13px;
    position: relative;
}

.stack-row {
    display: flex;
    border: 1px solid #444;
    border-bottom: none;
    transition: background 0.2s;
}

.stack-row:last-child {
    border-bottom: 1px solid #444;
}

.stack-row:hover {
    background: rgba(255,255,255,0.05);
}

.stack-offset {
    padding: 8px 10px;
    background: #2a2d32;
    color: #999;
    width: 80px;
    border-right: 1px solid #444;
    text-align: right;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.stack-content {
    padding: 8px 12px;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.stack-val {
    font-weight: bold;
    color: #b5cea8;
}

.stack-label {
    font-size: 11px;
    color: #888;
    text-align: right;
}

.stack-row.stack-frame-header {
    background: #252526;
}

.stack-row.stack-frame-header .stack-content {
    color: #666;
    font-style: italic;
}

.stack-row.stack-var {
    background: #1e1e1e;
}

.stack-pointer-tag {
    display: inline-block;
    font-size: 9px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    white-space: nowrap;
    margin-left: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

.stack-pointer-tag.esp-tag {
    background: #ff6b6b;
    color: #fff;
}

.stack-pointer-tag.ebp-tag {
    background: #4ecdc4;
    color: #1e1e1e;
}

.stack-var-bar {
    display: inline-block;
    width: 4px;
    height: 100%;
    position: absolute;
    left: 80px;
    top: 0;
    bottom: 0;
}

.stack-direction {
    text-align: center;
    color: #555;
    font-size: 11px;
    padding: 6px 0 2px;
    font-family: var(--font-ui);
    letter-spacing: 0.5px;
}
/* ===== EXECUTION MODE ===== */
.exec-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(78,205,196,0.08);
    padding: 4px 10px;
    border-radius: 14px;
    border: 1px solid rgba(78,205,196,0.3);
}

.exec-btn {
    background: #333;
    color: #e0e0e0;
    border: 1px solid #555;
    padding: 4px 10px;
    border-radius: 6px;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.exec-btn:hover { background: #444; border-color: #777; }
.exec-btn.primary { background: #4ecdc4; color: #1a1a2e; border-color: #4ecdc4; }
.exec-btn.primary:hover { background: #3dbdb5; }
.exec-btn.warn { background: transparent; color: #ff6b6b; border-color: #ff6b6b; }
.exec-btn.warn:hover { background: rgba(255,107,107,0.1); }

.step-counter {
    color: #4ecdc4;
    font-weight: 700;
    font-size: 13px;
    font-family: var(--font-code);
    min-width: 55px;
    text-align: center;
}

.exec-badge {
    font-size: 9px;
    font-weight: 700;
    color: #4ecdc4;
    background: rgba(78,205,196,0.15);
    padding: 1px 6px;
    border-radius: 3px;
    letter-spacing: 0.5px;
    margin-left: 4px;
    vertical-align: middle;
}

/* --- Execution-mode panel highlights --- */
.code-line.exec-done { opacity: 0.35; }
.code-line.exec-active {
    background: rgba(78,205,196,0.12) !important;
    box-shadow: inset 3px 0 0 #4ecdc4;
    color: #fff;
}
.code-line.exec-jump-target {
    background: rgba(247,183,49,0.12) !important;
    box-shadow: inset 3px 0 0 #f7b731;
    animation: exec-flash 0.6s ease-out;
}

.machine-code-item.exec-done { opacity: 0.35; }
.machine-code-item.exec-active {
    background: rgba(78,205,196,0.1) !important;
    border: 1px solid rgba(78,205,196,0.3);
}
.machine-code-item.exec-active .mc-hex {
    color: #f7b731 !important;
    font-weight: bold;
}
.machine-code-item.exec-active .mc-addr {
    color: #4ecdc4 !important;
}

.stack-row.exec-written {
    background: rgba(247,183,49,0.12) !important;
    animation: exec-flash 0.6s ease-out;
}
.stack-row.exec-read {
    background: rgba(78,205,196,0.08) !important;
}
.stack-write-tag {
    color: #f7b731;
    font-size: 10px;
    font-weight: 700;
    margin-left: 6px;
}
.stack-read-tag {
    color: #4ecdc4;
    font-size: 10px;
    font-weight: 700;
    margin-left: 6px;
}

.reg-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px;
}
.reg-item {
    font-family: var(--font-code);
    font-size: 13px;
    padding: 6px 8px;
    background: #252526;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #888;
    border: 1px solid transparent;
    transition: all 0.3s;
}
.reg-item .reg-name { color: #4ecdc4; font-weight: 700; }
.reg-item .reg-val { color: #b5cea8; }
.reg-item.reg-changed {
    background: rgba(78,205,196,0.1);
    border-color: rgba(78,205,196,0.3);
}
.reg-item.reg-changed .reg-val { color: #fff; font-weight: 700; }

/* Explain bar sotto i pannelli */
.explain-bar {
    background: #1a2a2a;
    border: 1px solid rgba(78,205,196,0.25);
    border-radius: 6px;
    padding: 10px 14px;
    font-family: var(--font-code);
    font-size: 12px;
    color: #ccc;
    line-height: 1.6;
    margin-top: 0;
}
.explain-bar .cycle-num { color: #f7b731; font-weight: 700; }
.explain-bar .explain-val { color: #4ecdc4; font-weight: 600; }
.explain-bar .explain-instr { color: #dcdcaa; }

/* Memory hex highlight in exec mode */
.mem-byte-exec { font-family: var(--font-code); font-size: 13px; }
.mem-byte-exec.past { color: #f7b731; }
.mem-byte-exec.current { color: #4ecdc4; font-weight: bold; background: rgba(78,205,196,0.15); border-radius: 2px; padding: 0 2px; }
.mem-byte-exec.future { color: #555; }

@keyframes exec-flash {
    0% { background: rgba(247,183,49,0.3); }
    100% { background: rgba(247,183,49,0.12); }
}

/* Topbar disabled controls in exec mode */
.topbar .controls-disabled { opacity: 0.35; pointer-events: none; }
