:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --accent-color: #e74c3c;
    --success-color: #27ae60;
    --warning-color: #f39c12;
    --background-color: #ecf0f1;
    --card-background: #ffffff;
    --text-color: #2c3e50;
    --border-color: #bdc3c7;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
}

/* ====================================
   PORTRAIT LAYOUT (default)
   ==================================== */

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 20px;
    min-height: auto;
    text-align: center;
    margin-bottom: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border-radius: 10px;
    box-shadow: var(--shadow);
    position: relative;
}

header h1 {
    font-size: 2.5em;
    margin: 0;
    font-weight: 300;
}

.header-title-wrapper {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 20px;
}

.header-text-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.header-logo {
    height: 52px;
    width: auto;
    object-fit: contain;
    filter: invert(1);
    mix-blend-mode: screen;
    opacity: 0.92;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    align-self: flex-end;
    text-align: right;
    margin: 5px 0 0 0;
}

/* Theme selector - absolutely positioned in portrait */
.theme-selector {
    position: absolute;
    top: 14px;
    right: 16px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.theme-selector label {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.82em;
    white-space: nowrap;
}

.theme-selector select {
    padding: 5px 8px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 0.82em;
    cursor: pointer;
}

.theme-selector select:hover {
    background: rgba(255, 255, 255, 0.25);
}

.theme-selector select option {
    background: var(--primary-color);
    color: white;
}

main {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

section {
    background: var(--card-background);
    padding: 30px;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

footer {
    text-align: center;
    padding: 20px;
    color: rgba(44, 62, 80, 0.7);
    font-size: 0.9em;
    margin-top: 10px;
}

footer a {
    color: var(--secondary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* ====================================
   SHARED COMPONENTS
   ==================================== */

.info-box {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 6px;
    font-size: 0.9em;
    line-height: 1.5;
    border: 1px solid transparent;
}

.info-box.tip {
    background-color: rgba(0, 86, 179, 0.1);
    border-color: rgba(0, 86, 179, 0.2);
}

.info-box.warning {
    background-color: rgba(243, 156, 18, 0.1);
    border-color: rgba(243, 156, 18, 0.3);
}

.info-box strong {
    margin-right: 5px;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.file-input-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    width: 100%;
}

.file-input-wrapper input[type=file] {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: block;
    padding: 15px 20px;
    background: var(--background-color);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.file-input-label:hover {
    border-color: var(--secondary-color);
    background: #f8f9fa;
}

.file-input-label.file-selected {
    border-color: var(--success-color);
    background: #f0fff4;
    color: var(--success-color);
}

.file-input-label.drag-over {
    border-color: var(--secondary-color);
    background: #eef7ff;
    color: var(--secondary-color);
}

.folder-input-label .file-input-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.85em;
    color: var(--primary-color);
    opacity: 0.7;
}

.mode-toggle {
    display: flex;
    gap: 15px;
    background: #f8f9fb;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
}

.mode-option {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--primary-color);
    cursor: pointer;
    user-select: none;
}

.mode-option input[type="radio"] {
    accent-color: var(--secondary-color);
}

.mode-option input[type="radio"]:checked + span {
    color: var(--secondary-color);
}

.options {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95em;
    cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
    accent-color: var(--secondary-color);
    width: 18px;
    height: 18px;
}

.process-btn {
    padding: 15px 30px;
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.process-btn:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

.process-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.download-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn:hover {
    background: #1f2d3a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(44, 62, 80, 0.25);
}

.download-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--background-color);
    border-radius: 4px;
    overflow: hidden;
    margin: 15px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color), var(--success-color));
    border-radius: 4px;
    transition: width 0.3s ease;
    width: 0%;
}

.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.result-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.result-label {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-background);
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 24px;
    cursor: pointer;
    color: var(--border-color);
}

.close:hover {
    color: var(--accent-color);
}

.result-panel + .result-panel {
    margin-top: 25px;
}

