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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

/* Header */
#header {
    background: #2c3e50;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#header h1 {
    font-size: 24px;
    font-weight: 600;
}

#controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

#controls button {
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#controls button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

#controls button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

#controls button:disabled {
    background: #bdc3c7 !important;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Individual button colors */
.btn-load {
    background: #3498db; /* Blue - file operations */
}

.btn-load:hover:not(:disabled) {
    background: #2980b9;
}

.btn-symbols {
    background: #9b59b6; /* Purple - info/search */
}

.btn-symbols:hover:not(:disabled) {
    background: #8e44ad;
}

.btn-step {
    background: #f39c12; /* Orange - single step */
}

.btn-step:hover:not(:disabled) {
    background: #e67e22;
}

.btn-run {
    background: #27ae60; /* Green - go/execute */
}

.btn-run:hover:not(:disabled) {
    background: #229954;
}

.btn-stop {
    background: #e74c3c; /* Red - stop/halt */
}

.btn-stop:hover:not(:disabled) {
    background: #c0392b;
}

.btn-reset {
    background: #34495e; /* Dark gray - reset */
}

.btn-reset:hover:not(:disabled) {
    background: #2c3e50;
}

#controls input[type="file"] {
    display: none;
}

/* Layout: left pane 55%, right pane 45% - give more space to right pane */
#main-container {
    display: flex;
    height: calc(100vh - 120px);
    gap: 1px;
    background: #bdc3c7;
}

#left-pane {
    flex: 55%;
    overflow: hidden;  /* Don't scroll the pane itself - let code-panel handle scrolling */
    background: white;
    border-right: 1px solid #bdc3c7;
    display: flex;
    flex-direction: column;
}

#right-pane {
    flex: 45%;
    overflow-y: auto;
    background: white;
    display: flex;
    flex-direction: column;
}

/* Panels */
#disasm-panel, #regs-panel, #memory-panel, #bp-panel {
    padding: 15px;
    border-bottom: 1px solid #ecf0f1;
}

#disasm-panel {
    overflow: hidden;  /* Panel itself doesn't scroll */
}

#disasm-content {
    flex: 1;
    overflow: auto;  /* Content area scrolls */
}

#regs-panel, #memory-panel, #bp-panel {
    flex: 1;
}

#regs-panel h2, #memory-panel h2, #bp-panel h2, #disasm-panel h2 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
}

/* Disassembly styling */
.disasm-line { 
    font-family: 'Courier New', monospace; 
    padding: 2px 6px; 
    padding-left: 18px; /* reserve space for gutter so no shift occurs */
    cursor: default; 
    font-size: 13px;
    line-height: 1.3;
    border-left: 3px solid transparent;
    transition: background 0.15s ease-in-out;
    display: flex;
    align-items: center;
    gap: 8px;
    position: relative; /* allow absolute gutter without shifting content */
}

.disasm-line:hover { background: #ecf0f1; }

.disasm-line.current-pc { background: #fff3cd; border-left-color: #ffc107; }

.disasm-line.breakpoint { 
    background: #f8d7da; 
    border-left-color: #dc3545;
}

/* Suppress legacy inline breakpoint dot; we use gutter dot instead */
.disasm-line.breakpoint:before { 
    content: '';
}

.disasm-line.current-pc.breakpoint {
    background: #ffeaa7;
    border-left-color: #f39c12;
}

.dis-gutter { position: absolute; left: 4px; top: 50%; width: 10px; height: 10px; transform: translateY(-50%); text-align: center; }
.dis-gutter:after { content: '\25CF'; color: transparent; font-size: 9px; line-height: 10px; display: inline-block; }
.disasm-line.breakpoint .dis-gutter:after { color: #dc3545; }

/* Register grid */
#regs-content { 
    display: grid; 
    grid-template-columns: repeat(4, 1fr); 
    gap: 8px; 
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.reg-item { 
    padding: 8px; 
    border: 1px solid #dee2e6; 
    border-radius: 4px;
    background: #f8f9fa;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.reg-item:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.reg-item:active {
    background: #dee2e6;
    border-color: #6c757d;
}

.reg-item:first-child {
    background: #e3f2fd;
    border-color: #2196f3;
    font-weight: bold;
}

/* Register section titles */
.reg-section-title {
    grid-column: 1 / -1;
    padding: 8px 12px;
    background: #495057;
    color: white;
    font-weight: 600;
    font-size: 14px;
    border-radius: 4px;
    margin-top: 12px;
    margin-bottom: 4px;
    text-align: left;
}

.reg-section-title:first-child {
    margin-top: 0;
}

.reg-section-title.mmu-section {
    background: #8e44ad;
}

/* MMU registers in main panel */
.reg-item.mmu-reg {
    background: #f3e5f5;
    border-color: #8e44ad;
}

.reg-item.mmu-reg:hover {
    background: #e1bee7;
    border-color: #7d3c98;
}

/* Memory controls */
.memory-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.memory-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.memory-controls input {
    padding: 6px 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    transition: border-color 0.2s;
}

.memory-controls input:focus {
    outline: none;
    border-color: #3498db;
}

.memory-controls button {
    background: #28a745;
    color: white;
    border: none;
    padding: 7px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
}

.memory-controls button:hover {
    background: #218838;
}

/* TRAP Information */
#trap-panel {
    margin-bottom: 20px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: #f8f9fa;
}

#trap-panel h2 {
    margin: 0;
    padding: 8px 12px;
    background: #e9ecef;
    border-bottom: 1px solid #ddd;
    font-size: 14px;
    font-weight: 600;
}

.trap-controls {
    padding: 8px 12px;
    border-bottom: 1px solid #ddd;
    background: #fff;
}

.trap-controls button {
    padding: 4px 8px;
    font-size: 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.trap-controls button:hover {
    background: #c82333;
}

#trap-content {
    padding: 8px 12px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    line-height: 1.4;
    max-height: 200px;
    overflow-y: auto;
}

.trap-entry {
    margin-bottom: 4px;
    padding: 2px 0;
}

.trap-addr {
    color: #6c757d;
    font-weight: bold;
    margin-right: 8px;
}

.trap-type {
    color: #dc3545;
    font-weight: 600;
    margin-right: 8px;
}

.trap-desc {
    color: #495057;
}

/* Memory hex dump - matches disassembler style */
#memory-content {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.4;
    max-height: 300px;
    overflow-y: auto;
}

