/* Layout - Modals, Navigation Header, Tabs, Panels */

/* Modal */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,11,66,0.6); backdrop-filter: blur(4px); align-items: center; justify-content: center; z-index: 1000; }
.modal.hidden { display: none; }
.modal:not(.hidden) { display: flex; }
.modal-content { background: var(--light-card); padding: 28px; border-radius: 16px; min-width: 320px; box-shadow: var(--shadow-lg); }
.modal-content h3 { margin-bottom: 20px; color: var(--text-primary); }
.modal-content .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }

/* Generic Modal Overlay */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,11,66,0.6); backdrop-filter: blur(4px); display: none; align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.visible { display: flex; }
.modal-dialog { background: var(--light-card); border-radius: 16px; min-width: 400px; max-width: 600px; max-height: 90vh; overflow: hidden; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--light-border); }
.modal-header h3 { margin: 0; color: var(--text-primary); font-size: 18px; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-muted); padding: 0; line-height: 1; }
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 24px; overflow-y: auto; max-height: calc(90vh - 80px); }

/* Side-by-Side Modal (Verify/Page) */
.verify-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}
.verify-modal.visible { display: flex; }
.verify-modal-container {
    width: 95vw;
    height: 90vh;
    background: var(--light-card);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.verify-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--light-border);
    background: var(--light-bg);
    flex-shrink: 0;
}
.verify-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}
.verify-modal-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-left: 12px;
}
.verify-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
}
.verify-modal-close:hover { color: var(--text-primary); }
.verify-modal-body {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--light-border);
    overflow: hidden;
}
.verify-page-panel {
    background: #1a1a2e;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
}
.verify-page-panel img {
    max-width: 100%;
    transition: transform 0.2s;
    cursor: zoom-in;
}
.verify-page-panel img.zoomed {
    max-width: none;
    cursor: zoom-out;
}
.verify-content-panel {
    background: var(--light-card);
    overflow-y: auto;
    padding: 24px;
}
.verify-section-header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--light-border);
}
.verify-section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}
.verify-section-type {
    font-size: 13px;
    color: var(--text-muted);
}

/* Page Modal Info Grid */
.page-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.page-info-item {
    padding: 12px;
    background: var(--light-bg);
    border-radius: 8px;
}
.page-info-item.page-info-full {
    grid-column: span 2;
}
.page-info-label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.page-info-value {
    font-size: 14px;
    color: var(--text-primary);
}
.page-modal-actions {
    display: flex;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--light-border);
}

