:root {
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Dark Mode Theme Default */
    --bg-main: #0B0F19;
    --bg-sidebar: #111827;
    --bg-card: rgba(31, 41, 55, 0.65);
    --bg-card-hover: rgba(31, 41, 55, 0.85);
    --bg-input: #1F2937;
    
    --border-color: rgba(255, 255, 255, 0.1);
    --border-highlight: rgba(99, 102, 241, 0.4);

    --primary: #6366F1;
    --primary-hover: #4F46E5;
    --primary-glow: rgba(99, 102, 241, 0.35);
    --secondary: #06B6D4;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;

    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --text-inverse: #111827;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --transition: all 0.25s ease;
}

[data-theme="light"] {
    --bg-main: #F3F4F6;
    --bg-sidebar: #FFFFFF;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: #FFFFFF;
    --bg-input: #F9FAFB;
    
    --border-color: rgba(0, 0, 0, 0.08);
    --border-highlight: rgba(99, 102, 241, 0.5);

    --text-main: #111827;
    --text-muted: #6B7280;
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.06);
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* App Container Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    z-index: 10;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 36px;
}

.logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.brand-text h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.brand-text h2 span {
    color: var(--primary);
}

.brand-text p {
    font-size: 12px;
    color: var(--text-muted);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
    position: relative;
}

.nav-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.nav-btn.active {
    color: white;
    background: var(--primary);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.nav-btn .badge {
    margin-left: auto;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
}

.nav-btn .badge.secondary {
    background: var(--secondary);
    color: white;
}

/* API Card in Sidebar */
.api-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.api-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--warning);
}

.status-dot.valid {
    background-color: var(--success);
    box-shadow: 0 0 8px var(--success);
}

/* Main Content Area */
.main-content {
    flex: 1;
    padding: 32px 40px;
    display: flex;
    flex-direction: column;
    gap: 28px;
    max-width: 1400px;
}

.top-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-title h1 {
    font-size: 26px;
    font-weight: 700;
}

.header-title p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.model-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid var(--border-highlight);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.theme-toggle-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.theme-toggle-btn:hover {
    background: var(--bg-card-hover);
}

/* Tab Sections */
.tab-content {
    display: none;
}

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

/* Card Styling & Glassmorphism */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.grid-2-col {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 28px;
}

.card-header {
    margin-bottom: 20px;
}

.card-header h3 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

input[type="text"],
input[type="password"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Dropzones */
.dropzone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    background: rgba(0, 0, 0, 0.05);
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.dropzone-sm {
    padding: 16px;
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-icon {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 10px;
}

.browse-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: underline;
}

.file-info {
    font-size: 12px;
    color: var(--text-muted);
    display: block;
    margin-top: 6px;
}

.file-preview-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 12px;
}