.mem-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 2px 6px;
    transition: background 0.15s ease-in-out;
}

.mem-line:hover {
    background: #ecf0f1;
}

.mem-addr {
    color: #6c757d;
    font-weight: bold;
    width: 80px;
    text-align: right;
}

.mem-addr:after {
    content: ':';
    margin-left: 2px;
}

.mem-hex {
    color: #b58900;
    font-family: 'Courier New', monospace;
    min-width: 380px;
    letter-spacing: 0.5px;
}

.mem-ascii {
    color: #28a745;
    font-weight: bold;
    border-left: 2px solid #dee2e6;
    padding-left: 12px;
    letter-spacing: 1px;
}

/* Breakpoint controls */
.bp-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.bp-controls input {
    padding: 6px 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    width: 150px;
}

.bp-controls button {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.bp-controls button:hover {
    background: #c82333;
}

/* Breakpoint list */
.bp-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    margin-bottom: 4px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.bp-item input[type="checkbox"] {
    cursor: pointer;
}

.bp-item button {
    background: #6c757d;
    color: white;
    border: none;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 10px;
    margin-left: auto;
}

.bp-item button:hover {
    background: #5a6268;
}

/* Status bar */
#status-bar {
    background: #2c3e50;
    color: white;
    padding: 8px 20px;
    font-size: 14px;
    border-top: 1px solid #34495e;
}

/* Drag-drop zone */
#drop-zone {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(44, 62, 80, 0.9);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

#drop-zone.hidden {
    display: none;
}

/* Load Modal */
#loadModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

#loadModal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-content h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.modal-content .row {
    margin-bottom: 15px;
}

.modal-content label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-size: 14px;
    font-weight: 500;
}

.modal-content input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

.modal-content input[type="text"],
.modal-content input[type="file"],
.modal-content select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.2s;
}

.modal-content input[type="text"]:focus,
.modal-content select:focus {
    outline: none;
    border-color: #3498db;
}

.modal-content input[type="file"] {
    padding: 6px;
    cursor: pointer;
}

.modal-content .actions {
    margin-top: 25px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-content .actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

#loadCancelBtn {
    background: #95a5a6;
    color: white;
}

#loadCancelBtn:hover {
    background: #7f8c8d;
}

#loadConfirmBtn {
    background: #3498db;
    color: white;
}

#loadConfirmBtn:hover {
    background: #2980b9;
}

#splitFields.hidden,
#aoutFields.hidden {
    display: none;
}

.modal-error {
    margin-top: 15px;
    padding: 12px 15px;
    background: #fee;
    border: 1px solid #fcc;
    border-left: 4px solid #f44;
    border-radius: 4px;
    color: #c33;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.modal-error.hidden {
    display: none;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

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

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

/* Responsive design */
@media (max-width: 768px) {
    #main-container {
        flex-direction: column;
        height: calc(100vh - 140px);
    }
    
    #left-pane, #right-pane {
        flex: none;
        height: 50%;
    }
    
    #header {
        flex-direction: column;
        gap: 10px;
        padding: 10px;
    }
    
    #controls {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    #regs-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