/* Verify Modal Meta & Badges */
.verify-section-meta {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.verify-type-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}
.verify-type-badge.Diagram { background: rgba(16,185,129,0.12); color: #059669; }
.verify-type-badge.PartsList { background: rgba(245,158,11,0.12); color: #d97706; }
.verify-type-badge.Photo { background: rgba(59,130,246,0.12); color: #2563eb; }
.verify-type-badge.Table { background: rgba(139,92,246,0.12); color: #7c3aed; }
.verify-type-badge.Text { background: rgba(107,114,128,0.12); color: #4b5563; }
.verify-type-badge.Other { background: rgba(107,114,128,0.12); color: #4b5563; }

/* Detail Modal Styles */
.detail-modal {
    max-width: 700px;
    width: 90vw;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    padding: 0;
}
.detail-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 20px 24px;
    border-bottom: 1px solid var(--light-border);
    flex-shrink: 0;
}
.detail-modal-title {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}
.detail-modal-icon { font-size: 28px; flex-shrink: 0; }
.detail-modal-title h3 { margin: 0 0 4px 0; font-size: 18px; color: var(--text-primary); }
.detail-modal-subtitle { font-size: 13px; color: var(--text-muted); }
.detail-modal-body { flex: 1; overflow-y: auto; padding: 20px 24px; }
.detail-section { margin-bottom: 20px; }
.detail-section:last-child { margin-bottom: 0; }
.detail-section h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detail-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}
.detail-content-box { background: var(--light-bg); border-radius: 8px; padding: 14px; }
.detail-content-text { font-size: 13px; color: var(--text-primary); line-height: 1.6; white-space: pre-wrap; }
.detail-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.detail-meta-item { background: var(--light-bg); padding: 12px; border-radius: 8px; }
.detail-meta-label { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.detail-meta-value { font-size: 14px; font-weight: 500; color: var(--text-primary); }
.detail-image-container { background: var(--dark-navy); border-radius: 8px; padding: 16px; text-align: center; }
.detail-image { max-width: 100%; max-height: 400px; object-fit: contain; border-radius: 4px; }
.detail-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--light-border);
}
.models-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* Preview Empty State */
.preview-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
}
.preview-empty-icon { font-size: 48px; opacity: 0.3; margin-bottom: 12px; }
.preview-empty-text { font-size: 13px; }
.preview-image-container {
    background: var(--dark-navy);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 16px;
    text-align: center;
}
.preview-image { max-width: 100%; max-height: 300px; object-fit: contain; border-radius: 4px; }

/* Preview Metadata */
.preview-meta { background: var(--light-bg); border-radius: 8px; padding: 12px; margin-bottom: 16px; }
.preview-meta-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--light-border);
}
.preview-meta-row:last-child { border-bottom: none; }
.preview-meta-label { color: var(--text-muted); }
.preview-meta-value { font-weight: 500; color: var(--text-primary); }
.preview-actions { display: flex; gap: 8px; margin-top: 16px; }
.preview-actions button { flex: 1; padding: 10px; font-size: 12px; }

/* Parts List Preview */
.parts-list-preview { max-height: 400px; overflow-y: auto; }
.parts-table { width: 100%; font-size: 12px; border-collapse: collapse; }
.parts-table th {
    text-align: left;
    padding: 8px 10px;
    background: var(--light-bg);
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--light-border);
    position: sticky;
    top: 0;
}
.parts-table td { padding: 8px 10px; border-bottom: 1px solid var(--light-border); color: var(--text-primary); }
.parts-table tr:hover td { background: rgba(119,95,255,0.04); }
.part-number { font-family: 'SF Mono', Consolas, monospace; font-weight: 500; color: var(--primary); }

/* Page Image Modal (Legacy) */
.page-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.9);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}
.page-modal.visible { opacity: 1; visibility: visible; }
.page-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: rgba(0,0,0,0.5);
    color: white;
}
.page-modal-title { font-size: 16px; font-weight: 500; }
.page-modal-controls { display: flex; gap: 12px; align-items: center; }
.page-modal-controls button {
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.page-modal-controls button:hover { background: rgba(255,255,255,0.2); }
.page-modal-close { font-size: 24px; padding: 8px 12px !important; }
.page-modal-body {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}
.page-modal-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s;
    cursor: zoom-in;
}
.page-modal-image.zoomed { max-width: none; max-height: none; cursor: zoom-out; }

/* Instructions Previews */
.instructions-previews-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.instruction-preview-card { background: var(--light-bg); border-radius: 12px; border: 1px solid var(--light-border); padding: 14px; }
.instruction-preview-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.instruction-preview-title { font-weight: 600; color: var(--text-primary); font-size: 0.9em; }
.instruction-preview-text { font-size: 0.85em; color: var(--text-secondary); line-height: 1.4; max-height: 60px; overflow: hidden; text-overflow: ellipsis; }
.instruction-preview-text.empty { color: var(--text-muted); font-style: italic; opacity: 0.7; }