.study-messages {
    background: #fff6f6;
    border: 1px solid rgba(231, 76, 60, 0.2);
    border-radius: 8px;
    padding: 12px 15px;
    margin-top: 15px;
    color: var(--accent-color);
    line-height: 1.4;
}

.file-list {
    margin-top: 20px;
    overflow-x: auto;
}

.file-list table {
    width: 100%;
    border-collapse: collapse;
    min-width: 480px;
}

.file-list th,
.file-list td {
    border-bottom: 1px solid var(--border-color);
    padding: 10px 12px;
    text-align: left;
    font-size: 0.95em;
}

.file-list th {
    background: #f8f9fb;
    font-weight: 600;
    color: var(--primary-color);
}

.file-list tr.success td {
    color: var(--success-color);
}

.file-list tr.error td {
    color: var(--accent-color);
}

.file-download-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    background: var(--secondary-color);
    color: #fff;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s ease;
}

.file-download-btn:hover {
    background: #2980b9;
}

.file-download-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
}

.status-success {
    color: var(--success-color);
}

.status-error {
    color: var(--accent-color);
}

.status-processing {
    color: var(--secondary-color);
}

.status-detail {
    margin-top: 8px;
    color: rgba(44, 62, 80, 0.78);
    font-size: 0.92em;
    word-break: break-word;
}

