/* =============================================================================
   AMIP Exception Dashboard Styles
   ============================================================================= */

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-secondary: #64748b;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    --color-danger: #ef4444;
    --color-background: #f8fafc;
    --color-surface: #ffffff;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-border: #e2e8f0;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: ui-monospace, 'SF Mono', Monaco, monospace;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: var(--font-sans);
    background: var(--color-background);
    color: var(--color-text);
    line-height: 1.5;
}

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

.app-header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-content h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.stats-bar {
    display: flex;
    gap: 1.5rem;
}

.stat {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.app-main {
    flex: 1;
    padding: 2rem;
    width: 100%;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

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

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-back {
    background: transparent;
    color: var(--color-secondary);
    padding: 0.25rem 0.5rem;
}

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

/* Error Banner */
.error-banner {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--color-danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.error-banner button {
    background: transparent;
    border: none;
    color: var(--color-danger);
    cursor: pointer;
    font-weight: 500;
}

/* Loading */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 4rem;
    color: var(--color-text-muted);
}

/* Exception List */
.exception-list-container {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.toolbar h2 {
    font-size: 1.125rem;
    font-weight: 600;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.count {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

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

.exception-table th,
.exception-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.exception-table th {
    font-weight: 500;
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.exception-row {
    cursor: pointer;
    transition: background 0.15s ease;
}

.exception-row:hover {
    background: var(--color-background);
}

.doc-id .filename {
    font-weight: 500;
}

.doc-id .id-text {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-invoice { background: #dbeafe; color: #1e40af; }
.badge-bol { background: #dcfce7; color: #166534; }
.badge-pod { background: #fef3c7; color: #92400e; }
.badge-rate_confirmation { background: #f3e8ff; color: #6b21a8; }
.badge-packing_list { background: #fce7f3; color: #9d174d; }
.badge-other { background: #f1f5f9; color: #475569; }

.confidence-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: 4px;
}

.confidence-high { background: #dcfce7; color: #166534; }
.confidence-medium { background: #fef3c7; color: #92400e; }
.confidence-low { background: #fef2f2; color: #991b1b; }

/* Issues List */
.issues-list {
    list-style: none;
    font-size: 0.8125rem;
}

.issues-list li {
    color: var(--color-danger);
    padding: 0.125rem 0;
}

.no-issues {
    color: var(--color-success);
    font-size: 0.8125rem;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    font-size: 3rem;
    color: var(--color-success);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--color-text-muted);
}

/* Document Detail */
.document-detail-container {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-left h2 {
    font-size: 1.125rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

.status-exception { background: #f3f4f6; color: #374151; }
.status-corrected { background: #dcfce7; color: #166534; }
.status-extracted { background: #dbeafe; color: #1e40af; }

.doc-type-badge {
    padding: 0.25rem 0.5rem;
    background: var(--color-background);
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.detail-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
}

@media (max-width: 1024px) {
    .detail-content {
        grid-template-columns: 1fr;
    }
}

.document-viewer {
    padding: 1.5rem;
    border-right: 1px solid var(--color-border);
}

.document-viewer h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.pages-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.page-preview {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.page-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Bounding Box Overlay */
.current-page-container {
    position: relative;
}

.bbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.bbox-rect {
    cursor: pointer;
    pointer-events: auto;
    transition: opacity 0.2s ease;
}

.bbox-rect:hover {
    opacity: 0.8 !important;
    stroke-width: 0.003 !important;
}

.page-number {
    padding: 0.5rem;
    text-align: center;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    background: var(--color-background);
}

.no-pages {
    padding: 2rem;
    text-align: center;
    color: var(--color-text-muted);
    background: var(--color-background);
    border-radius: var(--radius);
}

.ocr-text-section {
    margin-top: 1rem;
}

.ocr-text-section summary {
    cursor: pointer;
    font-weight: 500;
    padding: 0.5rem 0;
}

.ocr-text {
    background: var(--color-background);
    padding: 1rem;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    max-height: 300px;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* Extraction Form */
.extraction-form {
    padding: 1.5rem;
}

.extraction-form h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.extraction-meta {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.validation-results {
    background: var(--color-background);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.validation-results h4 {
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.rule-results {
    list-style: none;
}

.rule-result {
    padding: 0.375rem 0;
    font-size: 0.8125rem;
    display: flex;
    gap: 0.5rem;
}

.rule-pass { color: var(--color-success); }
.rule-warn { color: var(--color-warning); }
.rule-fail { color: var(--color-danger); }

.rule-name {
    font-weight: 500;
}

.rule-message {
    color: var(--color-text-muted);
}

/* Data Editor */
.data-editor {
    margin-bottom: 1.5rem;
}

.data-editor h4 {
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.field-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.field-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.field-input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    width: 100%;
}

.field-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.nested-fields {
    padding-left: 1rem;
    border-left: 2px solid var(--color-border);
}

.field-json {
    background: var(--color-background);
    padding: 0.5rem;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    overflow-x: auto;
}

.no-extraction {
    padding: 2rem;
    text-align: center;
    color: var(--color-text-muted);
    background: var(--color-background);
    border-radius: var(--radius);
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.form-actions .btn {
    flex: 1;
}

/* Not Found */
.not-found {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--color-text-muted);
}

/* Header Navigation */
.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.header-left h1 a {
    color: inherit;
    text-decoration: none;
}

.header-left h1 a:hover {
    color: var(--color-primary);
}

.header-nav {
    display: flex;
    gap: 1rem;
}

.nav-link {
    color: var(--color-text-muted);
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-weight: 500;
    transition: all 0.15s ease;
}

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

.nav-link.active {
    color: var(--color-primary);
    background: rgba(37, 99, 235, 0.1);
}

/* Upload Page */
.upload-container {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
}

.upload-header {
    margin-bottom: 2rem;
}

.upload-header h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.upload-subtitle {
    color: var(--color-text-muted);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.2s ease;
    background: var(--color-background);
}

.drop-zone:hover {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.02);
}

.drop-zone-active {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
    transform: scale(1.01);
}

.drop-zone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.drop-icon {
    font-size: 3rem;
    opacity: 0.6;
}

.drop-text {
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--color-text);
}

.drop-or {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.file-select-btn {
    cursor: pointer;
}

/* Selected Files */
.selected-files {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.selected-files h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.file-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--color-background);
    border-radius: var(--radius);
}

.file-icon {
    font-size: 1.25rem;
}

.file-name {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-size {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* Upload Actions */
.upload-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    justify-content: flex-end;
}

/* Recent Uploads */
.recent-uploads {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--color-border);
}

.recent-uploads h3 {
    font-size: 1rem;
    margin-bottom: 1rem;
}

.upload-results {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.upload-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
}

.result-success {
    background: #dcfce7;
}

.result-warning {
    background: #fef3c7;
}

.result-error {
    background: #fef2f2;
}

.result-icon {
    font-size: 1rem;
    font-weight: bold;
}

.result-success .result-icon {
    color: var(--color-success);
}

.result-warning .result-icon {
    color: var(--color-warning);
}

.result-error .result-icon {
    color: var(--color-danger);
}

.result-filename {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.result-status {
    color: var(--color-text-muted);
    font-size: 0.875rem;
    text-transform: uppercase;
}

.result-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

.result-link:hover {
    text-decoration: underline;
}

.result-error-msg {
    color: var(--color-danger);
    font-size: 0.875rem;
}

/* Architecture Page */
.app-main:has(.architecture-fullscreen) {
    padding: 0;
}

.architecture-fullscreen {
    width: 100%;
    height: calc(100vh - 60px);
    overflow: hidden;
}

.architecture-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Documents Page */
.documents-container {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.documents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.documents-header h2 {
    font-size: 1.5rem;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Upload Section - Compact */
.upload-section {
    background: var(--color-background);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
}

.drop-zone-compact {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    flex: 1;
    min-width: 250px;
}

.drop-zone-compact:hover {
    border-color: var(--color-primary);
}

.drop-zone-compact.drop-zone-active {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.05);
}

.drop-zone-content-compact {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.drop-icon-small {
    font-size: 1.25rem;
}

.drop-text-small {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.selected-files-compact {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.file-count {
    font-weight: 500;
    color: var(--color-text);
}

.file-list-inline {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
}

.file-item-compact {
    background: var(--color-surface);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.875rem;
}

.upload-actions-compact {
    display: flex;
    gap: 0.5rem;
}

.recent-uploads-compact {
    font-size: 0.875rem;
    padding: 0.75rem 1rem;
    margin-top: 1rem;
    background: #f0fdf4;
    border-left: 3px solid var(--color-success);
    border-radius: 4px;
}

.recent-label {
    font-weight: 600;
    color: var(--color-success);
}

.upload-result-link {
    color: var(--color-success);
    text-decoration: none;
    font-weight: 500;
}

.upload-result-link:hover {
    text-decoration: underline;
}

.upload-result-inline {
    color: var(--color-text-muted);
}

/* Documents Table */
.documents-table-container {
    overflow-x: auto;
}

.documents-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.documents-table th,
.documents-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.documents-table th {
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-background);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.documents-table tbody tr:hover {
    background: var(--color-background);
}

.filename-cell a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 500;
}

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

/* Status Badges */
.status-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
}

/* Processing states with pulse animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.status-received {
    background: #dbeafe;
    color: #1e40af;
    animation: pulse 2s ease-in-out infinite;
}
.status-received::after {
    content: " \u23F3";  /* Hourglass emoji */
}

.status-normalized {
    background: #e0e7ff;
    color: #3730a3;
    animation: pulse 2s ease-in-out infinite;
}
.status-normalized::after {
    content: " \u23F3";
}

.status-ocr_done { background: #fef3c7; color: #92400e; }
.status-classified { background: #fce7f3; color: #9d174d; }
.status-extracted { background: #d1fae5; color: #065f46; }
.status-validated { background: #cffafe; color: #0e7490; }
.status-approved { background: #d1fae5; color: #065f46; }
.status-auto_approved {
    background: #bbf7d0;
    color: #166534;
}
.status-auto_approved::after {
    content: " \u2713";  /* Checkmark */
}
.status-exception { background: #f3f4f6; color: #374151; }
.status-cloud_escalation { background: #fef9c3; color: #854d0e; }
.status-corrected { background: #e0e7ff; color: #4338ca; }
.status-failed {
    background: #fecaca;
    color: #b91c1c;
}
.status-failed::after {
    content: " \u2717";  /* X mark */
}

/* Doc Type Badge */
.doc-type-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    background: var(--color-background);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.doc-type-unknown {
    color: var(--color-text-muted);
}

/* Extraction Badge */
.extraction-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Actions Cell */
.actions-cell {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Action Menu (Dropdown) */
.action-menu {
    position: relative;
    display: inline-block;
}

.action-menu-trigger {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #6b7280;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    border-radius: 4px;
    font-size: 1rem;
    line-height: 1;
}

.action-menu-trigger:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.action-menu-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 0.25rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    min-width: 150px;
    z-index: 1000;
}

.action-menu:hover .action-menu-dropdown,
.action-menu:focus-within .action-menu-dropdown {
    display: block;
}

.action-menu-item {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    text-align: left;
    background: none;
    border: none;
    color: #374151;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.action-menu-item:hover {
    background: #f9fafb;
}

.action-menu-item:first-child {
    border-radius: 6px 6px 0 0;
}

.action-menu-item:last-child {
    border-radius: 0 0 6px 6px;
}

.action-menu-item-danger {
    color: #dc2626;
}

.action-menu-item-danger:hover {
    background: #fef2f2;
}

/* Small Buttons */
.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.btn-link {
    background: transparent;
    color: var(--color-primary);
    border: none;
}

.btn-link:hover {
    background: var(--color-background);
}

.btn-danger {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.btn-danger:hover {
    background: #fecaca;
}

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

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

/* Reprocess Section */
.reprocess-section {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.reprocess-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.reprocess-buttons {
    display: flex;
    gap: 0.5rem;
}

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

.cancel-section {
    margin-right: 1rem;
    padding-right: 1rem;
    border-right: 1px solid var(--color-border);
}

/* Actions Dropdown (Issue 4) */
.form-actions-container {
    display: flex;
    justify-content: flex-end;
    padding: 1rem;
    border-top: 1px solid var(--color-border);
}

.actions-dropdown-wrapper {
    position: relative;
}

.actions-dropdown-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 120px;
}

.dropdown-arrow {
    font-size: 0.75rem;
    transition: transform 0.2s ease;
}

.actions-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 240px;
    z-index: 1000;
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    text-align: left;
    border: none;
    background: none;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dropdown-item:hover {
    background-color: #f3f4f6;
}

.dropdown-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.25rem 0;
}

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

/* Loading Overlay */
.loading-overlay {
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
}

/* Date Cell */
.date-cell {
    color: var(--color-text-muted);
    font-size: 0.8125rem;
}

/* =============================================================================
   Document Segments
   ============================================================================= */

.segment-count-badge {
    background: #8b5cf6;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
    font-weight: 500;
}

.segments-panel {
    width: 100%;
}

.segments-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.segment-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.segment-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--color-border);
}

.segment-number {
    font-weight: 600;
    color: var(--color-text);
}

.segment-pages {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.segment-confidence {
    color: var(--color-text-muted);
    font-size: 0.75rem;
    margin-left: auto;
}

.segment-status {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    text-transform: uppercase;
    font-weight: 500;
}

.segment-status.status-detected {
    background: #dbeafe;
    color: #1e40af;
}

.segment-status.status-extracted {
    background: #dcfce7;
    color: #166534;
}

.segment-status.status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.segment-extraction {
    padding: 1rem;
}

.segment-no-extraction {
    padding: 1rem;
    color: var(--color-text-muted);
    font-style: italic;
}

.extraction-preview {
    margin-top: 0.75rem;
}

.extraction-preview summary {
    cursor: pointer;
    color: var(--color-primary);
    font-size: 0.875rem;
    font-weight: 500;
}

.extraction-preview summary:hover {
    text-decoration: underline;
}

.extraction-json {
    margin-top: 0.5rem;
    background: #f8fafc;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    overflow-x: auto;
    max-height: 300px;
    overflow-y: auto;
}

/* Document type color badges */
.doc-type-invoice {
    background: #dbeafe;
    color: #1e40af;
}

.doc-type-bol {
    background: #dcfce7;
    color: #166534;
}

.doc-type-pod {
    background: #fef3c7;
    color: #92400e;
}

.doc-type-rate_confirmation {
    background: #f3e8ff;
    color: #7c3aed;
}

.doc-type-packing_list {
    background: #fce7f3;
    color: #be185d;
}

.doc-type-other {
    background: #f1f5f9;
    color: #475569;
}

/* Multi-type document badges */
.doc-types-multi {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.doc-type-badge-small {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.segment-count {
    display: inline-block;
    background: #f3f4f6;
    color: #374151;
    padding: 0.125rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
}

.segments-cell {
    text-align: center;
}

/* =============================================================================
   Processing Pipeline
   ============================================================================= */

.pipeline-container {
    background: var(--color-background);
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.pipeline-stages {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.pipeline-stages::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--color-border);
    z-index: 0;
}

.pipeline-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    background: var(--color-background);
    padding: 0 0.5rem;
    z-index: 1;
}

.stage-icon {
    width: 1.5rem;
    height: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: bold;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
}

.stage-name {
    font-size: 0.6875rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

.stage-completed .stage-icon {
    background: var(--color-success);
    border-color: var(--color-success);
    color: white;
}

.stage-completed .stage-name {
    color: var(--color-success);
}

.stage-current .stage-icon {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: white;
    animation: pulse 2s infinite;
}

.stage-current .stage-name {
    color: var(--color-primary);
    font-weight: 600;
}

.stage-pending .stage-icon {
    background: var(--color-surface);
    border-color: var(--color-border);
    color: var(--color-text-muted);
}

.stage-failed .stage-icon {
    background: var(--color-danger);
    border-color: var(--color-danger);
    color: white;
}

.stage-failed .stage-name {
    color: var(--color-danger);
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); }
}

.pipeline-error {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    color: var(--color-danger);
    font-size: 0.8125rem;
    text-align: center;
}

.pipeline-success {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    color: #166534;
    font-size: 0.8125rem;
    text-align: center;
}

.pipeline-warning {
    margin-top: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: var(--radius);
    color: #92400e;
    font-size: 0.8125rem;
    text-align: center;
}

/* Collapsible Pipeline Dropdown */
.pipeline-collapsible {
    background: var(--color-background);
    border-bottom: 1px solid var(--color-border);
}

.pipeline-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text);
    text-align: left;
}

.pipeline-toggle-btn:hover {
    background: var(--color-surface);
}

.toggle-chevron {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    width: 1rem;
}

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

.pipeline-collapsible .status-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.pipeline-collapsible .status-received {
    background: #e0e7ff;
    color: #3730a3;
}

.pipeline-collapsible .status-ocr {
    background: #dbeafe;
    color: #1e40af;
}

.pipeline-collapsible .status-classified {
    background: #e0f2fe;
    color: #0369a1;
}

.pipeline-collapsible .status-extracted {
    background: #ccfbf1;
    color: #0f766e;
}

.pipeline-collapsible .status-validated {
    background: #d1fae5;
    color: #047857;
}

.pipeline-collapsible .status-approved {
    background: #dcfce7;
    color: #166534;
}

.pipeline-collapsible .status-exception {
    background: #f3f4f6;
    color: #374151;
}

.pipeline-collapsible .status-escalated {
    background: #fef3c7;
    color: #92400e;
}

.pipeline-collapsible .status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.pipeline-collapsible .status-unknown {
    background: #f1f5f9;
    color: #64748b;
}

.pipeline-collapsible .pipeline-container {
    padding: 0.75rem 1rem 1rem;
    border-bottom: none;
}

/* =============================================================================
   Paginated Document Viewer
   ============================================================================= */

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.viewer-header h3 {
    font-size: 1rem;
    margin: 0;
}

.page-navigation {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-nav {
    width: 2rem;
    height: 2rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.btn-nav:hover:not(:disabled) {
    background: var(--color-background);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-nav:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-indicator {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    min-width: 100px;
    text-align: center;
}

.current-page-container {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    max-height: 600px;
}

.current-page-image {
    max-width: 100%;
    max-height: 600px;
    object-fit: contain;
}

/* Page Thumbnails */
.page-thumbnails {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding: 0.75rem 0;
    margin-top: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.thumbnail {
    flex-shrink: 0;
    width: 60px;
    cursor: pointer;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    overflow: hidden;
    transition: all 0.15s ease;
}

.thumbnail:hover {
    border-color: var(--color-primary);
}

.thumbnail-active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.thumbnail-image {
    width: 100%;
    height: 80px;
    object-fit: cover;
    display: block;
}

.thumbnail-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem;
    background: var(--color-background);
    font-size: 0.625rem;
}

.thumbnail-number {
    font-weight: 600;
    color: var(--color-text-muted);
}

.thumbnail-type {
    padding: 0.125rem 0.25rem;
    border-radius: 2px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.5rem;
}

/* Page count badge */
.page-count-badge {
    background: var(--color-background);
    color: var(--color-text-muted);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
}

/* =============================================================================
   Context-Sensitive Extraction Panel
   ============================================================================= */

.context-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: normal;
}

.segment-header-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.segment-detail {
    background: var(--color-background);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.segment-extraction-detail {
    margin-top: 0.75rem;
}

.extraction-data-expanded {
    margin-top: 0.75rem;
}

.extraction-data-expanded .extraction-json {
    max-height: 400px;
}

.no-segment-for-page {
    background: var(--color-background);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
}

.no-segment-for-page h3 {
    margin-bottom: 0.5rem;
}

.no-segment-for-page p {
    color: var(--color-text-muted);
    margin: 0;
}

/* All Segments Summary */
.all-segments-summary {
    margin: 1rem 0;
    padding: 0.75rem;
    background: var(--color-background);
    border-radius: var(--radius);
}

.all-segments-summary summary {
    cursor: pointer;
    font-weight: 500;
    font-size: 0.875rem;
    color: var(--color-text);
}

.all-segments-summary summary:hover {
    color: var(--color-primary);
}

.segments-summary-list {
    margin-top: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.segment-summary-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    background: var(--color-surface);
    border-radius: 4px;
    font-size: 0.8125rem;
}

.segment-index {
    font-weight: 600;
    color: var(--color-text-muted);
    min-width: 1.5rem;
}

.segment-pages-small {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

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

.status-dot.status-detected {
    background: #3b82f6;
}

.status-dot.status-extracted {
    background: #22c55e;
}

.status-dot.status-failed {
    background: #ef4444;
}

.extraction-check {
    color: var(--color-success);
    font-weight: bold;
}

.extraction-pending {
    color: var(--color-text-muted);
}

/* Segment extraction status messages */
.segment-no-extraction,
.segment-extraction-pending,
.segment-extraction-failed,
.segment-extraction-exception {
    padding: 1rem;
    border-radius: var(--radius);
    text-align: center;
    font-size: 0.875rem;
}

.segment-no-extraction {
    background: var(--color-background);
    color: var(--color-text-muted);
}

.segment-extraction-pending {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #1e40af;
}

.segment-extraction-failed {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--color-danger);
}

.segment-extraction-exception {
    background: #fef3c7;
    border: 1px solid #fde68a;
    color: #92400e;
}

/* =============================================================================
   Line Items Table Rendering (Phase 2)
   ============================================================================= */

/* Table for line items (commodities, charges, etc.) */
.line-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.line-items-table thead {
    background: #f1f5f9;
}

.line-items-table th {
    padding: 0.75rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    border-bottom: 2px solid var(--color-border);
}

.line-items-table th.row-number-header {
    width: 3rem;
    text-align: center;
}

.line-items-table tbody tr {
    border-bottom: 1px solid var(--color-border);
}

.line-items-table tbody tr:last-child {
    border-bottom: none;
}

.line-items-table tbody tr:hover {
    background: #f8fafc;
}

.line-items-table td {
    padding: 0.75rem;
    font-size: 0.875rem;
}

.line-items-table td.row-number {
    text-align: center;
    font-weight: 500;
    color: var(--color-text-muted);
    background: #fafafa;
}

.line-items-table .table-cell-input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: var(--font-sans);
}

.line-items-table .table-cell-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.line-items-table .table-cell-checkbox {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

.line-items-table .table-cell-json {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--color-text-muted);
    background: #f8fafc;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    display: inline-block;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Simple array (non-object items) */
.simple-array {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.5rem 0;
}

.simple-array-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.array-item-index {
    font-weight: 500;
    color: var(--color-text-muted);
    min-width: 2rem;
}

/* Empty array indicator */
.empty-array {
    padding: 1rem;
    text-align: center;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    font-style: italic;
    background: #fafafa;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
}

/* Responsive table on small screens */
@media (max-width: 768px) {
    .line-items-table {
        font-size: 0.75rem;
    }

    .line-items-table th,
    .line-items-table td {
        padding: 0.5rem;
    }

    .line-items-table .table-cell-input {
        font-size: 0.75rem;
        padding: 0.25rem 0.375rem;
    }
}

/* =============================================================================
   Line-Level Exception Highlighting (Phase 3)
   ============================================================================= */

/* Row-level error highlighting */
.line-items-table tbody tr.has-error {
    background: #fef2f2;
    border-left: 3px solid var(--color-danger);
}

.line-items-table tbody tr.has-warning {
    background: #fef3c7;
    border-left: 3px solid var(--color-warning);
}

/* Cell-level error highlighting */
.table-cell.has-error .table-cell-input {
    border-color: var(--color-danger);
    background: #fef2f2;
}

.table-cell.has-warning .table-cell-input {
    border-color: var(--color-warning);
    background: #fef3c7;
}

/* Error indicator icon in cell */
.table-cell-error-icon {
    display: inline-block;
    margin-left: 0.25rem;
    color: var(--color-danger);
    font-weight: bold;
    cursor: help;
}

.table-cell-warning-icon {
    display: inline-block;
    margin-left: 0.25rem;
    color: var(--color-warning);
    font-weight: bold;
    cursor: help;
}

/* Error tooltip */
.validation-error-tooltip {
    position: absolute;
    background: var(--color-danger);
    color: white;
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    z-index: 1000;
    max-width: 200px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.validation-warning-tooltip {
    background: var(--color-warning);
    color: white;
}

/* Line-level validation summary */
.line-validation-summary {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    background: #fef2f2;
    border: 1px solid #fecaca;
}

.line-validation-summary.has-warnings-only {
    background: #fef3c7;
    border-color: #fde68a;
}

.line-validation-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    font-size: 0.875rem;
}

.line-validation-item-error {
    color: var(--color-danger);
}

.line-validation-item-warning {
    color: #92400e;
}

.line-validation-icon {
    font-weight: bold;
}

/* Validation Banner (for segment extraction view) */
.validation-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
}

.validation-banner.warning {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
}

.validation-banner.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* ============================================================================
   BBox Hover Interactions
   ============================================================================ */

/* Highlight field when hovered */
.field-row.field-hovered {
    background-color: rgba(59, 130, 246, 0.1);
    border-left: 3px solid #3b82f6;
    padding-left: 12px;
    margin-left: -15px;
    transition: all 0.2s ease;
}

/* Highlight bbox when its field is hovered (via Elm state) */
.bbox-rect.bbox-hovered {
    stroke: #3b82f6 !important;
    stroke-width: 0.004 !important;
    opacity: 0.9 !important;
    fill: rgba(59, 130, 246, 0.1) !important;
}

/* Highlight bbox on direct hover */
.bbox-rect:hover {
    stroke: #3b82f6 !important;
    stroke-width: 0.004 !important;
    opacity: 0.9 !important;
    fill: rgba(59, 130, 246, 0.1) !important;
    cursor: pointer;
}

/* Smooth transitions for all bbox rects */
.bbox-rect {
    transition: stroke-width 0.2s ease, opacity 0.2s ease, fill 0.2s ease;
}

/* ============================================================================
   Data Editor Sections (Scalars vs Arrays)
   ============================================================================ */

.field-sections {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.scalar-fields-section,
.line-items-section {
    padding: 16px;
    background: white;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.section-title {
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6b7280;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

.array-field-section {
    margin-bottom: 20px;
}

.array-field-section:last-child {
    margin-bottom: 0;
}

.empty-array-section {
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px dashed #d1d5db;
}

.empty-message {
    color: #9ca3af;
    font-size: 0.875rem;
    margin: 4px 0 0 0;
}

/* ============================================================================
   Classification Correction (Learning System)
   ============================================================================ */

/* Classification correction button in segment header */
.classification-correction-btn {
    margin-left: auto;
    padding: 4px 12px;
    font-size: 0.85rem;
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.classification-correction-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* Modal content */
.modal-content {
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.classification-modal {
    max-width: 700px;
}

/* Modal header */
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.75rem;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
}

.modal-close:hover {
    background: #f3f4f6;
}

/* Modal body */
.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.current-classification {
    margin-bottom: 24px;
}

.current-classification p {
    font-size: 0.875rem;
    color: #6b7280;
    margin: 0 0 8px 0;
}

.classification-badge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.confidence-badge {
    background: #e5e7eb;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.classification-selector p {
    font-size: 0.875rem;
    color: #374151;
    margin: 0 0 12px 0;
    font-weight: 500;
}

/* Document type grid */
.doc-type-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.doc-type-option {
    padding: 10px 12px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 0.875rem;
    text-align: center;
    transition: all 0.2s;
    position: relative;
}

.doc-type-option:hover:not(.disabled) {
    border-color: #3b82f6;
    background: #eff6ff;
}

.doc-type-option.current {
    border-color: #d1d5db;
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

.doc-type-option.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.current-indicator {
    font-size: 0.75rem;
    color: #9ca3af;
}

/* Modal footer */
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #e5e7eb;
}

.correction-progress {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Segment header inline layout */
.segment-header-inline {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

/* =============================================================================
   OCR Block Visual Overlay Styles
   ============================================================================= */

/* Viewer controls - toggle button and page nav */
.viewer-controls {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* OCR toggle button */
.btn-toggle {
    padding: 4px 10px;
    font-size: 0.75rem;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    transition: all 0.2s;
}

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

.btn-toggle.active {
    background: #eff6ff;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* Combined overlay container */
.combined-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: all;
}

/* OCR block rectangles - blue boxes showing all OCR detected text */
.ocr-block-rect {
    transition: all 0.15s ease;
    vector-effect: non-scaling-stroke;
}

.ocr-block-group:hover .ocr-block-rect,
.ocr-block-group.ocr-block-hovered .ocr-block-rect {
    stroke-width: 0.004 !important;
    fill-opacity: 0.2 !important;
    stroke: #1d4ed8 !important;
}

/* OCR block labels - hidden by default, shown on hover */
.ocr-block-label {
    pointer-events: none;
    transition: fill-opacity 0.15s ease;
}

/* Show label only when hovering the parent group */
.ocr-block-group:hover .ocr-block-label,
.ocr-block-group.ocr-block-hovered .ocr-block-label {
    fill-opacity: 1 !important;
}

/* Extraction bbox hover highlighting */
.bbox-rect {
    transition: all 0.15s ease;
}

.bbox-rect:hover,
.bbox-rect.bbox-hovered {
    stroke-width: 0.004 !important;
    fill: rgba(59, 130, 246, 0.1) !important;
}

/* Selected bbox styling */
.bbox-rect.bbox-selected {
    stroke: #16a34a !important;
    stroke-width: 0.005 !important;
    fill: rgba(22, 163, 74, 0.15) !important;
    opacity: 1 !important;
}

/* Selected bbox pulsing animation */
@keyframes bbox-pulse {
    0%, 100% {
        stroke-width: 0.005;
    }
    50% {
        stroke-width: 0.007;
    }
}

.bbox-rect.bbox-selected {
    animation: bbox-pulse 1.5s ease-in-out infinite;
}

/* Field hover sync - highlight field row when bbox hovered */
.field-row.field-hovered {
    background: #eff6ff;
    border-left: 3px solid var(--color-primary);
    margin-left: -3px;
}

/* OCR block count badge in header */
.ocr-count-badge {
    background: #dbeafe;
    color: var(--color-primary);
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 4px;
}

/* =============================================================================
   THREE-COLUMN LAYOUT (Phase 3)
   ============================================================================= */

/* Two-column layout container (simplified) */
.detail-content.two-column {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 0;
    height: calc(100vh - 180px);
    overflow: hidden;
}

/* Three-column layout container (legacy) */
.detail-content.three-column {
    display: grid;
    grid-template-columns: 280px 1fr 360px;
    gap: 0;
    height: calc(100vh - 180px);
    overflow: hidden;
}

/* =============================================================================
   LEFT SIDEBAR: Extracted Fields List
   ============================================================================= */

.extracted-fields-sidebar {
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
    background: #f8fafc;
}

.sidebar-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 4px 0;
}

.field-count {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.warning-count {
    color: var(--color-warning);
    font-weight: 500;
}

/* Fields list container */
.fields-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* Individual field item */
.field-list-item {
    padding: 10px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

.field-list-item:hover {
    background: #f8fafc;
}

.field-list-item.hovered {
    background: #eff6ff;
}

.field-list-item.selected {
    background: #dbeafe;
    border-left: 3px solid var(--color-primary);
    padding-left: 13px;
}

.field-list-item.has-warning {
    background: #fef3c7;
}

.field-list-item.has-warning:hover {
    background: #fde68a;
}

.field-list-item.has-warning.selected {
    background: #fcd34d;
    border-left-color: var(--color-warning);
}

/* Field item header (icon + name) */
.field-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.warning-icon {
    color: var(--color-warning);
    font-size: 0.875rem;
    flex-shrink: 0;
}

.field-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Field item value */
.field-item-value {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding-left: 0;
}

.field-list-item.has-warning .field-item-value {
    padding-left: 20px;
}

.empty-value {
    font-style: italic;
    color: #9ca3af;
}

/* Field with bbox indicator */
.field-list-item.has-bbox {
    border-left: 2px solid var(--color-primary);
}

.field-list-item.has-bbox:not(.selected) {
    padding-left: 14px;
}

/* Field on different page indicator */
.field-list-item.on-different-page {
    opacity: 0.85;
}

.field-list-item.on-different-page:hover {
    opacity: 1;
}

/* Page indicator badge */
.page-indicator-badge {
    font-size: 9px;
    padding: 1px 5px;
    background: #e2e8f0;
    color: #64748b;
    border-radius: 8px;
    margin-left: auto;
    font-weight: 500;
}

.field-list-item:hover .page-indicator-badge {
    background: var(--color-primary);
    color: white;
}

.field-list-item.selected .page-indicator-badge {
    background: var(--color-primary-dark);
    color: white;
}

/* =============================================================================
   CENTER: Document Viewer adjustments
   ============================================================================= */

.document-viewer {
    background: #f1f5f9;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.viewer-header {
    padding: 12px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.viewer-header h3 {
    font-size: 0.875rem;
    font-weight: 600;
    margin: 0;
}

/* Enhanced viewer header with metadata (Issue 6) */
.viewer-header.enhanced {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 1rem;
    align-items: center;
    padding: 0.75rem 1rem;
}

.viewer-title-section {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
}

.page-indicator {
    font-size: 0.75rem;
    color: #6b7280;
    font-weight: 400;
}

.document-metadata {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.confidence-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
}

.confidence-badge.high {
    background: #dcfce7;
    color: #166534;
}

.confidence-badge.medium {
    background: #fef3c7;
    color: #92400e;
}

.confidence-badge.low {
    background: #fee2e2;
    color: #991b1b;
}

.confidence-icon {
    font-weight: 600;
}

.field-count-badge {
    padding: 0.25rem 0.75rem;
    background: #f3f4f6;
    border-radius: 12px;
    font-size: 0.875rem;
    color: #374151;
    font-weight: 500;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
}

.btn-zoom {
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 4px;
}

.btn-zoom:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.zoom-level {
    min-width: 48px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.btn-reset-zoom {
    font-size: 0.7rem;
    padding: 4px 8px;
    margin-left: 4px;
}

.document-zoom-container {
    transition: transform 0.15s ease;
}

.current-page-container {
    flex: 1;
    overflow: auto;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* Viewer body with vertical thumbnails sidebar */
.viewer-body-with-thumbnails {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.thumbnails-sidebar {
    width: 80px;
    flex-shrink: 0;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    padding: 8px;
}

.page-thumbnails-vertical {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.thumbnail-vertical {
    cursor: pointer;
    border: 2px solid var(--color-border);
    border-radius: 4px;
    overflow: hidden;
    background: white;
    transition: border-color 0.15s ease;
}

.thumbnail-vertical:hover {
    border-color: var(--color-primary);
}

.thumbnail-vertical-active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.2);
}

.thumbnail-vertical-image {
    width: 100%;
    height: auto;
    aspect-ratio: 8.5 / 11;
    object-fit: cover;
    display: block;
}

.thumbnail-vertical-label {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
    background: var(--color-background);
    font-size: 0.625rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.thumbnail-type-badge {
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.5rem;
}

.main-document-area {
    flex: 1;
    overflow: auto;
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.current-page-image {
    max-width: 100%;
    max-height: calc(100vh - 340px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    background: white;
}

/* Wrapper for image + overlay - must be positioned relative */
.page-image-wrapper {
    position: relative;
    display: inline-block;
    line-height: 0; /* Remove gap below image */
}

/* SVG overlay must match the image dimensions exactly */
.page-image-wrapper .combined-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: all;
}

/* Page thumbnails at bottom */
.page-thumbnails {
    padding: 12px 16px;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 8px;
    overflow-x: auto;
    flex-shrink: 0;
}

/* =============================================================================
   RIGHT: Extraction Panel adjustments
   ============================================================================= */

.extraction-form {
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    overflow-y: auto;
    padding: 0;
}

.segments-panel {
    padding: 16px;
}

.segments-panel h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    margin: 0 0 8px 0;
}

/* Make actions sticky at bottom of right panel */
.form-actions {
    position: sticky;
    bottom: 0;
    background: var(--color-surface);
    padding: 16px;
    border-top: 1px solid var(--color-border);
    margin-top: auto;
}

/* =============================================================================
   Responsive: Stack on smaller screens
   ============================================================================= */

@media (max-width: 1200px) {
    .detail-content.three-column {
        grid-template-columns: 240px 1fr 320px;
    }
}

@media (max-width: 992px) {
    .detail-content.three-column {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr auto;
        height: auto;
    }

    .extracted-fields-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        max-height: 200px;
    }

    .extraction-form {
        border-left: none;
        border-top: 1px solid var(--color-border);
    }
}

/* =============================================================================
   Inline Editor - Positioned near selected bbox
   ============================================================================= */

.inline-editor {
    background: white;
    border: 2px solid #16a34a;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 4px rgba(22, 163, 74, 0.1);
    min-width: 240px;
    max-width: 320px;
    animation: editor-pop-in 0.15s ease-out;
}

@keyframes editor-pop-in {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.inline-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f0fdf4;
    border-bottom: 1px solid #bbf7d0;
    border-radius: 6px 6px 0 0;
}

.inline-editor-field-name {
    font-size: 12px;
    font-weight: 600;
    color: #166534;
    text-transform: capitalize;
}

.inline-editor-close {
    background: none;
    border: none;
    font-size: 18px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.inline-editor-close:hover {
    background: #fee2e2;
    color: #dc2626;
}

.inline-editor-body {
    padding: 12px;
}

.inline-editor-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.inline-editor-input:focus {
    border-color: #16a34a;
    box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.1);
}

.inline-editor-input::placeholder {
    color: #9ca3af;
}

.inline-editor-actions {
    display: flex;
    gap: 8px;
    padding: 8px 12px 12px;
    justify-content: flex-end;
}

.inline-editor-actions .btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.inline-editor-actions .btn-primary {
    background: #16a34a;
    color: white;
    border: none;
}

.inline-editor-actions .btn-primary:hover {
    background: #15803d;
}

.inline-editor-actions .btn-secondary {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}

.inline-editor-actions .btn-secondary:hover {
    background: #f9fafb;
}

/* Arrow pointer from editor to bbox */
.inline-editor::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #16a34a;
}

.inline-editor::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 22px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #f0fdf4;
}

/* =============================================================================
   Document Type Dropdown Selector
   ============================================================================= */

.doc-type-selector {
    display: inline-block;
}

.doc-type-dropdown {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    padding: 6px 32px 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    background-color: white;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M2.5 4.5L6 8l3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.doc-type-dropdown:hover {
    border-color: #94a3b8;
}

.doc-type-dropdown:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.doc-type-dropdown option {
    padding: 8px;
}

/* Style when a value is selected (not placeholder) */
.doc-type-dropdown:not(:invalid) {
    background-color: #eff6ff;
    border-color: var(--color-primary);
    color: var(--color-primary);
}

/* =============================================================================
   SCHEMA-DRIVEN FIELDS PANEL
   ============================================================================= */

.schema-fields-panel {
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.schema-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    background: #f8fafc;
}

.schema-panel-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

/* Confidence indicator bar */
.confidence-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #f1f5f9;
    font-size: 0.8125rem;
}

.confidence-label {
    color: var(--color-text-muted);
}

.confidence-value {
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
}

.confidence-value.confidence-high {
    background: #dcfce7;
    color: #166534;
}

.confidence-value.confidence-medium {
    background: #fef3c7;
    color: #92400e;
}

.confidence-value.confidence-low {
    background: #fee2e2;
    color: #991b1b;
}

.extraction-method {
    color: var(--color-text-muted);
    font-size: 0.75rem;
}

/* Schema fields content area */
.schema-fields-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.no-extraction-message {
    padding: 24px;
    text-align: center;
    color: var(--color-text-muted);
    background: #f8fafc;
    border-radius: var(--radius);
    font-size: 0.875rem;
}

/* Schema organized fields */
.schema-organized-fields {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Field sections */
.fields-section {
    background: white;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.fields-section.required-section {
    border-left: 3px solid var(--color-primary);
}

.fields-section.optional-section {
    border-left: 3px solid #94a3b8;
}

.section-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid var(--color-border);
    margin: 0;
}

.fields-grid {
    display: flex;
    flex-direction: column;
}

/* Individual schema field row */
.schema-field-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s ease;
}

.schema-field-row:last-child {
    border-bottom: none;
}

.schema-field-row:hover {
    background: #f8fafc;
}

.schema-field-row.is-hovered {
    background: #eff6ff;
}

.schema-field-row.is-selected {
    background: #dbeafe;
}

.schema-field-row.has-error {
    background: #fef2f2;
}

/* Field status column */
.field-status-col {
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 4px;
}

.field-status-icon {
    font-size: 0.875rem;
}

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

.field-status-icon.status-empty {
    color: #d1d5db;
}

.field-status-icon.status-error {
    color: var(--color-danger);
}

/* Field content column */
.field-content-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.schema-field-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text);
}

.required-marker {
    color: var(--color-danger);
}

.schema-field-input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.schema-field-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.schema-field-input::placeholder {
    color: #9ca3af;
}

.schema-field-row.has-error .schema-field-input {
    border-color: var(--color-danger);
    background: #fef2f2;
}

.field-error-message {
    font-size: 0.75rem;
    color: var(--color-danger);
}

/* Actions section at bottom */
.schema-fields-panel .form-actions {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid var(--color-border);
    display: flex;
    gap: 12px;
}

/* OCR info bar */
.ocr-info-bar {
    padding: 8px 20px;
    background: #eff6ff;
    border-bottom: 1px solid #bfdbfe;
    font-size: 0.8125rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ocr-info-bar span:first-child {
    font-weight: 600;
    color: var(--color-primary);
}

.ocr-hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* All extracted fields container */
.all-extracted-fields {
    display: flex;
    flex-direction: column;
}

/* Individual extracted field row */
.extracted-field-row {
    display: flex;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 1px solid #f1f5f9;
    cursor: pointer;
    transition: background 0.15s ease;
}

.extracted-field-row:hover {
    background: #f8fafc;
}

.extracted-field-row.is-hovered {
    background: #3b82f620;  /* Light blue background to match bbox hover */
    border-left: 3px solid #3b82f6;  /* Blue border to match bbox hover */
    margin-left: -3px;
    box-shadow: 0 0 0 1px #3b82f640;  /* Blue glow effect */
}

.extracted-field-row.is-selected {
    background: #22c55e20;  /* Light green background to match bbox */
    border-left: 4px solid #16a34a;  /* Green border to match bbox */
    margin-left: -4px;
    box-shadow: 0 0 0 2px #22c55e40;  /* Green glow effect */
}

.extracted-field-row.has-error {
    background: #fef2f2;
}

.extracted-field-row.has-warning {
    background: #fef3c7;
}

/* Field status indicator */
.field-status-indicator {
    width: 20px;
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    padding-top: 2px;
}

.status-icon {
    font-size: 0.75rem;
    font-weight: 600;
}

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

.status-icon.status-empty {
    color: #d1d5db;
}

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

.status-icon.status-warning {
    color: var(--color-warning);
}

/* Field content */
.field-content {
    flex: 1;
    min-width: 0;
}

.field-label-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.field-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--color-text);
}

.validation-icon {
    color: var(--color-warning);
    font-size: 0.75rem;
}

.field-value {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    word-break: break-word;
    white-space: pre-wrap;
}

.extracted-field-row:hover .field-value,
.extracted-field-row.is-hovered .field-value {
    color: var(--color-text);
}

/* Field edit container (when selected) */
.field-edit-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field-edit-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    font-size: 0.875rem;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

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

.field-edit-actions .btn-save {
    padding: 4px 12px;
    background: var(--color-success);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

.field-edit-actions .btn-cancel {
    padding: 4px 12px;
    background: #f3f4f6;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 1024px) {
    .detail-content.two-column {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
        height: auto;
    }

    .schema-fields-panel {
        border-left: none;
        border-top: 1px solid var(--color-border);
        max-height: 50vh;
    }
}

/* =============================================================================
   FEEDBACK NOTES SECTION
   ============================================================================= */

.feedback-notes-section {
    padding: 16px 20px;
    background: #f8fafc;
    border-top: 1px solid var(--color-border);
}

.feedback-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.feedback-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    line-height: 1.5;
    resize: vertical;
    min-height: 80px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.feedback-textarea::placeholder {
    color: #9ca3af;
}

/* ============================================
   Hierarchical Field Display (Shopify-style)
   ============================================ */

.fields-hierarchical {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.field-group {
    border-left: 3px solid #3b82f6;
    margin-bottom: 0.75rem;
    border-radius: 4px;
    overflow: hidden;
}

.field-group.array-group {
    border-left-color: #8b5cf6;
}

.group-header {
    padding: 0.5rem 0.75rem;
    background: #f9fafb;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border-radius: 4px 4px 0 0;
    transition: background-color 0.15s ease;
}

.group-header:hover {
    background: #f3f4f6;
}

.group-icon {
    font-size: 1.25rem;
    line-height: 1;
}

.group-label {
    flex: 1;
    font-size: 0.875rem;
}

.group-count {
    color: #6b7280;
    font-size: 0.875rem;
    font-weight: 400;
}

.group-children {
    padding-left: 1rem;
    border-left: 2px solid #e5e7eb;
    margin-left: 0.5rem;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
}

.field-row {
    padding: 0.25rem 0;
}

/* ============================================
   Linked Documents Panel Styles
   ============================================ */

.linked-documents-panel {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin: 16px 24px;
    padding: 16px;
}

.linked-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.linked-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.reference-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.reference-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #f3f4f6;
    border-radius: 999px;
    font-size: 0.75rem;
}

.reference-badge .ref-type {
    color: #6b7280;
    font-weight: 500;
}

.reference-badge .ref-value {
    color: var(--color-text);
    font-weight: 600;
}

.ref-bol_number { background: #dbeafe; }
.ref-pro_number { background: #dcfce7; }
.ref-load_number { background: #fef3c7; }
.ref-po_number { background: #f3e8ff; }
.ref-container_number { background: #fee2e2; }

.btn-view-load {
    padding: 4px 12px;
    font-size: 0.75rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background 0.15s ease;
}

.btn-view-load:hover {
    background: var(--color-primary-dark);
}

.linked-docs-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.linked-doc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: #f9fafb;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
}

.linked-doc-item:hover {
    background: #f3f4f6;
    border-color: var(--color-primary);
}

.linked-doc-filename {
    flex: 1;
    font-size: 0.875rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.linked-doc-status {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 999px;
}

.linked-doc-match {
    font-size: 0.75rem;
    color: #6b7280;
}

.no-linked-docs {
    color: #9ca3af;
    font-size: 0.875rem;
    text-align: center;
    padding: 16px;
}

/* ============================================
   Load View Page Styles
   ============================================ */

.load-view-container {
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.load-view-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.load-view-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
}

.load-summary {
    display: flex;
    gap: 16px;
    margin-left: auto;
}

.doc-count {
    font-size: 0.875rem;
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 12px;
    border-radius: 999px;
}

.primary-bol {
    font-size: 0.875rem;
    color: var(--color-primary);
    font-weight: 500;
}

.load-view-content {
    display: grid;
    gap: 24px;
}

/* Timeline */
.load-timeline {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
}

.load-timeline h3 {
    margin: 0 0 20px 0;
    font-size: 1rem;
    font-weight: 600;
}

.timeline-container {
    display: flex;
    gap: 0;
    overflow-x: auto;
    padding-bottom: 8px;
}

.timeline-stage {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 120px;
    position: relative;
}

.timeline-stage.complete .stage-icon .badge {
    opacity: 1;
}

.timeline-stage.pending .stage-icon .badge {
    opacity: 0.7;
}

.stage-icon {
    margin-bottom: 8px;
}

.stage-content {
    text-align: center;
}

.stage-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 8px;
}

.stage-docs {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.timeline-doc {
    padding: 6px 10px;
    background: #f9fafb;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.15s ease;
}

.timeline-doc:hover {
    background: #f3f4f6;
    border-color: var(--color-primary);
}

.timeline-doc .doc-filename {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.timeline-doc .doc-status {
    font-size: 0.625rem;
    display: block;
    margin-top: 2px;
}

.stage-connector {
    position: absolute;
    top: 20px;
    right: -50%;
    width: 100%;
    height: 2px;
    background: #e5e7eb;
    z-index: -1;
}

.timeline-stage.complete .stage-connector {
    background: var(--color-success);
}

/* Documents List Table */
.load-documents-list {
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
}

.load-documents-list h3 {
    margin: 0 0 16px 0;
    font-size: 1rem;
    font-weight: 600;
}

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

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

.documents-table th {
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: #f9fafb;
}

.documents-table .document-row {
    cursor: pointer;
    transition: background 0.15s ease;
}

.documents-table .document-row:hover {
    background: #f9fafb;
}

.filename-cell {
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.confidence-cell {
    font-variant-numeric: tabular-nums;
}

.reference-cell {
    font-size: 0.8125rem;
}

.reference-cell .ref-type {
    color: #6b7280;
}

.reference-cell .ref-value {
    font-weight: 500;
}

.date-cell {
    color: #6b7280;
    font-size: 0.8125rem;
}

/* =============================================================================
   Admin Dashboard Styles
   ============================================================================= */

.admin-dashboard {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.admin-content {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.admin-header {
    text-align: center;
    margin-bottom: 2rem;
}

.admin-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.admin-subtitle {
    font-size: 1rem;
    color: var(--color-text-muted);
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
}

.admin-quick-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
}

.quick-link-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: inherit;
    display: block;
}

.quick-link-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--color-primary);
}

.quick-link-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.quick-link-icon {
    font-size: 1.5rem;
}

.quick-link-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
}

.quick-link-description {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    line-height: 1.4;
    margin-bottom: 1rem;
}

.preview-list {
    list-style: none;
    padding: 0;
}

.preview-list li {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    padding: 0.25rem 0;
    border-top: 1px solid var(--color-border);
}

.preview-list li:first-child {
    border-top: none;
}

/* Admin Pages */
.admin-page {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
}

.page-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.back-button {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--color-text);
    transition: all 0.2s;
}

.back-button:hover {
    background: var(--color-background);
    border-color: var(--color-primary);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
}

.page-description {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-left: auto;
}

/* Document Types Grid */
.tier-section {
    margin-bottom: 3rem;
}

.tier-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-primary);
}

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

.document-type-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.document-type-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
    border-color: var(--color-primary);
}

.document-type-header {
    margin-bottom: 1rem;
}

.document-type-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text);
    margin: 0 0 0.25rem 0;
}

.document-type-code {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-family: monospace;
}

.document-type-meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    align-items: center;
}

.field-count {
    font-weight: 500;
    color: var(--color-primary);
}

/* Field Groups */
.field-groups-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field-group-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.field-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.field-group-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
}

.field-count {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    background: var(--color-background);
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
}

.field-group-description {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 1rem;
}

.field-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.field-tag {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 1rem;
    color: var(--color-text);
}

/* Learned Rules */
.learned-rules-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rule-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.rule-field {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    font-family: var(--font-mono);
}

.rule-meta {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.confidence-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-weight: 600;
}

.confidence-high {
    background: rgba(34, 197, 94, 0.1);
    color: var(--color-success);
}

.confidence-medium {
    background: rgba(245, 158, 11, 0.1);
    color: var(--color-warning);
}

.confidence-low {
    background: rgba(239, 68, 68, 0.1);
    color: var(--color-danger);
}

.rule-type-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: var(--color-background);
    border: 1px solid var(--color-border);
    border-radius: 0.25rem;
    color: var(--color-text-muted);
}

.rule-pattern {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    font-family: var(--font-mono);
    background: var(--color-background);
    padding: 0.5rem;
    border-radius: 0.25rem;
    margin-top: 0.5rem;
}

/* AI Learning Page */
.ai-learning-page {
    padding: 2rem;
}

.learning-header {
    text-align: center;
    margin-bottom: 2rem;
}

.learning-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.learning-description {
    font-size: 1rem;
    color: var(--color-text-muted);
    max-width: 800px;
    margin: 0 auto 2rem;
    line-height: 1.6;
}

.view-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
}

.view-link {
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.view-link:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--color-primary);
}

.list-view-link:hover {
    border-color: var(--color-success);
}

.graph-view-link:hover {
    border-color: #8b5cf6;
}

.view-icon {
    font-size: 3rem;
    text-align: center;
    margin-bottom: 1rem;
}

.view-label {
    font-size: 1.25rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.5rem;
}

.view-description {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-align: center;
    line-height: 1.5;
}

/* Fullscreen views */
.learned-patterns-fullscreen {
    padding: 0;
    max-width: none;
}

/* Loading and Error States */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--color-text-muted);
}

.error {
    text-align: center;
    padding: 3rem;
    color: var(--color-danger);
}

/* ============================================================================
   Admin Dashboard Styles
   ============================================================================ */

/* Dashboard Container - Split 60/40 layout */
.admin-dashboard-container {
    display: grid;
    grid-template-columns: 60% 40%;
    gap: 1.5rem;
    padding: 1.5rem;
    height: calc(100vh - 120px);
    background: var(--color-bg);
}

/* Left Panel - Graphs and Stats */
.dashboard-left-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow: hidden;
}

/* Right Panel - Management and Context */
.dashboard-right-panel {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    overflow-y: auto;
    box-shadow: var(--shadow-md);
}

/* Overview Stats */
.overview-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1rem;
}

.overview-stats.loading {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 2rem;
    color: var(--color-text-muted);
}

.stat-card {
    background: var(--color-surface);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    text-align: center;
    transition: all 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Graph Tabs */
.graph-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.graph-tab {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.graph-tab:hover {
    background: var(--color-bg);
    border-color: var(--color-primary-light);
}

.graph-tab.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* Graph Container */
.graph-container {
    flex: 1;
    position: relative;
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.graph-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--color-text-muted);
    font-size: 1.125rem;
}

/* D3 Graph Canvas */
.d3-graph {
    width: 100%;
    height: 100%;
    min-height: 400px;
    background: #1a1a1a;
    position: relative;
}

.d3-graph svg {
    width: 100%;
    height: 100%;
}

.d3-graph .node-label {
    font-family: var(--font-mono);
    font-size: 11px;
    pointer-events: none;
    user-select: none;
}

.d3-graph .edge-label {
    font-family: var(--font-mono);
    font-size: 9px;
    pointer-events: none;
    user-select: none;
}

/* Graph Legend */
.graph-legend {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.85);
    padding: 1rem;
    border-radius: var(--radius-md);
    color: white;
    backdrop-filter: blur(10px);
    max-width: 200px;
}

.graph-legend h4 {
    margin: 0 0 0.75rem 0;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #aaa;
}

.graph-legend ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.graph-legend li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

.graph-legend li:last-child {
    margin-bottom: 0;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid white;
}

.legend-color.document {
    background: #4CAF50;
}

.legend-color.reference {
    background: #FF9800;
}

.legend-color.doctype {
    background: #2196F3;
}

.legend-color.field {
    background: #00BCD4;
}

.legend-color.rule {
    background: #9C27B0;
}

.legend-color.correction {
    background: #F44336;
}

/* Node Context Panel */
.node-context {
    animation: fadeInRight 0.3s ease;
}

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

.node-context h3 {
    margin: 0 0 1rem 0;
    color: var(--color-primary);
    font-size: 1.25rem;
}

.node-info {
    background: var(--color-bg);
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
}

.node-info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.node-info-row:last-child {
    border-bottom: none;
}

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

.node-info-row .value {
    color: var(--color-text);
    font-family: var(--font-mono);
    font-size: 0.9rem;
}

/* Node Connections */
.node-connections {
    margin-top: 1.5rem;
}

.node-connections h4 {
    margin: 0 0 1rem 0;
    font-size: 1rem;
    color: var(--color-text);
}

.node-connections ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.node-connections li {
    padding: 0.5rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

.connection-label {
    color: var(--color-text-muted);
    font-style: italic;
}

/* Quick Actions */
.quick-actions h3 {
    margin: 0 0 1.5rem 0;
    font-size: 1.25rem;
    color: var(--color-text);
}

.actions-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.action-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--color-bg);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text);
    transition: all 0.2s ease;
}

.action-button:hover {
    border-color: var(--color-primary);
    background: var(--color-primary-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.action-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.action-label {
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
}

.back-button-container {
    margin-top: 2rem;
}

.back-button {
    width: 100%;
    padding: 0.75rem;
    background: var(--color-surface);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.back-button:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

/* Fullscreen Mode */
.admin-dashboard-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: var(--color-bg);
    padding: 0;
    margin: 0;
    grid-template-columns: 1fr;
}

.admin-dashboard-container.fullscreen .dashboard-left-panel {
    height: 100vh;
    padding: 0;
}

.admin-dashboard-container.fullscreen .graph-container {
    height: 100vh;
}

.admin-dashboard-container.fullscreen .d3-graph {
    height: calc(100vh - 60px) !important;
}

.fullscreen-button {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.fullscreen-button:hover {
    background: rgba(0, 0, 0, 0.9);
    border-color: var(--color-primary);
}

/* Floating Node Panel (for fullscreen mode) */
.floating-node-panel {
    position: fixed;
    top: 5rem;
    right: 2rem;
    width: 350px;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
    background: rgba(30, 30, 30, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(10px);
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.floating-node-panel .node-context {
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 1.5rem;
}

.floating-node-panel .node-context h3 {
    margin-top: 0;
    color: var(--color-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 0.5rem;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .admin-dashboard-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .dashboard-left-panel {
        height: 600px;
    }
    
    .overview-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .overview-stats {
        grid-template-columns: 1fr;
    }
    
    .graph-tabs {
        flex-direction: column;
    }
    
    .actions-grid {
        grid-template-columns: 1fr;
    }
}
