:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --ink: #152126;
  --muted: #64747b;
  --line: #dbe3e6;
  --accent: #165d66;
  --accent-dark: #0e474f;
  --danger: #9d2e2e;
  --success: #256b46;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); line-height: 1.5; }
a { color: inherit; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; text-decoration: none; }
nav { display: flex; align-items: center; gap: 22px; }
nav a, .link-button { color: var(--muted); text-decoration: none; font: inherit; }
.link-button { border: 0; background: none; padding: 0; cursor: pointer; }
.shell { width: min(1120px, calc(100% - 32px)); margin: 0 auto; padding: 44px 0 72px; }
footer { color: var(--muted); text-align: center; padding: 24px; font-size: .82rem; }
.hero { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 26px; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -.025em; }
h1 { font-size: clamp(2rem, 4vw, 3.3rem); max-width: 850px; }
h2 { font-size: 1.35rem; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: .72rem; font-weight: 800; letter-spacing: .13em; }
.muted, .hint { color: var(--muted); }
.hint { font-size: .82rem; margin-bottom: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; box-shadow: 0 8px 28px rgba(27, 50, 57, .045); }
.narrow { max-width: 520px; }
.login-card { margin: 8vh auto; padding: 34px; }
.login-card h1 { font-size: 2rem; }
.stack { display: grid; gap: 16px; margin-top: 22px; }
label { display: grid; gap: 7px; font-size: .88rem; font-weight: 650; }
input { width: 100%; border: 1px solid #b9c6ca; border-radius: 9px; background: #fff; padding: 11px 12px; color: var(--ink); font: inherit; }
input:focus { outline: 2px solid rgba(22, 93, 102, .2); border-color: var(--accent); }
button, .button { border-radius: 9px; padding: 10px 15px; font: inherit; font-weight: 750; cursor: pointer; text-decoration: none; display: inline-flex; justify-content: center; align-items: center; }
.primary { border: 1px solid var(--accent); background: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-dark); }
.secondary { border: 1px solid var(--line); background: var(--surface); }
.danger { border: 1px solid #e1b8b8; background: #fff7f7; color: var(--danger); }
.upload-card { margin-bottom: 38px; }
.upload-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: end; margin-top: 16px; }
.file-field input { padding: 8px; }
.section-heading { display: flex; justify-content: space-between; align-items: end; margin: 34px 0 14px; }
.count { color: var(--muted); }
.job-list { display: grid; gap: 9px; }
.job-row { display: flex; justify-content: space-between; gap: 18px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 16px 18px; text-decoration: none; }
.job-row:hover { border-color: #a9b9bd; box-shadow: 0 6px 18px rgba(27,50,57,.05); }
.job-main { min-width: 0; display: grid; gap: 3px; }
.job-main strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-main span, .job-meta { color: var(--muted); font-size: .82rem; }
.job-meta { display: flex; align-items: center; gap: 12px; white-space: nowrap; }
.status { display: inline-flex; align-items: center; border-radius: 999px; padding: 4px 9px; font-size: .73rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; background: #eef2f3; }
.status.complete { background: #e8f4ed; color: var(--success); }
.status.failed { background: #faeaea; color: var(--danger); }
.status.processing { background: #e9f3f5; color: var(--accent); }
.status.large { padding: 7px 12px; }
.job-header { display: flex; justify-content: space-between; align-items: start; gap: 24px; margin-bottom: 24px; }
.back { display: inline-block; color: var(--muted); font-size: .85rem; text-decoration: none; margin-bottom: 28px; }
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 18px 0 28px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: 16px; display: grid; gap: 4px; }
.metric span { color: var(--muted); font-size: .78rem; }
.metric strong { font-size: 1.35rem; }
.table-wrap { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .055em; background: #fafcfc; }
tr:last-child td { border-bottom: 0; }
.alert { border-radius: 10px; padding: 13px 15px; margin: 16px 0; }
.alert.error { border: 1px solid #e5b8b8; background: #fff5f5; color: #7c2626; }
.alert.success { border: 1px solid #b8dac7; background: #f1faf5; color: #245b3d; }
.processing { display: flex; align-items: center; gap: 18px; }
.spinner { width: 25px; height: 25px; border: 3px solid #dce7e9; border-top-color: var(--accent); border-radius: 50%; }
.diagnostics ul { margin-bottom: 0; padding-left: 20px; }
.diagnostics li { margin: 6px 0; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 26px; }
.inline { display: inline; margin: 0; }
.empty { color: var(--muted); text-align: center; padding: 36px; }
@media (max-width: 760px) {
  .topbar { padding: 0 16px; }
  .shell { width: min(100% - 22px, 1120px); padding-top: 28px; }
  nav { gap: 12px; font-size: .86rem; }
  .upload-form { grid-template-columns: 1fr; }
  .job-row { align-items: flex-start; flex-direction: column; }
  .job-meta { flex-wrap: wrap; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .job-header { flex-direction: column; }
}
@media (prefers-reduced-motion: no-preference) {
  .spinner { animation: spin .8s linear infinite; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.hero.compact { align-items: start; background: linear-gradient(135deg,#edf5f5,#fff); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.hero.compact h2 { font-size: 1.55rem; margin-bottom: 8px; }
.recommendation-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 12px; }
.rec-card { display: grid; gap: 10px; }
.rec-top { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.tag { font-size: .68rem; text-transform: uppercase; font-weight: 800; letter-spacing: .06em; color: var(--accent); }
.page-ref { color: var(--muted); font-size: .78rem; }
.rec-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -.025em; }
.source-excerpt { margin: 0; color: #43545b; font-size: .86rem; }
.recommendation-stack { display: grid; gap: 10px; }
.engine-rec { padding: 0; overflow: hidden; }
.engine-rec summary { cursor: pointer; list-style: none; padding: 17px 20px; display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.engine-rec summary::-webkit-details-marker { display: none; }
.engine-rec summary span:first-child { display: grid; gap: 3px; }
.engine-rec summary small { color: var(--muted); font-weight: 500; }
.rec-body { border-top: 1px solid var(--line); padding: 18px 20px; }
.rec-body h4 { margin-bottom: 6px; }
.rec-body ul { margin-top: 4px; padding-left: 20px; }
.disposition { font-size: .7rem; padding: 5px 8px; border-radius: 999px; background: #eef2f3; white-space: nowrap; }
.disposition.calculated_recommendation { background: #e8f4ed; color: var(--success); }
.disposition.insufficient_evidence, .disposition.requires_engineering_judgment { background: #fff3d9; color: #745600; }
.disposition.unsupported_method { background: #f2eef8; color: #5e4379; }
.output-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.output-chips span { border: 1px solid var(--line); background: #f8fbfb; border-radius: 8px; padding: 7px 9px; font-size: .79rem; }
.assessment { font-weight: 750; }

.criteria-form { display: grid; gap: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 12px; }
.compact-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
select { width: 100%; border: 1px solid #b9c6ca; border-radius: 9px; background: #fff; padding: 11px 12px; color: var(--ink); font: inherit; }
.check-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px 18px; }
.check-grid label { display: flex; align-items: center; gap: 8px; font-weight: 550; }
.check-grid input { width: auto; }
.criteria-note { border-left: 3px solid var(--accent); background: #f1f7f7; padding: 10px 12px; color: #41545a; font-size: .82rem; }
.profile-card { padding: 0; margin-bottom: 10px; overflow: hidden; }
.profile-card summary { cursor: pointer; padding: 15px 18px; display: flex; justify-content: space-between; gap: 15px; }
.profile-card > .table-wrap { border-top: 1px solid var(--line); }
.diagnostic-list { padding: 0 30px 14px; font-size: .82rem; }
.diagnostic-list .warning { color: #725700; }
.diagnostic-list .error { color: var(--danger); }
@media (max-width: 900px) {
  .recommendation-grid { grid-template-columns: 1fr; }
  .form-grid, .compact-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
}
@media (max-width: 560px) {
  .form-grid, .compact-grid, .check-grid { grid-template-columns: 1fr; }
  .engine-rec summary { align-items: flex-start; flex-direction: column; }
}

.source-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.source-link:hover { text-decoration: underline; }
.audit-detail { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfc; }
.audit-detail > summary { cursor: pointer; padding: 11px 13px; font-weight: 750; color: var(--accent-dark); }
.audit-body { border-top: 1px solid var(--line); padding: 12px 14px; }
.calc-step { padding: 12px 0; border-bottom: 1px solid var(--line); }
.calc-step:last-child { border-bottom: 0; }
.calc-step h4 { margin: 0 0 7px; font-size: .94rem; }
.equation { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; background: #f0f4f5; border-radius: 7px; padding: 8px 10px; overflow-x: auto; font-size: .82rem; }
.term-list { display: grid; gap: 4px; margin-top: 9px; font-size: .82rem; }
.term-list > strong { color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-size: .7rem; }
.calc-source { margin-top: 9px; color: var(--muted); font-size: .76rem; }
.fact-list { display: grid; gap: 9px; max-height: 420px; overflow: auto; }
.fact-list > div { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.fact-list p { margin: 5px 0 0; color: var(--muted); font-size: .82rem; }
.fact-basis { margin-left: 8px; color: var(--accent); font-size: .7rem; text-transform: uppercase; letter-spacing: .04em; }
