:root {
    --blue-950: #082f49;
    --blue-900: #0b3c5d;
    --blue-700: #075985;
    --blue-100: #e0f2fe;
    --blue-50: #f0f9ff;
    --ink: #17212b;
    --muted: #5f6b76;
    --line: #dbe4ea;
    --surface: #ffffff;
    --background: #f4f7f9;
    --good: #137a4b;
    --good-bg: #e8f7ef;
    --warn: #9a5b00;
    --warn-bg: #fff5d9;
    --bad: #b42318;
    --bad-bg: #fff0ee;
    --radius: 14px;
    --shadow: 0 10px 30px rgba(8, 47, 73, .08);
}

* { box-sizing: border-box; }

html { color-scheme: light; }

body {
    margin: 0;
    background: var(--background);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 16px;
    line-height: 1.55;
}

a { color: var(--blue-700); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--blue-950); }

h1, h2, h3, h4 { color: var(--blue-950); line-height: 1.2; margin-top: 0; }
h1 { font-size: clamp(1.9rem, 4vw, 2.8rem); letter-spacing: -.035em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.08rem; margin-top: 1.8rem; }
h4 { font-size: .98rem; margin: 1.25rem 0 .5rem; }

.container { width: min(1220px, calc(100% - 36px)); margin-inline: auto; }
.page { min-height: calc(100vh - 145px); padding-block: 42px 64px; }
.narrow { max-width: 720px; margin-inline: auto; }
.lead { color: var(--muted); font-size: 1.08rem; }
.eyebrow { color: var(--blue-700); font-size: .75rem; font-weight: 800; letter-spacing: .13em; margin: 0 0 .45rem; text-transform: uppercase; }
.help, small { color: var(--muted); font-size: .83rem; }