.dis-addr { color: #6c757d; text-align: right; width: 8ch; }

.dis-bytes { color: #b58900; white-space: pre; width: 24ch; }

.dis-text { color: #2c3e50; white-space: pre; flex: 1 1 auto; }
.dis-mnemonic { color: #268bd2; font-weight: 600; } /* blue */
.dis-mnemonic.branch { color: #d33682; } /* magenta for branches/calls */
.dis-operands { color: #2c3e50; margin-left: 0; } /* darker gray for operands */

/* Symbol labels - cyan (bright) to match nd500-dis color_label() */
.disasm-symbol {
    border-left: none;
    padding-left: 18px;
}
.dis-symbol-label {
    color: #00d7ff; /* bright cyan - matches ANSI \033[96m */
    font-weight: bold;
}

/* Comments - blue (bright) to match nd500-dis color_comment() */
.dis-comment {
    color: #5c94ff; /* bright blue - matches ANSI \033[94m */
    font-style: italic;
}

/* Unresolved externals - red to highlight issues */
.dis-comment .unresolved {
    color: #ff5555; /* bright red */
    font-weight: bold;
}

/* Symbols Modal */
#symbolsModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

#symbolsModal.hidden {
    display: none;
}

.symbols-modal {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 700px;
    width: 90%;
    height: 80vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
    display: flex;
    flex-direction: column;
}

.symbols-modal h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
    flex-shrink: 0;
}

.symbols-type-filter {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    flex-shrink: 0;
}

.symbols-type-filter label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #495057;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.symbols-type-filter label:hover {
    background: #e9ecef;
}

.symbols-type-filter input[type="radio"] {
    cursor: pointer;
    margin: 0;
}

.symbols-type-filter label:has(input[type="radio"]:checked) {
    background: #3498db;
    color: white;
}

.symbols-search {
    margin-bottom: 15px;
    flex-shrink: 0;
}

.symbols-search input {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.symbols-search input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.symbols-search input::placeholder {
    color: #adb5bd;
}

#symbols-list {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 20px;
    min-height: 0;
}

.symbols-modal .actions {
    margin-top: 0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.symbols-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.symbols-table thead {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    z-index: 10;
}

.symbols-table th {
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
}

.symbol-row {
    cursor: pointer;
    transition: background 0.15s;
}

.symbol-row:hover {
    background: #e3f2fd;
}

.symbol-row:active {
    background: #bbdefb;
}

.symbols-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #ecf0f1;
}

.symbol-name {
    color: #2c3e50;
    font-weight: 500;
}

.symbol-addr {
    color: #6c757d;
    font-family: 'Courier New', monospace;
}

.symbol-type {
    color: #28a745;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 11px;
}

.symbol-empty {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    font-size: 14px;
}

#symbolsCancelBtn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#symbolsCancelBtn:hover {
    background: #7f8c8d;
}

/* Console Button */
.btn-console {
    background: #16a085; /* Teal - console/terminal */
}

.btn-console:hover:not(:disabled) {
    background: #138d75;
}

/* MMU Button */
.btn-mmu {
    background: #8e44ad; /* Purple - memory management */
}

.btn-mmu:hover:not(:disabled) {
    background: #7d3c98;
}

/* Console Modal */
#consoleModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

#consoleModal.hidden {
    display: none;
}

.console-modal {
    background: #1e1e1e;
    border-radius: 8px;
    max-width: 900px;
    width: 90%;
    height: 70vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.2s ease-out;
    display: flex;
    flex-direction: column;
    color: #d4d4d4;
    font-family: 'Courier New', monospace;
}

.console-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #252525;
    border-bottom: 1px solid #3c3c3c;
    border-radius: 8px 8px 0 0;
}

.console-header h3 {
    margin: 0;
    font-size: 18px;
    color: #d4d4d4;
    font-weight: 600;
}

.console-clear-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.console-clear-btn:hover {
    background: #c82333;
}

#console-output {
    flex: 1;
    overflow-y: auto;
    padding: 15px 20px;
    font-size: 14px;
    line-height: 1.5;
    background: #1e1e1e;
    min-height: 0;
}

.console-line {
    margin-bottom: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.console-line.command {
    color: #4ec9b0; /* Cyan for commands */
    font-weight: 600;
}

.console-line.command::before {
    content: '> ';
    color: #858585;
}

.console-line.output {
    color: #d4d4d4; /* Normal output */
}

.console-line.error {
    color: #f48771; /* Red for errors */
}

.console-input-container {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    background: #252525;
    border-top: 1px solid #3c3c3c;
    gap: 8px;
}

.console-prompt {
    color: #858585;
    font-size: 16px;
    font-weight: bold;
}

.console-input {
    flex: 1;
    background: #1e1e1e;
    color: #d4d4d4;
    border: 1px solid #3c3c3c;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.2s;
}

.console-input:focus {
    outline: none;
    border-color: #0e639c;
}

.console-input::placeholder {
    color: #6a6a6a;
}

.console-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: #252525;
    border-top: 1px solid #3c3c3c;
    border-radius: 0 0 8px 8px;
}

.console-hint {
    font-size: 12px;
    color: #858585;
    font-style: italic;
}

#consoleCancelBtn {
    background: #95a5a6;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#consoleCancelBtn:hover {
    background: #7f8c8d;
}

/* Console scrollbar styling */
#console-output::-webkit-scrollbar {
    width: 10px;
}

#console-output::-webkit-scrollbar-track {
    background: #252525;
}

#console-output::-webkit-scrollbar-thumb {
    background: #3c3c3c;
    border-radius: 5px;
}

#console-output::-webkit-scrollbar-thumb:hover {
    background: #4e4e4e;
}

/* MMU Panel (inline status in right pane) */
#mmu-panel {
    padding: 15px;
    border-bottom: 1px solid #ecf0f1;
    flex: 1;
}

#mmu-panel h2 {
    font-size: 16px;
    margin-bottom: 10px;
    color: #2c3e50;
    border-bottom: 2px solid #8e44ad;
    padding-bottom: 5px;
}

#mmu-content {
    font-family: 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

.mmu-status-inline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mmu-status-inline-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #dee2e6;
}

.mmu-status-inline-label {
    font-weight: 600;
    color: #495057;
    font-size: 0.95em;
}

.mmu-status-inline-value {
    color: #1a252f;
    font-weight: 600;
    font-size: 1.0em;
}

.mmu-status-inline-value.enabled {
    color: #28a745;
    font-weight: 700;
}

.mmu-status-inline-value.disabled {
    color: #dc3545;
    font-weight: 700;
}

/* MMU Modal */
#mmuModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

#mmuModal.hidden {
    display: none;
}

.mmu-modal {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 1000px;
    width: 95%;
    height: 88vh;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
    display: flex;
    flex-direction: column;
}