/* Instructions Modal */
.instructions-modal { max-width: 700px; width: 90vw; max-height: 85vh; display: flex; flex-direction: column; }
.instructions-modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 1px solid var(--light-border); }
.instructions-modal-header h3 { margin: 0; }
.instructions-modal-tabs { display: flex; gap: 5px; }
.tab-btn { padding: 8px 18px; border-radius: 8px; font-size: 0.9em; background: var(--light-bg); color: var(--text-secondary); border: 1px solid var(--light-border); font-weight: 500; }
.tab-btn:hover { background: var(--light-bg); color: var(--text-primary); box-shadow: none; transform: none; }
.tab-btn.active { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: white; border-color: var(--primary); }
.instructions-content { flex: 1; overflow-y: auto; min-height: 300px; max-height: 50vh; }
#instructionsEditor { width: 100%; min-height: 300px; font-family: 'JetBrains Mono', 'Consolas', monospace; font-size: 0.9em; padding: 14px; border: 1px solid var(--light-border); border-radius: 10px; resize: vertical; background: var(--light-bg); }
#instructionsEditor:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(119,95,255,0.15); }

/* Markdown Rendered Content */
.markdown-body { padding: 16px; background: var(--light-card); border-radius: 10px; border: 1px solid var(--light-border); }
.markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 { color: var(--text-primary); margin-top: 1em; margin-bottom: 0.5em; }
.markdown-body h1 { font-size: 1.5em; border-bottom: 1px solid var(--light-border); padding-bottom: 0.3em; }
.markdown-body h2 { font-size: 1.3em; }
.markdown-body h3 { font-size: 1.1em; }
.markdown-body p { margin: 0.8em 0; line-height: 1.6; }
.markdown-body ul, .markdown-body ol { margin: 0.8em 0; padding-left: 2em; }
.markdown-body li { margin: 0.3em 0; }
.markdown-body code { background: var(--light-bg); padding: 2px 6px; border-radius: 4px; font-family: 'JetBrains Mono', monospace; font-size: 0.9em; }
.markdown-body pre { background: var(--dark-navy); color: #d4d4d4; padding: 14px; border-radius: 10px; overflow-x: auto; margin: 1em 0; }
.markdown-body pre code { background: none; padding: 0; color: inherit; }
.markdown-body blockquote { border-left: 4px solid var(--primary-light); padding-left: 1em; margin: 1em 0; color: var(--text-secondary); }
.markdown-body table { border-collapse: collapse; width: 100%; margin: 1em 0; }
.markdown-body th, .markdown-body td { border: 1px solid var(--light-border); padding: 10px 14px; text-align: left; }
.markdown-body th { background: var(--light-bg); font-weight: 600; }
.markdown-body a { color: var(--primary); }
.empty-instructions { color: var(--text-muted); font-style: italic; text-align: center; padding: 40px 20px; }

/* ===== Modern Navigation Header ===== */
.nav-header {
    height: 56px;
    background: linear-gradient(135deg, #0d0a1f 0%, #0f0f2d 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.nav-left, .nav-right {
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-back {
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: all 0.15s;
}
.nav-back:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}
.nav-logo {
    display: flex;
    align-items: center;
    margin-right: 8px;
}
.nav-workspace {
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-separator {
    color: rgba(255,255,255,0.3);
    font-size: 0.9rem;
}
.nav-select {
    background: rgba(255,255,255,0.08);
    color: white;
    border: 1px solid rgba(255,255,255,0.15);
    padding: 0 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.5)' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 26px;
    height: 30px;
    box-sizing: border-box;
    vertical-align: middle;
}
.nav-select:hover, .nav-select:focus {
    background: rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.25);
    outline: none;
}
.nav-select option {
    background: #1a1a2e;
    color: white;
}
.nav-select-brand { min-width: 120px; max-width: 180px; font-weight: 500; }
.nav-select-snapshot { min-width: 100px; max-width: 140px; }
.nav-icon-btn {
    background: transparent;
    border: 1px solid transparent;
    color: rgba(255,255,255,0.7);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}
.nav-icon-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}
.nav-icon-btn-accent {
    background: rgba(34,197,94,0.2);
    border-color: rgba(34,197,94,0.3);
    color: #4ade80;
}
.nav-icon-btn-accent:hover {
    background: rgba(34,197,94,0.3);
    color: #86efac;
}