.site-header { background: var(--blue-950); color: #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, .15); }
.header-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { color: #fff; font-size: 1.05rem; font-weight: 800; text-decoration: none; }
.brand span { display: block; color: #b9dced; font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.site-header nav { display: flex; align-items: center; gap: 17px; }
.site-header nav > a, .site-header .link-button { color: #e7f6ff; font-size: .9rem; text-decoration: none; }
.site-header .user { color: #a9ccdd; font-size: .82rem; }

.site-footer { border-top: 1px solid var(--line); color: var(--muted); padding: 22px 0; font-size: .82rem; }

.panel, .report-section, .summary-card, .explanation-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel { padding: clamp(22px, 4vw, 38px); }

.button {
    appearance: none;
    background: var(--blue-700);
    border: 1px solid var(--blue-700);
    border-radius: 9px;
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font: inherit;
    font-size: .92rem;
    font-weight: 750;
    line-height: 1;
    min-height: 43px;
    padding: 0 18px;
    text-decoration: none;
}
.button:hover { background: var(--blue-950); border-color: var(--blue-950); color: #fff; }
.button:disabled { cursor: not-allowed; opacity: .5; }
.button-secondary { background: #fff; border-color: var(--line); color: var(--blue-900); }
.button-secondary:hover { background: var(--blue-50); color: var(--blue-950); }
.button-small { min-height: 34px; padding-inline: 13px; }
.button-full { width: 100%; }
.link-button { appearance: none; background: transparent; border: 0; cursor: pointer; font: inherit; padding: 0; text-decoration: underline; text-underline-offset: 3px; }
.link-button.danger { color: var(--bad); }
.inline-form { display: inline-flex; margin: 0; }

.alert { border: 1px solid; border-radius: 9px; margin: 0 0 22px; padding: 13px 15px; }
.alert-success { background: var(--good-bg); border-color: #a6dec0; color: #075d36; }
.alert-error { background: var(--bad-bg); border-color: #efb0aa; color: #8d1c12; }
.alert-info { background: var(--blue-50); border-color: #a6d9ef; color: var(--blue-900); }

label { color: var(--blue-950); display: grid; font-size: .88rem; font-weight: 720; gap: 7px; }
input, select, textarea {
    background: #fff;
    border: 1px solid #b9c8d2;
    border-radius: 9px;
    color: var(--ink);
    font: inherit;
    min-height: 44px;
    padding: 9px 11px;
    width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue-700); box-shadow: 0 0 0 3px rgba(7, 89, 133, .13); outline: 0; }
fieldset { border: 1px solid var(--line); border-radius: 11px; display: grid; gap: 16px; margin: 0; padding: 20px; }
legend { color: var(--blue-950); font-weight: 800; padding-inline: 7px; }

.installer-body { background: linear-gradient(145deg, #edf7fb 0%, #f7f9fb 45%, #e9f1f5 100%); }
.installer { margin-inline: auto; max-width: 850px; }
.installer h2 { border-top: 1px solid var(--line); margin-top: 28px; padding-top: 25px; }
.form-grid { display: grid; gap: 22px; }
.requirements { display: grid; gap: 5px; list-style: none; padding: 0; }
.requirements li span { display: inline-grid; border-radius: 50%; color: #fff; font-weight: 900; height: 22px; margin-right: 7px; place-items: center; width: 22px; }
.requirements .ok span { background: var(--good); }
.requirements .bad span { background: var(--bad); }

.login-shell { display: grid; min-height: calc(100vh - 130px); place-items: center; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 20px 60px rgba(8, 47, 73, .14); max-width: 430px; padding: 42px; width: 100%; }
.login-card h1 { margin-bottom: .2rem; }
.stacked-form { display: grid; gap: 18px; margin-top: 28px; }

.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 25px; margin-bottom: 28px; }
.page-heading h1 { margin-bottom: .25rem; }
.page-heading p:last-child { margin-bottom: 0; }
.upload-form { display: grid; gap: 25px; }
.file-drop { background: var(--blue-50); border: 2px dashed #8ec8e2; border-radius: 13px; padding: 25px; }
.form-columns { display: grid; gap: 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.check { align-items: center; display: flex; gap: 10px; }
.check input { min-height: 20px; width: 20px; }
.privacy-note { background: #f8fafc; border-left: 4px solid var(--blue-700); padding: 13px 16px; }

.billing-grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 22px; }
.wallet-card h2 { margin-bottom: 6px; }
.wallet-balance { color: var(--good); font-size: 2.2rem; font-weight: 850; letter-spacing: -.04em; }
.compact-form { border-top: 1px solid var(--line); gap: 13px; margin-top: 20px; padding-top: 20px; }
.admin-section { margin-top: 22px; }
.billing-settings { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.billing-settings .form-submit { align-items: end; display: flex; grid-column: 1 / -1; }
.admin-section table input { min-width: 125px; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; min-width: 700px; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 13px 12px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
td { font-size: .9rem; }
td small { display: block; margin-top: 5px; }
tbody tr:last-child td { border-bottom: 0; }
.jobs-table .actions { display: flex; gap: 14px; white-space: nowrap; }
.status, .badge { border-radius: 999px; display: inline-block; font-size: .72rem; font-weight: 800; line-height: 1.2; padding: 5px 9px; white-space: nowrap; }
.status-queued, .badge-neutral { background: #eef2f5; color: #44515b; }
.status-processing { background: var(--blue-100); color: var(--blue-900); }
.status-completed, .badge-good { background: var(--good-bg); color: var(--good); }
.status-failed, .badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.empty-state { text-align: center; }

.job-state { margin-inline: auto; max-width: 760px; text-align: center; }
.spinner { animation: spin 1s linear infinite; border: 5px solid var(--blue-100); border-radius: 50%; border-top-color: var(--blue-700); height: 54px; margin: 0 auto 22px; width: 54px; }
.spinner.is-stopped { animation: none; border-color: var(--bad-bg); border-top-color: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }

.report-toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 28px; }
.report-title { margin-bottom: 28px; }
.report-title h1 { margin-bottom: .45rem; max-width: 950px; }
.report-meta { color: var(--muted); font-size: .82rem; }
.report-layout { display: grid; gap: 26px; grid-template-columns: minmax(0, 1fr) 330px; }
.report-main { display: grid; gap: 22px; min-width: 0; }
.report-section { padding: clamp(22px, 3vw, 32px); }
.report-section > h2 { border-bottom: 2px solid var(--blue-100); margin-bottom: 22px; padding-bottom: 12px; }
.report-aside { align-self: start; display: grid; gap: 18px; position: sticky; top: 22px; }
.summary-card, .explanation-card { padding: 24px; }
.score-number { color: var(--blue-950); font-size: 3rem; font-weight: 850; letter-spacing: -.06em; line-height: 1; }
.score-number span { color: var(--muted); font-size: .95rem; letter-spacing: 0; margin-left: 3px; }
.score-band { color: var(--blue-700); font-weight: 800; margin: 5px 0 20px; }
.summary-row { border-top: 1px solid var(--line); display: grid; gap: 2px; padding: 10px 0; }
.summary-row span { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.summary-row strong { font-size: .9rem; }
.summary-card hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0 20px; }
.summary-card h2, .explanation-card h2 { font-size: 1rem; margin-bottom: 8px; }
.recommendation { color: var(--blue-950); font-size: 1.07rem; font-weight: 800; }
.explanation-card p { font-size: .83rem; margin: 5px 0; }

.definition-grid { display: grid; gap: 0 20px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.definition-grid > div { border-bottom: 1px solid var(--line); padding: 11px 0; }
.definition-grid dt { color: var(--muted); font-size: .72rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.definition-grid dd { margin: 3px 0 0; }
.metric-strip { display: grid; gap: 8px; grid-template-columns: repeat(5, 1fr); }
.metric-strip > div { background: #f5f8fa; border-radius: 9px; display: grid; padding: 12px; text-align: center; }
.metric-strip strong { color: var(--blue-950); font-size: 1.3rem; }
.metric-strip span { color: var(--muted); font-size: .7rem; }
.metric-strip .accent { background: var(--blue-950); }
.metric-strip .accent strong, .metric-strip .accent span { color: #fff; }
.judgment { border-top: 1px solid var(--line); padding-top: 5px; }
.judgment:first-of-type { border-top: 0; }
.judgment-head { align-items: center; display: flex; justify-content: space-between; gap: 12px; }
.large-badge { background: var(--blue-100); border-radius: 999px; color: var(--blue-900); font-size: .82rem; font-weight: 800; padding: 6px 10px; }
.confidence { color: var(--muted); font-size: .83rem; }
.finding { background: #f8fafb; border-left: 3px solid #a9c5d4; margin: 12px 0; padding: 13px 15px; }
.finding p:last-child { margin-bottom: 0; }
.evidence { list-style: none; margin: 9px 0; padding: 0; }
.evidence li { display: grid; gap: 3px; margin: 7px 0; }
.evidence span { color: var(--blue-700); font-size: .75rem; font-weight: 750; }
.evidence q { color: #3b4852; font-size: .84rem; font-style: italic; }
.plain-list { padding-left: 20px; }
.warning-box { background: var(--warn-bg); border: 1px solid #e8c979; border-radius: 9px; color: #694000; padding: 15px; }
.score-banner { background: var(--blue-950); border-radius: 12px; color: #fff; display: grid; grid-template-columns: repeat(2, 1fr); margin-bottom: 22px; padding: 20px; }
.score-banner div { display: grid; }
.score-banner span { color: #b9dced; font-size: .75rem; text-transform: uppercase; }
.score-banner strong { font-size: 1.5rem; }
.recommendation-box { background: var(--blue-50); border: 1px solid #b9ddeb; border-radius: 11px; margin-top: 22px; padding: 20px; }
.prose p { margin: 0 0 1rem; }
.letter { border-left: 4px solid var(--blue-700); padding-left: 20px; }

@media (max-width: 940px) {
    .report-layout { grid-template-columns: 1fr; }
    .report-aside { grid-row: 1; position: static; }
    .summary-card { display: block; }
}

@media (max-width: 700px) {
    .container { width: min(100% - 24px, 1220px); }
    .page { padding-block: 26px 42px; }
    .header-inner, .page-heading { align-items: flex-start; flex-direction: column; }
    .header-inner { padding-block: 14px; }
    .site-header nav { flex-wrap: wrap; gap: 12px; }
    .form-columns, .options, .definition-grid, .billing-settings { grid-template-columns: 1fr; }
    .metric-strip { grid-template-columns: repeat(2, 1fr); }
    .metric-strip .accent { grid-column: 1 / -1; }
    .login-card { padding: 28px 22px; }
    .panel, .report-section { padding: 20px; }
}

@media print {
    @page { margin: 15mm; size: A4; }
    body { background: #fff; color: #111; font-size: 10pt; }
    .no-print { display: none !important; }
    .container { max-width: none; width: 100%; }
    .page { padding: 0; }
    .report-title { margin-bottom: 14px; }
    .report-title h1 { font-size: 20pt; }
    .report-layout { display: flex; flex-direction: column; }
    .report-aside { order: -1; position: static; }
    .summary-card { box-shadow: none; break-inside: avoid; }
    .explanation-card { display: none; }
    .report-main { display: block; }
    .report-section { border: 0; border-radius: 0; box-shadow: none; break-inside: auto; margin-top: 14px; padding: 0; }
    .report-section > h2 { font-size: 14pt; margin-bottom: 8px; padding-bottom: 6px; }
    h3 { font-size: 11pt; }
    table { min-width: 0; }
    th, td { font-size: 8pt; padding: 6px; }
    tr, .finding, .judgment, .metric-strip, .score-banner { break-inside: avoid; }
    .definition-grid { grid-template-columns: repeat(2, 1fr); }
    .summary-card, .warning-box, .finding, .recommendation-box { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
