/* ===== Base Variables ===== */
:root {
    --bg-primary: #1e293b;
    --bg-secondary: #334155;
    --bg-tertiary: #475569;
    --bg-hover: rgba(255, 255, 255, 0.08);
    --bg-active: #2d3154;
    --border: #475569;
    --border-light: #64748b;
    --text-primary: #f8fafc;
    --text-secondary: #e2e8f0;
    --text-muted: #cbd5e1;
    --accent: #6366f1;
    --accent-hover: #8b5cf6;
    --accent-dim: rgba(99, 102, 241, 0.15);
    --success: #10b981;
    --success-dim: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.15);
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.15);
    --modified: #f59e0b;
    --modified-bg: rgba(245, 158, 11, 0.08);
    --disabled-text: #4a4e68;
    --disabled-bg: rgba(74, 78, 104, 0.08);
    --type-M: #8b5cf6;
    --type-C: #3b82f6;
    --type-F: #22c55e;
    --type-H: #64748b;
    --type-N: #94a3b8;
    --type-I: #f59e0b;
    --radius-sm: 4px;
    --radius: 6px;
    --radius-lg: 10px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 150ms ease;
    --font: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 13px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

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

/* ===== Header ===== */
#app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 52px;
    padding: 0 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 12px; }
.logo { display: flex; align-items: center; }
.header-title h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.3px; }
.header-subtitle { font-size: 11px; color: var(--text-muted); }
.header-actions { display: flex; align-items: center; gap: 6px; }
.header-separator { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }

/* ===== Info Bar ===== */
.info-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 8px 16px;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    font-size: 12px;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.info-label {
    color: var(--text-muted);
    font-weight: 500;
}

.info-value {
    font-weight: 600;
    color: var(--text-primary);
}

.info-input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    padding: 4px 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    width: 140px;
    transition: border-color var(--transition);
}

.info-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn svg { flex-shrink: 0; }
.btn:disabled { opacity: 0.4; cursor: default; pointer-events: none; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 6px 8px;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { filter: brightness(1.1); }

.btn-accent { background: var(--accent-dim); color: var(--accent-hover); border: 1px solid rgba(99,102,241,0.3); }
.btn-accent:hover { background: rgba(99,102,241,0.25); }

.btn-danger { background: var(--danger-dim); color: #f87171; }
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 4px 8px; font-size: 11px; }

/* ===== View Toggle ===== */
.view-toggle {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 2px;
    border: 1px solid var(--border);
}

.view-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.view-btn:hover { color: var(--text-secondary); }
.view-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 1px 4px rgba(99,102,241,0.4);
}

/* ===== Main Layout ===== */
#app-main {
    display: flex;
    height: calc(100vh - 52px - var(--info-bar-height, 0px));
    position: relative;
    overflow: hidden;
}

#tree-panel {
    flex: 1;
    min-width: 350px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
}

#props-panel {
    width: 380px;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

#panelResizer {
    position: absolute;
    right: 380px;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: col-resize;
    z-index: 5;
}
#panelResizer:hover, #panelResizer.active { background: var(--accent); }

/* ===== Tree Panel ===== */
.panel-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.search-box {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0 10px;
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 12px;
    padding: 6px 0;
    outline: none;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box:focus-within { border-color: var(--accent); }

.toolbar-actions { display: flex; gap: 4px; }

.tree-stats {
    padding: 4px 12px;
    font-size: 11px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.tree-container {
    flex: 1;
    overflow: auto;
    padding: 4px 0;
}

/* ===== Empty State ===== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--text-muted);
    padding: 40px;
    text-align: center;
}
.empty-state h3 { font-size: 16px; font-weight: 500; }
.empty-state p { font-size: 13px; }

/* ===== Tree Node ===== */
.tree-node {
    user-select: none;
}

.tree-node-row {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px 2px 0;
    cursor: pointer;
    border-radius: 0;
    transition: background var(--transition);
    position: relative;
    min-height: 28px;
}

.tree-node-row:hover { background: var(--bg-hover); }
.tree-node-row.selected { background: var(--accent-dim); }
.tree-node-row.selected::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
}

.tree-node-row.drag-over-top { border-top: 2px solid var(--accent); }
.tree-node-row.drag-over-bottom { border-bottom: 2px solid var(--accent); }
.tree-node-row.drag-over-inside { background: var(--accent-dim); outline: 1px dashed var(--accent); }

.tree-indent { flex-shrink: 0; }

.tree-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: none;
    background: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    font-size: 10px;
}
.tree-toggle:hover { background: var(--bg-active); color: var(--text-primary); }
.tree-toggle.expanded { transform: rotate(90deg); }
.tree-toggle.hidden { visibility: hidden; }

.tree-type-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 18px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-mono);
    flex-shrink: 0;
    margin-right: 4px;
}