/* Header button overrides for dark background */
.app-header .btn {
    margin: 0;
    padding: 0 12px;
    font-size: 0.8rem;
    border-radius: 6px;
    height: 30px;
    line-height: 1;
}
.app-header .btn-primary {
    background: rgba(119,95,255,0.3);
    border: 1px solid rgba(119,95,255,0.5);
    color: #c4b5fd;
}
.app-header .btn-primary:hover {
    background: rgba(119,95,255,0.4);
    transform: none;
    box-shadow: none;
}
.app-header .btn-secondary {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.9);
}
.app-header .btn-secondary:hover {
    background: rgba(255,255,255,0.15);
    transform: none;
}
.nav-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.15);
    margin: 0 4px;
}
.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
}
.nav-user-name {
    font-size: 0.82rem;
    color: rgba(255,255,255,0.8);
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ===== Navigation Tabs ===== */
.nav-tabs {
    display: flex;
    gap: 2px;
    background: var(--light-bg);
    padding: 6px 16px;
    border-bottom: 1px solid var(--light-border);
}
.nav-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.15s;
}
.nav-tab:hover {
    background: rgba(119,95,255,0.08);
    color: var(--primary);
}
.nav-tab.active {
    background: var(--light-card);
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.nav-tab svg { opacity: 0.7; }
.nav-tab.active svg { opacity: 1; }

.tab-content {
    display: none;
    padding: 20px 24px 24px;
}
.tab-content.active {
    display: block;
}

/* Settings Instruction Buttons */
.settings-instruction-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--light-border);
    border-radius: 6px;
    background: var(--light-card);
    cursor: pointer;
    transition: all 0.15s;
    text-align: left;
    color: var(--text-primary);
}
.settings-instruction-btn:hover {
    background: var(--light-bg);
    border-color: var(--primary-light);
}
.settings-instruction-btn.active {
    background: rgba(119,95,255,0.08);
    border-color: var(--primary);
    color: var(--primary);
}
.settings-instruction-btn .instruction-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}
.settings-instruction-btn .instruction-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: inherit;
}

/* Header collapsible controls - base styles */
.header-controls {
    display: contents;
}
.header-toggle-btn {
    display: none;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 11px;
    gap: 4px;
    align-items: center;
}
.header-toggle-btn:hover {
    background: rgba(255,255,255,0.25);
}
.header-toggle-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.2s;
}
.header-toggle-btn.expanded svg {
    transform: rotate(0deg);
}
.header-toggle-btn:not(.expanded) svg {
    transform: rotate(-90deg);
}

