/* ============================================
   Edit Page - Modern Design System
   ============================================ */

:root {
    --primary: #3370ff;
    --primary-dark: #2455cc;
    --primary-light: #e8f0ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f9fafb;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-tertiary: #6b7280;
    --border-light: #e5e7eb;
    --border: #d1d5db;
    --border-focus: #3370ff;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --header-height: 72px;
}

/* ============================================
   Neo Brutalist Refresh
   ============================================ */

:root {
    --ink: #111111;
    --paper: #fffdf3;
    --acid: #1f2937;
    --blue: #3b82f6;
    --pink: #ff4fa3;
    --orange: #ff9f1c;
    --green: #18c964;
    --red: #ff3b30;
    --muted: #f1efe3;
    --surface: #ffffff;
    --bg: var(--paper);
    --text-primary: var(--ink);
    --text-secondary: #2f2f2f;
    --text-tertiary: #5e5e5e;
    --border: var(--ink);
    --border-light: var(--ink);
    --primary: var(--acid);
    --primary-dark: #c7ef1e;
    --primary-light: #f0ff8a;
    --danger: var(--red);
    --success: var(--green);
    --warning: var(--orange);
    --shadow-hard: 4px 4px 0 var(--ink);
    --shadow-hard-sm: 2px 2px 0 var(--ink);
    --radius: 8px;
}

body {
    background:
        linear-gradient(90deg, rgba(17, 17, 17, 0.045) 1px, transparent 1px),
        linear-gradient(rgba(17, 17, 17, 0.045) 1px, transparent 1px),
        var(--paper);
    background-size: 28px 28px;
}

.top-nav {
    background: var(--surface);
    border-bottom: 3px solid var(--ink);
    box-shadow: 0 3px 0 var(--ink);
}

.logo-icon svg rect {
    fill: var(--acid);
    stroke: var(--ink);
    stroke-width: 2px;
}

.logo-icon svg path {
    stroke: var(--ink);
}

.page-header,
.form-section,
.table-card,
.modal-content {
    background: var(--surface);
    border: 3px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
}

.page-header {
    padding: 24px;
    margin: 32px 0 28px;
}

.section-number {
    background: var(--acid);
    color: var(--ink);
    border: 2px solid var(--ink);
    box-shadow: var(--shadow-hard-sm);
}

.btn {
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard-sm);
    color: var(--ink);
}

.btn:hover:not(:disabled) {
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 var(--ink);
}

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

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

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

.btn-ai {
    background: var(--pink);
    color: #ffffff;
}

.btn-add {
    background: #fff8d7;
    color: var(--ink);
    border: 2px dashed var(--ink);
}

.btn-remove,
.btn-close {
    border: 2px solid var(--ink);
    background: var(--surface);
    box-shadow: var(--shadow-hard-sm);
}

.form-input,
.form-select,
.form-textarea {
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard-sm);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: 3px solid var(--acid);
    border-color: var(--ink);
}

/* ============================================
   Final compact edit-page overrides
   Keep this block last so older theme rules cannot reintroduce heavy cards.
   ============================================ */

body {
    background: var(--paper) !important;
}

.page-header {
    display: none !important;
}

.top-nav {
    border-bottom: 1px solid var(--border-light) !important;
    box-shadow: none !important;
}

.main-content {
    max-width: 980px !important;
    padding-top: calc(var(--header-height) + 24px) !important;
}

.form-section {
    margin-bottom: 0 !important;
    padding: 18px 0 20px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--border-light) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.section-header {
    gap: 8px !important;
    margin-bottom: 12px !important;
    padding: 0 !important;
    border: 0 !important;
}

.section-header h2 {
    font-size: 16px !important;
}

.section-number {
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--text-tertiary) !important;
}

.table-card,
.mapping-row,
.radio-card,
.mapping-hint,
.mapping-toolbar,
.default-toolbar,
.default-value-row,
.ai-suggestion,
.advanced-options {
    padding: 10px 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.table-card-header {
    margin: 0 0 10px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    color: var(--text-primary) !important;
}

.table-icon,
.tables-divider .divider-arrow,
.mapping-arrow,
.ai-confidence {
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--text-tertiary) !important;
}

