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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
    background: #0a0f1c;
    color: #e0e6ed;
    min-height: 100vh;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

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

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}

.header-row h1 {
    font-size: 2.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #4ade80, #22d3ee);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.3rem;
}

header h1 {
    font-size: 2.4rem;
    font-weight: 700;
    background: linear-gradient(135deg, #4ade80, #22d3ee);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 0.3rem;
}

.subtitle {
    color: #7a8ba8;
    font-size: 1rem;
}

.user-info {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
}

.user-email {
    font-size: 0.85rem;
    color: #94a3b8;
}

.logout-link {
    font-size: 0.8rem;
    color: #4ade80;
    text-decoration: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.logout-link:hover {
    text-decoration: underline;
}

/* Rate limit banner */
.rate-limit-banner {
    background: #1c1a0a;
    border: 1px solid #854d0e;
    color: #fbbf24;
    padding: 0.8rem 1.2rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Auth styles */
.auth-card {
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 2rem;
    max-width: 420px;
    margin: 0 auto 2rem;
}

.auth-card h2 {
    font-size: 1.3rem;
    margin-bottom: 1.2rem;
    color: #e0e6ed;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-group input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: #1e293b;
    border: 2px solid #2d3a4f;
    border-radius: 8px;
    color: #e0e6ed;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus {
    border-color: #4ade80;
}

.form-hint {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.3rem;
    display: block;
}

.auth-btn {
    width: 100%;
    padding: 0.9rem;
    background: linear-gradient(135deg, #059669, #0d9488);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.auth-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.4);
}

.verify-info {
    color: #94a3b8;
    font-size: 0.9rem;
    margin-bottom: 1.2rem;
}

.verify-info strong {
    color: #e0e6ed;
}

.code-input {
    text-align: center;
    font-size: 1.8rem !important;
    font-weight: 700;
    letter-spacing: 12px;
    font-family: 'Courier New', monospace;
}

.resend-form {
    text-align: center;
    margin-top: 0.8rem;
}

.resend-btn {
    background: none;
    border: none;
    color: #4ade80;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0.4rem;
}

.resend-btn:hover {
    text-decoration: underline;
}

.auth-switch {
    margin-top: 1.2rem;
    font-size: 0.85rem;
    color: #7a8ba8;
    text-align: center;
}

.auth-switch a {
    color: #4ade80;
    text-decoration: none;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Flash messages */
.flash {
    padding: 0.7rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.flash-error {
    background: #1c0a0a;
    border: 1px solid #7f1d1d;
    color: #fca5a5;
}

.flash-success {
    background: #0a1c0a;
    border: 1px solid #166534;
    color: #86efac;
}

.flash-warning {
    background: #1c1a0a;
    border: 1px solid #854d0e;
    color: #fbbf24;
}

/* Sample reports */
.sample-reports {
    margin-bottom: 2rem;
}

.sample-reports-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.sample-reports-header h2 {
    font-size: 1.3rem;
    color: #e0e6ed;
}

.sample-reports-note {
    color: #7a8ba8;
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.outdated-badge {
    background: #854d0e;
    color: #fbbf24;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.outdated-badge-sm {
    background: #422006;
    color: #fbbf24;
    padding: 0.15rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

.sample-report-card {
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 12px;
    margin-bottom: 0.8rem;
    overflow: hidden;
}

.sample-report-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.2rem;
    cursor: pointer;
}

.sample-report-meta {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}

.sample-report-meta h3 {
    font-size: 1rem;
    color: #e0e6ed;
}

.expand-sample-btn {
    background: none;
    border: none;
    color: #64748b;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.3rem;
    transition: color 0.2s;
}

.expand-sample-btn:hover {
    color: #4ade80;
}

.chevron {
    display: inline-block;
    transition: transform 0.2s;
}

.sample-report-body {
    padding: 0 1.2rem 1.2rem;
    border-top: 1px solid #1e293b;
}

.sample-report-body .summary-content {
    line-height: 1.7;
    color: #cbd5e1;
    font-size: 0.9rem;
    white-space: pre-wrap;
    margin-bottom: 1rem;
}

.sample-papers h4 {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.sample-paper {
    padding: 0.5rem 0;
    border-bottom: 1px solid #1e293b;
}

.sample-paper:last-child {
    border-bottom: none;
}

.sample-paper-title {
    display: block;
    font-size: 0.85rem;
    color: #e0e6ed;
    font-weight: 500;
    margin-bottom: 0.2rem;
}

/* Sample page nav */
.sample-nav {
    margin-bottom: 1.5rem;
}

.back-link {
    color: #4ade80;
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    text-decoration: underline;
}

.sample-picker {
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.sample-picker label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

/* Layman intro */
.layman-intro {
    background: #0d2818;
    border: 1px solid #166534;
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.2rem;
    font-size: 0.92rem;
    line-height: 1.6;
    color: #bbf7d0;
}

.layman-intro strong {
    color: #4ade80;
}

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

@media (max-width: 600px) {
    .mode-grid {
        grid-template-columns: 1fr;
    }
}

/* Report formatting */
.report-heading {
    color: #4ade80;
    font-size: 1.05rem;
    font-weight: 700;
    margin: 1.3rem 0 0.6rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid #1e293b;
}

.report-subheading {
    color: #22d3ee;
    font-size: 0.95rem;
    font-weight: 600;
    margin: 1rem 0 0.4rem;
}

.summary-content p {
    margin-bottom: 0.4rem;
}

.summary-content .list-item {
    padding-left: 0.5rem;
    margin-bottom: 0.3rem;
}

.summary-content .bullet-item {
    padding-left: 1rem;
    margin-bottom: 0.3rem;
}

/* Evidence table */
.evidence-table-wrap {
    overflow-x: auto;
    margin: 0.8rem 0 1rem;
    border-radius: 8px;
    border: 1px solid #1e293b;
}

.evidence-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.evidence-table th,
.evidence-table td {
    padding: 0.6rem 0.8rem;
    text-align: left;
    border-bottom: 1px solid #1e293b;
}

.evidence-table .table-header th {
    background: #1e293b;
    color: #4ade80;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.04em;
}

.evidence-table td {
    color: #cbd5e1;
}

.evidence-table tr:hover td {
    background: #111827;
}

.conf-high {
    color: #4ade80;
    font-weight: 600;
}

.conf-med {
    color: #fbbf24;
    font-weight: 600;
}

.conf-low {
    color: #f87171;
    font-weight: 600;
}

/* Citation count badge */
.cite-count {
    color: #fbbf24;
    font-weight: 600;
}

/* Dropdown row */
.dropdown-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 700px) {
    .dropdown-row {
        grid-template-columns: 1fr;
    }
}

.form-select {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: #1e293b;
    border: 2px solid #2d3a4f;
    border-radius: 8px;
    color: #e0e6ed;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.2s;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.5rem;
}

.form-select:focus {
    border-color: #4ade80;
}

.form-select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.form-select option {
    background: #1e293b;
    color: #e0e6ed;
}

/* Controls */
.controls {
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 1.8rem;
    margin-bottom: 2rem;
}

.control-group {
    margin-bottom: 1.5rem;
}

.control-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 0.75rem;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.6rem;
}

.select-btn {
    background: #1e293b;
    border: 2px solid #2d3a4f;
    border-radius: 8px;
    padding: 0.7rem 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    color: #e0e6ed;
}

.select-btn:hover:not(:disabled) {
    border-color: #4ade80;
    background: #1a2636;
}

.select-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.select-btn.active {
    border-color: #4ade80;
    background: #0d2818;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.15);
}

.btn-label {
    display: block;
    font-weight: 600;
    font-size: 0.95rem;
}

.btn-sub {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    font-style: italic;
    margin-top: 2px;
}

.select-btn.active .btn-sub {
    color: #4ade80;
}

.search-btn {
    width: 100%;
    padding: 0.9rem;
    background: linear-gradient(135deg, #059669, #0d9488);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 0.5rem;
}

.search-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.4);
}

.search-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

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

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

/* Results */
.results {
    animation: fadeIn 0.3s ease;
}

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

.results-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.results-header h2 {
    font-size: 1.3rem;
    color: #e0e6ed;
}

.badge {
    background: #059669;
    color: white;
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.summary-section {
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.summary-section h3 {
    font-size: 1rem;
    color: #4ade80;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.summary-content {
    line-height: 1.7;
    color: #cbd5e1;
    font-size: 0.95rem;
    white-space: pre-wrap;
}

.articles-section h3 {
    font-size: 1rem;
    color: #22d3ee;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.article-card {
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 10px;
    padding: 1.2rem;
    margin-bottom: 0.8rem;
    transition: border-color 0.2s;
}

.article-card:hover {
    border-color: #334155;
}

.article-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.article-title a {
    color: #e0e6ed;
    text-decoration: none;
}

.article-title a:hover {
    color: #4ade80;
}

.article-meta {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.6rem;
}

.article-abstract {
    font-size: 0.85rem;
    color: #94a3b8;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-abstract.expanded {
    -webkit-line-clamp: unset;
}

.expand-btn {
    background: none;
    border: none;
    color: #4ade80;
    cursor: pointer;
    font-size: 0.8rem;
    padding: 0.3rem 0;
    margin-top: 0.3rem;
}

.error {
    background: #1c0a0a;
    border: 1px solid #7f1d1d;
    color: #fca5a5;
    padding: 1rem 1.5rem;
    border-radius: 10px;
    margin-top: 1rem;
}

.no-results-notice {
    background: #0a1c14;
    border: 1px solid #065f46;
    color: #6ee7b7;
    padding: 1.2rem 1.5rem;
    border-radius: 10px;
    margin-top: 1rem;
    line-height: 1.6;
}

.no-results-notice strong {
    color: #a7f3d0;
    display: block;
    margin-bottom: 0.3rem;
    font-size: 1.05rem;
}

.no-results-notice .no-results-hint {
    color: #86efac;
    font-size: 0.9rem;
    margin-top: 0.4rem;
    opacity: 0.85;
}

/* Figures */
.figures-section {
    margin-bottom: 1.5rem;
}

.figures-section h3 {
    font-size: 1rem;
    color: #22d3ee;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.figure-block {
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    overflow-x: auto;
}

.figure-header {
    font-size: 0.95rem;
    font-weight: 700;
    color: #4ade80;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #1e293b;
}

.figure-svg {
    text-align: center;
}

.figure-svg svg {
    max-width: 100%;
    height: auto;
    background: #ffffff;
    border-radius: 8px;
}

/* Download button */
.download-btn {
    display: block;
    width: 100%;
    margin-top: 1.5rem;
    padding: 0.8rem 1.2rem;
    background: linear-gradient(135deg, #1a5276, #117a65);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.download-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(26, 82, 118, 0.4);
}

.download-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

/* Confirmation modal */
.confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.confirm-overlay.visible {
    opacity: 1;
}

.confirm-modal {
    background: #111827;
    border: 1px solid #2d3a4f;
    border-radius: 14px;
    padding: 2rem;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.confirm-overlay.visible .confirm-modal {
    transform: scale(1);
}

.confirm-modal h3 {
    font-size: 1.2rem;
    color: #e0e6ed;
    margin-bottom: 0.4rem;
}

.confirm-note {
    font-size: 0.85rem;
    color: #fbbf24;
    margin-bottom: 1.2rem;
}

.confirm-details {
    background: #0a0f1c;
    border: 1px solid #1e293b;
    border-radius: 8px;
    padding: 0.8rem 1rem;
    margin-bottom: 1.5rem;
}

.confirm-row {
    display: flex;
    justify-content: space-between;
    padding: 0.45rem 0;
    border-bottom: 1px solid #1e293b;
}

.confirm-row:last-child {
    border-bottom: none;
}

.confirm-label {
    font-size: 0.8rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.confirm-value {
    font-size: 0.9rem;
    color: #e0e6ed;
    font-weight: 600;
}

.confirm-actions {
    display: flex;
    gap: 0.8rem;
}

.confirm-cancel {
    flex: 1;
    padding: 0.75rem;
    background: #1e293b;
    border: 2px solid #2d3a4f;
    border-radius: 8px;
    color: #94a3b8;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.confirm-cancel:hover {
    border-color: #64748b;
    color: #e0e6ed;
}

.confirm-go {
    flex: 1;
    padding: 0.75rem;
    background: linear-gradient(135deg, #059669, #0d9488);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.confirm-go:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(5, 150, 105, 0.4);
}

@media (max-width: 600px) {
    .button-grid {
        grid-template-columns: 1fr 1fr;
    }
    header h1, .header-row h1 {
        font-size: 1.8rem;
    }
    .header-row {
        flex-direction: column;
        text-align: center;
        gap: 0.8rem;
    }
    .user-info {
        align-items: center;
    }
    .sample-report-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }
}

/* ---------- Legal pages ---------- */

.legal-card {
    background: #111827;
    border: 1px solid #1e293b;
    border-radius: 12px;
    padding: 2rem 2.5rem;
    max-width: 720px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

.legal-card h2 {
    color: #4ade80;
    font-size: 1.05rem;
    margin-top: 1.8rem;
    margin-bottom: 0.5rem;
}

.legal-card h2:first-of-type {
    margin-top: 0.5rem;
}

.legal-card p {
    color: #cbd5e1;
    font-size: 0.92rem;
    margin-bottom: 0.6rem;
}

.legal-card ul {
    margin: 0.5rem 0 0.8rem 1.5rem;
    color: #cbd5e1;
    font-size: 0.92rem;
}

.legal-card li {
    margin-bottom: 0.35rem;
}

.legal-card a {
    color: #4ade80;
    text-decoration: none;
}

.legal-card a:hover {
    text-decoration: underline;
}

.legal-updated {
    color: #64748b !important;
    font-size: 0.82rem !important;
    font-style: italic;
    margin-bottom: 1rem !important;
}

.legal-nav {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #1e293b;
    display: flex;
    gap: 1.5rem;
}

.legal-footer {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.8rem;
}

.legal-footer a {
    color: #64748b;
    text-decoration: none;
    margin: 0 0.5rem;
}

.legal-footer a:hover {
    color: #94a3b8;
}