/* Responsive */
@media (max-width: 768px) {
    /* Header - collapsible on mobile */
    .app-header {
        padding: 8px 10px;
        min-height: 44px;
        gap: 6px;
        flex-wrap: wrap;
    }
    .app-header-logo svg {
        height: 28px;
    }
    .header-divider {
        display: none;
    }
    .header-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        order: 10;
        margin-left: auto;
    }
    .header-controls {
        display: flex;
        flex-wrap: wrap;
        width: 100%;
        gap: 8px;
        padding: 10px 0 6px;
        align-items: center;
        overflow: hidden;
        max-height: 150px;
        transition: max-height 0.3s ease, opacity 0.2s ease, padding 0.3s ease;
        order: 20;
    }
    .header-controls.collapsed {
        max-height: 0;
        opacity: 0;
        padding: 0;
        pointer-events: none;
    }
    .nav-back {
        padding: 6px;
    }
    .nav-select {
        height: 32px;
        font-size: 0.75rem;
        padding: 0 8px;
        padding-right: 24px;
        flex: 1;
        min-width: 80px;
    }
    .nav-select-brand {
        max-width: none;
    }
    .nav-select-snapshot {
        max-width: none;
    }
    .app-header .btn {
        height: 32px;
        padding: 0 10px;
        font-size: 0.75rem;
    }
    .app-header .btn svg {
        width: 14px;
        height: 14px;
    }
    /* Hide button text on mobile, show icons only */
    .header-controls .btn > span {
        display: none;
    }
    .nav-separator { display: none; }

    /* Nav header */
    .nav-header { padding: 0 8px; gap: 4px; }
    .nav-user-name { display: none; }
    .nav-divider { display: none; }
    .nav-icon-btn { width: 28px; height: 28px; }

    /* Navigation tabs - icon only on mobile */
    .nav-tabs {
        overflow-x: auto;
        padding: 4px 6px;
        gap: 2px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        justify-content: flex-start;
    }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tab {
        padding: 8px;
        font-size: 0;
        white-space: nowrap;
        flex-shrink: 0;
        min-width: 36px;
        width: 36px;
        height: 36px;
        justify-content: center;
        overflow: hidden;
    }
    .nav-tab svg {
        width: 18px;
        height: 18px;
        flex-shrink: 0;
    }

    /* Tab content */
    .tab-content { padding: 10px; }

    /* Modal */
    .modal-content { padding: 16px; min-width: auto; width: 95vw; }
    .modal-dialog { min-width: auto; width: 95vw; }

    /* Split layout */
    .split-layout {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }

    /* Verify modal */
    .verify-modal-body {
        grid-template-columns: 1fr;
    }
    .verify-page-panel {
        max-height: 40vh;
    }

    /* User section */
    .nav-user { display: none; }
    /* User info - show only Sign out button on mobile */
    .user-info {
        display: flex;
        align-items: center;
    }
    .user-info .user-name {
        display: none;
    }

    /* Foldable panels on mobile */
    .panel-fold-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 14px;
        background: var(--light-bg);
        border-bottom: 1px solid var(--light-border);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }
    .panel-fold-header h4 {
        margin: 0;
        font-size: 13px;
        color: var(--text-primary);
    }
    .panel-foldable .panel-body,
    .panel-foldable .file-detail-body,
    .panel-foldable .node-detail-body {
        max-height: 250px;
        transition: max-height 0.3s ease;
    }
    .panel-foldable.folded .panel-body,
    .panel-foldable.folded .file-detail-body,
    .panel-foldable.folded .node-detail-body {
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
        overflow: hidden;
    }
}

@media (max-width: 480px) {
    /* Extra small screens */
    .app-header {
        padding: 6px 8px;
        min-height: 40px;
    }
    .app-header-logo svg {
        height: 24px;
    }
    .header-toggle-btn {
        padding: 4px 8px;
        font-size: 10px;
    }
    .header-toggle-btn svg {
        width: 12px;
        height: 12px;
    }
    .header-controls {
        gap: 6px;
        padding: 8px 0 4px;
    }
    .nav-select {
        height: 28px;
        font-size: 0.7rem;
    }
    .app-header .btn {
        height: 28px;
        padding: 0 8px;
        font-size: 0.7rem;
    }

    .nav-header { height: 44px; padding: 0 6px; }
    .nav-logo img { height: 22px; }
    .nav-back { padding: 4px; }
    .nav-back img { width: 16px; height: 16px; }
    .nav-header .btn { height: 24px; min-width: 24px; padding: 0 4px; }
    .nav-header .btn img { width: 14px; height: 14px; }

    .nav-tabs { padding: 2px 4px; gap: 1px; }
    .nav-tab { padding: 6px; min-width: 30px; width: 30px; height: 30px; }
    .nav-tab svg { width: 14px; height: 14px; }

    .tab-content { padding: 8px; }
    .panel-header { padding: 8px 10px; font-size: 0.85rem; }
    .panel-body { padding: 8px 10px; }

    /* Mobile select sheet - smaller on very small screens */
    .mobile-select-sheet {
        max-height: 50vh;
    }
    .mobile-select-option {
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* Legacy app-header for brands view */
.app-header {
    background: linear-gradient(135deg, #0d0a1f 0%, #0f0f2d 100%);
    color: white;
    padding: 12px 20px;
    height: auto;
    min-height: 56px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    flex-wrap: wrap;
}
.app-header-logo {
    display: flex;
    align-items: center;
}
.app-header-logo svg {
    height: 38px;
    width: auto;
}

/* ==========================================
   MOBILE BOTTOM SHEET / SELECT OVERLAY
   ========================================== */
.mobile-select-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: none;
    align-items: flex-end;
    justify-content: center;
}
.mobile-select-overlay.visible {
    display: flex;
}
.mobile-select-sheet {
    background: var(--light-card);
    width: 100%;
    max-height: 60vh;
    border-radius: 16px 16px 0 0;
    overflow: hidden;
    animation: slideUp 0.25s ease;
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.mobile-select-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--light-border);
    background: var(--light-bg);
}
.mobile-select-header h4 {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
}
.mobile-select-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.mobile-select-options {
    max-height: calc(60vh - 60px);
    overflow-y: auto;
}
.mobile-select-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--light-border);
    cursor: pointer;
    transition: background 0.15s;
}
.mobile-select-option:hover,
.mobile-select-option:active {
    background: var(--light-bg);
}
.mobile-select-option.selected {
    background: rgba(119,95,255,0.1);
    color: var(--primary);
    font-weight: 500;
}
.mobile-select-option:last-child {
    border-bottom: none;
}
.mobile-select-check {
    color: var(--primary);
    opacity: 0;
}
.mobile-select-option.selected .mobile-select-check {
    opacity: 1;
}

