/* =============================================================================
   Scrape Admin - Styles
   ============================================================================= */

:root {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-card: #0f3460;
    --bg-code: #0d1117;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --accent: #e94560;
    --accent-hover: #ff6b6b;
    --success: #4ade80;
    --warning: #fbbf24;
    --error: #ef4444;
    --cherry: #4ade80;
    --lemon: #ef4444;
    --accept: #4ade80;
    --reject: #ef4444;
    --unknown: #fbbf24;
    --pending: #6b7280;
    --border: #2d3748;
}

[data-theme="light"] {
    --bg-primary: #f0f2f5;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-code: #f6f8fa;
    --text-primary: #1a1a2e;
    --text-secondary: #57606a;
    --accent: #d63050;
    --accent-hover: #c4283e;
    --success: #1a7f37;
    --warning: #9a6700;
    --error: #cf222e;
    --cherry: #1a7f37;
    --lemon: #cf222e;
    --accept: #1a7f37;
    --reject: #cf222e;
    --unknown: #9a6700;
    --pending: #6e7781;
    --border: #d0d7de;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

.hidden {
    display: none !important;
}

/* Global radio/checkbox accent + number spinner styling */
input[type="radio"],
input[type="checkbox"] {
    accent-color: var(--accent);
}

input[type="number"] {
    appearance: auto;
    -webkit-appearance: auto;
    -moz-appearance: auto;
    background: var(--bg-code, #1a1a2e);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    color-scheme: dark;
    font-size: 12px;
    padding: 2px 6px;
}
input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

/* =============================================================================
   Login Screen
   ============================================================================= */

#login-screen {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

.login-box {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 400px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 30px;
    color: var(--accent);
}

#login-form input {
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 16px;
}

#login-form input:focus {
    outline: none;
    border-color: var(--accent);
}

#login-form button {
    width: 100%;
    padding: 14px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

#login-form button:hover {
    background: var(--accent-hover);
}

.error {
    color: var(--error);
    text-align: center;
    margin-top: 16px;
}

/* =============================================================================
   Header
   ============================================================================= */

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 32px;
}

header h1 {
    font-size: 20px;
    color: var(--accent);
}

nav {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s;
}

.nav-link:hover {
    color: var(--text-primary);
    background: var(--bg-card);
}

.nav-link.active {
    color: var(--text-primary);
    background: var(--bg-card);
}

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

#quick-stats {
    font-size: 14px;
    color: var(--text-secondary);
    text-align: left;
    line-height: 1.3;
}
.quick-stats-version {
    font-size: 11px;
    color: var(--text-muted, #666);
    opacity: 0.7;
}

#logout-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
}

#logout-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* =============================================================================
   Main Content
   ============================================================================= */