.study-summary {
    display: grid;
    gap: 8px;
    padding: 18px 20px;
    background: linear-gradient(180deg, #f8fafc, #eef4f8);
    border: 1px solid #dce7ef;
    border-radius: 10px;
    margin-top: 18px;
}

.study-summary p {
    margin: 0;
}

.storage-panel {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid #dce7ef;
    border-radius: 10px;
    background: #f8fafc;
}

.storage-panel-header {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    align-items: flex-start;
}

.storage-panel h3 {
    margin-bottom: 4px;
    color: var(--primary-color);
}

.storage-panel p {
    margin: 0;
    color: rgba(44, 62, 80, 0.78);
}

.storage-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.secondary-btn {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #fff;
    color: var(--primary-color);
    cursor: pointer;
}

.secondary-btn:hover {
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

.danger-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.storage-list {
    max-height: 180px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 0.9em;
    color: rgba(44, 62, 80, 0.88);
}

.option-help {
    margin-top: 8px;
    font-size: 0.85em;
    color: rgba(44, 62, 80, 0.72);
}

/* Advanced options */
.advanced-options {
    margin-top: 20px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: color 0.3s ease;
}

.toggle-btn:hover {
    color: var(--secondary-color);
}

.toggle-arrow {
    font-size: 0.8em;
    transition: transform 0.3s ease;
}

.toggle-arrow.expanded {
    transform: rotate(90deg);
}

.advanced-content {
    margin-top: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 18px;
    border: 1px solid #e9ecef;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.option-group {
    min-width: 0;
}

.option-group-custom-replacements,
.options-grid > .option-help {
    grid-column: 1 / -1;
}

.option-group-custom-replacements {
    padding-top: 2px;
}

.option-group h4 {
    color: var(--primary-color);
    margin-bottom: 12px;
    font-weight: 600;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 5px;
}

.option-group .checkbox-wrapper {
    margin-bottom: 12px;
}

.option-group .checkbox-wrapper.option-disabled {
    color: rgba(44, 62, 80, 0.56);
    cursor: not-allowed;
}

.option-group .checkbox-wrapper.option-disabled .checkmark {
    opacity: 0.55;
}

.option-status {
    margin-left: 6px;
    color: rgba(44, 62, 80, 0.62);
    font-size: 0.88em;
    font-weight: 500;
}

.option-group label[for="verbosity"],
.option-group label[for="worker-count"],
.option-group label[for="study-output-mode"],
.option-group label[for="archive-compression-level"] {
    display: block;
    margin-bottom: 8px;
    margin-top: 12px;
    color: var(--primary-color);
    font-weight: 500;
}

.option-group select,
.option-group input[type="number"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: #ffffff;
    color: var(--text-color);
}

.option-group input[type="number"]:disabled,
.option-group select:disabled {
    opacity: 0.4;
    background-color: #f0f0f0;
    color: #999999;
    border-color: #d0d0d0;
    cursor: not-allowed;
}

.option-group input[type="number"]:disabled:hover,
.option-group select:disabled:hover {
    cursor: not-allowed;
}

.custom-replacements-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 15px;
    padding: 12px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e9ecef;
}

.custom-replacement-row {
    display: grid;
    grid-template-columns: minmax(220px, 1.1fr) minmax(220px, 1.3fr) auto;
    gap: 10px;
    align-items: start;
    padding: 8px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 5px;
}

.replacement-tag-cell {
    display: flex;
    gap: 4px;
    align-items: flex-start;
}

.replacement-tag-input-wrap {
    flex: 1;
    min-width: 0;
}

.replacement-tag-cell .replacement-tag {
    width: 100%;
}

.replacement-tag-description {
    margin-top: 4px;
    font-size: 12px;
    line-height: 1.25;
    color: rgba(44, 62, 80, 0.78);
    overflow-wrap: anywhere;
}

.replacement-tag-description-empty {
    color: rgba(44, 62, 80, 0.5);
}

.pick-tag-btn {
    flex-shrink: 0;
    padding: 4px 8px;
    font-size: 12px;
    background: #e2e8f0;
    border: 1px solid #cbd5e0;
    border-radius: 4px;
    cursor: pointer;
    color: #4a5568;
    white-space: nowrap;
    transition: all 0.2s;
}

.pick-tag-btn:hover {
    background: #cbd5e0;
}

.replacement-tag,
.replacement-value {
    padding: 8px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: monospace;
}

.replacement-tag {
    background-color: #f0f4f8;
}

.replacement-tag::placeholder {
    color: #999;
}

.replacement-value::placeholder {
    color: #999;
}

.remove-replacement-btn {
    padding: 6px 12px;
    min-height: 34px;
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    white-space: nowrap;
    transition: all 0.2s;
}

.remove-replacement-btn:hover {
    background-color: #f5c6cb;
    border-color: #f1b0b7;
}

#tag-picker-dropdown {
    position: absolute;
    z-index: 1000;
    background: #fff;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    width: 320px;
    max-height: 280px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.tag-picker-search {
    padding: 8px 10px;
    border: none;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
    outline: none;
}

.tag-picker-list {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow-y: auto;
    flex: 1;
}

.tag-picker-list li {
    display: flex;
    gap: 8px;
    padding: 6px 10px;
    cursor: pointer;
    align-items: baseline;
    font-size: 13px;
    white-space: nowrap;
}

.tag-picker-list li:hover {
    background: #ebf4ff;
}

.tag-picker-list .tag-id {
    font-family: monospace;
    color: #4a5568;
    min-width: 80px;
    font-size: 12px;
}

.tag-picker-list .tag-name {
    color: #2d3748;
}

#add-replacement-btn {
    margin-bottom: 10px;
}

/* Portrait responsive */
@media (max-width: 600px) {
    .container {
        padding: 10px;
    }

    header {
        padding: 25px 16px 20px;
    }

    header h1 {
        font-size: 2em;
    }

    .theme-selector {
        top: 10px;
        right: 10px;
    }

    .storage-panel-header {
        flex-direction: column;
    }
}

@media (max-width: 768px) {
    .options-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .option-group-custom-replacements,
    .options-grid > .option-help {
        grid-column: auto;
    }

    .advanced-content {
        padding: 15px;
    }

    .custom-replacement-row {
        grid-template-columns: 1fr;
    }

    .remove-replacement-btn {
        width: 100%;
    }
}