.mmu-modal h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #2c3e50;
    border-bottom: 2px solid #8e44ad;
    padding-bottom: 10px;
    flex-shrink: 0;
}

/* MMU Tabs */
.mmu-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid #dee2e6;
    flex-shrink: 0;
}

.mmu-tab {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.2s;
    position: relative;
    bottom: -2px;
}

.mmu-tab:hover {
    color: #8e44ad;
    background: #f8f9fa;
}

.mmu-tab.active {
    color: #8e44ad;
    border-bottom-color: #8e44ad;
    background: transparent;
}

/* Tab Content */
.mmu-tab-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.mmu-tab-content.active {
    display: flex;
    flex-direction: column;
}

.tab-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-shrink: 0;
}

.mmu-section {
    margin-bottom: 25px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.mmu-section h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    color: #495057;
    font-weight: 600;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 8px;
}

.mmu-status-row {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    margin-bottom: 8px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.mmu-status-row:last-child {
    margin-bottom: 0;
}

.mmu-label {
    font-weight: 600;
    color: #495057;
    min-width: 100px;
}

.mmu-value {
    flex: 1;
    font-family: 'Courier New', monospace;
    color: #1a252f;
    font-size: 14px;
    font-weight: 600;
}

.mmu-value.enabled {
    color: #28a745;
    font-weight: 700;
}

.mmu-value.disabled {
    color: #dc3545;
    font-weight: 700;
}

.mmu-toggle-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background 0.2s;
    min-width: 80px;
}

.mmu-toggle-btn:hover {
    background: #218838;
}

.mmu-toggle-btn.disable {
    background: #dc3545;
}

.mmu-toggle-btn.disable:hover {
    background: #c82333;
}

.mmu-action-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.mmu-action-btn:hover {
    background: #2980b9;
}

.mmu-action-btn.primary {
    background: #8e44ad;
    padding: 8px 16px;
    font-size: 14px;
}

.mmu-action-btn.primary:hover {
    background: #7d3c98;
}

.mmu-regs-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.mmu-reg-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.mmu-reg-item:hover {
    background: #e3f2fd;
    border-color: #3498db;
}

.mmu-reg-name {
    font-weight: 600;
    color: #8e44ad;
    font-size: 14px;
    font-family: 'Courier New', monospace;
}

.mmu-reg-value {
    font-family: 'Courier New', monospace;
    color: #2c3e50;
    font-size: 16px;
    font-weight: 600;
}

.mmu-reg-desc {
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

.mmu-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

#mmuCancelBtn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#mmuCancelBtn:hover {
    background: #7f8c8d;
}

/* PST Inspector Modal */
#pstModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
    backdrop-filter: blur(3px);
}

#pstModal.hidden {
    display: none;
}

.pst-modal {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 1000px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
    display: flex;
    flex-direction: column;
}

.pst-modal h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #2c3e50;
    border-bottom: 2px solid #8e44ad;
    padding-bottom: 10px;
}

.pst-filters {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    flex-wrap: wrap;
    align-items: center;
}

.pst-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pst-filter-group label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.pst-mode-filter {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.pst-mode-filter label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: normal;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.pst-mode-filter label:hover {
    background: #e9ecef;
}

.pst-mode-filter input[type="radio"] {
    cursor: pointer;
}

#pstSearchInput {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    min-width: 200px;
    transition: border-color 0.2s;
}

#pstSearchInput:focus {
    outline: none;
    border-color: #8e44ad;
}

.pst-stats {
    margin-left: auto;
    font-weight: 600;
    color: #6c757d;
    font-size: 14px;
}

#pst-table-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    min-height: 300px;
    max-height: 500px;
}

.pst-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.pst-table thead {
    position: sticky;
    top: 0;
    background: #f8f9fa;
    z-index: 10;
}

.pst-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #2c3e50;
    border-bottom: 2px solid #8e44ad;
    white-space: nowrap;
}

.pst-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid #ecf0f1;
}

.pst-table tbody tr:hover {
    background: #e3f2fd;
}

.pst-table tbody tr:active {
    background: #bbdefb;
}

.pst-table td {
    padding: 10px 12px;
    color: #2c3e50;
}

.pst-mode-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
}

.pst-mode-badge.azi {
    background: #d1ecf1;
    color: #0c5460;
}

.pst-mode-badge.asi {
    background: #fff3cd;
    color: #856404;
}

.pst-mode-badge.adi {
    background: #f8d7da;
    color: #721c24;
}

.pst-action-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    transition: background 0.2s;
}

.pst-action-btn:hover {
    background: #2980b9;
}

.pst-table-empty {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    font-size: 14px;
}

#pstCloseBtn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#pstCloseBtn:hover {
    background: #7f8c8d;
}

#pstRefreshBtn {
    background: #28a745;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#pstRefreshBtn:hover {
    background: #218838;
}

/* PST Entry Edit Modal */
#pstEditModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2200;
    backdrop-filter: blur(3px);
}

#pstEditModal.hidden {
    display: none;
}

.pst-edit-modal {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
}

.pst-edit-modal h3 {
    margin: 0 0 25px 0;
    font-size: 20px;
    color: #2c3e50;
    border-bottom: 2px solid #8e44ad;
    padding-bottom: 10px;
}

.pst-edit-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.pst-edit-form .form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pst-edit-form label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.pst-edit-form input,
.pst-edit-form select {
    padding: 10px 12px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.2s;
}

