:root {
    --bg-color: #0b0f19;
    --card-bg: rgba(22, 28, 45, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-glow: rgba(79, 70, 229, 0.4);
    
    --success: #10b981;
    --success-bg: rgba(16, 185, 129, 0.12);
    --success-border: rgba(16, 185, 129, 0.25);
    
    --danger: #f43f5e;
    --danger-bg: rgba(244, 63, 94, 0.12);
    --danger-border: rgba(244, 63, 94, 0.25);

    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --warning-border: rgba(245, 158, 11, 0.25);
    
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    position: relative;
    overflow-x: hidden;
}

/* Background Glowing Orbs */
.background-glows {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.45;
}

.glow-1 {
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(79, 70, 229, 0.25) 0%, rgba(0,0,0,0) 70%);
    top: -10%;
    left: -10%;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.18) 0%, rgba(0,0,0,0) 70%);
    bottom: -5%;
    right: -5%;
}

/* Layout Container */
.app-container {
    width: 100%;
    max-width: 1100px;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Header */
.app-header {
    text-align: center;
    margin-bottom: 0.5rem;
    animation: fadeIn 0.8s ease-out;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.app-logo {
    width: 2.5rem;
    height: 2.5rem;
    color: #818cf8;
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.app-header h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 400;
    max-width: 600px;
    margin: 0 auto;
}

/* Cards (Glassmorphism) */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 2rem;
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 15px 35px -8px rgba(0, 0, 0, 0.6);
}

/* Collapsible Master List */
.collapsible-wrapper {
    display: flex;
    flex-direction: column;
}

.btn-collapse {
    background: transparent;
    border: none;
    color: var(--text-primary);
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.15rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0;
    font-family: inherit;
}

.btn-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-title svg {
    color: #818cf8;
}

.chevron {
    transition: transform var(--transition-normal);
    color: var(--text-secondary);
}

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

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-normal) cubic-bezier(0, 1, 0, 1), margin var(--transition-normal);
    margin-top: 0;
}

.collapsible-content.expanded {
    max-height: 1000px; /* arbitrary high value for auto height */
    transition: max-height var(--transition-normal) cubic-bezier(0.5, 0, 1, 0);
    margin-top: 1rem;
}

#master-chevron.rotated {
    transform: rotate(-180deg);
}

.section-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

/* Inputs & Textareas */
textarea {
    width: 100%;
    height: 160px;
    background: rgba(10, 12, 18, 0.6);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 1rem;
    color: var(--text-primary);
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

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

.master-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.75rem;
}

.status-msg {
    font-size: 0.85rem;
    font-weight: 500;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

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

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    outline: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--card-border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
    color: white;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(79, 70, 229, 0.6);
}

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

.divider {
    height: 1px;
    background: var(--card-border);
    margin: 1.75rem 0;
}

/* Upload Section */
.upload-section h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.upload-section h3 svg {
    color: #818cf8;
}

.dropzone {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    background: rgba(10, 12, 18, 0.4);
    cursor: pointer;
    position: relative;
    transition: all var(--transition-fast);
}

.dropzone:hover, .dropzone.dragover {
    border-color: var(--primary);
    background: rgba(79, 70, 229, 0.04);
}

.dropzone input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.dropzone-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    pointer-events: none;
}

.upload-icon {
    color: var(--text-secondary);
    transition: transform var(--transition-normal) cubic-bezier(0.175, 0.885, 0.32, 1.275), color var(--transition-fast);
}

.dropzone:hover .upload-icon, .dropzone.dragover .upload-icon {
    color: #818cf8;
    transform: translateY(-4px) scale(1.05);
}

.main-text {
    font-size: 0.95rem;
    font-weight: 500;
}

.browse-link {
    color: #818cf8;
    text-decoration: underline;
}

.sub-text {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* File Selected State */
.selected-file-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--card-border);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    max-width: 400px;
    margin: 0 auto;
    animation: zoomIn 0.3s ease;
}

.selected-file-info svg {
    color: #f43f5e;
}

.file-name {
    font-size: 0.9rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-remove-file {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 0.25rem;
    margin-left: auto;
    transition: color var(--transition-fast);
}

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

/* Threshold and Reconciliation Controls */
.controls-wrapper {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 1.75rem;
}

.control-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.control-group label span {
    color: #818cf8;
}

.slider-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.1);
    outline: none;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #818cf8;
    cursor: pointer;
    box-shadow: 0 0 8px var(--primary-glow);
    transition: transform 0.1s ease;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.btn-reconcile {
    width: 100%;
    padding: 0.9rem;
    font-size: 1rem;
}

/* Spinner */
.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Results Panel styling */
.results-panel {
    animation: slideUp 0.5s ease-out;
}

.results-header {
    margin-bottom: 1.5rem;
}