/* ====================================
   THEME: DASHBOARD
   Left sidebar (config) + right panel (status/results)
   Full-viewport, IDE-style layout
   ==================================== */

.theme-dashboard {
    overflow: hidden;
}

.theme-dashboard .container {
    max-width: 100%;
    width: 100%;
    height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Slim top bar */
.theme-dashboard header {
    border-radius: 0;
    margin-bottom: 0;
    padding: 0 24px;
    height: 54px;
    flex-shrink: 0;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.theme-dashboard header > .header-title-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: flex-start;
}

.theme-dashboard .header-text-container {
    display: flex;
    align-items: baseline;
    gap: 14px;
}

.theme-dashboard .header-logo {
    height: 30px;
}

.theme-dashboard header h1 {
    font-size: 1.35em;
    margin-bottom: 0;
    font-weight: 400;
}

.theme-dashboard .subtitle {
    font-size: 0.8em;
    opacity: 0.75;
}

.theme-dashboard .theme-selector {
    position: static;
}

/* Two-column main area */
.theme-dashboard main {
    display: grid;
    grid-template-columns: 400px 1fr;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

/* Left sidebar: the config form */
.theme-dashboard .upload-section {
    border-radius: 0;
    box-shadow: none;
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 20px 18px;
    background: var(--card-background);
}

.theme-dashboard .upload-section h2 {
    font-size: 1.05em;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--secondary-color);
}

.theme-dashboard .upload-form {
    gap: 18px;
}

/* Collapse the options-grid to one column in the narrow sidebar */
.theme-dashboard .options-grid {
    grid-template-columns: 1fr;
}

.theme-dashboard .option-group-custom-replacements,
.theme-dashboard .options-grid > .option-help {
    grid-column: auto;
}

.theme-dashboard .custom-replacement-row {
    grid-template-columns: 1fr;
}

.theme-dashboard .remove-replacement-btn {
    width: 100%;
}

/* Right panel: injected by JS, holds status + results */
.theme-dashboard .dashboard-right-panel {
    overflow-y: auto;
    padding: 24px;
    background: var(--background-color);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.theme-dashboard .dashboard-right-panel > section {
    flex-shrink: 0;
}

/* Empty-state panel */
.theme-dashboard .dashboard-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: rgba(44, 62, 80, 0.32);
    text-align: center;
    padding: 60px 40px;
}

.theme-dashboard .dashboard-empty-title {
    font-size: 1.4em;
    font-weight: 300;
    color: rgba(44, 62, 80, 0.4);
}

.theme-dashboard .dashboard-empty-text {
    font-size: 0.92em;
    max-width: 280px;
    line-height: 1.7;
}

/* Results metrics more compact in the right panel */
.theme-dashboard .results-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.theme-dashboard footer {
    display: none;
}

/* Dashboard narrow screens: collapse to portrait */
@media (max-width: 900px) {
    .theme-dashboard {
        overflow: auto;
    }

    .theme-dashboard .container {
        height: auto;
        min-height: 100vh;
    }

    .theme-dashboard header {
        height: auto;
        padding: 14px 18px;
        flex-wrap: wrap;
        gap: 10px;
    }

    .theme-dashboard main {
        grid-template-columns: 1fr;
        overflow: visible;
    }

    .theme-dashboard .upload-section {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .theme-dashboard .dashboard-right-panel {
        padding: 16px;
    }
}


/* ====================================
   THEME: TABBED
   Tab-based workflow: Configure | Results
   Advanced options always visible (no collapse)
   ==================================== */

.theme-tabbed .container {
    max-width: 980px;
}

/* Header blends into tab bar */
.theme-tabbed header {
    border-radius: 10px 10px 0 0;
    margin-bottom: 0;
    padding: 22px 28px 18px;
}

/* Tab navigation bar */
.theme-tabbed .tab-nav {
    display: flex;
    align-items: stretch;
    background: #1e2e3d;
    padding: 0 20px;
    margin-bottom: 24px;
    border-radius: 0;
    gap: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}

.theme-tabbed .tab-btn {
    padding: 14px 30px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.97em;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.18s, border-color 0.18s, background 0.18s;
    white-space: nowrap;
    position: relative;
    letter-spacing: 0.02em;
}

.theme-tabbed .tab-btn:hover {
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.06);
}

.theme-tabbed .tab-btn.active {
    color: #fff;
    border-bottom-color: var(--secondary-color);
}

.theme-tabbed .tab-btn.tab-notify {
    color: #fff;
}

.theme-tabbed .tab-badge {
    display: inline-block;
    background: var(--secondary-color);
    color: #fff;
    border-radius: 9px;
    font-size: 0.75em;
    padding: 1px 7px;
    margin-left: 7px;
    vertical-align: middle;
    font-weight: 600;
}

/* Tab panel containers */
.theme-tabbed main {
    gap: 0;
}

.theme-tabbed .tab-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Configure tab: always show advanced options, remove toggle */
.theme-tabbed .advanced-options > h3 {
    display: none;
}

.theme-tabbed .advanced-content {
    display: block !important;
    margin-top: 0;
    background: transparent;
    border: none;
    padding: 0;
}

.theme-tabbed .advanced-options {
    border-top: none;
    padding-top: 0;
    margin-top: 0;
}

/* Options in configure tab: 3-column grid for the option groups */
.theme-tabbed .options-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    background: #f8f9fa;
    border-radius: 8px;
    padding: 18px;
    border: 1px solid #e9ecef;
}