.pst-edit-form input:focus,
.pst-edit-form select:focus {
    outline: none;
    border-color: #8e44ad;
}

.pst-edit-form input[readonly] {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

#pstEditCancelBtn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#pstEditCancelBtn:hover {
    background: #7f8c8d;
}

#pstEditSaveBtn {
    background: #8e44ad;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#pstEditSaveBtn:hover {
    background: #7d3c98;
}

/* PCB Viewer Modal */
#pcbModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2100;
    backdrop-filter: blur(3px);
}

#pcbModal.hidden {
    display: none;
}

.pcb-modal {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 1000px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
    display: flex;
    flex-direction: column;
}

.pcb-modal h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #2c3e50;
    border-bottom: 2px solid #8e44ad;
    padding-bottom: 10px;
}

.pcb-filters {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
    align-items: center;
}

.pcb-filter-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pcb-filter-group label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

#pcbSearchInput {
    padding: 8px 12px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    min-width: 200px;
    transition: border-color 0.2s;
}

#pcbSearchInput:focus {
    outline: none;
    border-color: #8e44ad;
}

.pcb-stats {
    margin-left: auto;
    font-weight: 600;
    color: #6c757d;
    font-size: 14px;
}

#pcb-domain-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    min-height: 300px;
    max-height: 500px;
    background: white;
}

#pcb-domain-list {
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.pcb-domain {
    border-bottom: 1px solid #ecf0f1;
}

.pcb-domain-header {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    cursor: pointer;
    transition: background 0.15s;
    border-left: 4px solid #8e44ad;
}

.pcb-domain-header:hover {
    background: #e9ecef;
}

.pcb-domain-header.expanded {
    background: #e3f2fd;
    border-left-color: #2196f3;
}

.pcb-domain-toggle {
    font-size: 16px;
    margin-right: 10px;
    user-select: none;
    width: 20px;
    text-align: center;
}

.pcb-domain-name {
    font-weight: 600;
    color: #2c3e50;
    flex: 1;
}

.pcb-domain-count {
    color: #6c757d;
    font-size: 12px;
}

.pcb-segments {
    display: none;
    background: white;
}

.pcb-segments.expanded {
    display: block;
}

.pcb-segments-table {
    width: 100%;
    border-collapse: collapse;
}

.pcb-segments-table thead {
    background: #f8f9fa;
}

.pcb-segments-table th {
    padding: 10px 15px;
    text-align: left;
    font-weight: 600;
    color: #495057;
    border-bottom: 1px solid #dee2e6;
    font-size: 12px;
}

.pcb-segments-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.pcb-segments-table tbody tr:hover {
    background: #f0f8ff;
}

.pcb-segments-table td {
    padding: 8px 15px;
    color: #2c3e50;
    border-bottom: 1px solid #f8f9fa;
}

.pcb-expand-arrow {
    font-size: 14px;
    margin-right: 10px;
    user-select: none;
    width: 20px;
    text-align: center;
    transition: transform 0.2s;
}

.pcb-domain-title {
    font-weight: 600;
    color: #2c3e50;
    flex: 1;
}

.pcb-no-flags {
    color: #adb5bd;
    font-style: italic;
}

.pcb-description {
    font-size: 12px;
    color: #6c757d;
}

.pcb-capability {
    font-family: 'Courier New', monospace;
    font-size: 12px;
}

.pcb-flags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.pcb-flag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
    font-size: 10px;
    text-transform: uppercase;
}

.pcb-flag.dir {
    background: #d1ecf1;
    color: #0c5460;
}

.pcb-flag.wrp {
    background: #f8d7da;
    color: #721c24;
}

.pcb-flag.pac {
    background: #d4edda;
    color: #155724;
}

.pcb-action-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 4px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
}

.pcb-action-btn:hover {
    background: #2980b9;
}

.pcb-empty {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    font-size: 14px;
}

/* ═══════════════════════════════════════════════════════ */
/* Segment Card - Detailed Bit Layout Display */
/* ═══════════════════════════════════════════════════════ */

.segment-card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin: 8px 0;
    padding: 12px;
}

.segment-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e9ecef;
}

.segment-number {
    font-weight: bold;
    font-size: 1.1em;
    color: #212529;
}

.segment-hint {
    color: #6c757d;
    font-size: 0.9em;
    font-style: italic;
}

.pcb-action-btn-small {
    margin-left: auto;
    background: #3498db;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 11px;
    transition: background 0.2s;
}

.pcb-action-btn-small:hover {
    background: #2980b9;
}

/* Capability Section Styles */

.capability-section {
    margin: 12px 0;
    padding: 10px;
    border-radius: 4px;
    background: #f8f9fa;
}

.prog-cap-direct {
    border-left: 4px solid #4CAF50;
}

.prog-cap-indirect {
    border-left: 4px solid #2196F3;
}

.data-cap {
    border-left: 4px solid #FF9800;
}

.capability-title {
    font-weight: 600;
    font-size: 0.95em;
    color: #495057;
    margin-bottom: 4px;
}

.capability-raw {
    font-family: 'Courier New', monospace;
    font-size: 0.85em;
    color: #6c757d;
    margin-bottom: 8px;
}

/* Bit Layout Display */

.bit-layout {
    display: flex;
    gap: 2px;
    font-family: 'Courier New', monospace;
    margin: 8px 0;
}

.bit-field {
    background: #e3f2fd;
    border: 1px solid #2196F3;
    padding: 4px 8px;
    text-align: center;
    font-size: 0.9em;
    font-weight: 600;
    min-width: 30px;
    flex-shrink: 0;
}