/* ==========================================
   FOLDABLE DETAIL PANELS (Mobile)
   ========================================== */
.panel-foldable {
    transition: max-height 0.3s ease;
}
.panel-fold-header {
    display: none;
}
.panel-fold-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--light-bg);
    transition: transform 0.2s;
}
.panel-fold-indicator svg {
    width: 12px;
    height: 12px;
    color: var(--text-muted);
}
.panel-foldable.folded .panel-fold-indicator {
    transform: rotate(-90deg);
}
.panel-fold-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s;
}
.panel-foldable.folded .panel-fold-content {
    max-height: 0 !important;
    opacity: 0;
}

/* Split layout for tree + content */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    height: calc(100vh - 280px);
    min-height: 400px;
}
.split-layout .panel {
    background: var(--light-card);
    border-radius: 12px;
    border: 1px solid var(--light-border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    max-height: 100%;
}
.panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--light-border);
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.panel-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
}

@media (max-width: 768px) {
    .split-layout {
        grid-template-columns: 1fr;
    }
    .tabs {
        overflow-x: auto;
    }
}

/* ========== Dark Mode Overrides ========== */
:root.dark-mode .modal,
:root.dark-mode .modal-overlay {
    background: rgba(0,0,0,0.8);
}

:root.dark-mode .modal-content,
:root.dark-mode .modal-dialog {
    background: var(--light-card);
    box-shadow: var(--shadow-lg);
}

:root.dark-mode .modal-header,
:root.dark-mode .modal-header h3,
:root.dark-mode .modal-header h2 {
    color: var(--text-primary);
}

:root.dark-mode .modal-close {
    color: var(--text-muted);
}

:root.dark-mode .modal-close:hover {
    color: var(--text-primary);
}

:root.dark-mode .verify-modal {
    background: rgba(0,0,0,0.95);
}

:root.dark-mode .verify-modal-container {
    background: var(--light-card);
}

:root.dark-mode .verify-modal-header {
    background: var(--light-bg);
}

:root.dark-mode .verify-modal-title {
    color: var(--text-primary);
}

:root.dark-mode .verify-modal-close:hover {
    color: var(--text-primary);
}

:root.dark-mode .verify-content-panel {
    background: var(--light-card);
}

:root.dark-mode .app-header {
    background: linear-gradient(135deg, #0f0d1f 0%, #1a1738 100%);
}

:root.dark-mode .mobile-select-sheet {
    background: var(--light-card);
}

:root.dark-mode .mobile-select-header {
    background: var(--light-bg);
}

:root.dark-mode .mobile-select-header h4 {
    color: var(--text-primary);
}

:root.dark-mode .split-layout .panel {
    background: var(--light-card);
}