.theme-tabbed .option-group-custom-replacements,
.theme-tabbed .options-grid > .option-help {
    grid-column: 1 / -1;
}

/* Results tab: placeholder when nothing is processed yet */
.theme-tabbed .tab-results-placeholder {
    background: var(--card-background);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 70px 30px;
    text-align: center;
    color: rgba(44, 62, 80, 0.38);
    font-size: 0.97em;
    font-style: italic;
}

@media (max-width: 900px) {
    .theme-tabbed .options-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .theme-tabbed .tab-btn {
        padding: 13px 18px;
        font-size: 0.9em;
    }
}

@media (max-width: 600px) {
    .theme-tabbed .container {
        padding: 0;
    }

    .theme-tabbed header {
        padding: 18px 16px 14px;
    }

    .theme-tabbed .tab-nav {
        padding: 0 10px;
    }

    .theme-tabbed .tab-btn {
        padding: 12px 14px;
        font-size: 0.85em;
    }

    .theme-tabbed main {
        padding: 0 10px 10px;
    }

    .theme-tabbed .options-grid {
        grid-template-columns: 1fr;
    }

    .theme-tabbed .option-group-custom-replacements,
    .theme-tabbed .options-grid > .option-help {
        grid-column: auto;
    }
}


/* ====================================
   THEME: DASHBOARD V2
   Left pane = full portrait layout (unchanged)
   Right pane = status + results, sticky
   ==================================== */

.theme-dashboard2 .container {
    max-width: 1500px;
}

.theme-dashboard2 main {
    display: grid;
    grid-template-columns: minmax(480px, 1.4fr) minmax(340px, 1fr);
    gap: 30px;
    align-items: start;
}

/* Left pane: upload section keeps every portrait style as-is */