.bit-field.wide {
    flex: 2;
    min-width: 60px;
}

.bit-labels {
    display: flex;
    gap: 2px;
    font-size: 0.8em;
    color: #495057;
    margin-top: 2px;
}

.bit-labels span {
    padding: 2px 8px;
    min-width: 30px;
    text-align: center;
    flex-shrink: 0;
}

.bit-labels span:last-child {
    flex: 2;
    min-width: 60px;
}

.indirect-pointer {
    margin-top: 8px;
    font-size: 0.9em;
    color: #495057;
    font-style: italic;
}

/* Permission Badge */

.permission-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    margin-top: 8px;
    font-weight: bold;
    font-size: 0.85em;
}

.permission-badge.sg-rw {
    background: #4CAF50;
    color: white;
}

.permission-badge.sg-ro {
    background: #FFC107;
    color: black;
}

.permission-badge.sg-urw {
    background: #2196F3;
    color: white;
}

.permission-badge.sg-uro {
    background: #9C27B0;
    color: white;
}

.permission-badge.none {
    background: #9E9E9E;
    color: white;
}

#pcbCloseBtn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#pcbCloseBtn:hover {
    background: #7f8c8d;
}

#pcbRefreshBtn {
    background: #28a745;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#pcbRefreshBtn:hover {
    background: #218838;
}

/* PCB Capability Edit Modal */
#pcbEditModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2200;
    backdrop-filter: blur(3px);
}

#pcbEditModal.hidden {
    display: none;
}

.pcb-edit-modal {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
}

.pcb-edit-modal h3 {
    margin: 0 0 25px 0;
    font-size: 20px;
    color: #2c3e50;
    border-bottom: 2px solid #8e44ad;
    padding-bottom: 10px;
}

.pcb-edit-modal h4 {
    margin: 20px 0 10px 0;
    font-size: 16px;
    color: #495057;
    font-weight: 600;
}

.pcb-edit-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 25px;
}

.pcb-edit-form .form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pcb-edit-form label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

.pcb-edit-form .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    transition: background 0.2s;
}

.pcb-edit-form .checkbox-label:hover {
    background: #f8f9fa;
}

.pcb-edit-form input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.pcb-edit-form input[type="text"],
.pcb-edit-form select {
    padding: 10px 12px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-size: 14px;
    font-family: 'Courier New', monospace;
    transition: border-color 0.2s;
}

.pcb-edit-form input[type="text"]:focus,
.pcb-edit-form select:focus {
    outline: none;
    border-color: #8e44ad;
}

.pcb-edit-form input[readonly] {
    background: #f8f9fa;
    color: #6c757d;
    cursor: not-allowed;
}

#pcbEditCancelBtn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#pcbEditCancelBtn:hover {
    background: #7f8c8d;
}

#pcbEditSaveBtn {
    background: #8e44ad;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#pcbEditSaveBtn:hover {
    background: #7d3c98;
}

/* Simple Register Editor Modal */
#regEditorModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2300;
    backdrop-filter: blur(3px);
}

#regEditorModal.hidden {
    display: none;
}

.reg-editor-modal {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
}

.reg-editor-modal h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.reg-editor-current-value {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
}

.reg-editor-current-value label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

#regEditorCurrentValue {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.reg-editor-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 25px;
}

.reg-editor-input label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

#regEditorInput {
    padding: 12px 15px;
    border: 2px solid #dee2e6;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 16px;
    transition: border-color 0.2s;
}

#regEditorInput:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

#regEditorCancelBtn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#regEditorCancelBtn:hover {
    background: #7f8c8d;
}

#regEditorApplyBtn {
    background: #3498db;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#regEditorApplyBtn:hover {
    background: #2980b9;
}

/* Bit Editor Modal */
#bitEditorModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2300;
    backdrop-filter: blur(3px);
}

#bitEditorModal.hidden {
    display: none;
}

.bit-editor-modal {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 900px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.2s ease-out;
}

.bit-editor-modal h3 {
    margin: 0 0 20px 0;
    font-size: 24px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 10px;
}

.bit-editor-current-value {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
}

.bit-editor-current-value label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
}

#bitEditorCurrentValue {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.bit-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.bit-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 12px 8px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
    min-height: 80px;
    justify-content: center;
}

.bit-item:hover {
    background: #e9ecef;
    border-color: #adb5bd;
    transform: scale(1.05);
}

.bit-item.active {
    background: #007bff;
    color: white;
    border-color: #0056b3;
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.3);
}

.bit-item.active:hover {
    background: #0056b3;
}

/* Reorder bit cell content: label → toggle → bit number */
.bit-label {
    order: 1;
    font-size: 11px;
    font-weight: 700;
    text-align: center;
    margin-bottom: 4px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    word-wrap: break-word;
    line-height: 1.2;
    color: #0056b3;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.bit-item.active .bit-label {
    color: #ffffff;
    font-weight: 800;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.bit-toggle {
    order: 2;
    font-size: 28px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    line-height: 1;
    margin: 4px 0;
}

.bit-number {
    order: 3;
    font-size: 10px;
    font-weight: normal;
    margin-top: 4px;
    opacity: 0.6;
    color: #6c757d;
}

.bit-item.active .bit-number {
    opacity: 0.8;
    color: #fff;
}

.bit-editor-preview {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: #e3f2fd;
    border-radius: 6px;
    margin-bottom: 20px;
    border: 2px solid #2196f3;
}

.bit-editor-preview label {
    font-weight: 600;
    color: #0d47a1;
    font-size: 14px;
}

#bitEditorPreview {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #2196f3;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 600;
    color: #0d47a1;
    background: white;
}