.preview-thumb {
    position: relative;
    width: 80px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.preview-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-thumb .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 10px;
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 16px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-outline:hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Info Timeline */
.step-timeline {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin: 20px 0;
}

.step-item {
    display: flex;
    gap: 16px;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.step-text h4 {
    font-size: 14px;
    font-weight: 600;
}

.step-text p {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

.feature-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 20px;
}

.pill {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Loading Overlay */
.loading-overlay {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 60px 20px;
    text-align: center;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(99, 102, 241, 0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Review Toolbar */
.review-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.meta-tag {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 12px;
}

/* MCQ Cards Grid */
.questions-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 24px;
}

.mcq-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    transition: var(--transition);
}

.mcq-card:hover {
    border-color: var(--border-highlight);
    box-shadow: 0 12px 35px -10px rgba(99, 102, 241, 0.2);
}

.mcq-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.q-badge {
    background: var(--primary);
    color: white;
    font-weight: 700;
    font-size: 13px;
    padding: 4px 12px;
    border-radius: 6px;
}

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

.icon-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
}

.q-stem {
    font-size: 16px;
    font-weight: 500;
    line-height: 1.6;
}

/* Figure Crop Display */
.figure-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px dashed var(--border-highlight);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.figure-container img {
    max-width: 100%;
    max-height: 300px;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

.fig-caption {
    font-size: 11px;
    color: var(--secondary);
    font-weight: 600;
}

/* MCQ Options */
.options-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.option-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
}

.option-item.correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.opt-label {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    font-weight: 700;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.option-item.correct .opt-label {
    background: var(--success);
    color: white;
}

.key-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid var(--success);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.explanation-box {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid var(--warning);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--text-muted);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-card {
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}

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

/* DB Toolbar */
.db-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.db-search {
    flex: 1;
    position: relative;
}

.db-search i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.db-search input {
    padding-left: 40px;
}

.db-actions {
    display: flex;
    gap: 12px;
}

/* Question Type Badges */
.pill-type {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 12px;
}
.pill-mcq {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}
.pill-tof {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.pill-mtf {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.pill-subjective {
    background: rgba(14, 165, 233, 0.15);
    color: #38bdf8;
    border: 1px solid rgba(14, 165, 233, 0.3);
}

/* ==============================
   ANALYTICS DASHBOARD STYLES
============================== */

/* Stat Grid */
.analytics-stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    backdrop-filter: blur(10px);
}

.stat-card:hover {
    border-color: var(--border-highlight);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--stat-color) 15%, transparent);
    border: 1px solid color-mix(in srgb, var(--stat-color) 40%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--stat-color);
    flex-shrink: 0;
}

.stat-body {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.stat-value {
    font-size: 22px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-label {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Bar Chart */
.token-bar-chart {
    padding: 20px 20px 12px;
    min-height: 130px;
    display: flex;
    align-items: flex-end;
    gap: 8px;
    overflow-x: auto;
    border-top: 1px solid var(--border-color);
}

.chart-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 13px;
    min-height: 90px;
}

.chart-empty i {
    font-size: 28px;
    opacity: 0.4;
}

.chart-bar-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.chart-bar-stack {
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    width: 36px;
    gap: 1px;
    cursor: pointer;
    position: relative;
}

.chart-bar-stack:hover .chart-tooltip {
    opacity: 1;
    pointer-events: auto;
}

.chart-bar-prompt {
    background: linear-gradient(to top, #6366F1, #818CF8);
    border-radius: 3px 3px 0 0;
    width: 100%;
    transition: height 0.4s ease;
}

.chart-bar-output {
    background: linear-gradient(to top, #06B6D4, #22D3EE);
    border-radius: 0;
    width: 100%;
    transition: height 0.4s ease;
}

.chart-bar-label {
    font-size: 9px;
    color: var(--text-muted);
    text-align: center;
    max-width: 36px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(17, 24, 39, 0.95);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 100;
    color: var(--text-main);
    line-height: 1.6;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.chart-legend {
    display: flex;
    gap: 16px;
    padding: 10px 20px;
    border-top: 1px solid var(--border-color);
    font-size: 11px;
    color: var(--text-muted);
}

.legend-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 4px;
}

/* Analytics Table */
.analytics-table-wrap {
    overflow-x: auto;
    border-top: 1px solid var(--border-color);
}

.analytics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.analytics-table thead th {
    padding: 12px 14px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    background: rgba(0,0,0,0.15);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.analytics-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.analytics-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.analytics-table tbody td {
    padding: 10px 14px;
    color: var(--text-main);
    vertical-align: middle;
    white-space: nowrap;
}

.analytics-table tbody td.mono {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-muted);
}

.analytics-table tbody td.num {
    font-family: var(--font-mono);
    text-align: right;
}

.token-mini-bar {
    width: 80px;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.token-mini-bar-fill {
    height: 100%;
    background: linear-gradient(to right, #6366F1, #06B6D4);
    border-radius: 3px;
    transition: width 0.4s ease;
}

.action-pill {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.action-pill.extraction { background: rgba(99,102,241,0.15); color: #818CF8; }
.action-pill.key { background: rgba(245,158,11,0.15); color: #FCD34D; }
.action-pill.retry { background: rgba(239,68,68,0.15); color: #F87171; }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

/* ==============================
   HITL WIZARD STYLES
============================== */

/* Wizard Progress Bar */
.wizard-progress {
    margin-bottom: 24px;
    padding: 20px 28px;
}

.wizard-steps {
    display: flex;
    align-items: center;
    gap: 0;
}

.wizard-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.wizard-step span {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.wizard-step.active span,
.wizard-step.done span {
    color: var(--primary);
}

.ws-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: var(--text-muted);
    transition: var(--transition);
}

.wizard-step.active .ws-circle {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 16px var(--primary-glow);
}

.wizard-step.done .ws-circle {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}

.ws-connector {
    flex: 1;
    height: 2px;
    background: var(--border-color);
    margin: 0 8px;
    margin-bottom: 18px;
    transition: var(--transition);
}

.ws-connector.done {
    background: var(--success);
}

/* Wizard nav row */
.wizard-nav-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    padding: 16px 0 0;
    border-top: 1px solid var(--border-color);
    gap: 12px;
    flex-wrap: wrap;
}

/* Section Config Rows */
.section-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    margin-bottom: 8px;
    transition: var(--transition);
}

.section-row:hover {
    border-color: var(--border-highlight);
}

.section-row input[type="text"] {
    font-size: 13px;
}

.section-row input[type="number"] {
    width: 80px;
    font-size: 13px;
    text-align: center;
    font-family: var(--font-mono);
}

.section-remove-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 14px;
    transition: var(--transition);
}

.section-remove-btn:hover {
    background: rgba(239,68,68,0.1);
}

.total-questions-banner {
    margin-top: 16px;
    padding: 10px 14px;
    background: rgba(99,102,241,0.08);
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-muted);
}

.total-questions-banner strong {
    color: var(--primary);
    font-family: var(--font-mono);
    font-size: 16px;
}

/* Order Grid (page/key thumbnails with sequence inputs) */
.order-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

.order-thumb {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.order-thumb:hover {
    border-color: var(--border-highlight);
}

.order-thumb img {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 4px;
}

.order-thumb-label {
    font-size: 10px;
    color: var(--text-muted);
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
}

.order-thumb input[type="number"] {
    width: 60px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 600;
    padding: 4px;
    border-radius: 4px;
}

/* Loading Center */
.loading-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
    color: var(--text-muted);
}

.loading-center h3 {
    color: var(--text-main);
    font-size: 18px;
}

.loading-center p {
    font-size: 13px;
}

/* Validation Banner */
.validation-banner {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.validation-banner.warn {
    background: rgba(245,158,11,0.12);
    border: 1px solid rgba(245,158,11,0.4);
    color: #FCD34D;
}

.validation-banner.ok {
    background: rgba(16,185,129,0.12);
    border: 1px solid rgba(16,185,129,0.4);
    color: #34D399;
}

/* Key Image Thumbs */
.key-image-thumbs {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px;
}

.key-image-thumbs img {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    object-fit: contain;
    max-height: 300px;
}

/* Key Edit Table */
.key-table-wrap {
    max-height: 400px;
    overflow-y: auto;
    border-top: 1px solid var(--border-color);
}

.key-edit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.key-edit-table thead th {
    padding: 10px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    background: rgba(0,0,0,0.12);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
}

.key-edit-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.key-edit-table tbody tr:hover {
    background: var(--bg-card-hover);
}

.key-edit-table tbody td {
    padding: 6px 10px;
    vertical-align: middle;
}

.key-edit-table input[type="text"] {
    font-family: var(--font-mono);
    font-size: 12px;
    padding: 4px 8px;
    width: 60px;
}

.key-edit-table select {
    font-size: 12px;
    padding: 4px 6px;
}

.key-row-del-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
    transition: var(--transition);
}

.key-row-del-btn:hover {
    background: rgba(239,68,68,0.12);
}

/* Page Progress Header */
.page-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    margin-bottom: 20px;
    gap: 20px;
}

.page-progress-info {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
}

.page-progress-info span {
    font-size: 14px;
    color: var(--text-muted);
    white-space: nowrap;
}

.page-progress-info span strong {
    color: var(--text-main);
}

.page-progress-bar-wrap {
    flex: 1;
    height: 6px;
    background: var(--border-color);
    border-radius: 3px;
    overflow: hidden;
}

.page-progress-bar {
    height: 100%;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Page Extract Grid */
.page-extract-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr;
    gap: 20px;
    align-items: start;
}

.page-image-panel,
.page-questions-panel {
    height: fit-content;
}

.page-preview-img {
    width: 100%;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    object-fit: contain;
    max-height: 500px;
    margin-top: 8px;
}

.page-questions-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 520px;
    overflow-y: auto;
    padding: 8px 4px;
}

/* All Done Panel */
.all-done-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 48px 32px;
    text-align: center;
}

.all-done-panel h2 {
    font-size: 28px;
    background: linear-gradient(to right, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.all-done-panel p {
    color: var(--text-muted);
    font-size: 15px;
}

/* Completion message */
.completion-msg {
    font-size: 14px;
    color: var(--success);
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

/* Compact MCQ card for page-by-page view */
.page-mcq-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    transition: var(--transition);
}

.page-mcq-card:hover {
    border-color: var(--border-highlight);
}

.page-mcq-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.page-mcq-stem {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-main);
    margin-bottom: 8px;
}

.page-mcq-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.page-opt-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    background: var(--bg-input);
    border: 1px solid transparent;
}

.page-opt-item.correct {
    background: rgba(16,185,129,0.1);
    border-color: rgba(16,185,129,0.35);
}

.page-opt-label {
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--primary);
    width: 16px;
    flex-shrink: 0;
}


.page-opt-item.correct .page-opt-label {
    color: var(--success);
}

/* ============================================================
   STEP 2: PAGE SEQUENCER
   ============================================================ */
.step2-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    align-items: start;
}

.step2-left-panel {
    display: flex;
    flex-direction: column;
}

.step2-sequencer-card {
    display: flex;
    flex-direction: column;
    padding: 0 !important;
    overflow: hidden;
}

.sequencer-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0,0,0,0.15);
    flex-shrink: 0;
}

.sequencer-header h3 {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
}

/* Main sequencer body: slot list + photo panel */
.page-sequencer {
    display: flex;
    flex: 1;
    min-height: 460px;
    max-height: 520px;
    overflow: hidden;
}

/* LEFT SLOT PANEL */
.slot-panel {
    width: 260px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    background: rgba(0,0,0,0.1);
    overflow: hidden;
}

.slot-panel-header {
    padding: 10px 14px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.slot-list {
    overflow-y: auto;
    flex: 1;
}

.slot-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    cursor: pointer;
    transition: background 0.15s, border-left 0.15s;
    border-left: 3px solid transparent;
    min-height: 56px;
}

.slot-item:hover {
    background: rgba(99,102,241,0.06);
}

.slot-item.active {
    background: rgba(99,102,241,0.12);
    border-left-color: var(--primary);
}

.slot-num-badge {
    font-size: 10px;
    font-weight: 700;
    font-family: var(--font-mono);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2px 6px;
    min-width: 30px;
    text-align: center;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: all 0.15s;
}

.slot-item.active .slot-num-badge {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 8px var(--primary-glow);
}

.slot-content {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.slot-thumb-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
}

.slot-file-label {
    font-size: 11px;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.slot-item.filled .slot-file-label {
    color: var(--text-main);
}

.slot-empty-hint {
    font-size: 11px;
    color: var(--text-muted);
    font-style: italic;
}

.slot-item.active .slot-empty-hint {
    color: var(--primary);
}

.slot-clear-btn {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 3px;
    font-size: 11px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.15s;
    line-height: 1;
}

.slot-item:hover .slot-clear-btn {
    opacity: 1;
}

/* RIGHT PHOTO PANEL */
.photo-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-main);
}

