:root {
    --bg: #0f1419;
    --surface: #1a2332;
    --surface2: #243044;
    --border: #2d3a4f;
    --text: #e8edf4;
    --muted: #8b9cb3;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --accent: #10b981;
    --accent-hover: #059669;
    --danger: #ef4444;
    --radius: 10px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.brand {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text);
    text-decoration: none;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, opacity 0.15s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-accent {
    background: var(--accent);
    color: #fff;
    width: 100%;
    margin-top: 0.75rem;
    padding: 0.85rem;
}

.btn-accent:hover:not(:disabled) {
    background: var(--accent-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--surface2);
    color: var(--text);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.input {
    width: 100%;
    padding: 0.7rem 1rem;
    margin-top: 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
}

.input:focus {
    outline: none;
    border-color: var(--primary);
}

.hidden {
    display: none !important;
}

.message {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.message.error {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.message.success {
    background: rgba(16, 185, 129, 0.15);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Auth */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.auth-card h1 {
    font-size: 1.75rem;
    margin-bottom: 0.25rem;
}

.subtitle {
    color: var(--muted);
    margin-bottom: 1.5rem;
}

.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.tab {
    flex: 1;
    padding: 0.6rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    cursor: pointer;
    font-weight: 600;
}

.tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.auth-form label {
    display: block;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.auth-form input {
    width: 100%;
    padding: 0.7rem 1rem;
    margin-top: 0.35rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 1rem;
}

.auth-form button {
    margin-top: 1.5rem;
}

/* Dashboard */
.dashboard {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.panel h2 {
    font-size: 1.2rem;
}

.hint {
    color: var(--muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.upload-btn {
    cursor: pointer;
}

.documents-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.doc-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s;
}

.doc-item.selected {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.08);
}

.doc-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.doc-info {
    flex: 1;
    min-width: 0;
}

.doc-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-meta {
    font-size: 0.8rem;
    color: var(--muted);
}

.doc-delete {
    background: none;
    border: none;
    color: var(--danger);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
}

.doc-delete:hover {
    text-decoration: underline;
}

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 2rem;
}

.upload-progress, .loading-state {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    color: var(--muted);
}

.spinner {
    width: 22px;
    height: 22px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.quiz-history {
    list-style: none;
}

.quiz-history li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    gap: 1rem;
}

.quiz-history li:last-child {
    border-bottom: none;
}

.quiz-history span {
    color: var(--muted);
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Quiz page */
.quiz-page {
    max-width: 720px;
    margin: 0 auto;
    padding: 2rem;
}

.quiz-header {
    margin-bottom: 2rem;
}

.quiz-header h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.quiz-progress {
    color: var(--muted);
    font-size: 0.9rem;
}

.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.question-type {
    display: inline-block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent);
    background: rgba(16, 185, 129, 0.12);
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    margin-bottom: 0.75rem;
}

.question-text {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.answers {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.answer-option {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.answer-option:hover {
    border-color: var(--primary);
}

.answer-option.selected {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.answer-option.correct {
    border-color: var(--accent);
    background: rgba(16, 185, 129, 0.12);
}

.answer-option.wrong {
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.answer-option input {
    margin-top: 0.2rem;
    accent-color: var(--primary);
}

.quiz-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
}

.quiz-result {
    text-align: center;
    padding: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.result-score {
    font-size: 3rem;
    font-weight: 800;
    color: var(--accent);
}

.result-label {
    color: var(--muted);
    margin: 0.5rem 0 1.5rem;
}

@media (max-width: 600px) {
    .navbar, .dashboard, .quiz-page {
        padding: 1rem;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .quiz-history li {
        flex-direction: column;
        align-items: flex-start;
    }
}