.form-input,
.form-select,
.form-textarea {
    border: 1px solid var(--border-light) !important;
    box-shadow: none !important;
    border-radius: 6px !important;
}

.btn,
.btn-primary,
.btn-secondary,
.btn-ai,
.btn-add,
.btn-close,
.btn-remove {
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
}

.btn-primary {
    background: #1f2937 !important;
    color: #ffffff !important;
}

.btn-ai {
    background: #374151 !important;
    color: #ffffff !important;
}

.btn-add,
.btn-secondary {
    background: #ffffff !important;
    color: var(--text-secondary) !important;
}

.default-values-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.default-value-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(260px, 1.4fr) auto;
    align-items: end;
    gap: 12px;
}

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

.mapping-target-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 10px;
    align-items: center;
    gap: 8px;
}

.type-mismatch-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #dc2626;
    opacity: 0;
}

.mapping-row.type-mismatch .type-mismatch-dot {
    opacity: 1;
}

@media (max-width: 768px) {
    .default-value-row {
        grid-template-columns: 1fr;
        align-items: stretch;
    }
}

/* Final form simplification: keep below all earlier theme blocks. */
:root {
    --acid: #1f2937;
    --primary: #1f2937;
    --primary-dark: #111827;
    --primary-light: #e5e7eb;
    --ink: #0f172a;
    --paper: #f6f7f9;
    --surface: #ffffff;
    --muted: #eef1f5;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --border-light: #d7dce3;
    --border: #c6ccd5;
}