.tree-type-M { background: rgba(139,92,246,0.15); color: var(--type-M); }
.tree-type-C { background: rgba(59,130,246,0.15); color: var(--type-C); }
.tree-type-F { background: rgba(34,197,94,0.15); color: var(--type-F); }
.tree-type-H { background: rgba(100,116,139,0.15); color: var(--type-H); }
.tree-type-N { background: rgba(148,163,184,0.15); color: var(--type-N); }
.tree-type-I { background: rgba(245,158,11,0.15); color: var(--type-I); }

.tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
}

.tree-command {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 6px;
    flex-shrink: 0;
}

.tree-program {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 0px 4px;
    border-radius: 3px;
    margin-left: 4px;
    flex-shrink: 0;
}

.tree-code {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-left: 4px;
    opacity: 0.6;
}

.tree-link-badge {
    font-size: 10px;
    font-family: var(--font-mono);
    color: var(--accent-hover);
    background: var(--accent-dim);
    padding: 1px 4px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-left: 4px;
}

/* Disabled nodes */
.tree-node-row.disabled {
    opacity: 0.8;
}
.tree-node-row.disabled .tree-label {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Modified nodes */
.tree-node-row.modified {
    background: var(--modified-bg);
}
.tree-node-row.modified .tree-label {
    color: var(--modified);
}
.tree-node-row.modified::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--modified);
    margin-left: 4px;
    flex-shrink: 0;
}

.tree-children { }
.tree-children.collapsed { display: none; }

/* ===== Properties Panel ===== */
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.panel-header h2 { font-size: 13px; font-weight: 600; }
.panel-header-actions { display: flex; gap: 4px; }

.props-content {
    flex: 1;
    overflow: auto;
    padding: 12px 16px;
}

.empty-props {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    font-size: 13px;
    padding: 20px;
}

.prop-group {
    margin-bottom: 16px;
}

.prop-group-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--text-muted);
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid var(--border);
}

.prop-field { margin-bottom: 10px; }

.prop-field label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 3px;
}

.prop-field input, .prop-field select {
    width: 100%;
    padding: 6px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 12px;
    outline: none;
    transition: border-color var(--transition);
}

.prop-field input:focus, .prop-field select:focus {
    border-color: var(--accent);
}

.prop-field input[type="checkbox"] {
    width: auto;
    margin-right: 6px;
}

.prop-row {
    display: flex;
    gap: 8px;
}
.prop-row .prop-field { flex: 1; }

.prop-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
}
.prop-checkbox label {
    margin: 0;
    cursor: pointer;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 90vw;
    max-width: 700px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    animation: modalIn 200ms ease;
}

.modal-lg { max-width: 1100px; width: 95vw; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 16px; font-weight: 600; }

.modal-body {
    flex: 1;
    overflow: auto;
    padding: 16px 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid var(--border);
}

.import-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    background: var(--bg-tertiary);
    padding: 3px;
    border-radius: var(--radius);
}

.import-tab {
    flex: 1;
    padding: 6px 12px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.import-tab:hover { color: var(--text-secondary); }
.import-tab.active { background: var(--accent); color: white; }

.import-tab-content { display: none; }
.import-tab-content.active { display: block; }

.import-tab-content label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.import-tab-content textarea,
.modal-body textarea {
    width: 100%;
    height: 420px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 12px;
    resize: vertical;
    outline: none;
    line-height: 1.4;
    white-space: pre;
    overflow-x: auto;
}

.import-tab-content textarea.diff-mode,
.modal-body textarea.diff-mode {
    border-color: var(--accent-hover);
    background: #0f172a;
}

.import-tab-content textarea:focus { border-color: var(--accent); }

/* ===== Context Menu ===== */
.context-menu {
    position: fixed;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 4px;
    min-width: 180px;
    box-shadow: var(--shadow);
    z-index: 200;
    display: none;
}

.context-menu.active { display: block; }

.ctx-item {
    display: block;
    width: 100%;
    padding: 6px 12px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition);
}
.ctx-item:hover { background: var(--bg-hover); }
.ctx-danger:hover { background: var(--danger-dim); color: #f87171; }

.context-menu hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 4px 0;
}