.photo-panel-header {
    padding: 10px 16px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.photo-panel-header em {
    font-style: normal;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.photo-strip {
    display: flex;
    flex-direction: row;
    gap: 14px;
    padding: 18px 20px;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 1;
    align-items: flex-start;
    scroll-behavior: smooth;
}

.photo-strip::-webkit-scrollbar {
    height: 5px;
}
.photo-strip::-webkit-scrollbar-track {
    background: transparent;
}
.photo-strip::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.photo-strip-item {
    flex-shrink: 0;
    width: 180px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
    background: var(--bg-input);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.photo-strip-item:hover:not(.assigned) {
    border-color: var(--primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(99,102,241,0.25);
}

.photo-strip-item.assigned {
    opacity: 0.38;
    cursor: not-allowed;
    filter: grayscale(70%);
}

.photo-strip-item img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.photo-strip-name {
    display: block;
    font-size: 10px;
    color: var(--text-muted);
    padding: 6px 6px 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.assigned-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--success);
}

.photo-strip-item .assigned-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: var(--success);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 2px 5px;
    border-radius: 3px;
    line-height: 1;
}

/* ============================================================
   STEP 3: KEY REVIEW GRID
   ============================================================ */
.key-review-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.key-image-side {
    position: sticky;
    top: 0;
}

.key-image-side .key-image-thumbs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 55vh;
    overflow-y: auto;
}

.key-image-thumbs img {
    width: 100%;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    display: block;
}

.key-grid-side {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.key-grid-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.key-grid-topbar h3 {
    font-size: 14px;
    font-weight: 600;
}

.key-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
}

.key-search-wrap i {
    color: var(--text-muted);
    font-size: 12px;
}

.key-search-wrap input {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 12px;
    width: 90px;
    outline: none;
    padding: 0;
}

.key-option-style-toggle {
    display: flex;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.kopts-btn {
    padding: 5px 11px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
    background: var(--bg-input);
    border: none;
    border-right: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.05em;
}

.kopts-btn:last-child {
    border-right: none;
}

.kopts-btn.active {
    background: var(--primary);
    color: #fff;
}

.badge.warn {
    background: rgba(245,158,11,0.15);
    color: var(--warning);
    border: 1px solid rgba(245,158,11,0.3);
}

.key-sections-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding-right: 4px;
}

.key-sections-container::-webkit-scrollbar {
    width: 4px;
}
.key-sections-container::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

.key-section-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.key-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1;
}