.results-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.table-container {
    overflow-x: auto;
    border-radius: 8px;
    background: rgba(10, 12, 18, 0.4);
    border: 1px solid var(--card-border);
}

/* DataTables Styling Overrides */
.dataTables_wrapper {
    padding: 1rem 0;
    color: var(--text-primary) !important;
}

table.dataTable {
    border-collapse: collapse !important;
    margin: 0.5rem 0 1.5rem 0 !important;
}

table.dataTable thead th {
    background-color: rgba(255, 255, 255, 0.02) !important;
    border-bottom: 1px solid var(--card-border) !important;
    color: var(--text-primary) !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 16px !important;
    text-align: left;
}

table.dataTable tbody td {
    border-bottom: 1px solid rgba(255, 255, 255, 0.03) !important;
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 12px 16px !important;
    vertical-align: middle;
}

/* Custom Row Color Coding */
table.dataTable tbody tr.row-matched {
    background-color: var(--success-bg) !important;
}

table.dataTable tbody tr.row-matched td {
    color: #a7f3d0;
}

table.dataTable tbody tr.row-matched td:first-child {
    border-left: 4px solid var(--success);
}

table.dataTable tbody tr.row-unmatched {
    background-color: var(--danger-bg) !important;
}

table.dataTable tbody tr.row-unmatched td {
    color: #fecdd3;
}

table.dataTable tbody tr.row-unmatched td:first-child {
    border-left: 4px solid var(--danger);
}

table.dataTable tbody tr.row-low-confidence {
    background-color: var(--warning-bg) !important;
}

table.dataTable tbody tr.row-low-confidence td {
    color: #fef3c7;
}

table.dataTable tbody tr.row-low-confidence td:first-child {
    border-left: 4px solid var(--warning);
}

table.dataTable.no-footer {
    border-bottom: 1px solid var(--card-border) !important;
}

/* DataTables Buttons (PDF Export) */
.dt-buttons {
    margin-bottom: 1.5rem !important;
    display: flex;
    justify-content: flex-end;
}

button.dt-button {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%) !important;
    border: none !important;
    color: white !important;
    font-family: inherit !important;
    font-weight: 600 !important;
    font-size: 0.85rem !important;
    padding: 0.5rem 1.25rem !important;
    border-radius: 6px !important;
    box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3) !important;
    transition: all var(--transition-fast) !important;
}

button.dt-button:hover:not(.disabled) {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 14px rgba(16, 185, 129, 0.45) !important;
    background: linear-gradient(135deg, #059669 0%, #047857 100%) !important;
}

/* DataTables search input & info */
.dataTables_filter {
    float: left !important;
    margin-bottom: 1rem !important;
    text-align: left !important;
}

.dataTables_filter label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.dataTables_filter input {
    background: rgba(10, 12, 18, 0.6) !important;
    border: 1px solid var(--card-border) !important;
    color: var(--text-primary) !important;
    border-radius: 6px !important;
    padding: 0.4rem 0.8rem !important;
    margin-left: 0.5rem !important;
    outline: none !important;
    font-family: inherit;
    font-size: 0.85rem;
}

.dataTables_filter input:focus {
    border-color: var(--primary) !important;
}

.dataTables_info {
    color: var(--text-muted) !important;
    font-size: 0.8rem !important;
    padding-top: 1rem !important;
}

.dataTables_paginate {
    padding-top: 1rem !important;
}

.dataTables_paginate .paginate_button {
    color: var(--text-secondary) !important;
    border: 1px solid transparent !important;
    border-radius: 4px !important;
    padding: 0.3rem 0.75rem !important;
    font-size: 0.8rem !important;
    transition: all var(--transition-fast);
}

.dataTables_paginate .paginate_button.current, .dataTables_paginate .paginate_button.current:hover {
    background: var(--primary) !important;
    border-color: var(--primary) !important;
    color: white !important;
}

.dataTables_paginate .paginate_button:hover {
    background: rgba(255, 255, 255, 0.05) !important;
    color: var(--text-primary) !important;
}

.score-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

.score-badge.high {
    background-color: var(--success-bg);
    border: 1px solid var(--success-border);
    color: #34d399;
}

.score-badge.low {
    background-color: var(--danger-bg);
    border: 1px solid var(--danger-border);
    color: #fb7185;
}

.score-badge.medium {
    background-color: var(--warning-bg);
    border: 1px solid var(--warning-border);
    color: #fbbf24;
}

.badge-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-status.matched {
    background-color: rgba(16, 185, 129, 0.15);
    color: #10b981;
}

.badge-status.unmatched {
    background-color: rgba(244, 63, 94, 0.15);
    color: #f43f5e;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

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

/* Footer styling */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-top: 1rem;
    margin-bottom: 2rem;
}