body { background: var(--paper) !important; }
.page-header { display: none !important; }
.top-nav { border-bottom: 1px solid var(--border-light) !important; box-shadow: none !important; }
.logo-icon svg rect { fill: #1f2937 !important; stroke: #1f2937 !important; }
.logo-icon svg path { stroke: #ffffff !important; }
.main-content { max-width: 980px !important; padding-top: calc(var(--header-height) + 24px) !important; }
.form-section { margin-bottom: 0 !important; padding: 18px 0 20px !important; border: 0 !important; border-bottom: 1px solid var(--border-light) !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; }
.section-header { gap: 8px !important; margin-bottom: 12px !important; padding: 0 !important; border: 0 !important; }
.section-header h2 { font-size: 16px !important; }
.section-number { width: auto !important; height: auto !important; padding: 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; color: var(--text-tertiary) !important; }
.form-grid, .tables-grid, .radio-group { gap: 12px !important; }
.table-card, .mapping-row, .radio-card, .mapping-hint, .mapping-toolbar, .ai-suggestion, .advanced-options { padding: 10px 0 !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; }
.table-card-header { margin: 0 0 10px !important; padding: 0 !important; border: 0 !important; background: transparent !important; color: var(--text-primary) !important; }
.table-icon, .tables-divider .divider-arrow, .mapping-arrow, .ai-confidence { border: 0 !important; box-shadow: none !important; background: transparent !important; color: var(--text-tertiary) !important; }
.form-input, .form-select, .form-textarea { border: 1px solid var(--border-light) !important; box-shadow: none !important; border-radius: 6px !important; }
.btn, .btn-primary, .btn-secondary, .btn-ai, .btn-add, .btn-close, .btn-remove { border: 1px solid var(--border) !important; box-shadow: none !important; }
.btn-primary { background: #1f2937 !important; color: #ffffff !important; }
.btn-ai { background: #374151 !important; color: #ffffff !important; }
.btn-add, .btn-secondary { background: #ffffff !important; color: var(--text-secondary) !important; }
.mapping-toolbar { display: flex; align-items: center; border-bottom: 1px solid var(--border-light) !important; }
.radio-card:has(input:checked) { background: #eef1f5 !important; color: var(--text-primary) !important; }

/* ============================================
   Simplified task form sections
   ============================================ */

.form-section {
    padding: 22px;
    border: 2px solid var(--ink);
    box-shadow: 3px 3px 0 var(--ink);
}

.section-header {
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.section-number {
    width: 28px;
    height: 28px;
    box-shadow: none;
}

.table-card,
.mapping-row,
.radio-card,
.mapping-hint,
.mapping-toolbar,
.ai-suggestion {
    border: 1px solid var(--border-light);
    box-shadow: none;
    background: #ffffff;
}

.table-card {
    padding: 18px;
}

.table-card-header {
    margin: 0 0 18px;
    padding: 0 0 12px;
    border-bottom: 1px solid var(--border-light);
    background: transparent !important;
    color: var(--ink) !important;
}

.table-icon {
    border: 1px solid var(--border-light);
    box-shadow: none;
}

.mapping-toolbar {
    background: #fffdf3;
}

.mapping-row {
    padding: 14px;
}

.radio-card {
    padding: 14px 16px;
}

.form-input,
.form-select,
.form-textarea {
    box-shadow: none;
    border: 1px solid var(--border);
}

.btn,
.btn-close,
.btn-remove,
.ai-confidence {
    box-shadow: none;
}

.tables-divider .divider-arrow,
.mapping-arrow {
    box-shadow: none;
    border: 1px solid var(--border-light);
    background: var(--muted);
}

/* ============================================
   Minimal cleanup overrides
   ============================================ */

.page-header {
    display: none;
}

.main-content {
    padding-top: calc(var(--header-height) + 24px);
}

.nav-brand {
    color: inherit;
}

.form-section {
    border: 0;
    box-shadow: none;
    background: #ffffff;
    padding: 20px 0 24px;
    border-bottom: 1px solid var(--border-light);
    border-radius: 0;
}

.section-header {
    margin-bottom: 16px;
    padding-bottom: 0;
    border-bottom: 0;
}

.section-number {
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-light);
    box-shadow: none;
    background: var(--muted);
    color: var(--text-secondary);
}

.table-card,
.mapping-row,
.radio-card,
.mapping-hint,
.mapping-toolbar,
.ai-suggestion {
    border: 0;
    box-shadow: none;
    background: #fafafa;
}

.table-card,
.mapping-row,
.radio-card {
    padding: 14px;
}

.table-card-header {
    margin: 0 0 14px;
    padding: 0;
    border-bottom: 0;
}

.form-input,
.form-select,
.form-textarea {
    border: 1px solid var(--border-light);
    box-shadow: none;
}

.btn,
.btn-close,
.btn-remove {
    box-shadow: none;
}

/* ============================================
   Final form simplification
   ============================================ */

:root {
    --ink: #0f172a;
    --paper: #f6f7f9;
    --surface: #ffffff;
    --muted: #eef1f5;
    --acid: #1f2937;
    --primary: #1f2937;
    --primary-dark: #111827;
    --primary-light: #e5e7eb;
    --blue: #1e3a8a;
    --pink: #7f1d1d;
    --green: #166534;
    --red: #991b1b;
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-tertiary: #6b7280;
    --border-light: #d7dce3;
    --border: #c6ccd5;
}

body {
    background: var(--paper) !important;
}

.top-nav {
    border-bottom: 1px solid var(--border-light) !important;
    box-shadow: none !important;
}

.logo-icon svg rect {
    fill: #1f2937 !important;
    stroke: #1f2937 !important;
}

.logo-icon svg path {
    stroke: #ffffff !important;
}

.main-content {
    max-width: 980px !important;
}

.form-section {
    margin-bottom: 0 !important;
    padding: 18px 0 20px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--border-light) !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.section-header {
    gap: 8px !important;
    margin-bottom: 12px !important;
    padding: 0 !important;
    border: 0 !important;
}

.section-header h2 {
    font-size: 16px !important;
}

.section-number {
    width: auto !important;
    height: auto !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--text-tertiary) !important;
}

.form-grid,
.tables-grid,
.radio-group {
    gap: 12px !important;
}

.table-card,
.mapping-row,
.radio-card,
.mapping-hint,
.mapping-toolbar,
.ai-suggestion,
.advanced-options {
    padding: 10px 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
}

.table-card-header {
    margin: 0 0 10px !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    color: var(--text-primary) !important;
}

.table-icon,
.tables-divider .divider-arrow,
.mapping-arrow,
.ai-confidence {
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    color: var(--text-tertiary) !important;
}

.form-input,
.form-select,
.form-textarea {
    border: 1px solid var(--border-light) !important;
    box-shadow: none !important;
    border-radius: 6px !important;
}

.btn,
.btn-primary,
.btn-secondary,
.btn-ai,
.btn-add,
.btn-close,
.btn-remove {
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
}

.btn-primary {
    background: #1f2937 !important;
    color: #ffffff !important;
}

.btn-ai {
    background: #374151 !important;
    color: #ffffff !important;
}

.btn-add,
.btn-secondary {
    background: #ffffff !important;
    color: var(--text-secondary) !important;
}

.mapping-toolbar {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-light) !important;
}

.radio-card:has(input:checked) {
    background: #eef1f5 !important;
    color: var(--text-primary) !important;
}

.table-card {
    position: relative;
    overflow: hidden;
}

.table-card:first-child .table-card-header {
    background: var(--blue);
    color: #ffffff;
}

.table-card:last-child .table-card-header {
    background: var(--pink);
    color: #ffffff;
}

.table-card-header {
    margin: -28px -28px 24px;
    padding: 18px 28px;
    border-bottom: 3px solid var(--ink);
}

.table-icon {
    background: var(--surface);
    border: 2px solid var(--ink);
    border-radius: var(--radius);
}

.tables-divider .divider-arrow,
.mapping-arrow {
    background: var(--acid);
    border: 2px solid var(--ink);
    border-radius: 999px;
    box-shadow: var(--shadow-hard-sm);
    color: var(--ink);
}

.mapping-row,
.radio-card,
.mapping-hint,
.ai-suggestion {
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-hard-sm);
}

.radio-card:has(input:checked) {
    background: var(--acid);
}

.ai-confidence {
    background: var(--acid);
    border: 2px solid var(--ink);
    border-radius: 999px;
    color: var(--ink);
}

@media (max-width: 768px) {
    .top-nav {
        padding: 12px 16px;
    }

    .main-content {
        padding-left: 18px;
        padding-right: 18px;
    }

    .table-card-header {
        margin: -20px -20px 20px;
        padding: 16px 20px;
    }
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

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

a {
    color: inherit;
    text-decoration: none;
}

/* Top Navigation */
.top-nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.auth-status {
    color: var(--text-secondary);
    font-size: 13px;
    white-space: nowrap;
}

/* Main Content */
.main-content {
    padding-top: var(--header-height);
    max-width: 900px;
    margin: 0 auto;
    padding-left: 32px;
    padding-right: 32px;
    padding-bottom: 60px;
}

.page-header {
    padding: 40px 0 32px;
}

.page-header h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 8px;
}

.page-desc {
    font-size: 16px;
    color: var(--text-tertiary);
}

/* Form Section */
.form-section {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.section-number {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.section-header h2 {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
}

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

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

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

.btn-secondary {
    background: var(--gray-100);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background: var(--gray-200);
    color: var(--text-primary);
}

.btn-ai {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-size: 13px;
    padding: 8px 16px;
}

.btn-ai:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-add {
    background: transparent;
    color: var(--primary);
    border: 1px dashed var(--border);
    width: 100%;
    margin-top: 16px;
}

.btn-add:hover {
    background: var(--primary-light);
    border-color: var(--primary);
}

.mapping-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding: 12px 14px;
    background: #fff8d7;
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard-sm);
}

.mapping-summary {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
}

.mapping-summary.has-warning {
    color: var(--red);
}

.mapping-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

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

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

.btn-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius);
    cursor: pointer;
}

/* Form Fields */
.form-grid {
    display: grid;
    gap: 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-field-full {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.form-label-small {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-select {
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-primary);
    font-family: inherit;
    transition: all 0.2s;
}

.form-input:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-select {
    cursor: pointer;
}

.form-hint {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

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

.input-group {
    display: flex;
    gap: 10px;
}

.input-group .form-input {
    flex: 1;
}

/* Tables Grid */
.tables-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 24px;
    align-items: start;
}

.table-card {
    background: var(--gray-50);
    border-radius: var(--radius-md);
    padding: 24px;
    border: 1px solid var(--border-light);
}

.table-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.table-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.source-icon {
    background: var(--primary-light);
}

.target-icon {
    background: var(--success-light);
}

.table-card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.table-card-header p {
    font-size: 13px;
    color: var(--text-tertiary);
}

.tables-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    padding-top: 60px;
}

.divider-arrow {
    width: 40px;
    height: 40px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.table-detail {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    font-size: 14px;
}

.detail-label {
    color: var(--text-tertiary);
}

.detail-value {
    font-weight: 600;
    color: var(--text-primary);
}

/* Mapping */
.mapping-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--primary-light);
    border-radius: var(--radius);
    font-size: 13px;
    color: var(--primary-dark);
    margin-bottom: 16px;
}

.mapping-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mapping-list-header {
    display: grid;
    grid-template-columns: 1fr 50px 1fr 40px;
    gap: 12px;
    align-items: center;
    margin-bottom: 8px;
    padding: 0 12px;
    color: var(--text-tertiary);
    font-size: 12px;
    font-weight: 600;
}

.mapping-row {
    display: grid;
    grid-template-columns: 1fr 50px 1fr 40px;
    gap: 12px;
    align-items: center;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.mapping-field {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.mapping-field .form-select {
    padding: 10px 12px;
}

.mapping-field .form-select:disabled {
    background: var(--gray-100);
    cursor: not-allowed;
}

.mapping-arrow {
    text-align: center;
    font-size: 20px;
    color: var(--primary);
}

.btn-remove {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: var(--radius);
}

.btn-remove:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* Radio Group */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sync-rule-block {
    margin-bottom: 18px;
}

.sync-rule-label {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

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

.checkbox-line input {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

.radio-card {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
}

.radio-card:hover {
    background: var(--surface);
    border-color: var(--border);
}

.radio-card input[type="radio"] {
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: var(--primary);
}

.radio-card input[type="radio"]:checked + .radio-content {
    color: var(--primary);
}

.radio-card:has(input:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
}

.radio-title {
    font-weight: 600;
    font-size: 15px;
    margin-bottom: 4px;
}

.radio-desc {
    font-size: 13px;
    color: var(--text-tertiary);
}

/* Form Actions */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    padding-top: 32px;
    border-top: 1px solid var(--border-light);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-large {
    max-width: 800px;
}

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

.modal-header h3 {
    font-size: 20px;
    font-weight: 700;
}

.modal-subtitle {
    font-size: 14px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.modal-body {
    padding: 24px;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid var(--border-light);
    background: var(--gray-50);
}

/* AI Loading */
.ai-loading {
    text-align: center;
    padding: 60px 20px;
}

.ai-spinner {
    width: 60px;
    height: 60px;
    margin: 0 auto 24px;
    border: 4px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.ai-suggestions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ai-suggestion {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}

.ai-suggestion input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.ai-mapping-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-source,
.ai-target {
    font-weight: 600;
}

.ai-arrow {
    color: var(--primary);
}

.ai-confidence {
    font-size: 12px;
    color: var(--text-tertiary);
    padding: 4px 8px;
    background: var(--surface);
    border-radius: 4px;
}

/* Responsive */
@media (max-width: 768px) {
    .main-content {
        padding-left: 20px;
        padding-right: 20px;
    }

    .tables-grid {
        grid-template-columns: 1fr;
    }

    .tables-divider {
        padding-top: 0;
        transform: rotate(90deg);
    }

    .mapping-row {
        grid-template-columns: 1fr;
        gap: 12px;
    }

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

    .form-actions {
        flex-direction: column;
    }
}

/* ============================================
   Neo Brutalist Final Overrides
   Keep this block at the end of the file.
   ============================================ */

body {
    background:
        linear-gradient(90deg, rgba(17, 17, 17, 0.045) 1px, transparent 1px),
        linear-gradient(rgba(17, 17, 17, 0.045) 1px, transparent 1px),
        var(--paper);
    background-size: 28px 28px;
}

.top-nav {
    background: var(--surface);
    border-bottom: 3px solid var(--ink);
    box-shadow: 0 3px 0 var(--ink);
}

.page-header,
.form-section,
.table-card,
.modal-content {
    border: 3px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
    background: var(--surface);
}

.btn,
.section-number,
.form-input,
.form-select,
.form-textarea,
.mapping-row,
.radio-card,
.mapping-hint,
.ai-suggestion,
.btn-close,
.btn-remove {
    border: 2px solid var(--ink);
    box-shadow: var(--shadow-hard-sm);
}

.btn-primary,
.section-number,
.radio-card:has(input:checked) {
    background: var(--acid);
    color: var(--ink);
}

.btn-secondary,
.btn-close,
.btn-remove {
    background: var(--surface);
    color: var(--ink);
}

.btn-ai {
    background: var(--pink);
    color: #ffffff;
}

.btn-add {
    background: #fff8d7;
    color: var(--ink);
    border: 2px dashed var(--ink);
}

.table-card:first-child .table-card-header {
    background: var(--blue);
    color: #ffffff;
}

.table-card:last-child .table-card-header {
    background: var(--pink);
    color: #ffffff;
}

.table-card-header {
    border-bottom: 3px solid var(--ink);
}

.tables-divider .divider-arrow,
.mapping-arrow,
.ai-confidence {
    background: var(--acid);
    border: 2px solid var(--ink);
    color: var(--ink);
    box-shadow: var(--shadow-hard-sm);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: 3px solid var(--acid);
    border-color: var(--ink);
}

/* v0.3 sync-rule layout overrides. Keep after older theme overrides. */
.sync-rule-grid {
    display: grid !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 14px !important;
}

.edit-main,
.main-content:has(.sync-rule-grid) {
    max-width: 1180px !important;
}

.sync-rule-card {
    padding: 12px !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: none !important;
}

.sync-rule-options {
    display: grid !important;
    gap: 10px !important;
}

.sync-rule-card .sync-rule-label {
    margin: 0 0 10px !important;
    color: var(--text-primary) !important;
    font-size: 14px !important;
    font-weight: 700 !important;
}

.sync-rule-card .sync-option {
    min-height: 112px !important;
    padding: 14px !important;
    gap: 10px !important;
    background: var(--gray-50) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: none !important;
}

.sync-rule-card .sync-option:has(input:checked) {
    background: var(--ink) !important;
    border-color: var(--ink) !important;
    color: #ffffff !important;
}

.sync-rule-card .sync-option:has(input:checked) .radio-title,
.sync-rule-card .sync-option:has(input:checked) .radio-desc {
    color: #ffffff !important;
}

.sync-rule-card .sync-option:has(input:checked) .radio-desc {
    opacity: 0.72 !important;
}

.sync-rule-card .radio-title {
    color: inherit !important;
}

.sync-rule-card .radio-desc {
    line-height: 1.45 !important;
}

.sync-checkbox-option input[type="checkbox"] {
    width: 20px !important;
    height: 20px !important;
    margin-top: 2px !important;
    accent-color: var(--primary) !important;
}

.saving-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    background: rgba(17, 17, 17, 0.5);
    backdrop-filter: blur(3px);
}

.saving-overlay.active {
    display: flex;
}

.saving-panel {
    width: min(320px, calc(100vw - 40px));
    padding: 28px;
    text-align: center;
    background: var(--surface);
    border: 2px solid var(--ink);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hard);
}

.saving-spinner {
    width: 42px;
    height: 42px;
    margin: 0 auto 16px;
    border: 3px solid var(--border);
    border-top-color: var(--ink);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.saving-title {
    color: var(--text-primary);
    font-size: 17px;
    font-weight: 700;
}

.saving-desc {
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 13px;
}

.form-actions .btn.disabled {
    pointer-events: none;
    opacity: 0.65;
}

@media (max-width: 640px) {
    .sync-rule-grid {
        grid-template-columns: 1fr !important;
    }
}