/* ===== Toast ===== */
#toastContainer {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-size: 12px;
    box-shadow: var(--shadow);
    animation: toastIn 200ms ease;
    max-width: 320px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast.error { border-left: 3px solid var(--danger); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* ===== Drag & Drop Ghost ===== */
.drag-ghost {
    position: fixed;
    pointer-events: none;
    z-index: 1000;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 4px 10px;
    font-size: 12px;
    opacity: 0.9;
    box-shadow: var(--shadow);
}

/* ===== Revolution View ===== */
.revolution-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.rev-tabs {
    display: flex;
    background: linear-gradient(135deg, #b91c1c, #991b1b);
    padding: 0;
    overflow-x: auto;
    flex-shrink: 0;
    border-bottom: 2px solid #7f1d1d;
}

.rev-tab {
    padding: 10px 18px;
    border: none;
    background: transparent;
    color: rgba(255,255,255,0.7);
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
    border-bottom: 3px solid transparent;
    position: relative;
}

.rev-tab:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.rev-tab.active {
    color: white;
    background: rgba(255,255,255,0.15);
    border-bottom-color: white;
    font-weight: 600;
}

.rev-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.rev-sidebar {
    width: 100%;
    overflow-y: auto;
    padding: 8px 0;
    background: var(--bg-primary);
}

.rev-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 12px 16px 6px 16px;
    letter-spacing: -0.2px;
}

.rev-section-title:not(:first-child) {
    border-top: 1px solid var(--border);
    margin-top: 4px;
    padding-top: 14px;
}

.rev-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 16px 5px 28px;
    cursor: pointer;
    font-size: 12.5px;
    color: var(--text-secondary);
    transition: all var(--transition);
    border-left: 3px solid transparent;
}

.rev-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.rev-item.selected {
    background: var(--accent-dim);
    color: var(--accent-hover);
    border-left-color: var(--accent);
}

.rev-item.disabled {
    opacity: 0.8;
}
.rev-item.disabled .rev-item-label {
    text-decoration: line-through;
    color: var(--text-muted);
}

.rev-item.modified {
    color: var(--modified);
}
.rev-item.modified::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--modified);
    margin-left: 4px;
    flex-shrink: 0;
}

.rev-item .rev-item-label { flex: 1; }

.rev-item .rev-item-cmd {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 3px;
    opacity: 0;
    transition: opacity var(--transition);
}

.rev-item:hover .rev-item-cmd { opacity: 1; }

.rev-l0-items {
    padding-bottom: 4px;
    margin-bottom: 2px;
}

.rev-separator {
    height: 1px;
    background: var(--border);
    margin: 6px 16px;
}

/* ===== Drop Zone ===== */
.drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px 20px;
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    background: var(--bg-tertiary);
    text-align: center;
    transition: all 200ms ease;
    cursor: pointer;
}
.drop-zone h3 { font-size: 15px; font-weight: 500; color: var(--text-secondary); }
.drop-zone p { font-size: 12px; color: var(--text-muted); margin: 0; }
.drop-zone.drag-active {
    border-color: var(--accent);
    background: var(--accent-dim);
}
.drop-hint { font-size: 11px !important; margin-top: 4px !important; }
.file-btn { cursor: pointer; margin-top: 4px; }

.file-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.file-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 12px;
}
.file-item .file-name { font-weight: 500; }
.file-item .file-type {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 600;
}
.file-item .file-type.type-a { background: var(--accent-dim); color: var(--accent-hover); }
.file-item .file-type.type-g { background: var(--success-dim); color: var(--success); }
.file-item .file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 16px;
}
.file-item .file-remove:hover { color: var(--danger); }

/* ===== Gestione _G View ===== */
.manage-g-container {
    padding: 16px;
    height: 100%;
    overflow-y: auto;
    background: var(--bg-primary);
}

.g-toolbar {
    display: flex;
    justify-content: space-between;
    margin-bottom: 16px;
    align-items: center;
}

.g-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.g-table th, .g-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.g-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-muted);
}

.g-table tr:hover {
    background: var(--bg-hover);
}

.g-table input[type="text"] {
    width: 100%;
    padding: 4px 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary);
    border-radius: var(--radius-sm);
}

.g-table input[type="text"]:focus {
    border-color: var(--accent);
    background: var(--bg-primary);
    outline: none;
}

.g-table .g-col-code { width: 120px; font-family: var(--font-mono); }
.g-table .g-col-type { width: 80px; text-align: center; }
.g-table .g-col-desc { flex: 1; }
.g-table .g-col-actions { width: 100px; text-align: right; }

.g-table tr.disabled {
    opacity: 0.8;
}

.g-table tr.disabled input {
    text-decoration: line-through;
}

/* ===== Light Theme Overrides ===== */
body.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-hover: rgba(15, 23, 42, 0.05);
    --bg-active: #e2e8f0;
    --border: #e2e8f0;
    --border-light: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --accent: #E30613; /* Ranocchi Red */
    --accent-hover: #b91c1c;
    --accent-dim: rgba(227, 6, 19, 0.08);
    --success: #10b981;
    --success-dim: rgba(16, 185, 129, 0.08);
    --warning: #f59e0b;
    --warning-dim: rgba(245, 158, 11, 0.08);
    --danger: #ef4444;
    --danger-dim: rgba(239, 68, 68, 0.08);
    --modified: #d97706;
    --modified-bg: rgba(217, 119, 6, 0.05);
    --disabled-text: #94a3b8;
    --disabled-bg: rgba(148, 163, 184, 0.05);
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
}

