/* CSS Variables */
:root {
    --bg-primary: #0a0a0b;
    --bg-secondary: #111113;
    --bg-tertiary: #18181b;
    --bg-hover: #1f1f23;
    --border-color: #27272a;
    --border-subtle: #1e1e21;
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-subtle: rgba(59, 130, 246, 0.1);
    --success: #22c55e;
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --font-sans: 'Outfit', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Consolas, monospace;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.login-overlay[hidden] {
    display: none;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-md);
}

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

.login-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    padding: 0.75rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

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

.login-error {
    padding: 0.75rem 1rem;
    background: var(--error-bg);
    border: 1px solid var(--error);
    border-radius: var(--radius-sm);
    color: var(--error);
    font-size: 0.875rem;
    text-align: center;
}

.login-error[hidden] {
    display: none;
}

.login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    margin-top: 0.5rem;
}

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

.login-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-btn .btn-text[hidden],
.login-btn .btn-loader[hidden] {
    display: none;
}

.login-btn .btn-loader {
    display: inline-flex;
    align-items: center;
}

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

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

/* Layout */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    font-weight: 300;
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-section label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

textarea {
    width: 100%;
    min-height: 200px;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: 1.7;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea::placeholder {
    color: var(--text-muted);
}

textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.input-footer-left {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.upload-section {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.upload-section .secondary-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.upload-section .secondary-btn svg {
    flex-shrink: 0;
}

.file-name {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-name::before {
    content: "📄 ";
}

.char-count {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Buttons */
.primary-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

.primary-btn:active:not(:disabled) {
    transform: scale(0.98);
}

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

.secondary-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.secondary-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.success-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.success-btn:hover:not(:disabled) {
    background: #16a34a;
}

.success-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.success-btn .btn-text[hidden],
.success-btn .btn-loader[hidden] {
    display: none;
}

.success-btn .btn-loader {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

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

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

.btn-text,
.btn-loader {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-text[hidden],
.btn-loader[hidden] {
    display: none;
}

/* Error Section */
.error-section {
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.error-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--error-bg);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    color: var(--error);
}

.error-icon {
    font-size: 1.2rem;
}

/* Results Section */
.results-section {
    animation: fadeIn 0.4s ease;
}

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

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

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    height: 28px;
    padding: 0 0.5rem;
    background: var(--accent-subtle);
    color: var(--accent);
    border-radius: 999px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
}

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

/* Table */
.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th {
    text-align: left;
    padding: 0.875rem 1rem;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-hover);
}

td a {
    color: var(--accent);
    text-decoration: none;
}

td a:hover {
    text-decoration: underline;
}

td.invalid {
    color: var(--error);
}

td.empty {
    color: var(--text-muted);
    font-style: italic;
}

/* Editable cells */
td.editable-cell {
    padding: 0.5rem;
}

.cell-input {
    width: 100%;
    padding: 0.375rem 0.5rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    transition: all 0.15s;
}

.cell-input:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.cell-input:focus {
    outline: none;
    background: var(--bg-tertiary);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.cell-input::placeholder {
    color: var(--text-muted);
    font-style: italic;
}

.cell-select {
    width: 100%;
    padding: 0.375rem 0.5rem;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    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='%23a1a1aa' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    padding-right: 1.5rem;
}

.cell-select:hover {
    background-color: var(--bg-tertiary);
    border-color: var(--border-color);
}

.cell-select:focus {
    outline: none;
    background-color: var(--bg-tertiary);
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.cell-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* Category badges */
.category-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: var(--font-sans);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.category-participant {
    background: rgba(34, 197, 94, 0.15);
    color: #4ade80;
}

.category-community {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
}

.category-provider {
    background: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
}

.category-unknown {
    background: rgba(113, 113, 122, 0.15);
    color: var(--text-muted);
}

/* Push result message */
.push-result {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    animation: fadeIn 0.3s ease;
}

.push-result.success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid var(--success);
    color: var(--success);
}

.push-result.error {
    background: var(--error-bg);
    border: 1px solid var(--error);
    color: var(--error);
}

.push-result .result-stats {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.push-result .stat {
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.push-result .stat-label {
    color: var(--text-secondary);
    margin-right: 0.5rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.25rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease;
    z-index: 1000;
}

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

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }
    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

/* Footer */
footer {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-subtle);
    text-align: center;
}

footer p {
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

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

.modal-content h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.duplicate-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.duplicate-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}

.duplicate-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
}

.duplicate-info {
    flex: 1;
}

.duplicate-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

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

.duplicate-match span {
    color: var(--error);
    font-weight: 500;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        padding: 2rem 1rem;
    }

    h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .input-footer {
        flex-direction: column;
        gap: 1rem;
        align-items: stretch;
    }

    .input-footer-left {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .upload-section {
        flex-wrap: wrap;
    }

    .file-name {
        max-width: 150px;
    }

    .primary-btn {
        justify-content: center;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    th, td {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
}

