:root {
  --ink: #172326;
  --muted: #627176;
  --line: #d9e0df;
  --surface: #ffffff;
  --canvas: #f4f6f4;
  --brand: #174f47;
  --brand-dark: #0f3934;
  --accent: #d9f28a;
  --danger: #9f2f2f;
  --warning: #8b5a09;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(16, 51, 47, 0.07);
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--canvas); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
a { color: var(--brand); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--brand-dark); }
button, input, select, textarea { font: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 3px solid #98bd32; outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 99; background: #fff; padding: 8px 12px; }
.skip-link:focus { left: 8px; }
.site-header { min-height: 72px; padding: 12px clamp(18px, 4vw, 52px); display: flex; align-items: center; gap: 30px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 800; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: white; background: var(--brand); }
nav { display: flex; gap: 20px; }
nav a { color: var(--muted); font-weight: 650; text-decoration: none; }
.account { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: .88rem; }
.page-shell { width: min(1500px, calc(100% - 36px)); margin: 0 auto; padding: 42px 0 70px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 30px; margin-bottom: 28px; }
.page-heading h1 { margin: 3px 0 7px; font-size: clamp(2rem, 4vw, 3.35rem); line-height: 1.05; letter-spacing: -.04em; }
.page-heading h2, .panel h2 { margin: 0; font-size: 1.08rem; }
.eyebrow { margin: 0; color: var(--brand); font-size: .75rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.lede { margin: 0; max-width: 720px; color: var(--muted); font-size: 1.06rem; }
.muted, .help { color: var(--muted); }
.help { margin: 4px 0 0; font-size: .82rem; }
.danger { color: var(--danger) !important; }
.messages { display: grid; gap: 8px; margin-bottom: 20px; }
.message { padding: 12px 15px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.message-success { border-color: #8ac5a0; background: #eefaf2; }
.message-error { border-color: #e0a2a2; background: #fff1f1; }
.panel { padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-large { min-width: 0; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 18px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 15px; border: 1px solid transparent; border-radius: 10px; cursor: pointer; font-weight: 750; text-decoration: none; }
.button-primary { color: #fff; background: var(--brand); }
.button-primary:hover { color: #fff; background: var(--brand-dark); }
.button-secondary { color: var(--brand); border-color: #aebeba; background: #fff; }
.button-danger { color: #fff; background: var(--danger); }
.button-danger:hover { color: #fff; background: #762121; }
.button-quiet { min-height: 34px; padding: 5px 10px; color: var(--muted); border-color: transparent; background: transparent; }
.button-wide { width: 100%; }
button:disabled { opacity: .45; cursor: not-allowed; }
.dashboard-grid, .tab-grid, .editor-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, .8fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }
.project-list, .question-list { margin: 0 -22px -22px; }
.project-row, .question-row { display: grid; align-items: center; gap: 18px; padding: 17px 22px; color: var(--ink); border-top: 1px solid var(--line); text-decoration: none; }
.project-row { grid-template-columns: minmax(220px, 1fr) auto; }
.project-row > div:first-child, .question-copy { display: grid; gap: 3px; }
.project-row span, .question-copy span, .clean-list span { color: var(--muted); font-size: .86rem; }
.project-row:hover, .question-row:hover { background: #f7faf8; }
.project-metrics { display: flex; align-items: center; gap: 20px; }
.status, .answer-state { display: inline-flex; width: fit-content; padding: 4px 8px; border-radius: 999px; color: #33504c; background: #e4efec; font-size: .76rem; font-weight: 800; white-space: nowrap; }
.confidence { display: inline-flex; width: fit-content; padding: 4px 8px; border: 1px solid #c6d4d1; border-radius: 999px; color: #33504c; background: #fff; font-size: .76rem; font-weight: 800; white-space: nowrap; }
.confidence-strong { color: #14633b; border-color: #8ac5a0; background: #eefaf2; }
.confidence-medium, .confidence-weak { color: #7a4d08; border-color: #eed39c; background: #fff8e8; }
.confidence-conflict { color: #8b2828; border-color: #e0a2a2; background: #fff1f1; }
.status-review, .state-in_review { color: #684e09; background: #fff3ca; }
.status-submitted, .state-approved { color: #14633b; background: #dbf4e4; }
.status-no_bid, .status-withdrawn, .state-rejected, .state-conflict { color: #8b2828; background: #fde5e5; }
.state-needs_information, .state-needs_evidence, .state-changes_requested { color: #7a4d08; background: #fff0d2; }
.state-empty { color: #5e676a; background: #edf0f0; }
.clean-list, .source-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 13px; }
.clean-list li { display: grid; gap: 2px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.clean-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.empty-state { padding: 70px 20px; text-align: center; }
.empty-state.compact { padding: 40px 20px; }
.empty-state h2, .empty-state h3 { margin-bottom: 5px; }
.auth-card { width: min(470px, 100%); margin: 5vh auto; padding: 36px; background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
.auth-brand { display: grid; justify-items: center; gap: 14px; margin-bottom: 28px; text-align: center; }
.auth-logo { display: block; width: 132px; height: auto; }
.auth-card h1 { margin: 0; font-size: 2.2rem; }
.divider { display: flex; align-items: center; gap: 10px; margin: 24px 0; color: var(--muted); font-size: .8rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.form-stack { display: grid; gap: 16px; }
.compact-form { margin-top: 18px; gap: 9px; }
.field { display: grid; gap: 5px; }
label { font-size: .85rem; font-weight: 750; }
input, select, textarea { width: 100%; padding: 10px 11px; color: var(--ink); border: 1px solid #b9c5c2; border-radius: 9px; background: #fff; }
input[type="checkbox"] { width: auto; }
textarea { resize: vertical; }
.errorlist { margin: 3px 0; color: var(--danger); font-size: .85rem; }
.actions { display: flex; gap: 10px; }
.narrow { width: min(760px, 100%); margin: 0 auto; }
.breadcrumbs { display: flex; gap: 8px; margin-bottom: 20px; color: var(--muted); font-size: .86rem; }
.heading-status { display: flex; align-items: center; gap: 12px; }
.project-heading { align-items: end; }
.deadline-card { display: grid; gap: 3px; min-width: 230px; padding: 14px 16px; border-left: 3px solid var(--accent); background: #fff; }
.deadline-card span { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; }
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.metric-strip div { display: grid; gap: 2px; padding: 17px 20px; border-right: 1px solid var(--line); }
.metric-strip div:last-child { border-right: 0; }
.metric-strip strong { font-size: 1.35rem; }
.metric-strip span { color: var(--muted); font-size: .8rem; }
.question-row { grid-template-columns: 70px minmax(0, 1fr) auto; }
.question-id { font-family: ui-monospace, monospace; color: var(--brand); font-weight: 800; }
.callout { padding: 12px 14px; margin: 0 0 15px; border-radius: 9px; font-size: .88rem; }
.callout-warning { color: var(--warning); border: 1px solid #eed39c; background: #fff8e8; }
.callout-info { color: #285a67; border: 1px solid #b9dce4; background: #eef9fb; }
.callout-success { color: #14633b; border: 1px solid #8ac5a0; background: #eefaf2; }
.readiness-panel { margin-bottom: 20px; }
.readiness-state { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: .76rem; font-weight: 800; }
.readiness-ready { color: #14633b; background: #dbf4e4; }
.readiness-blocked { color: #7a4d08; background: #fff0d2; }
.readiness-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.readiness-check { display: flex; gap: 10px; min-height: 72px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; }
.readiness-check > span { display: grid; place-items: center; flex: 0 0 24px; width: 24px; height: 24px; border-radius: 50%; font-weight: 900; }
.readiness-check div { display: grid; align-content: start; gap: 3px; }
.readiness-check small { color: var(--muted); }
.check-pass > span { color: #14633b; background: #dbf4e4; }
.check-fail > span { color: #8b4d08; background: #fff0d2; }
.three-column { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 20px; align-items: start; }
.inline-form { display: inline; }
.link-button { padding: 0; color: var(--brand); border: 0; background: transparent; cursor: pointer; text-decoration: underline; }
.live-status.htmx-request { opacity: .65; }
.status-subheading { margin: 20px 0 10px; font-size: .9rem; }
hr { width: 100%; height: 1px; border: 0; background: var(--line); }
blockquote { margin: 6px 0; padding-left: 12px; color: #445357; border-left: 2px solid #b4c4c0; }
.danger-zone { border-color: #e2b5b5; }
.knowledge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.knowledge-card { padding: 18px; border: 1px solid var(--line); border-radius: 12px; }
.knowledge-card h2 { margin: 12px 0 5px; }
.card-heading { display: flex; justify-content: space-between; color: var(--muted); font-size: .8rem; }
.version-timeline { display: grid; gap: 12px; }
.version-card { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfb; }
.version-current { border-color: #8fb3aa; background: #f4faf7; }
.version-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.current-label { margin-left: 6px; color: var(--brand); font-size: .72rem; font-weight: 800; text-transform: uppercase; }
.version-meta { margin: 5px 0 10px; color: var(--muted); font-size: .78rem; }
.version-card summary { color: var(--brand); cursor: pointer; font-weight: 750; }
.version-content { margin-top: 12px; }
.version-content p:last-child { margin-bottom: 0; }
.audit-item-list { display: grid; gap: 14px; }
.audit-item { padding: 17px; border: 1px solid var(--line); border-radius: 11px; }
.audit-item h3 { margin: 12px 0 7px; font-size: 1rem; }
.audit-item h4 { margin: 16px 0 8px; }
.audit-item-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.audit-item-heading > div { display: flex; align-items: center; gap: 10px; }
.hash, .full-hash { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .76rem; }
.hash { color: var(--muted); }
.full-hash { display: block; padding: 10px; overflow-wrap: anywhere; border-radius: 8px; background: #f2f5f4; }
.diagnostic-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.diagnostic { display: flex; gap: 11px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.diagnostic > span { display: grid; place-items: center; flex: 0 0 27px; width: 27px; height: 27px; border-radius: 50%; font-weight: 900; }
.diagnostic p { margin: 3px 0 0; color: var(--muted); font-size: .84rem; }
.diagnostic-pass > span { color: #14633b; background: #dbf4e4; }
.diagnostic-fail > span { color: #8b4d08; background: #fff0d2; }
dl { display: grid; gap: 4px; }
dl div { display: grid; grid-template-columns: 80px 1fr; }
dt { color: var(--muted); }
dd { margin: 0; }

@media (max-width: 980px) {
  .dashboard-grid, .tab-grid, .editor-grid, .three-column, .readiness-grid { grid-template-columns: 1fr; }
  .project-row { grid-template-columns: 1fr; }
  .project-metrics { flex-wrap: wrap; gap: 8px 14px; }
  .site-header { flex-wrap: wrap; }
  .account { width: 100%; margin-left: 0; }
}
@media (max-width: 640px) {
  .page-shell { width: min(100% - 22px, 1500px); padding-top: 25px; }
  .page-heading, .project-heading { display: grid; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric-strip div:nth-child(2) { border-right: 0; }
  .question-row { grid-template-columns: 50px 1fr; }
  .question-row .answer-state { grid-column: 2; }
  nav { order: 3; width: 100%; }
}