/* In light theme, adjust the tree selections and details for visual harmony */
body.light-theme .tree-node-row.selected {
    background: var(--accent-dim);
    color: var(--accent);
}

body.light-theme .tree-node-row.selected::before {
    background: var(--accent);
}

body.light-theme .rev-tab.active {
    background: rgba(255, 255, 255, 0.2);
}

/* ===== Theme Toggle Button ===== */
.theme-btn {
    position: relative;
    padding: 6px;
    border-radius: var(--radius);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.theme-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

/* ===== Tree Panel Footer ===== */
.tree-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.tree-footer .dev-name {
    font-weight: 500;
}

.tree-footer .version-link {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    background: var(--accent-dim);
    padding: 2px 6px;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
}

.tree-footer .version-link:hover {
    background: var(--accent);
    color: white;
    box-shadow: 0 2px 6px rgba(227, 6, 19, 0.2);
}

/* ===== Version Modal & Timeline ===== */
.timeline {
    position: relative;
    padding-left: 20px;
    margin: 16px 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-secondary);
    box-shadow: 0 0 0 3px var(--accent-dim);
    z-index: 1;
}

.timeline-header {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 6px;
}

.timeline-version {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.timeline-date {
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.timeline-changes {
    list-style: none;
    font-size: 12.5px;
    color: var(--text-secondary);
    padding-left: 0;
}

.timeline-changes li {
    margin-bottom: 6px;
    position: relative;
    padding-left: 14px;
    line-height: 1.4;
}

/* ===== Move Modal ===== */
.move-modal-list {
    display: flex;
    flex-direction: column;
}

.move-group-header {
    background: var(--bg-tertiary);
    padding: 10px 16px;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    border-top: 1px solid var(--border);
    margin-top: -1px; /* collapse borders */
    position: sticky;
    top: 0;
    z-index: 1;
}

.move-item {
    padding: 8px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
    transition: background var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.move-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.move-item-code {
    font-family: var(--font-mono);
    color: var(--text-muted);
    font-size: 11px;
    min-width: 60px;
}

/* Identation based on depth */
.move-item[data-depth="1"] { padding-left: 24px; }
.move-item[data-depth="2"] { padding-left: 40px; }
.move-item[data-depth="3"] { padding-left: 56px; }
.move-item[data-depth="4"] { padding-left: 72px; }
.move-item[data-depth="5"] { padding-left: 88px; }

/* Empty state */
.move-empty {
    padding: 24px;
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
}
.timeline-changes li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--accent);
}

/* ===== Tree & Table Separators ===== */
.tree-separator-row {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    opacity: 0.7;
    font-family: var(--font-mono);
    font-size: 10.5px;
    user-select: none;
    color: var(--text-muted);
    transition: background var(--transition);
    border-radius: var(--radius);
}
.tree-separator-row:hover {
    background: var(--bg-hover);
    opacity: 1;
}
.tree-separator-line {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-top: 1px dashed var(--border);
    padding-top: 2px;
    letter-spacing: 0.5px;
}
.tree-separator-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 6px;
    opacity: 0;
    transition: opacity var(--transition), color var(--transition);
}
.tree-separator-row:hover .tree-separator-delete {
    opacity: 1;
}
.tree-separator-delete:hover {
    color: var(--danger);
}
.g-table-separator {
    background: var(--bg-tertiary);
    opacity: 0.8;
}



/* ===== Diff View and Highlighting ===== */
.import-tab-content .diff-view,
.modal-body .diff-view {
    width: 100%;
    height: 420px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.5;
    overflow: auto;
    white-space: pre;
    color: var(--text-primary);
    box-sizing: border-box;
}

.diff-line {
    display: block;
    width: fit-content;
    min-width: 100%;
    padding: 2px 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    white-space: pre;
    box-sizing: border-box;
}

.diff-add {
    background-color: rgba(46, 160, 67, 0.12);
    color: #2ea043;
}

.diff-del {
    background-color: rgba(248, 81, 73, 0.12);
    color: #da3633;
}

body:not(.light-theme) .diff-add {
    color: #4ade80;
    background-color: rgba(46, 160, 67, 0.15);
}

body:not(.light-theme) .diff-del {
    color: #f87171;
    background-color: rgba(248, 81, 73, 0.15);
}

.diff-line ins {
    background-color: rgba(46, 160, 67, 0.35) !important;
    text-decoration: none;
    font-weight: bold;
    border-radius: 2px;
    padding: 0 2px;
}

.diff-line del {
    background-color: rgba(248, 81, 73, 0.35) !important;
    text-decoration: line-through;
    font-weight: bold;
    border-radius: 2px;
    padding: 0 2px;
}