/* Bit editor bottom row - horizontal layout for description + buttons */
.bit-editor-bottom-row {
    display: flex;
    gap: 20px;
    align-items: stretch;
    margin-top: 20px;
}

/* Bit description panel */
.bit-editor-description {
    flex: 1;
    min-height: 80px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    display: flex;
    align-items: center;
}

.bit-hover-info {
    font-size: 14px;
    line-height: 1.6;
    color: #495057;
    text-align: left;
    opacity: 0.6;
    transition: opacity 0.2s ease;
    font-style: italic;
    width: 100%;
}

.bit-hover-info:not(:empty) {
    font-style: normal;
}

/* Action buttons in bottom row */
.bit-editor-bottom-row .actions {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center;
}

#bitEditorCancelBtn {
    background: #95a5a6;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#bitEditorCancelBtn:hover {
    background: #7f8c8d;
}

#bitEditorApplyBtn {
    background: #3498db;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#bitEditorApplyBtn:hover {
    background: #2980b9;
}

/* Responsive bit grid for smaller screens */
@media (max-width: 768px) {
    .bit-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        padding: 10px;
    }

    .bit-item {
        padding: 8px 4px;
        min-height: 60px;
    }

    .bit-toggle {
        font-size: 20px;
    }

    .bit-label {
        font-size: 8px;
    }
}

/* MMU Status Banner in Load Modal */
.mmu-status-banner {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 6px;
    border: 1px solid #ddd;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.mmu-status-label {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.mmu-status-value {
    font-weight: 700;
    font-size: 16px;
}

.mmu-status-hint {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* MMU Toggle Button in Load Modal */
.mmu-toggle-btn-small {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    color: white;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.mmu-toggle-btn-small:hover {
    opacity: 0.9;
}

.mmu-toggle-btn-small:active {
    opacity: 0.7;
}

/* Memory Map Tab */
.memory-summary {
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.memory-stats {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    color: #2c3e50;
    font-weight: 600;
    margin-bottom: 10px;
}

.memory-usage-bar {
    width: 100%;
    height: 20px;
    background: #eceff1;
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid #dee2e6;
}

.memory-used {
    height: 100%;
    background: linear-gradient(90deg, #3498db, #2980b9);
    transition: width 0.3s ease;
}

.memory-map-container {
    flex: 1;
    overflow-y: auto;
    min-height: 200px;
    max-height: 350px;
    margin-bottom: 15px;
}

.memory-blocks {
    position: relative;
    height: 60px;
    border: 2px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    background: #f8f9fa;
}

.memory-block {
    height: 100%;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.2s;
    position: relative;
    border-right: 1px solid rgba(255, 255, 255, 0.3);
}

.memory-block:last-child {
    border-right: none;
}

.memory-block.mapped {
    opacity: 1;
}

.memory-block.mapped:hover {
    opacity: 0.8;
}

.memory-block.free {
    background: #eceff1;
    border-right: 1px solid #dee2e6;
}

.memory-info-panel {
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    min-height: 120px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #495057;
    margin-bottom: 15px;
}

.memory-info-row {
    padding: 4px 0;
    line-height: 1.6;
}

.memory-info-row strong {
    color: #2c3e50;
    margin-right: 8px;
}

.memory-map-empty,
.memory-map-error {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
    font-style: italic;
    font-size: 14px;
}

.memory-map-error {
    color: #dc3545;
}

/* PCB Edit Modal - Tab Navigation */
.pcb-edit-tabs {
    display: flex;
    gap: 0;
    margin: 20px 0 0 0;
    border-bottom: 2px solid #dee2e6;
}

.pcb-tab-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    color: #6c757d;
    transition: all 0.2s;
    position: relative;
    bottom: -2px;
}

.pcb-tab-btn:hover {
    color: #3498db;
    background: #f8f9fa;
}

.pcb-tab-btn.active {
    color: #3498db;
    border-bottom-color: #3498db;
    background: transparent;
}

.pcb-tab-content {
    display: none;
    padding: 20px 0;
}

.pcb-tab-content.active {
    display: block;
}

/* PCB Edit Modal - Program Capability Type Selector */
.prog-type-selector {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
}

.prog-type-selector label {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: 500;
}

.prog-type-selector input[type="radio"] {
    margin-right: 8px;
}

/* Program Capability Fields Containers */
.prog-cap-fields {
    margin-bottom: 15px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 4px solid #3498db;
}

.prog-cap-fields.hidden {
    display: none;
}

.prog-cap-fields .form-row {
    margin-bottom: 12px;
}

.prog-cap-fields .form-row:last-child {
    margin-bottom: 0;
}

/* Checkbox Labels */
.checkbox-label {
    display: flex !important;
    align-items: center;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

/* Permission Preset Buttons */
.permission-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.preset-btn {
    padding: 8px 16px;
    border: 1px solid #3498db;
    background: white;
    color: #3498db;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.preset-btn:hover {
    background: #3498db;
    color: white;
}

.preset-btn:active {
    transform: scale(0.95);
}

/* Raw Value Preview Inputs */
input[readonly] {
    background: #e9ecef !important;
    color: #495057;
    cursor: not-allowed;
    font-weight: 600;
}

/* Hints */
.hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #6c757d;
    font-style: italic;
}

/* ═══════════════════════════════════════════════════════ */
/* CODE VIEW TABS (Disassembly / Source) */
/* ═══════════════════════════════════════════════════════ */

.code-tabs {
    display: flex;
    background: #34495e;
    border-bottom: 2px solid #2c3e50;
    flex: 0 0 auto;  /* Don't grow or shrink, stay fixed */
}

.code-tab {
    flex: 1;
    padding: 12px 20px;
    background: #34495e;
    color: #bdc3c7;
    border: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-right: 1px solid #2c3e50;
}

.code-tab:last-child {
    border-right: none;
}

.code-tab:hover {
    background: #3e5468;
    color: white;
}

.code-tab.active {
    background: #2c3e50;
    color: white;
    border-bottom: 2px solid #3498db;
}

.code-panel {
    display: none;
    flex: 1 1 auto;  /* Grow to fill remaining space */
    overflow: auto;
}

.code-panel.active {
    display: flex;
    flex-direction: column;
}

/* ═══════════════════════════════════════════════════════ */
/* SOURCE VIEW PANEL */
/* ═══════════════════════════════════════════════════════ */

#source-panel {
    /* DON'T set display here - it conflicts with .code-panel display:none rule! */
    /* .code-panel.active already sets display:flex and flex-direction:column */
    overflow: hidden;  /* Prevent the panel itself from scrolling */
}

#source-file-selector {
    flex: 0 0 auto;  /* Fixed size, don't grow or shrink */
    padding: 10px 15px;
    background: #ecf0f1;
    border-bottom: 1px solid #bdc3c7;
}

#source-file-selector label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
}

