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

:root {
    --accent: #0066ff;
    --accent-dark: #0052cc;
    --accent-glow: rgba(0, 102, 255, 0.15);
    --bg: #fafbfc;
    --card: #ffffff;
    --text: #0d1117;
    --text-secondary: #57606a;
    --text-muted: #8b949e;
    --border: #d1d9e0;
    --success: #1a7f37;
    --success-bg: #dafbe1;
    --warning: #9a6700;
    --warning-bg: #fff8c5;
    --danger: #cf222e;
    --danger-bg: #ffebe9;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(145deg, #f0f4ff 0%, var(--bg) 50%, #f0fff4 100%);
    background-attachment: fixed;
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 24px;
    line-height: 1.5;
}

main {
    width: 100%;
    max-width: 440px;
}

/* Upload Page */
.upload-container {
    background: var(--card);
    border-radius: 20px;
    padding: 44px 40px;
    text-align: center;
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.03),
        0 2px 4px rgba(0,0,0,0.02),
        0 12px 40px rgba(0,0,0,0.06);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.5px;
}

.logo span {
    color: var(--accent);
}

.tagline {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 40px;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 16px;
    padding: 48px 28px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    background: linear-gradient(180deg, var(--bg) 0%, var(--card) 100%);
}

.upload-zone:hover {
    border-color: var(--accent);
    background: var(--accent-glow);
}

.upload-zone.drag-over {
    border-color: var(--accent);
    background: var(--accent-glow);
    transform: scale(1.01);
}

.upload-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 20px;
    background: var(--accent);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}

.upload-icon svg {
    width: 26px;
    height: 26px;
}

.upload-text {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.upload-subtext {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.upload-zone input[type="file"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-name {
    margin-top: 18px;
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    min-height: 1.4rem;
}

.analyse-btn {
    margin-top: 20px;
    width: 100%;
    padding: 14px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    background: var(--accent);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.25);
}

.analyse-btn:hover:not(:disabled) {
    background: var(--accent-dark);
    box-shadow: 0 6px 16px rgba(0, 102, 255, 0.35);
    transform: translateY(-1px);
}

.analyse-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    box-shadow: none;
}

.footer-note {
    margin-top: 36px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Loading */
.htmx-indicator {
    display: none;
    margin-top: 32px;
}

.htmx-request .htmx-indicator {
    display: block;
}

.htmx-request #upload-form {
    opacity: 0.4;
    pointer-events: none;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 14px;
}

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

.htmx-indicator p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Results */
.results {
    background: var(--card);
    border-radius: 20px;
    padding: 36px;
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.03),
        0 2px 4px rgba(0,0,0,0.02),
        0 12px 40px rgba(0,0,0,0.06);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 20px;
    transition: color 0.15s;
}

.back-link:hover {
    color: var(--accent);
}

.back-link::before {
    content: "\2190";
}

.hero-cost {
    font-size: 3.25rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
    background: linear-gradient(135deg, var(--text) 0%, #374151 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-cost.cost-good { background: linear-gradient(135deg, #15803d 0%, #166534 100%); -webkit-background-clip: text; background-clip: text; }
.hero-cost.cost-average { background: linear-gradient(135deg, #a16207 0%, #854d0e 100%); -webkit-background-clip: text; background-clip: text; }
.hero-cost.cost-high { background: linear-gradient(135deg, #c2410c 0%, #9a3412 100%); -webkit-background-clip: text; background-clip: text; }
.hero-cost.cost-excessive { background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%); -webkit-background-clip: text; background-clip: text; }
.hero-cost.cost-neutral { background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%); -webkit-background-clip: text; background-clip: text; font-size: 2rem; letter-spacing: -0.5px; }

.hero-subtitle {
    display: block;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-top: 8px;
    margin-bottom: 20px;
}

.score-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 100px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 28px;
}

.score-badge::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.score-good { background: var(--success-bg); color: var(--success); }
.score-good::before { background: var(--success); }
.score-average { background: var(--warning-bg); color: var(--warning); }
.score-average::before { background: var(--warning); }
.score-high { background: #ffedd5; color: #c2410c; }
.score-high::before { background: #ea580c; }
.score-excessive { background: var(--danger-bg); color: var(--danger); }
.score-excessive::before { background: var(--danger); }
.score-neutral { background: #f3f4f6; color: #6b7280; }
.score-neutral::before { background: #9ca3af; }

.breakdown-section {
    background: var(--bg);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid rgba(0,0,0,0.04);
}

.lender-fees-note {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px dashed var(--border);
    font-size: 0.8rem;
    color: var(--text-muted);
    font-style: italic;
}

.breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.breakdown-table td {
    padding: 11px 0;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

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

.breakdown-table td:last-child {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    color: var(--text);
}

.breakdown-table .total-row td {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
    border-top: 2px solid var(--border);
    border-bottom: none;
    padding-top: 14px;
}

.rate-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    padding: 14px 16px;
    background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 100%);
    border-radius: 10px;
    font-weight: 500;
}

.rate-summary::before {
    content: "%";
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--accent);
    background: white;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.warnings {
    list-style: none;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.warning-item {
    font-size: 0.85rem;
    color: var(--warning);
    padding: 12px 14px 12px 42px;
    position: relative;
    background: var(--warning-bg);
    border-radius: 10px;
    font-weight: 500;
}

.warning-item::before {
    content: "!";
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background: white;
    color: var(--warning);
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.verdict {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    padding: 18px 20px;
    background: var(--bg);
    border-radius: 10px;
    border-left: 4px solid var(--accent);
    font-style: italic;
    line-height: 1.6;
}

.explanation {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.7;
}

.tips {
    margin-bottom: 20px;
    background: var(--success-bg);
    border-radius: 12px;
    padding: 18px 20px;
}

.tips-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--success);
    font-size: 0.8rem;
    margin-bottom: 14px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.tips-header::before {
    content: "\1F4A1";
    font-size: 1rem;
}

.tip-item {
    font-size: 0.85rem;
    color: #166534;
    padding: 6px 0 6px 24px;
    position: relative;
    list-style: none;
}

.tip-item::before {
    content: "\2713";
    position: absolute;
    left: 0;
    font-weight: 700;
    color: var(--success);
}

.disclaimer {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.error {
    text-align: center;
    padding: 48px 32px;
    background: var(--card);
    border-radius: 20px;
    box-shadow:
        0 0 0 1px rgba(0,0,0,0.03),
        0 12px 40px rgba(0,0,0,0.06);
}

.error p {
    color: var(--danger);
    font-size: 0.95rem;
    font-weight: 500;
}

@media (max-width: 480px) {
    body { padding: 16px; }
    .upload-container, .results { padding: 32px 24px; border-radius: 16px; }
    .hero-cost { font-size: 2.5rem; }
    .hero-cost.cost-neutral { font-size: 1.75rem; }
    .upload-zone { padding: 40px 20px; }
}
