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

:root {
    --color-bg: #f8f9fa;
    --color-surface: #ffffff;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-text: #1f2937;
    --color-text-muted: #6b7280;
    --color-border: #e5e7eb;
    --color-error: #dc2626;
    --color-error-bg: #fef2f2;
    --color-success: #059669;
    --color-table-stripe: #f9fafb;
    --color-table-header: #f3f4f6;
    --radius: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    font-size: 15px;
}

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

.report-container {
    max-width: 1200px;
}

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

header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--color-text-muted);
    font-size: 1rem;
}

/* === Forms === */
.form-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.form-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

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

.form-group label {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--color-text);
}

.form-group input {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.hint {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.btn-primary {
    display: block;
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

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

.btn-primary:disabled {
    background: var(--color-text-muted);
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--color-surface);
    color: var(--color-primary);
    border: 1px solid var(--color-primary);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: rgba(37, 99, 235, 0.05);
}

/* === Error === */
.error-banner {
    background: var(--color-error-bg);
    color: var(--color-error);
    border: 1px solid var(--color-error);
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* === Loading === */
.loading {
    text-align: center;
    padding: 2rem;
}

.loading p {
    color: var(--color-text-muted);
    margin-top: 1rem;
}

.hidden {
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}

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

/* === Report Navigation === */
.report-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.report-source {
    margin-left: auto;
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

/* === Report Content === */
.report-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.report-content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2rem 0 1rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--color-primary);
}

.report-content h1:first-child {
    margin-top: 0;
}

.report-content h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 1.75rem 0 0.75rem 0;
    color: var(--color-text);
}

.report-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.25rem 0 0.5rem 0;
}

.report-content p {
    margin-bottom: 0.75rem;
}

.report-content strong {
    font-weight: 600;
}

.report-content hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: 2rem 0;
}

.report-content ul, .report-content ol {
    margin: 0.5rem 0 1rem 1.5rem;
}

.report-content li {
    margin-bottom: 0.25rem;
}

/* === Tables === */
.report-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
    font-size: 0.8rem;
    overflow-x: auto;
    display: block;
}

.report-content thead {
    display: table-header-group;
}

.report-content tbody {
    display: table-row-group;
}

.report-content tr {
    display: table-row;
}

.report-content th, .report-content td {
    display: table-cell;
    padding: 0.5rem 0.75rem;
    text-align: left;
    border: 1px solid var(--color-border);
    white-space: nowrap;
}

.report-content th {
    background: var(--color-table-header);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    position: sticky;
    top: 0;
}

.report-content tbody tr:nth-child(even) {
    background: var(--color-table-stripe);
}

.report-content tbody tr:hover {
    background: rgba(37, 99, 235, 0.04);
}

/* === Report Footer === */
.report-footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--color-text-muted);
}

.report-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
}

.report-footer a:hover {
    text-decoration: underline;
}

/* === Privacy Notice === */
.privacy-notice {
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    margin-top: 1rem;
}

/* === Feedback Section === */
.feedback-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.5rem 2rem;
    margin-top: 2rem;
    box-shadow: var(--shadow);
}

.feedback-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}

.rating-options {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.rating-option {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: border-color 0.15s, background 0.15s;
}

.rating-option:hover {
    border-color: var(--color-primary);
    background: rgba(37, 99, 235, 0.04);
}

.rating-option input[type="radio"]:checked + span {
    color: var(--color-primary);
    font-weight: 600;
}

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

.feedback-section textarea,
.feedback-section input[type="email"] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color 0.15s;
}

.feedback-section textarea:focus,
.feedback-section input[type="email"]:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.feedback-section .btn-primary {
    margin-top: 0.5rem;
}

/* === Intro Section === */
.intro-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-primary);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

.intro-section p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
}

.intro-section p:last-child {
    margin-bottom: 0;
}

.intro-sign-off {
    font-weight: 600;
    font-style: italic;
}

/* === Help Icon & Modal === */
.help-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    cursor: pointer;
    margin-left: 0.35rem;
    vertical-align: middle;
    line-height: 1;
}

.help-icon:hover {
    background: var(--color-primary-hover);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-overlay.hidden {
    display: none;
}

.modal-content {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 90vw;
    max-height: 90vh;
    position: relative;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-content img {
    max-width: 100%;
    max-height: 75vh;
    display: block;
    border-radius: var(--radius);
}

.modal-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.75rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--color-text-muted);
    cursor: pointer;
    line-height: 1;
    padding: 0.25rem;
}

.modal-close:hover {
    color: var(--color-text);
}

/* === Print === */
@media print {
    body {
        background: white;
        font-size: 11pt;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .report-nav, .report-footer, .feedback-section, .modal-overlay, .btn-secondary {
        display: none;
    }

    .report-content {
        border: none;
        box-shadow: none;
        padding: 0;
    }

    .report-content table {
        font-size: 8pt;
    }

    .report-content h1 {
        break-after: avoid;
    }

    .report-content table {
        break-inside: avoid;
    }
}

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

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

    .report-nav {
        flex-wrap: wrap;
    }

    .report-source {
        margin-left: 0;
        width: 100%;
    }
}