#source-file-dropdown {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

#source-content {
    flex: 1;
    overflow: auto;
    background: #ffffff;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.source-line {
    display: flex;
    padding: 2px 10px;
    min-height: 20px;
    border-left: 3px solid transparent;
    cursor: pointer;
    transition: background-color 0.15s;
}

/* Alternating row colors for better readability */
.source-line:nth-child(even) {
    background-color: #f8f9fa;
}

.source-line:hover {
    background-color: #e3f2fd;
}

.source-line.current-line {
    background-color: #fff3cd;
    border-left-color: #f39c12;
}

.source-line.has-breakpoint {
    background-color: #ffe6e6;
    border-left-color: #e74c3c;
}

.source-line.current-line.has-breakpoint {
    background-color: #ffd6a5;
    border-left-color: #d35400;
}

.source-line-number {
    display: inline-block;
    width: 50px;
    color: #95a5a6;
    text-align: right;
    user-select: none;
    padding-right: 15px;
    flex-shrink: 0;
}

.source-line-content {
    flex: 1;
    white-space: pre;
    color: #2c3e50;
}

.source-empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #95a5a6;
    font-size: 14px;
    text-align: center;
    padding: 40px 20px;
}

/* ═══════════════════════════════════════════════════════ */
/* SOURCE FILES UPLOAD MODAL */
/* ═══════════════════════════════════════════════════════ */

.btn-source {
    background: #16a085; /* Teal - source files */
}

.btn-source:hover:not(:disabled) {
    background: #138d75;
}

.source-modal {
    width: 600px;
    max-width: 90%;
}

.modal-description {
    color: #7f8c8d;
    font-size: 14px;
    margin-bottom: 20px;
}

.source-upload-section {
    margin-bottom: 20px;
}

.source-upload-section h4 {
    color: #2c3e50;
    font-size: 16px;
    margin-bottom: 12px;
    font-weight: 600;
}

.file-upload-row {
    margin-bottom: 15px;
}

.file-upload-label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.label-text {
    font-size: 14px;
    font-weight: 500;
    color: #34495e;
}

.file-upload-label input[type="file"] {
    padding: 8px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    background: white;
    cursor: pointer;
}

.file-upload-label input[type="file"]:hover {
    border-color: #3498db;
}

.file-name {
    font-size: 13px;
    color: #7f8c8d;
    font-style: italic;
}

.file-name.has-file {
    color: #27ae60;
    font-weight: 500;
}

.source-upload-divider {
    text-align: center;
    color: #95a5a6;
    font-weight: 600;
    font-size: 14px;
    margin: 25px 0;
    position: relative;
}

.source-upload-divider::before,
.source-upload-divider::after {
    content: '';
    position: absolute;
    top: 50%;
    width: 40%;
    height: 1px;
    background: #bdc3c7;
}

.source-upload-divider::before {
    left: 0;
}

.source-upload-divider::after {
    right: 0;
}

.upload-status {
    margin: 15px 0;
    padding: 12px;
    border-radius: 4px;
    font-size: 14px;
}

.upload-status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.upload-status.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.upload-status.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ═══════════════════════════════════════════════════════ */
/* SOURCE ANNOTATIONS IN DISASSEMBLY */
/* ═══════════════════════════════════════════════════════ */

.disasm-source-annotation {
    background: #e8f4f8;
    padding: 6px 12px;
    margin: 4px 0;
    border-left: 3px solid #3498db;
    font-size: 12px;
    color: #2c3e50;
    font-style: italic;
}

.disasm-source-file {
    font-weight: 600;
    color: #16a085;
}

.disasm-source-line {
    color: #7f8c8d;
    margin-left: 8px;
}

/* Source Files Modal */
#sourceModal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(3px);
}

#sourceModal.hidden {
    display: none;
}