/* Right pane: injected by JS */
.theme-dashboard2 .dashboard2-right-panel {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    /* subtle scrollbar so it does not distract */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.theme-dashboard2 .dashboard2-right-panel::-webkit-scrollbar {
    width: 5px;
}

.theme-dashboard2 .dashboard2-right-panel::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

/* Empty state */
.theme-dashboard2 .dashboard2-empty {
    background: var(--card-background);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 60px 28px;
    text-align: center;
    color: rgba(44, 62, 80, 0.35);
}

.theme-dashboard2 .dashboard2-empty-title {
    font-size: 1.15em;
    font-weight: 300;
    margin-bottom: 10px;
    color: rgba(44, 62, 80, 0.45);
}

.theme-dashboard2 .dashboard2-empty-text {
    font-size: 0.88em;
    line-height: 1.7;
}

/* Compact right panel sections */
.theme-dashboard2 .dashboard2-right-panel section {
    padding: 16px 18px;
}

.theme-dashboard2 .dashboard2-right-panel section h3 {
    font-size: 1em;
    margin-bottom: 12px;
}

.theme-dashboard2 .dashboard2-right-panel .progress-bar {
    margin: 8px 0;
    height: 6px;
}

.theme-dashboard2 .dashboard2-right-panel .results-grid {
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}

.theme-dashboard2 .dashboard2-right-panel .result-item {
    gap: 2px;
}

.theme-dashboard2 .dashboard2-right-panel .result-label {
    font-size: 0.76em;
}

.theme-dashboard2 .dashboard2-right-panel .study-summary {
    padding: 10px 12px;
    gap: 0;
    font-size: 0.84em;
    margin-top: 12px;
}

.theme-dashboard2 .dashboard2-right-panel .study-summary p {
    line-height: 1.5;
    padding: 1px 0;
}

.theme-dashboard2 .dashboard2-right-panel .download-btn {
    padding: 9px 18px;
    font-size: 0.9em;
    margin-top: 14px;
}

.theme-dashboard2 .dashboard2-right-panel .status-detail {
    font-size: 0.84em;
    margin-top: 5px;
}

@media (max-width: 1000px) {
    .theme-dashboard2 main {
        grid-template-columns: 1fr;
    }

    .theme-dashboard2 .dashboard2-right-panel {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
}


/* ====================================
   ERRORS LINK + ERRORS MODAL
   ==================================== */

.errors-link {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    text-align: left;
}

.errors-link:hover {
    text-decoration-style: solid;
}

.modal-content-errors {
    max-width: 1180px;
    max-height: 75vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-content-errors h3 {
    flex-shrink: 0;
    margin-bottom: 12px;
}

.errors-modal-list {
    overflow-y: auto;
    flex: 1;
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
    scrollbar-width: thin;
}

.error-modal-item {
    display: flex;
    gap: 10px;
    padding: 7px 6px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.88em;
    font-family: Consolas, 'Courier New', monospace;
    word-break: break-word;
    line-height: 1.45;
    align-items: baseline;
}

.error-modal-item:last-child {
    border-bottom: none;
}

.error-modal-num {
    color: var(--accent-color);
    font-weight: 600;
    flex-shrink: 0;
    min-width: 26px;
    font-size: 0.9em;
}

/* ====================================
   METADATA INDICATOR
   ==================================== */

.metadata-indicator {
    margin-top: 8px;
    padding: 6px 12px;
    border-radius: 5px;
    font-size: 0.85em;
    border: 1px solid transparent;
}

.metadata-indicator-active {
    background: #eaf4ff;
    border-color: var(--secondary-color);
    color: var(--secondary-color);
}

.metadata-indicator-none {
    background: #fdf6ec;
    border-color: #e0a84a;
    color: #7a5a1e;
}

/* ====================================
   METADATA MODAL
   ==================================== */

.metadata-options {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metadata-preview {
    margin: 15px 0 25px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    max-height: 250px;
    overflow-y: auto;
    font-size: 0.9em;
}

.metadata-study-node {
    margin-bottom: 15px;
}

.metadata-study-header {
    font-weight: 600;
    color: var(--primary-color);
    display: flex;
    gap: 10px;
    margin-bottom: 8px;
}

.metadata-series-list {
    margin-left: 20px;
    list-style: none;
    border-left: 2px solid #e9ecef;
    padding-left: 15px;
}

.metadata-series-item {
    margin-bottom: 6px;
    color: #4a5568;
}

.metadata-series-desc {
    color: var(--secondary-color);
    font-style: italic;
}

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