.key-section-header h4 {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.05em;
    margin: 0;
    color: var(--text-main);
}

.key-section-badges {
    display: flex;
    gap: 6px;
    align-items: center;
}

.key-answer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 1px;
    background: var(--border-color);
}

.key-q-item {
    background: var(--bg-card);
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background 0.1s;
}

.key-q-item:hover {
    background: var(--bg-card-hover);
}

.key-q-item.missing-ans {
    background: rgba(239,68,68,0.05);
}

.key-q-item.highlighted {
    background: rgba(99,102,241,0.15);
    outline: 1px solid var(--primary);
}

.key-q-num {
    font-size: 9px;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--text-muted);
    line-height: 1;
}

.key-q-item.has-ans .key-q-num {
    color: var(--text-main);
}

.key-opt-row {
    display: flex;
    gap: 3px;
}

.key-opt-btn {
    flex: 1;
    padding: 2px 1px;
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    border: 1px solid var(--border-color);
    background: var(--bg-input);
    color: var(--text-muted);
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.12s;
    text-align: center;
    line-height: 1;
}

.key-opt-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99,102,241,0.1);
}

.key-opt-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
    box-shadow: 0 0 6px var(--primary-glow);
}

.key-q-item.missing-ans .key-opt-btn.active {
    background: var(--warning);
    border-color: var(--warning);
    box-shadow: none;
}


.key-q-item.excluded { opacity: 0.4; pointer-events: none; text-decoration: line-through; background: rgba(255, 100, 100, 0.1); }
.key-q-item.excluded .key-opt-btn { background: var(--bg-hover) !important; color: var(--text-muted) !important; box-shadow: none !important; border: 1px solid var(--border-color) !important; }