main {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.page h2 {
    margin-bottom: 24px;
    font-size: 24px;
}

.section {
    margin-bottom: 32px;
}

.section h3 {
    margin-bottom: 16px;
    font-size: 18px;
    color: var(--text-secondary);
}

/* =============================================================================
   Stats Grid
   ============================================================================= */

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

.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: 12px;
    text-align: center;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* =============================================================================
   Buttons
   ============================================================================= */

.btn-primary {
    padding: 12px 24px;
    background: var(--accent);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    padding: 12px 24px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-danger {
    padding: 12px 24px;
    background: var(--error);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-danger:hover { opacity: 0.85; }
.btn-danger.btn-small { padding: 6px 12px; font-size: 12px; }

.btn-success {
    padding: 12px 24px;
    background: var(--success);
    border: none;
    border-radius: 8px;
    color: #000;
    font-size: 14px;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-success:hover:not(:disabled) { opacity: 0.85; }
.btn-success:disabled { background: var(--pending); color: var(--text-secondary); cursor: not-allowed; opacity: 0.6; }
.btn-success.btn-small { padding: 6px 12px; font-size: 12px; }

.action-buttons {
    display: flex;
    gap: 16px;
}

/* =============================================================================
   Sources Grid
   ============================================================================= */

.sources-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.source-card {
    background: var(--bg-secondary);
    padding: 16px 20px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.source-info h4 {
    margin-bottom: 4px;
    font-size: 15px;
}

.source-info span {
    font-size: 13px;
    color: var(--text-secondary);
}

.source-info a {
    color: #5b9bd5;
    text-decoration: none;
}

.source-info a:hover {
    text-decoration: underline;
    color: #7ab8e8;
}

.source-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.source-status.enabled {
    background: rgba(74, 222, 128, 0.2);
    color: var(--success);
}

.source-status.disabled {
    background: rgba(107, 114, 128, 0.2);
    color: var(--text-secondary);
}

/* =============================================================================
   Filters
   ============================================================================= */

.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.filters select {
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
}

.filters select:focus {
    outline: none;
    border-color: var(--accent);
}

/* =============================================================================
   Data Table
   ============================================================================= */

/* DB table container: horizontal scroll for many columns */
#db-table-container {
    overflow-x: auto;
    max-width: 100%;
    border-radius: 12px;
}

#db-table-container .data-table {
    min-width: max-content;
}

#db-table-container .data-table td {
    white-space: nowrap;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.db-url-cell {
    max-width: 250px !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.db-url-cell a {
    color: #5b9bd5;
    text-decoration: none;
}

.db-url-cell a:hover {
    text-decoration: underline;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 13px;
    text-transform: uppercase;
}

.data-table tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.data-table td {
    font-size: 14px;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.new { background: rgba(107, 114, 128, 0.2); color: var(--pending); }
.status-badge.queries_ready { background: rgba(251, 191, 36, 0.2); color: var(--warning); }
.status-badge.searched { background: rgba(251, 191, 36, 0.2); color: var(--warning); }
.status-badge.qualified { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.status-badge.fetched { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.status-badge.extracted { background: rgba(139, 92, 246, 0.2); color: #8b5cf6; }
.status-badge.validated { background: rgba(139, 92, 246, 0.2); color: #8b5cf6; }
.status-badge.done { background: rgba(74, 222, 128, 0.2); color: var(--success); }
.status-badge.exists { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.status-badge.update { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.status-badge.stored { background: rgba(74, 222, 128, 0.2); color: var(--success); }
.status-badge.added { background: rgba(74, 222, 128, 0.2); color: var(--success); }
.status-badge.updated { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.status-badge.skipped { background: rgba(148, 163, 184, 0.2); color: #94a3b8; }
.status-badge.dropped { background: rgba(251, 191, 36, 0.15); color: #b8960a; }

/* Ingest output table — 3-column fixed layout */
.intake-output-table { table-layout: fixed; width: 100%; border-collapse: collapse; }
.intake-output-table th,
.intake-output-table td { padding: 4px 6px; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.intake-output-table th:nth-child(1),
.intake-output-table td:nth-child(1) { width: 40%; }
.intake-output-table th:nth-child(2),
.intake-output-table td:nth-child(2) { width: 30%; }
.intake-output-table th:nth-child(3),
.intake-output-table td:nth-child(3) { width: 30%; }
.intake-output-table thead th { border-bottom: 1px solid var(--border); color: var(--text-secondary); font-weight: 500; }
.intake-output-table tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; }
.intake-output-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.intake-output-table .io-desc-row td { white-space: normal; }

/* Ingest pipeline step tables (01_date, 02_geo, 03_city, 08_result) */
.intake-step-table { table-layout: fixed; width: 100%; border-collapse: collapse; }
.intake-step-table th,
.intake-step-table td { padding: 4px 6px; font-size: 0.78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.intake-step-table th:nth-child(1),
.intake-step-table td:nth-child(1) { width: 30%; }
.intake-step-table th:nth-child(2),
.intake-step-table td:nth-child(2) { width: 20%; }
.intake-step-table th:nth-child(3),
.intake-step-table td:nth-child(3) { width: 16%; }
.intake-step-table thead th { border-bottom: 1px solid var(--border); color: var(--text-secondary); font-weight: 500; }
.intake-step-table tbody tr { border-bottom: 1px solid var(--border); cursor: pointer; }
.intake-step-table tbody tr:hover { background: rgba(255,255,255,0.03); }
.intake-step-table .io-desc-row td { white-space: normal; }

/* Ingest step detail (expandable data objects) */
/* ingest step detail rows reuse .eo-detail-row, .fetch-detail-tabs, .eo-obj-btn, .fetch-datamodel */

/* Deduplicate comparison table */
.dedup-compare { width: 100%; border-collapse: collapse; margin: 4px 0; }
.dedup-compare th, .dedup-compare td { padding: 6px 12px; font-size: 0.85rem; text-align: left; line-height: 1.6; }
.dedup-compare th { color: var(--text-secondary); font-weight: 600; }
.dedup-compare .val-diff { color: #f0ad4e; }

.io-event-name-link.dim { opacity: 0.55; }

/* =============================================================================
   Pagination
   ============================================================================= */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

/* DB table pagination bar — left/center/right columns */
#db-pagination {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 24px;
}

.db-pg-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.db-pg-right {
    display: flex;
    align-items: center;
}

.db-pg-info {
    font-size: 0.82rem;
    white-space: nowrap;
    margin-right: 6px;
}

.pagination button {
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover {
    border-color: var(--accent);
}

.pagination button.active {
    background: var(--accent);
    border-color: var(--accent);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =============================================================================
   Form Elements
   ============================================================================= */

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    max-width: 400px;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
}

.form-group select[multiple] {
    height: 150px;
}

/* =============================================================================
   Pipeline Toolbar
   ============================================================================= */

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

.pipeline-toolbar h2 {
    margin-bottom: 0;
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-group-inline {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-group-inline label {
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
}

.form-group-inline input {
    width: 100px;
    padding: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

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

/* =============================================================================
   Status Badge (Steps toolbar)
   ============================================================================= */

.idle-badge {
    background: rgba(107, 114, 128, 0.2);
    color: var(--text-secondary);
}

.running-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    animation: pulse-dot 1.2s ease-in-out infinite;
}

/* =============================================================================
   Run Controls Bar
   ============================================================================= */


.run-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.btn-run {
    padding: 7px 24px;
    background: #2e7d32;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.btn-run:hover {
    background: #388e3c;
}

.btn-run:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-run.btn-stop {
    background: var(--error);
}

.btn-run.btn-stop:hover {
    background: #dc2626;
}

/* Gray-Amber scope toggle variant (left=gray, right=amber) */
.scope-toggle.scope-gray-amber .slider {
    background: var(--pending);
}
.scope-toggle.scope-gray-amber input:checked + .slider {
    background: var(--warning);
}

/* =============================================================================
   Ingest Panel (always-visible above the pipeline steps)
   ============================================================================= */

.intake-panel {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.intake-panel-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.intake-panel-input .io-preview-box {
    flex: 1;
}

.intake-panel-output .io-preview-box {
    flex: 1;
    overflow: hidden;
}

.intake-panel-output .io-preview-table {
    max-height: 220px;
    overflow-y: auto;
}

.intake-run-bar {
    display: flex;
    justify-content: flex-end;
    padding-top: 4px;
}

/* =============================================================================
   Steps Layout (two-panel)
   ============================================================================= */

.steps-layout {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: auto 1fr;
    gap: 0 16px;
    min-height: calc(100vh - 140px);
}

/* Row 1: pipeline tabs + Run/Stop button on the right */
.pipeline-tabs-row {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    align-items: flex-end;
    border-bottom: 1px solid var(--border);
    margin-bottom: 8px;
    gap: 8px;
}

.pipeline-tabs-row .btn-run {
    margin-bottom: 4px;
    flex-shrink: 0;
}

.pipe-auto-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 4px;
    flex-shrink: 0;
    cursor: pointer;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.15;
    user-select: none;
}
.pipe-auto-toggle input[type="checkbox"] {
    margin: 0;
}
.pipe-auto-toggle span {
    white-space: nowrap;
}

.pipeline-tabs {
    flex: 1;
    display: flex;
    gap: 2px;
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.pipeline-tab {
    padding: 7px 18px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    border-radius: 6px 6px 0 0;
    transition: color 0.15s, background 0.15s;
    white-space: nowrap;
}

.pipeline-tab:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.pipeline-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: transparent;
}

/* Glowing text indicator for the pipeline that is currently running */
.pipeline-tab.tab-running {
    animation: tab-glow 1.5s ease-in-out infinite;
}
/* Active (selected) tab: glow in accent red */
.pipeline-tab.tab-running.active {
    animation: tab-glow-active 1.5s ease-in-out infinite;
}
@keyframes tab-glow {
    0%, 100% { color: var(--text-secondary); text-shadow: none; box-shadow: none; }
    50%      { color: #fbbf24; text-shadow: 0 0 8px rgba(251,191,36,0.6); box-shadow: inset 0 -2px 0 #fbbf24; }
}
@keyframes tab-glow-active {
    0%, 100% { text-shadow: none; box-shadow: none; }
    50%      { text-shadow: 0 0 8px rgba(251,191,36,0.7); box-shadow: inset 0 -2px 0 #fbbf24; }
}
/* Badge inherits glow from parent tab — single code path */
.pipeline-tab.tab-running .pipeline-badge-dual {
    animation: badge-glow 1.5s ease-in-out infinite;
}
@keyframes badge-glow {
    0%, 100% { box-shadow: none; }
    50%      { box-shadow: 0 0 6px rgba(251,191,36,0.5), 0 0 12px rgba(251,191,36,0.25); }
}
.pipeline-badge {
    display: inline-block;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    padding: 0 5px;
    margin-left: 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    text-align: center;
    background: rgba(255,255,255,0.12);
    color: var(--text-secondary);
    vertical-align: middle;
}
.pipeline-tab.active .pipeline-badge {
    background: rgba(233,69,96,0.2);
    color: var(--accent);
}

/* Dual badge: input (red/left) + output (green/right) */
.pipeline-badge-dual {
    display: inline-flex;
    margin-left: 6px;
    border-radius: 8px;
    overflow: hidden;
    font-size: 10px;
    font-weight: 600;
    vertical-align: middle;
    line-height: 16px;
}
.pipeline-badge-dual .badge-in {
    padding: 0 5px;
    min-width: 14px;
    text-align: center;
    background: rgba(233, 69, 96, 0.25);
    color: var(--error, #e94560);
}
.pipeline-badge-dual .badge-out {
    padding: 0 5px;
    min-width: 14px;
    text-align: center;
    background: rgba(34, 197, 94, 0.2);
    color: var(--success, #22c55e);
}
/* Dim zero values */
.pipeline-badge-dual .badge-in:empty,
.pipeline-badge-dual .badge-out:empty { display: none; }

.steps-sidebar {
    grid-column: 1;
    grid-row: 2;
    background: var(--bg-card);
    border-radius: 12px;
    overflow-y: auto;
    min-height: 0;
    max-height: calc(100vh - 200px);
}

.step-detail {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    background: var(--bg-card);
    border-radius: 12px;
    padding: 24px;
    align-self: stretch;
}

.step-detail h3 {
    margin-bottom: 8px;
    font-size: 18px;
}

.step-detail .step-description {
    color: var(--text-secondary);
    margin-bottom: 20px;
    font-size: 14px;
}

.step-detail .step-io-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.step-detail .io-box {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 14px;
}

.step-detail .io-box label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

.step-detail .io-box span {
    font-size: 14px;
}

.step-detail .step-settings-area h4 {
    margin-bottom: 12px;
    font-size: 15px;
    color: var(--text-secondary);
}

/* =============================================================================
   Settings Sections
   ============================================================================= */

.settings-section {
    margin-bottom: 32px;
}

.settings-section h3 {
    margin-bottom: 12px;
    font-size: 18px;
    color: var(--text-secondary);
}

/* Settings Menu */
.settings-menu {
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
}

.settings-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.settings-menu-item:last-of-type { border-bottom: none; }
.settings-menu-item:hover { background: rgba(255, 255, 255, 0.03); }
[data-theme="light"] .settings-menu-item:hover { background: rgba(0, 0, 0, 0.03); }
.settings-menu-label { font-weight: 600; font-size: 14px; flex: 1; }
.settings-menu-meta { font-size: 12px; color: var(--text-secondary); }
.settings-menu-arrow {
    font-size: 18px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}
.settings-menu-item.open .settings-menu-arrow { transform: rotate(90deg); }

.settings-subsection {
    padding: 0 16px 12px;
}

/* TOML raw editor */
.toml-editor {
    width: 100%;
    min-height: 400px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.5;
    background: var(--bg-code);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    resize: vertical;
    tab-size: 4;
}

/* Ingest queue warning */
.io-queue-warning {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 8px;
    font-size: 13px;
}

/* Ingest source picker */
.intake-section { margin-bottom: 12px; }
.intake-section-label { font-weight: 600; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--text-secondary); margin-bottom: 6px; }
.intake-source-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.intake-source-item { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.intake-source-item .source-name { font-weight: 500; }
.intake-source-item .source-loc { font-size: 12px; color: var(--text-secondary); }
.intake-date-modes { display: flex; gap: 10px; }
.ingest-manual-urls { width: 300%; max-width: 900px; background: #0a0a0a; color: var(--text-primary);
    border: 1px solid var(--border); border-radius: 4px; padding: 8px;
    font-family: monospace; font-size: 13px; resize: vertical; margin-bottom: 8px; }

/* Docs / Dataflow page */
.docs-nav {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.docs-nav-btn {
    padding: 6px 18px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.docs-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.docs-nav-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.docs-pre {
    background: var(--bg-code);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px 24px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Lane pushable buttons grid */
.lanes-btn-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}
.lane-btn {
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: background 0.15s, color 0.15s;
}
.lane-btn.active {
    background: rgba(74, 222, 128, 0.2);
    color: var(--success);
}
.lane-btn.muted {
    background: rgba(107, 114, 128, 0.2);
    color: var(--text-secondary);
}

.text-muted {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Step settings inline form */
.step-settings-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: end;
}

.step-settings-form .form-group {
    margin-bottom: 0;
}

.step-settings-form .form-group input,
.step-settings-form .form-group select {
    max-width: 100%;
}

.step-settings-form button {
    grid-column: 1 / -1;
    justify-self: start;
}

/* =============================================================================
   Step Items
   ============================================================================= */

.step-item {
    position: relative;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(45, 55, 72, 0.5);
    cursor: pointer;
    transition: background 0.15s;
}

.step-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.step-item.selected {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent);
}

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

.step-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.step-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.step-dot.pending { background: var(--pending); }
.step-dot.running { background: var(--warning); animation: pulse-dot 1.2s ease-in-out infinite; }
.step-dot.done { background: var(--success); }
.step-dot.error { background: var(--error); }
.step-dot.warning { background: linear-gradient(90deg, var(--success) 50%, var(--error) 50%); }
.step-dot.skipped { background: var(--text-secondary); opacity: 0.4; }

@keyframes pulse-dot {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.4); }
    50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
}

.step-name {
    min-width: 116px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.step-muted .step-name {
    color: var(--text-secondary);
    opacity: 0.5;
}
.step-muted .step-dot {
    opacity: 0.4;
}

.step-tags {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.step-tag {
    font-size: 9px;
    padding: 1px 5px;
    border-radius: 3px;
    font-weight: 500;
    opacity: 0.55;
    letter-spacing: 0.3px;
}
.step-tag-scrape {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}
.step-tag-llm {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}
.step-tag-geo {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}
.step-muted .step-tag {
    opacity: 0.25;
}

.step-io {
    font-size: 11px;
    color: var(--text-secondary);
    padding-left: 20px;
    line-height: 1.4;
}

/* Run Summary (sidebar footer) */
.run-summary-box {
    padding: 12px 16px;
    border-top: 1px solid rgba(45, 55, 72, 0.5);
    font-size: 12px;
}
.run-summary-title {
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 6px;
    letter-spacing: 0.04em;
}
.run-summary-row {
    display: flex;
    padding: 1px 0;
    color: var(--text-secondary);
}
.run-summary-label {
    min-width: 62px;
    flex-shrink: 0;
    color: var(--text-secondary);
}
.run-summary-value {
    flex: 1;
    color: var(--text-primary);
}
.timer-warning {
    color: var(--warning) !important;
}

/* =============================================================================
   Tab Bar
   ============================================================================= */

.tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
}

.tab-btn {
    padding: 10px 18px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.tab-content {
    display: none;
    flex: 1;
    min-height: 0;
}

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

.tab-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

/* =============================================================================
   Log Viewer
   ============================================================================= */

.log-viewer {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    flex: 1;
    min-height: 300px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.log-error { color: #ff6b6b; }
.log-warning { color: #ffd93d; }

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

.log-header h4 { margin: 0; }

.btn-copy {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 16px;
    line-height: 1;
    transition: color 0.15s, border-color 0.15s;
}

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

/* =============================================================================
   Sources Editor
   ============================================================================= */

.config-editor {
    width: 100%;
    flex: 1;
    min-height: 200px;
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
    resize: vertical;
}

.config-editor:focus {
    outline: none;
    border-color: var(--accent);
}

/* =============================================================================
   Lanes Grid
   ============================================================================= */

.lanes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.lane-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.lane-info h4 {
    margin-bottom: 4px;
    font-size: 14px;
}

.lane-info span {
    font-size: 12px;
    color: var(--text-secondary);
}

.lane-toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.lane-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.lane-toggle .slider {
    position: absolute;
    inset: 0;
    background: var(--pending);
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.lane-toggle .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}

.lane-toggle input:checked + .slider {
    background: var(--success);
}

.lane-toggle input:checked + .slider::before {
    transform: translateX(20px);
}

/* =============================================================================
   Schema Table
   ============================================================================= */

.schema-table {
    font-size: 13px;
}

.schema-table input {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 13px;
    width: 100%;
}

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

.schema-table select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 6px 10px;
    color: var(--text-primary);
    font-size: 13px;
}

.schema-table .btn-remove {
    padding: 4px 10px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--error);
    cursor: pointer;
    font-size: 12px;
}

.schema-table .btn-remove:hover {
    border-color: var(--error);
}

/* =============================================================================
   URL List (Qualification View)
   ============================================================================= */

.legend {
    display: flex;
    gap: 24px;
    margin-bottom: 16px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.dot-gray { background: var(--pending); }
.dot-green { background: var(--cherry); }
.dot-yellow { background: var(--unknown); }
.dot-red { background: var(--lemon); }

.url-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--pending);
}

.url-card.cherry, .url-card.accept { border-left-color: var(--accept); }
.url-card.lemon, .url-card.reject { border-left-color: var(--reject); }
.url-card.unknown { border-left-color: var(--unknown); }

.url-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.url-title {
    font-weight: 600;
    word-break: break-all;
}

.url-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.url-description {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 8px;
}

/* =============================================================================
   Runs List
   ============================================================================= */

.run-card {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.run-card:hover {
    background: var(--bg-secondary);
}

.run-info h4 {
    margin-bottom: 4px;
}

.run-info span {
    font-size: 13px;
    color: var(--text-secondary);
}

.run-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.run-status.running {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.run-status.completed {
    background: rgba(74, 222, 128, 0.2);
    color: var(--success);
}

.run-status.failed {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}

/* =============================================================================
   Artifacts
   ============================================================================= */

.artifacts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.artifact-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.artifact-card:hover {
    border-color: var(--accent);
}

.artifact-name {
    font-size: 13px;
    font-weight: 600;
    word-break: break-all;
    margin-bottom: 4px;
}

.artifact-meta {
    font-size: 12px;
    color: var(--text-secondary);
}

/* =============================================================================
   Event Info
   ============================================================================= */

#event-info {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
}

#event-info p {
    margin-bottom: 8px;
}

#event-info strong {
    color: var(--text-secondary);
    font-weight: 500;
}

/* =============================================================================
   Step Run Controls
   ============================================================================= */

.step-run-controls {
    margin-top: 20px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.step-run-controls h4 {
    margin-bottom: 12px;
    font-size: 15px;
    color: var(--text-secondary);
}

.run-controls-row {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.control-group-inline {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}

.control-group-inline input[type="number"] {
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.control-group-inline input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

.control-group {
    margin-bottom: 14px;
}

.control-group > label {
    display: block;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
}

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

/* =============================================================================
   Step Execution & Result Areas
   ============================================================================= */

.step-execution-area {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.step-execution-area h4 {
    margin-bottom: 8px;
    font-size: 15px;
    color: var(--text-secondary);
}

.step-execution-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.step-result-area {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.step-result-area h4 {
    margin-bottom: 8px;
    font-size: 15px;
    color: var(--text-secondary);
}

/* =============================================================================
   Ingest Config (Step 00)
   ============================================================================= */

.intake-config {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 14px;
    margin-bottom: 16px;
}

.intake-config .control-group {
    margin-bottom: 10px;
}

.intake-config .control-group:last-child {
    margin-bottom: 0;
}

.intake-config input[type="number"] {
    padding: 6px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 14px;
}

.intake-config input[type="number"]:focus {
    outline: none;
    border-color: var(--accent);
}

/* =============================================================================
   Highlight Toggle & Highlighted Row
   ============================================================================= */

.highlight-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 8px 0;
}

.highlight-toggle input[type="checkbox"] {
    accent-color: var(--accent);
}

.highlighted-row {
    background: rgba(233, 69, 96, 0.08) !important;
    border-left: 3px solid var(--accent);
}

.highlighted-row:hover {
    background: rgba(233, 69, 96, 0.12) !important;
}

/* =============================================================================
   Logs Layout (two-panel)
   ============================================================================= */

.logs-layout {
    display: flex;
    gap: 16px;
    min-height: calc(100vh - 220px);
    transition: all 0.2s ease;
}

.logs-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.logs-toolbar {
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.logs-toolbar .btn-copy { margin-left: auto; }

.logs-sidebar {
    width: 300px;
    flex-shrink: 0;
    background: var(--bg-card);
    border-radius: 12px;
    overflow: hidden;
    max-height: calc(100vh - 220px);
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease;
}

.logs-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 8px;
}

.logs-sidebar-header h4 {
    margin: 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.logs-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 4px 8px;
}

/* Fold / Unfold buttons */
.logs-fold-btn,
.logs-unfold-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 12px;
    padding: 2px 6px;
    line-height: 1;
    transition: color 0.15s;
}
.logs-fold-btn:hover,
.logs-unfold-btn:hover {
    color: var(--text-primary);
}

/* Folded state */
.logs-layout.logs-folded .logs-sidebar {
    width: 36px;
    min-width: 36px;
}
.logs-layout.logs-folded .logs-sidebar-header h4,
.logs-layout.logs-folded .logs-sidebar-body {
    display: none;
}
.logs-layout.logs-folded .logs-fold-btn {
    display: none;
}
.logs-layout.logs-folded .logs-unfold-btn {
    display: inline-block;
}
.logs-layout.logs-folded .logs-info-bar {
    display: flex !important;
}
/* When NOT folded, hide unfold btn and info bar */
.logs-layout:not(.logs-folded) .logs-unfold-btn { display: none; }
.logs-layout:not(.logs-folded) .logs-info-bar { display: none !important; }

/* Info bar (shown when sidebar folded) */
.logs-info-bar {
    display: none;
    flex-direction: row;
    align-items: center;
    gap: 16px;
}

.logs-info-bar .info-item {
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
}

.logs-info-bar .info-label {
    color: var(--text-secondary);
    margin-right: 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* =============================================================================
   Runs Table (logs sidebar)
   ============================================================================= */

.logs-runs-table {
    width: 100%;
    border-collapse: collapse;
}

.logs-runs-table thead th {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    padding: 4px 8px 6px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.logs-runs-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.logs-runs-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.logs-runs-table tbody tr.selected {
    background: var(--bg-secondary);
    border-left: 3px solid var(--accent);
}

.logs-runs-table td {
    padding: 6px 8px;
    font-size: 12px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
    border-bottom: 1px solid rgba(45, 55, 72, 0.3);
}

.logs-runs-table .logs-col-user  { width: 22%; }
.logs-runs-table .logs-col-pipe  { width: 22%; }
.logs-runs-table .logs-col-dt    { width: 32%; }
.logs-runs-table .logs-col-status { width: 24%; }

/* Logs toolbar label */
.logs-toolbar code {
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 4px;
}

.logs-live-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    animation: pulse-dot 1.2s ease-in-out infinite;
}

/* =============================================================================
   DB Tab Bar
   ============================================================================= */

.db-tab-bar {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.db-tab {
    padding: 8px 16px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    transition: all 0.2s;
}

.db-tab:hover {
    color: var(--text-primary);
}

.db-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.db-download-btn {
    margin-left: auto;
    padding: 6px 10px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    transition: color 0.2s;
}

.db-download-btn:hover {
    color: var(--accent);
}

/* =============================================================================
   Execution Label States
   ============================================================================= */

.exec-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.exec-running {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
    animation: pulse-dot 1.2s ease-in-out infinite;
}
.exec-done {
    background: rgba(74, 222, 128, 0.2);
    color: var(--success);
}
.exec-error {
    background: rgba(239, 68, 68, 0.2);
    color: var(--error);
}
.exec-stopped {
    background: rgba(251, 191, 36, 0.2);
    color: var(--warning);
}
.exec-inspect {
    background: rgba(245, 196, 0, 0.25);
    color: #c9a200;
}

/* Inline Stop Button */
.btn-stop-inline {
    padding: 2px 10px;
    margin-left: 8px;
    background: transparent;
    border: 1px solid var(--error);
    border-radius: 4px;
    color: var(--error);
    font-size: 11px;
    cursor: pointer;
    vertical-align: middle;
}
.btn-stop-inline:hover {
    background: rgba(239, 68, 68, 0.15);
}

/* Scope Toggle */
.scope-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    position: relative;
}
.scope-label {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
}
.scope-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.scope-toggle .slider {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    background: var(--pending);
    border-radius: 12px;
    transition: background 0.2s;
}
.scope-toggle .slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s;
}
.scope-toggle input:checked + .slider {
    background: var(--success);
}
.scope-toggle input:checked + .slider::before {
    transform: translateX(20px);
}

/* =============================================================================
   Halt Flag
   ============================================================================= */

.pause-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--warning);
    cursor: pointer;
    padding: 0;
    margin-left: auto;
}

.pause-toggle input[type="checkbox"] {
    accent-color: var(--warning);
}

.step-icon {
    margin-left: auto;
    flex-shrink: 0;
}

.step-resume-btn {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    background: none;
    border: none;
    color: var(--warning);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    opacity: 0.85;
}

.step-resume-btn:hover {
    opacity: 1;
}

.step-pause-marker {
    display: inline-flex;
    align-items: center;
    margin-left: auto;
    color: var(--warning);
    opacity: 0.7;
    flex-shrink: 0;
}

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

.pause-toggle-detail {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--warning);
    cursor: pointer;
}

.pause-toggle-detail input[type="checkbox"] {
    accent-color: var(--warning);
}

/* =============================================================================
   I/O Live Previews
   ============================================================================= */

.step-io-live {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.io-preview-box {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 14px;
}

.io-preview-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.io-preview-header label {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}

.io-preview-box.input-frozen {
    opacity: 0.82;
    pointer-events: none;
}
/* Allow expanding detail rows, inspect button, and external links even when input is frozen */
.io-preview-box.input-frozen .io-event-name-link,
.io-preview-box.input-frozen .result-input-detail-row,
.io-preview-box.input-frozen .inspect-btn,
.io-preview-box.input-frozen a[target="_blank"] {
    pointer-events: auto;
    cursor: pointer;
}

.io-preview-box.input-frozen .io-preview-header label::after {
    content: ' (frozen)';
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: normal;
    text-transform: none;
}

.io-hint {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', monospace;
}

.io-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-secondary);
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 4px;
}

.io-table {
    font-size: 12px;
    border-radius: 6px;
}

.io-table th, .io-table td {
    padding: 8px 10px;
}
.io-table td a {
    color: var(--text-primary);
}

.io-date-note {
    font-size: 11px;
    padding: 4px 10px 2px;
    opacity: 0.7;
}

.io-url-cell {
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.io-url-cell a {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    color: #c084fc;
    text-decoration: none;
}
.io-url-cell a:hover {
    text-decoration: underline;
    color: #d8b4fe;
}
[data-theme="light"] .io-url-cell a {
    color: #7c3aed;
}
[data-theme="light"] .io-url-cell a:hover {
    color: #6d28d9;
}

/* Input lane tables: fixed column widths for alignment across groups */
.input-lane-table {
    table-layout: fixed;
}
.input-lane-table th:nth-child(1) { width: 8%; }   /* # (or section label) */
.input-lane-table th:nth-child(2) { width: 44%; }  /* Title */
.input-lane-table th:nth-child(3) { width: 48%; }  /* URL */
.input-lane-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Section-label th: uppercase section name replaces the "#" column header */
.search-section-table { margin-bottom: 12px; }
.search-section-table .search-section-label {
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.04em;
}

/* Qualify lane tables: 4 columns — #, Title, URL, Status */
.qualify-lane-table {
    table-layout: fixed;
    width: 100%;
}
.qualify-lane-table td:nth-child(1) { width: 28px; }   /* # */
.qualify-lane-table td:nth-child(3) { width: 40%; }    /* URL */
.qualify-lane-table td:nth-child(4) { width: 80px; }   /* Status */
/* Title (td:nth-child 2) auto-fills the remaining space */
/* No-URL variant (3 cols: # | title | status) */
.qualify-lane-table.qualify-no-url td:nth-child(3) { width: 80px; }
.qualify-lane-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 09_result output: Checkbox | Title | Date | City | Status */
.result-events-table {
    table-layout: fixed;
    width: 100%;
}
.result-events-table td:nth-child(1) { width: 28px; }   /* checkbox */
/* td:nth-child(2) = Title — auto-fills remaining space */
.result-events-table td:nth-child(3) { width: 95px; }   /* Date */
.result-events-table td:nth-child(4) { width: 130px; }  /* City */
.result-events-table td:nth-child(5) { width: 65px; }   /* Status */
.result-events-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-sel-link {
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
}
.result-sel-link:hover { color: var(--text-primary); }
.btn-edit-selected {
    margin-left: 8px;
    padding: 2px 10px;
    font-size: 11px;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
.btn-edit-selected:hover { background: #15803d; }
.btn-edit-selected.hidden { display: none; }
.qualify-status {
    white-space: nowrap;
}
.qs-accept { font-weight: 700; color: var(--success); }
.qs-reject { font-weight: 700; color: var(--error); }
.qs-review { font-weight: 700; color: var(--warning); }
.qs-neutral { font-weight: 600; color: var(--text-secondary); opacity: 0.7; }
.qs-info { font-weight: 700; color: #5b9bd5; }
.qs-pending { font-weight: 600; color: var(--text-muted); opacity: 0.5; }
.qs-queued { font-weight: 400; color: var(--text-secondary); }
.qs-processing { font-weight: 700; color: var(--accent); animation: qs-pulse 1.2s ease-in-out infinite; }
@keyframes qs-pulse { 0%,100%{opacity:1} 50%{opacity:.5} }
.was-review-frame {
    display: inline-block;
    padding: 2px 4px;
    border-radius: 3px;
    background:
        linear-gradient(#fde047, #fde047) top    / 100% 2px no-repeat,
        linear-gradient(#fde047, #fde047) bottom / 100% 2px no-repeat,
        linear-gradient(#fde047, #fde047) left   / 2px 100% no-repeat,
        linear-gradient(#fde047, #fde047) right  / 2px 100% no-repeat;
}
.qualify-reason {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* DB row: clickable data rows */
.db-data-row:hover {
    background: rgba(255, 255, 255, 0.04) !important;
}

/* Record detail (expandable row) */
.db-record-detail-row {
    background: var(--bg-secondary) !important;
}
.db-record-detail-row:hover {
    background: var(--bg-secondary) !important;
}
.db-record-detail-cell {
    padding: 16px 20px !important;
}
.record-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 24px;
    max-height: 500px;
    overflow-y: auto;
}
.record-field {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(45, 55, 72, 0.4);
}
.record-field-key {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
}
.record-field-value {
    font-size: 13px;
    word-break: break-word;
}
.record-field-text {
    white-space: pre-wrap;
}
.record-json {
    background: var(--bg-code);
    padding: 8px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    max-height: 200px;
    overflow-y: auto;
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* IO preview: clickable ID links */
.io-id-link {
    color: #5b9bd5;
    text-decoration: none;
    font-weight: 600;
}
.io-id-link:hover {
    text-decoration: underline;
    color: #7ab8e8;
}

/* IO preview: clickable event names */
.io-event-name-link {
    cursor: pointer;
    color: var(--text-primary);
    border-bottom: 1px dashed var(--text-secondary);
}
.io-event-name-link:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* IO preview: expandable description row */
.io-desc-row {
    background: rgba(15, 52, 96, 0.5) !important;
}
.io-desc-cell {
    padding: 10px 16px !important;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: normal !important;
    line-height: 1.5;
}
.io-desc-cell pre {
    white-space: pre-wrap;
    word-break: break-word;
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.4;
    max-height: 400px;
    overflow-y: auto;
}

/* =============================================================================
   Theme Toggle
   ============================================================================= */

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px 10px;
    font-size: 16px;
    line-height: 1;
    transition: border-color 0.2s, color 0.2s;
    display: flex;
    align-items: center;
}

.theme-toggle:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Light-theme tweaks for elements with hardcoded rgba or colors */
[data-theme="light"] #login-screen {
    background: linear-gradient(135deg, #e8ecf1 0%, #f0f2f5 100%);
}

[data-theme="light"] .step-item:hover,
[data-theme="light"] .run-card-mini:hover,
[data-theme="light"] .db-data-row:hover {
    background: rgba(0, 0, 0, 0.04) !important;
}

[data-theme="light"] .step-item.selected,
[data-theme="light"] .run-card-mini.selected {
    background: #f0f2f5;
}

[data-theme="light"] .highlighted-row {
    background: rgba(214, 48, 80, 0.06) !important;
}

[data-theme="light"] .highlighted-row:hover {
    background: rgba(214, 48, 80, 0.10) !important;
}

[data-theme="light"] .source-card,
[data-theme="light"] .lane-card {
    background: #f6f8fa;
}

[data-theme="light"] .io-preview-box {
    background: #f6f8fa;
}

[data-theme="light"] .db-record-detail-row,
[data-theme="light"] .db-record-detail-row:hover {
    background: #f6f8fa !important;
}

[data-theme="light"] .step-item {
    border-bottom-color: var(--border);
}
[data-theme="light"] .step-tag-scrape {
    background: rgba(180, 130, 0, 0.12);
    color: #92600a;
}
[data-theme="light"] .step-tag-llm {
    background: rgba(109, 40, 217, 0.10);
    color: #6d28d9;
}
[data-theme="light"] .step-tag-geo {
    background: rgba(22, 163, 74, 0.10);
    color: #15803d;
}

[data-theme="light"] .data-table {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .llm-tab-btn {
    background: #f0f2f5;
    border-color: var(--border);
    color: var(--text-primary);
}
[data-theme="light"] .llm-tab-btn.active {
    background: #7c3aed;
    border-color: #7c3aed;
    color: #fff;
}

/* =============================================================================
   Listing URLs (inside IO table)
   ============================================================================= */

.listing-link {
    color: #5b9bd5;
    text-decoration: none;
    font-size: 12px;
    line-height: 1.8;
}

.listing-link:hover {
    text-decoration: underline;
    color: #7ab8e8;
}

/* =============================================================================
   Result Meta (Step 00 result section)
   ============================================================================= */

.result-meta { margin-bottom: 12px; font-size: 12px; }
.result-meta-row { padding: 2px 0; color: var(--text-secondary); display: flex; }
.result-meta-label {
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 68px;
    flex-shrink: 0;
}
.result-meta-value { flex: 1; }
.result-url-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 2px;
}
.result-url {
    color: #5b9bd5;
    text-decoration: none;
    word-break: break-all;
    font-size: 11px;
}
.result-url:hover { text-decoration: underline; }
.btn-render {
    flex-shrink: 0;
    font-size: 10px;
    padding: 1px 6px;
    background: rgba(255,255,255,0.06);
    color: #5b9bd5;
    border: 1px solid var(--border);
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-render:hover { background: rgba(255,255,255,0.12); }

/* Screenshot overlay */
.screenshot-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.8);
    display: flex; align-items: flex-start; justify-content: center;
    overflow-y: auto; padding: 30px 20px;
}
.screenshot-container {
    position: relative; max-width: 900px; width: 100%;
}
.screenshot-close {
    position: sticky; top: 0; float: right; z-index: 1;
    background: rgba(0,0,0,0.6); color: #fff; border: none;
    font-size: 24px; width: 36px; height: 36px; border-radius: 50%;
    cursor: pointer; line-height: 1;
}
.screenshot-close:hover { background: rgba(255,255,255,0.2); }
.screenshot-loading {
    color: var(--text-secondary); padding: 40px; text-align: center; font-size: 13px;
}
.screenshot-img {
    display: none; width: 100%; border-radius: 4px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.5);
}

/* =============================================================================
   Search Lane Groups (Step 02)
   ============================================================================= */

.search-lane-group { margin-bottom: 12px; }
.search-lane-header {
    font-size: 12px; font-weight: 600; text-transform: uppercase;
    color: var(--text-secondary); padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between;
}
.search-lane-count { font-weight: normal; opacity: 0.7; }

.badge-origin {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 1px 5px;
    border-radius: 3px;
    background: var(--accent, #4a9eff);
    color: #fff;
    opacity: 0.85;
    margin-left: 5px;
    vertical-align: middle;
}
tr.row-origin { opacity: 0.9; }
tr.row-origin td:first-child { color: var(--accent, #4a9eff); font-size: 10px; }

.search-lane-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 0;
}
.search-lane-name {
    font-size: 13px;
    font-weight: 600;
    min-width: 90px;
}
.search-lane-max-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.lane-max-input {
    width: 50px; text-align: center;
    background: var(--bg-primary); border: 1px solid var(--border);
    color: var(--text-primary); border-radius: 4px; padding: 2px 4px;
    font-size: 13px; color-scheme: dark;
}
[data-theme="light"] .lane-max-input {
    color-scheme: light;
}
.lane-max-input:focus {
    outline: none;
    border-color: var(--accent);
}

/* =============================================================================
   Prompt Preview (Steps 03/03.1)
   ============================================================================= */

.prompt-preview { margin: 8px 0; }
.prompt-preview summary {
    cursor: pointer; font-size: 0.85em;
    color: var(--text-secondary); padding: 6px 0;
    display: flex; align-items: center; gap: 8px;
}
.prompt-preview summary:hover { color: var(--text-primary); }
.prompt-copy-btn {
    opacity: 0; transition: opacity 0.15s;
    padding: 2px 4px; line-height: 1;
}
.prompt-preview[open] .prompt-copy-btn,
.prompt-preview summary:hover .prompt-copy-btn { opacity: 1; }
.prompt-preview-body {
    max-height: 400px; overflow-y: auto;
    padding: 8px 12px; font-size: 0.8em;
    border: 1px solid var(--border); border-radius: 4px;
    background: var(--bg-secondary);
}
.prompt-preview-body pre {
    white-space: pre-wrap; margin: 0; line-height: 1.4;
}
.prompt-lane-header { font-weight: 700; margin-top: 12px; color: var(--text-primary); }

/* =============================================================================
   Quality Groups (Steps 03/03.1)
   ============================================================================= */

.quality-group { margin-bottom: 12px; }
.quality-group-header {
    font-size: 12px; font-weight: 600; text-transform: uppercase;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between;
}
.quality-cherry, .quality-accept  { color: var(--accept); }
.quality-lemon, .quality-reject   { color: var(--reject); }
.quality-unknown { color: var(--unknown); }

/* =============================================================================
   Fetch Lane Tables (Step 04)
   ============================================================================= */

/* Input table column widths: # | Title | URL (no header row) */
.fetch-lane-table {
    table-layout: fixed;
}
.fetch-lane-table td:nth-child(1) { width: 28px; }   /* seq # */
.fetch-lane-table td:nth-child(2) { width: 28%; }    /* Title (shorter) */
/* td:nth-child(3) = URL fills remaining */
.fetch-lane-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Output table column widths */
/* 5-column layout: # | Title | Stages | Diagnosis | KB (URL removed) */
.fetch-output-table {
    table-layout: fixed;
    width: 100%;
}
.fetch-output-table td:nth-child(1) { width: 28px; }   /* seq # */
/* td:nth-child(2) = Title — auto-fills remaining space */
.fetch-output-table td:nth-child(3) { width: 80px; }   /* Stages */
.fetch-output-table td:nth-child(4) { width: 130px; }  /* Diagnosis */
.fetch-output-table td:nth-child(5) { width: 60px; }   /* KB */
.fetch-output-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fetch-img-count { text-align: center; font-size: 12px; color: var(--text-secondary); }
.fetch-img-count:hover { color: var(--accent); }

/* Fetch status badges (input) */
.fs-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.fs-pending { background: rgba(107, 114, 128, 0.2); color: var(--pending); }
.fs-success { background: rgba(74, 222, 128, 0.2); color: var(--success); }
.fs-failed  { background: rgba(239, 68, 68, 0.2); color: var(--error); }

/* Fetch diagnosis badges (output) */
.fd-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.fd-success    { background: rgba(74, 222, 128, 0.2); color: var(--success); }
.fd-soft-block { background: rgba(251, 191, 36, 0.2); color: var(--warning); }
.fd-hard-block { background: rgba(239, 68, 68, 0.2); color: var(--error); }
.fd-terminal   { background: rgba(127, 29, 29, 0.3); color: #fca5a5; }
.fd-other      { background: rgba(107, 114, 128, 0.2); color: var(--pending); }

/* Rows with no content retrieved */
.fetch-row-no-content td {
    opacity: 0.5;
}

/* Fetch stage badges */
.fstage-a { background: rgba(59, 130, 246, 0.2); color: #3b82f6; }
.fstage-b { background: rgba(139, 92, 246, 0.2); color: #8b5cf6; }
.fstage-c { background: rgba(251, 191, 36, 0.2); color: var(--warning); }
.fstage-d { background: rgba(239, 68, 68, 0.2); color: var(--error); }

/* Expandable fetch detail rows */
.fetch-detail-row { background: var(--bg-code) !important; }
.fetch-detail-row td { padding: 0 !important; }

/* Unified Event Object detail rows */
.eo-detail-row { background: var(--bg-code) !important; }
.eo-detail-row td { padding: 0 !important; }

/* Base eo-table */
.eo-table { table-layout: fixed; width: 100%; }
.eo-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.eo-table td:nth-child(1),
.eo-table th:nth-child(1) { width: 28px; min-width: 28px; }
.eo-table th { text-align: left; font-weight: 500; font-size: 11px; color: var(--text-secondary); padding: 4px 6px; border-bottom: 1px solid var(--border); }

/* 3-col: # | Title | URL (03_search) */
.eo-table-url td:nth-child(3),
.eo-table-url th:nth-child(3) { width: 40%; }
.eo-table-url td:nth-child(3) { overflow: hidden; text-overflow: ellipsis; }

/* 3-col: # | Title | Status (04_prequalify, 06_qualify) */
.eo-table-status td:nth-child(3),
.eo-table-status th:nth-child(3) { width: 90px; text-align: right; }

/* 5-col: # | Title | Stages | Diagnosis | KB (05_sample) */
.eo-table-sample td:nth-child(3),
.eo-table-sample th:nth-child(3) { width: 80px; }
.eo-table-sample td:nth-child(4),
.eo-table-sample th:nth-child(4) { width: 130px; }
.eo-table-sample td:nth-child(5),
.eo-table-sample th:nth-child(5) { width: 60px; }

/* 5-col: # | Title | Stages | Diagnosis | KB (07_scrape) */
.eo-table-scrape td:nth-child(3),
.eo-table-scrape th:nth-child(3) { width: 80px; }
.eo-table-scrape td:nth-child(4),
.eo-table-scrape th:nth-child(4) { width: 130px; }
.eo-table-scrape td:nth-child(5),
.eo-table-scrape th:nth-child(5) { width: 60px; }

/* Data model viewer */
.fetch-datamodel {
    padding: 10px 14px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 12px;
    line-height: 1.6;
}
.fetch-dm-field {
    display: flex;
    gap: 12px;
    padding: 3px 0;
    border-bottom: 1px solid rgba(45, 55, 72, 0.3);
    overflow: hidden;
}
.fetch-dm-field:last-child { border-bottom: none; }
.fetch-dm-key {
    color: var(--text-secondary);
    min-width: 120px;
    flex-shrink: 0;
    font-weight: 600;
}
.fetch-dm-val {
    color: var(--text-primary);
    word-break: break-word;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
    min-width: 0;
}

.fetch-dm-images {
    display: flex; gap: 6px; padding: 8px 0; flex-wrap: wrap;
}
.fetch-dm-thumb {
    width: 72px; height: 72px; object-fit: cover;
    border-radius: 6px; cursor: pointer;
    border: 1px solid var(--border);
    transition: transform 0.15s;
}
.fetch-dm-thumb:hover { transform: scale(1.08); }
.lightbox-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
}
.lightbox-img {
    max-width: 90vw; max-height: 90vh;
    border-radius: 8px; box-shadow: 0 4px 30px rgba(0,0,0,0.5);
}

/* Fetch detail tabs (reuses llm-tab-btn styling) */
.fetch-detail-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    padding: 8px 14px 4px;
}

[data-theme="light"] .fetch-detail-row { background: #f6f8fa !important; }
[data-theme="light"] .eo-detail-row { background: #f6f8fa !important; }
[data-theme="light"] .fd-terminal { background: rgba(127, 29, 29, 0.15); color: #991b1b; }

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 16px;
    }

    .header-left {
        flex-direction: column;
        gap: 16px;
    }

    nav {
        flex-wrap: wrap;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .filters {
        flex-wrap: wrap;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
    }

    .steps-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto 1fr;
    }

    .pipeline-tabs-row { grid-column: 1; grid-row: 1; }
    .steps-sidebar { grid-column: 1; grid-row: 2; max-height: 200px; }
    .step-detail { grid-column: 1; grid-row: 3; }

    .logs-layout {
        flex-direction: column;
    }
    .logs-layout .logs-sidebar {
        width: 100% !important;
        max-height: 200px;
    }
    .logs-layout.logs-folded .logs-sidebar {
        width: 100% !important;
        height: auto;
    }

    .pipeline-toolbar {
        flex-wrap: wrap;
    }

    .llm-split {
        grid-template-columns: 1fr !important;
    }
}

/* =============================================================================
   LLM Calls Viewer
   ============================================================================= */

.llm-calls-summary {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-left: auto;
}

.llm-calls-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.llm-tab-btn {
    padding: 4px 12px;
    border: 1px solid #334155;
    border-radius: 4px;
    background: #1e293b;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.llm-tab-btn:hover {
    border-color: #8b5cf6;
    color: var(--text-primary);
}
.llm-tab-btn.active {
    border-color: #8b5cf6;
    background: #6d28d9;
    color: #fff;
}

.llm-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.llm-pane {
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.llm-pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.llm-pane-header strong {
    color: var(--text-primary);
    font-size: 0.8rem;
}

.llm-pane-body {
    max-height: 400px;
    overflow: auto;
    padding: 10px;
    background: var(--bg-code);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
    margin: 0;
}

.llm-call-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    border-radius: 0 0 6px 6px;
}

/* =============================================================================
   Human Review Panel (step 09_human)
   ============================================================================= */

.human-review-panel {
    display: flex;
    gap: 12px;
    height: 100%;
    min-height: 400px;
}

.review-col {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    min-width: 0;
}

.review-col-images  { flex: 0 0 220px; }
.review-col-fields  { flex: 1 1 auto; }
.review-col-sources { flex: 0 0 240px; }

.review-col-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
}

/* Image Picker */
.review-img-list {
    overflow-y: auto;
    flex: 1;
    padding: 6px;
}

.review-img-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 6px;
    border-radius: 4px;
    margin-bottom: 4px;
    cursor: pointer;
    transition: background 0.1s;
}

.review-img-row:hover {
    background: var(--bg-hover, rgba(255,255,255,0.05));
}

.review-img-row.is-default {
    border: 1px solid var(--accent, #4a9eff);
}

.review-img-radio {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    cursor: pointer;
}

.review-img-thumb {
    width: 80px;
    height: 60px;
    object-fit: cover;
    border-radius: 3px;
    display: block;
}

.review-img-placeholder {
    width: 80px;
    height: 60px;
    background: var(--bg-secondary);
    border-radius: 3px;
}

.review-img-exclude {
    display: flex;
    align-items: center;
    cursor: pointer;
}

.review-exclude-x {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.review-img-meta {
    font-size: 0.7rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.review-img-score { font-weight: 600; color: var(--text-primary); }

/* Field Editor */
.review-field-form {
    padding: 10px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.review-field-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.review-field-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.review-field-input {
    padding: 5px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input, var(--bg-primary));
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    resize: vertical;
}

.review-field-input:focus {
    outline: none;
    border-color: var(--accent, #4a9eff);
}

.review-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.review-status {
    font-size: 0.8rem;
    margin-top: 4px;
}

.review-status-ok    { color: #4caf50; }
.review-status-error { color: #ef5350; }

/* Source Refs */
.review-source-list {
    padding: 6px;
    overflow-y: auto;
    flex: 1;
}

.review-source-row {
    margin-bottom: 4px;
}

.review-source-summary {
    font-size: 0.78rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px;
    border-radius: 3px;
}

.review-source-summary:hover {
    background: var(--bg-hover, rgba(255,255,255,0.05));
}

.review-source-lane {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 600;
    min-width: 55px;
}

.review-source-json {
    font-size: 0.7rem;
    padding: 6px;
    margin: 4px 0 0 0;
    background: var(--bg-secondary);
    border-radius: 3px;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Image broken fallback */
.review-img-wrap {
    position: relative;
    width: 80px;
    height: 60px;
}

.review-img-broken {
    width: 80px;
    height: 60px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 3px;
    font-size: 0.6rem;
    color: var(--text-secondary);
    align-items: center;
    justify-content: center;
    text-align: center;
    word-break: break-all;
    padding: 3px;
    overflow: hidden;
}

/* Field groups */
.review-field-group {
    margin-bottom: 10px;
}

.review-field-group-header {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    padding: 3px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.review-field-bool {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    cursor: pointer;
}

.review-field-textarea-json {
    font-family: var(--font-mono, monospace);
    font-size: 0.72rem;
}

/* Source refs key summary */
.ref-key-summary {
    padding: 4px 6px;
    background: var(--bg-secondary);
    border-radius: 3px;
    margin: 4px 0;
}

.ref-key-row {
    display: flex;
    gap: 6px;
    font-size: 0.72rem;
    padding: 1px 0;
    align-items: baseline;
}

.ref-key-name {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 80px;
    flex-shrink: 0;
}

.ref-key-val {
    color: var(--text-primary);
    word-break: break-word;
}

.ref-json-details {
    margin-top: 4px;
}

.ref-json-toggle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 4px;
}

.ref-json-toggle:hover {
    color: var(--text-primary);
}

/* 07_scrape extracted images panel */
.scrape-images-section {
    padding: 0 8px 12px;
}

.scrape-img-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.scrape-img-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 120px;
}

.scrape-img-meta {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

/* 081_image tables */
.image-candidate-table { table-layout: fixed; width: 100%; }
.image-candidate-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-candidate-table td:nth-child(1) { width: 28px; }
.image-candidate-table td:nth-child(3) { width: 160px; }

.image-output-table { table-layout: fixed; width: 100%; }
.image-output-table td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-output-table .img-detail-row td { white-space: normal; overflow: visible; }
.img-preview-container { padding: 10px 14px; }
.img-preview-thumb { max-height: 200px; border-radius: 6px; cursor: pointer; border: 1px solid var(--border); }
.img-preview-thumb:hover { transform: scale(1.02); }

/* 09_human read-only input view */
.review-ro-val {
    font-size: 0.82rem;
    color: var(--text-primary);
}

.review-ro-pre {
    font-size: 0.72rem;
    font-family: var(--font-mono, monospace);
    background: var(--bg-secondary);
    padding: 4px 6px;
    border-radius: 3px;
    margin: 2px 0 0 0;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 120px;
    overflow-y: auto;
}


/* =============================================================================
   Batch Page
   ============================================================================= */

.batch-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    gap: 0;
}

.batch-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.batch-header h2 {
    margin: 0;
    font-size: 1rem;
}

.batch-main {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 0;
}

.batch-stack-panel {
    width: 280px;
    flex-shrink: 0;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    padding: 8px;
}

.batch-detail-panel {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

/* Batch list in left panel */
.batch-list-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.82rem;
    margin-bottom: 2px;
}

.batch-list-item:hover {
    background: var(--bg-hover, rgba(255,255,255,0.05));
}

.batch-status-icon { font-size: 1rem; }
.batch-id { font-family: monospace; font-size: 0.78rem; flex: 1; }
.batch-event-count { color: var(--text-secondary); font-size: 0.75rem; }
.batch-date { font-size: 0.72rem; }

/* Batch detail */
.batch-detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.batch-status-badge {
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 600;
}

.batch-status-running { background: #1565c0; color: #fff; }
.batch-status-done    { background: #2e7d32; color: #fff; }
.batch-status-stopped { background: #424242; color: #ccc; }

.batch-run-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.batch-run-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.batch-run-card:hover {
    border-color: var(--accent, #4a9eff);
}

.batch-run-active  { border-color: #1976d2; }
.batch-run-paused  { border-color: #f57c00; }
.batch-run-done    { border-color: #388e3c; }
.batch-run-pending { opacity: 0.6; }

.batch-run-icon {
    font-size: 1.2rem;
    min-width: 24px;
    text-align: center;
}

.batch-run-info { flex: 1; }
.batch-run-name { font-size: 0.85rem; font-weight: 500; }
.batch-run-status { font-size: 0.75rem; }

/* New Batch Dialog */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-box {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 700px;
    max-width: 95vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 { margin: 0; font-size: 0.95rem; }

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-secondary);
    padding: 2px 6px;
}

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

.modal-option-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    margin-bottom: 12px;
}

.modal-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.modal-footer .text-muted { margin-right: auto; }

/* Pending events table in dialog */
.pending-events-table {
    overflow: auto;
    max-height: 400px;
}

.pending-events-table-el {
    width: 100%;
    font-size: 0.8rem;
}

/* Status badges for event status */
.status-badge {
    padding: 1px 6px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
}

.status-new      { background: #424242; color: #ccc; }
.status-done     { background: #2e7d32; color: #fff; }
.status-awaiting_review { background: #e65100; color: #fff; }
.status-scraped  { background: #1565c0; color: #fff; }
.status-qualified { background: #6a1b9a; color: #fff; }
.status-searched { background: #00695c; color: #fff; }

/* =============================================================================
   DB Checkboxes + Action Menu
   ============================================================================= */

.db-check-th,
.db-check-cell {
    width: 32px;
    min-width: 32px;
    text-align: center;
    padding: 0 4px;
}

.db-row-disabled {
    opacity: 0.45;
}

.badge-disabled {
    background: #6b7280;
    color: #e8e8e8;
    margin-left: 4px;
}

/* Not-done quick filter chip */
.db-filter-chip {
    padding: 3px 10px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}
.db-filter-chip:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}
.db-filter-chip.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.db-geo-not-btn {
    margin-left: 4px;
    font-size: 0.75rem;
    padding: 3px 7px;
}

/* Action buttons in filter bar — right-aligned */
.db-action-menu-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.db-sel-count {
    font-size: 0.82rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* =============================================================================
   Editor Page
   ============================================================================= */

.editor-id-input {
    padding: 24px;
    max-width: 560px;
}

.editor-id-input h2 { margin-bottom: 12px; }
.editor-id-input .text-muted { margin-bottom: 8px; }

.loader-row {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.editor-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.editor-table-select {
    padding: 6px 10px;
    background: var(--bg-code);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
}

.editor-ids-field {
    flex: 1;
    padding: 6px 10px;
    background: var(--bg-code);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: monospace;
}

.editor-ids-textarea {
    width: 100%;
    font-family: monospace;
    font-size: 0.85rem;
    background: var(--bg-code);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px;
    resize: vertical;
    margin-bottom: 10px;
}

.editor-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 80px);
    overflow: hidden;
}

.editor-list {
    width: 220px;
    min-width: 180px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-list-header {
    padding: 6px 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.editor-nav-btns {
    display: flex;
    gap: 4px;
}

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

.editor-list-item {
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    transition: background 0.1s;
}

.editor-list-item:hover { background: var(--bg-card); }
.editor-list-item.selected { background: var(--bg-card); border-left: 3px solid var(--accent); }
.editor-list-item.dirty { color: var(--warning); }

.editor-list-id {
    color: var(--text-secondary);
    font-size: 0.75rem;
    flex-shrink: 0;
}

.editor-list-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.editor-dirty-dot {
    color: var(--warning);
    font-size: 0.65rem;
    flex-shrink: 0;
}

.editor-form-panel {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.editor-form {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.editor-form-fields {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
}

.editor-field-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 5px 0;
    border-bottom: 1px solid var(--border);
}

.editor-field-row.editor-field-dirty {
    background: rgba(251, 191, 36, 0.06);
}

.editor-field-label {
    width: 160px;
    min-width: 120px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding-top: 6px;
    word-break: break-all;
    cursor: default;
}

.editor-field-control {
    flex: 1;
}

.editor-field-input,
.editor-field-select {
    width: 100%;
    background: var(--bg-code);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.82rem;
    font-family: inherit;
}

.editor-field-textarea {
    width: 100%;
    background: var(--bg-code);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 4px 6px;
    font-size: 0.78rem;
    font-family: monospace;
    resize: vertical;
}

.editor-field-readonly {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: 4px 0;
    display: inline-block;
}

.editor-form-footer {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
    gap: 0;
}

.editor-footer-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.editor-footer-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.editor-footer-right {
    display: flex;
    align-items: center;
}

.editor-nav-btn {
    padding: 4px 10px !important;
    font-size: 13px !important;
}

.editor-nav-pos {
    font-size: 0.82rem;
    color: var(--text-secondary);
    min-width: 36px;
    text-align: center;
}

/* =============================================================================
   Ingest Stack (01_select input panel)
   ============================================================================= */

.intake-stack-header {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.intake-stack-source {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
    flex-wrap: wrap;
}

.source-radio-label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: color 0.15s;
}
.source-radio-label:hover { color: var(--text-primary); }
.source-radio-label input[type="radio"],
.source-radio-label input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); }
.source-radio-label.skip-warn { color: #e8b830; background: rgba(232,184,48,0.15); padding: 1px 6px; border-radius: 3px; }
.source-radio-label.skip-warn:hover { color: #f0c848; background: rgba(240,200,72,0.2); }

.intake-stack-source .source-run-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-left: auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.intake-db-picker {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 12px;
    flex-wrap: wrap;
}

.intake-db-picker input,
.intake-db-picker select {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    padding: 2px 6px;
}

.intake-db-picker input[type="number"] { width: 56px; }
.intake-db-picker input[type="text"]   { width: 140px; }

.intake-stack-filters {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.intake-stack-filters .btn-small {
    font-size: 11px;
    padding: 2px 8px;
}

/* Ingest stack table (replaces old flex list) */
.intake-stack-table tbody tr.row-processed { opacity: 0.5; }
.intake-stack-table tbody tr.row-failed { opacity: 0.6; }
.intake-stack-table td.cb-col,
.intake-stack-table th.cb-col { width: 24px; padding: 3px 2px; }
.intake-stack-table td.stack-id-col { color: var(--text-secondary); font-size: 11px; white-space: nowrap; width: 40px; }
.intake-detail-tr.hidden { display: none; }
.intake-detail-td { padding: 0 !important; border: none !important; }

.disposition-badge {
    font-size: 10px;
    padding: 1px 4px;
    border-radius: 3px;
    flex-shrink: 0;
}

.disposition-new {
    background: var(--green-dim, rgba(34,197,94,0.15));
    color: var(--green, #22c55e);
}

.disposition-update {
    background: var(--amber-dim, rgba(245,158,11,0.15));
    color: var(--amber, #f59e0b);
}

.stack-processed-icon {
    font-size: 11px;
    color: var(--green, #22c55e);
    flex-shrink: 0;
}

.stack-failed-icon {
    font-size: 11px;
    color: var(--error, #ef4444);
    flex-shrink: 0;
}

.intake-stack-item.failed {
    opacity: 0.6;
}

/* Stack status output panel */
.stack-status-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.stack-status-item .stack-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stack-status-item .stack-city {
    color: var(--text-secondary);
    font-size: 11px;
    min-width: 60px;
    text-align: right;
}

.stack-status-item .stack-date {
    color: var(--text-secondary);
    font-size: 11px;
    min-width: 72px;
    text-align: right;
}

.stack-status-dot,
.stack-status-dot-empty {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.stack-status-dot-empty { background: transparent; }
.stack-status-dot.status-processed   { background: var(--green, #22c55e); }
.stack-status-dot.status-failed      { background: var(--error, #ef4444); }
.stack-status-dot.status-in-progress { background: var(--warning, #fbbf24); animation: stack-pulse 1s infinite; }
.stack-status-dot.status-selected    { background: var(--text-secondary, #a0a0a0); }

@keyframes stack-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.stack-status-label {
    font-size: 10px;
    padding: 1px 5px;
    border-radius: 3px;
    flex-shrink: 0;
}

.stack-status-label.status-processed   { background: rgba(34,197,94,0.15);  color: var(--green, #22c55e); }
.stack-status-label.status-failed      { background: rgba(239,68,68,0.15);  color: var(--error, #ef4444); }
.stack-status-label.status-in-progress { background: rgba(251,191,36,0.15); color: var(--warning, #fbbf24); }
.stack-status-label.status-selected    { background: var(--bg-hover, rgba(255,255,255,0.05)); color: var(--text-secondary); }

.stack-spinner {
    font-size: 12px;
    flex-shrink: 0;
    display: inline-block;
    animation: stack-spin 1s linear infinite;
}

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

/* ID badge in stack items */
.stack-id {
    font-size: 10px;
    font-family: monospace;
    color: var(--text-secondary);
    flex-shrink: 0;
    min-width: 32px;
}

/* Inline event detail row */
.intake-detail-row {
    padding: 6px 8px 8px 24px;
    background: var(--bg-secondary);
    border-radius: 4px;
    margin: 2px 0 4px;
}

.intake-detail-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 3px 12px;
    font-size: 12px;
}

.intake-detail-grid .detail-key {
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
}

.intake-detail-grid .detail-val {
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
}

.intake-detail-grid .detail-val-link {
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

/* DB mode sub-mode buttons (Last / First / IDs) */
.db-mode-btn {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
}

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

.db-mode-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(233, 69, 96, 0.08);
}

/* DB controls container */
.intake-db-controls {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin-bottom: 8px;
}
.intake-db-mode-row { display: flex; align-items: center; }
.intake-db-input-row input[type="number"],
.intake-db-input-row input[type="text"] {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 12px;
    padding: 2px 8px;
}
.intake-db-input-row input[type="number"] { width: 76px; }
.intake-db-input-row input[type="text"]   { width: 140px; }

/* Horizontal text-style selector buttons (source + mode for 01_select) */
.sel-src-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    margin-right: 10px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text-secondary);
    border-radius: 4px;
    transition: color 0.15s;
}
.sel-src-btn:hover { color: var(--text-primary); }
.sel-src-btn.active { color: var(--text-primary); font-weight: 600; }

/* =============================================================================
   09_result Panel
   ============================================================================= */

.result-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.result-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.result-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 4px;
    border: 1px solid var(--border);
    font-size: 13px;
}

.result-item:hover {
    background: var(--bg-hover);
}

.result-item input[type="checkbox"] {
    margin-top: 2px;
    cursor: pointer;
    flex-shrink: 0;
}

.result-item-body {
    flex: 1;
    min-width: 0;
}

.result-item-title {
    cursor: pointer;
    font-weight: 500;
}

.result-item-title:hover {
    text-decoration: underline;
}

.result-item-meta {
    color: var(--text-secondary);
    font-size: 11px;
    margin-top: 2px;
}

.result-detail {
    margin-top: 8px;
    padding: 8px;
    background: var(--bg-code);
    border-radius: 4px;
    font-size: 12px;
    max-height: 300px;
    overflow-y: auto;
}

.result-detail table {
    border-collapse: collapse;
    width: 100%;
}

.result-detail td {
    padding: 2px 6px;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
    word-break: break-word;
}

.result-detail td:first-child {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    width: 140px;
}

/* kv-table: shared by both input + output detail expansions */
.kv-table { border-collapse: collapse; width: 100%; }
.kv-key {
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
    width: 160px;
    padding: 2px 8px 2px 4px;
    vertical-align: top;
    border-bottom: 1px solid var(--border);
}
.kv-val {
    padding: 2px 4px;
    vertical-align: top;
    word-break: break-word;
    white-space: pre-wrap;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
}

/* 09_result input expandable detail rows */
.result-input-detail-row { background: var(--bg-code); }
.result-input-detail-row.hidden { display: none; }
/* Suppress data-table tr:hover for detail rows and nested kv-table rows */
.data-table tr.result-input-detail-row,
.data-table tr.result-input-detail-row:hover { background: var(--bg-code); }
.data-table .kv-table tr,
.data-table .kv-table tr:hover { background: transparent; }
.result-input-detail-cell { padding: 0 !important; border: none !important; }
.result-input-detail-inner {
    display: flex;
    flex-direction: row;
    gap: 12px;
    padding: 10px 12px;
    overflow-x: auto;
}
.result-detail-section {
    flex: 1;
    min-width: 180px;
    max-width: 400px;
}
.result-detail-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid var(--border);
}

/* Result status badges */
.badge-result-done {
    display: inline-block;
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    padding: 1px 5px; border-radius: 3px;
    background: var(--color-done, #22c55e); color: #fff;
    opacity: 0.9; margin-left: 4px; vertical-align: middle;
}
.badge-result-failed {
    display: inline-block;
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    padding: 1px 5px; border-radius: 3px;
    background: var(--color-error, #ef4444); color: #fff;
    opacity: 0.9; margin-left: 4px; vertical-align: middle;
}


/* ── Inspect mode ─────────────────────────────────────────────────────────── */

/* Inspect button on 09_result input rows */
.inspect-btn {
    font-size: 10px; padding: 2px 7px; border-radius: 3px;
    border: 1px solid var(--border); background: transparent;
    color: var(--text-secondary); cursor: pointer;
}
.inspect-btn:hover { border-color: #f5c400; color: #f5c400; }
.inspect-btn.active { background: #f5c400; color: #000; border-color: #f5c400; font-weight: 600; }
.inspect-col { width: 60px; }

/* Sidebar frame overlay (positioned by JS) */
#inspect-frame {
    border: 3px solid transparent;
    border-image: repeating-linear-gradient(
        45deg, #f5c400 0px, #f5c400 7px, #111 7px, #111 14px
    ) 3;
    border-radius: 0;
    box-sizing: border-box;
}

/* Sidebar step items in inspect range — subtle yellow tint */
.step-item.inspect-range {
    background: rgba(245, 196, 0, 0.04);
}

/* =========================================================================
   Imager Page
   ========================================================================= */

.imager-layout {
    display: flex;
    gap: 0;
    height: calc(100vh - 60px);
}

.imager-detail-panel {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.imager-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.imager-nav-pos {
    font-size: 0.82rem;
    color: var(--text-secondary);
    min-width: 50px;
    text-align: center;
}

.imager-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Info table */
.imager-info {
    background: var(--bg-card);
    border-radius: 6px;
    padding: 12px 16px;
    border: 1px solid var(--border);
}

.imager-info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.imager-info-table td {
    padding: 4px 8px 4px 0;
    vertical-align: top;
}

.imager-info-table td:first-child {
    color: var(--text-secondary);
    white-space: nowrap;
    width: 100px;
    font-weight: 500;
}

.imager-info-table td:nth-child(2) {
    word-break: break-word;
}

.imager-info-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 8px;
}

/* Main image section */
.imager-main-section {
    background: var(--bg-card);
    border-radius: 6px;
    padding: 16px;
    border: 1px solid var(--border);
}

.imager-main-section h3 {
    margin: 0 0 12px 0;
    font-size: 0.92rem;
    font-weight: 600;
}

.imager-main-preview {
    position: relative;
    width: 100%;
    max-width: 400px;
    aspect-ratio: 4/3;
    background: var(--bg-main);
    border: 2px dashed var(--border);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 12px;
    transition: border-color 0.2s;
}

.imager-main-preview.drag-over {
    border-color: var(--accent);
    background: rgba(59, 130, 246, 0.05);
}

.imager-main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.imager-placeholder-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
    opacity: 0.6;
}

.imager-no-image {
    color: var(--text-secondary);
    font-size: 1rem;
    text-align: center;
}

.imager-drop-hint {
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.imager-main-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.imager-main-actions button {
    font-size: 0.8rem;
    padding: 5px 12px;
}

.imager-task-status {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 0.82rem;
    display: none;
}

.imager-task-status.visible {
    display: block;
}

.imager-task-status.processing {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.imager-task-status.succeed {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.imager-task-status.failed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Gallery section */
.imager-gallery {
    background: var(--bg-card);
    border-radius: 6px;
    padding: 16px;
    border: 1px solid var(--border);
}

.imager-gallery h3 {
    margin: 0 0 12px 0;
    font-size: 0.92rem;
    font-weight: 600;
}

.imager-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.imager-thumb {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.2s, transform 0.15s;
}

.imager-thumb:hover {
    border-color: var(--accent);
    transform: scale(1.03);
}

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

.imager-thumb-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 0.68rem;
    padding: 2px 4px;
    text-align: center;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

/* Cropper modal */
.imager-crop-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.imager-crop-modal {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 16px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.imager-crop-modal h3 {
    margin: 0;
    font-size: 0.95rem;
}

.imager-crop-container {
    width: 100%;
    max-height: 60vh;
    overflow: hidden;
}

.imager-crop-container img {
    max-width: 100%;
    display: block;
}

.imager-crop-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Prompt input */
.imager-prompt-row {
    display: flex;
    gap: 6px;
    align-items: stretch;
    margin-top: 8px;
}

.imager-prompt-input {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-main);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-family: inherit;
    resize: none;
    min-height: 32px;
}

/* DB page advanced filter inputs */
.db-filter-input {
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 14px;
    width: 140px;
}
.db-filter-input:focus { outline: none; border-color: var(--accent); }

.db-filter-date {
    padding: 8px 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 13px;
    width: 130px;
}
.db-filter-date:focus { outline: none; border-color: var(--accent); }

/* Address Book */
.intake-urls-area { display: flex; flex-direction: column; gap: 6px; }
.intake-source-modes { display: flex; gap: 12px; margin-bottom: 8px; }
.ab-entry-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.ab-entry-row { display: flex; align-items: center; gap: 8px; padding: 5px 8px; cursor: pointer; font-size: 13px; border-radius: 4px; }
.ab-entry-row:hover { background: var(--bg-hover, #2a2a2a); }
.ab-entry-row input[type="radio"] { flex-shrink: 0; }
.ab-entry-name { font-weight: 500; min-width: 140px; }
.ab-entry-badge { font-size: 11px; padding: 1px 6px; border-radius: 3px; background: var(--bg-secondary, #2a2a2a); border: 1px solid var(--border, #444); color: var(--text-secondary); }
.ab-scan-badge { background: #1a3a2a; border-color: #2a5a3a; color: #8fc; }
.manual-method-row { display: flex; gap: 16px; margin-top: 6px; font-size: 13px; }
.manual-method-row select { padding: 2px 6px; background: var(--bg-secondary, #2a2a2a); border: 1px solid var(--border, #444); border-radius: 4px; color: var(--text-primary); font-size: 12px; }

/* Pagination controls */
.pg-controls { display: flex; align-items: center; gap: 10px; padding: 6px 8px; margin-top: 6px; background: var(--bg-secondary, #1a1a2e); border: 1px solid var(--border, #444); border-radius: 6px; font-size: 13px; }
.pg-enable-label { display: flex; align-items: center; gap: 4px; font-weight: 500; }
.pg-field-label { color: var(--text-secondary); font-size: 12px; }
.pg-controls input[type="number"], .pg-controls input[type="date"] { padding: 2px 6px; background: var(--bg-primary, #1e1e1e); border: 1px solid var(--border, #444); border-radius: 4px; color: var(--text-primary); font-size: 12px; }

/* Pagination progress */
#pagination-progress { margin: 8px 0; padding: 8px; background: var(--bg-secondary, #1a1a2e); border: 1px solid var(--border, #444); border-radius: 6px; }
.pg-bar { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.pg-status { font-weight: 600; min-width: 80px; }
.pg-progress-track { flex: 1; height: 6px; background: var(--bg-primary, #1e1e1e); border-radius: 3px; overflow: hidden; }
.pg-progress-fill { height: 100%; background: var(--accent, #4fc3f7); border-radius: 3px; transition: width 0.3s; }
.pg-total { color: var(--text-secondary); font-size: 12px; white-space: nowrap; }
.pg-page-list { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.pg-page-chip { font-size: 11px; padding: 2px 6px; border-radius: 3px; background: #1a3a2a; border: 1px solid #2a5a3a; color: #8fc; }
.pg-page-chip.pg-empty { background: #3a3a1a; border-color: #5a5a2a; color: #ee8; }
.pg-page-chip.pg-failed { background: #3a1a1a; border-color: #5a2a2a; color: #f88; font-weight: 600; }
.pg-failed-urls { margin-top: 6px; font-size: 12px; }
.pg-failed-label { color: #f88; font-weight: 600; margin-right: 6px; }
.pg-failed-url { display: block; color: #f88; word-break: break-all; padding: 2px 0; text-decoration: underline; }

/* =============================================================================
   Analytics Page
   ============================================================================= */
.analytics-layout { display: flex; flex-direction: column; gap: 24px; padding: 16px 0; }
.analytics-section { background: var(--bg-secondary); border: 1px solid var(--border); border-radius: 8px; padding: 20px; }
.analytics-section h3 { margin: 0 0 16px 0; font-size: 16px; color: var(--text-primary); }
.analytics-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.analytics-toggle-group { display: flex; gap: 0; }
.analytics-toggle-btn { padding: 5px 14px; font-size: 12px; border: 1px solid var(--border); background: var(--bg-primary); color: var(--text-secondary); cursor: pointer; transition: all 0.15s; }
.analytics-toggle-btn:first-child { border-radius: 4px 0 0 4px; }
.analytics-toggle-btn:last-child { border-radius: 0 4px 4px 0; }
.analytics-toggle-btn:not(:first-child) { border-left: none; }
.analytics-toggle-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.analytics-toggle-btn:hover:not(.active) { background: var(--bg-card); }
.analytics-days-select { padding: 5px 8px; font-size: 12px; background: var(--bg-primary); color: var(--text-primary); border: 1px solid var(--border); border-radius: 4px; }
#analytics-date canvas { max-height: 220px; }
.analytics-geo-row { display: flex; gap: 20px; min-height: 350px; }
#analytics-map { height: 350px; border-radius: 6px; border: 1px solid var(--border); }
/* Geo cluster icons */
.geo-cluster-wrapper { background: none !important; border: none !important; }
.geo-cluster-icon { background: rgba(233,69,96,0.85); border: 2px solid rgba(233,69,96,0.4); border-radius: 50%; color: #fff; font-size: 12px; font-weight: 700; text-align: center; box-shadow: 0 0 6px rgba(0,0,0,0.5); }

/* Completeness bars (reused for geo state bars) */
.completeness-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.completeness-label { font-size: 12px; color: var(--text-secondary); min-width: 90px; text-align: right; }
.completeness-track { flex: 1; height: 16px; background: var(--bg-primary); border-radius: 3px; overflow: hidden; }
.completeness-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }
.completeness-pct { font-size: 12px; color: var(--text-primary); min-width: 40px; text-align: right; font-weight: 600; }
.completeness-count { font-size: 11px; min-width: 60px; }
