:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1a2332;
    --muted: #5c6b7f;
    --border: #dde3ec;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #059669;
    --danger: #dc2626;
    --warning-bg: #fff7ed;
    --warning-border: #fdba74;
    --radius: 12px;
    --shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.25rem 4rem;
}

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

.header h1 {
    margin: 0 0 0.5rem;
    font-size: 1.85rem;
    font-weight: 700;
}

.subtitle {
    margin: 0;
    color: var(--muted);
}

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 2rem;
}

.form-section {
    margin-bottom: 1.75rem;
}

.form-section h2 {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.radio-group-stacked {
    flex-direction: column;
    align-items: stretch;
}

.radio-group-stacked .radio-label {
    width: 100%;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.radio-label:has(input:checked) {
    border-color: var(--primary);
    background: #eff6ff;
}

.radio-label input {
    accent-color: var(--primary);
}

input[type="text"] {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
}

.file-upload input[type="file"] {
    display: none;
}

.file-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border: 2px dashed var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.file-label:hover {
    border-color: var(--primary);
    background: #f8fafc;
}

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

.hint {
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
    color: var(--muted);
}

.btn-primary,
.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn-primary {
    width: 100%;
    background: var(--primary);
    color: #fff;
}

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

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

.btn-secondary {
    background: var(--success);
    color: #fff;
}

.btn-secondary:hover {
    background: #047857;
}

.btn-spinner {
    width: 1.1rem;
    height: 1.1rem;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.results {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat {
    text-align: center;
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.stat-matched .stat-value {
    color: var(--success);
}

.stat-unmatched .stat-value {
    color: var(--danger);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--muted);
}

.unmatched-panel {
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: 8px;
}

.unmatched-panel h3 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
}

.unmatched-panel ul {
    margin: 0;
    padding-left: 1.25rem;
    font-size: 0.9rem;
}

.table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.table-toolbar h2 {
    margin: 0;
    font-size: 1.1rem;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    white-space: nowrap;
}

thead {
    background: #f1f5f9;
    position: sticky;
    top: 0;
}

th,
td {
    padding: 0.6rem 0.85rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

tbody tr:hover {
    background: #f8fafc;
}

tbody tr.unmatched-row {
    background: #fef2f2;
}

.year-input {
    width: 5.5rem;
    padding: 0.35rem 0.5rem;
    border: 2px solid var(--warning-border);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: #fff;
}

.title-input {
    min-width: 12rem;
    width: 100%;
    max-width: 20rem;
    padding: 0.35rem 0.5rem;
    border: 2px solid var(--warning-border);
    border-radius: 6px;
    font-size: 0.875rem;
    font-family: inherit;
    background: #fff;
}

.year-input:focus,
.title-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.unmatched-panel .hint {
    margin: 0 0 0.75rem;
}

.error-banner {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--danger);
    color: #fff;
    padding: 0.85rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow);
    max-width: 90%;
    z-index: 100;
}

@media (max-width: 640px) {
    .stats-bar {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 1.25rem;
    }
}
