/* Sign-in, sign-up, password and invitation pages. */
body.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: 0 10px 40px var(--shadow); }
.auth-card h1 { margin: 0 0 4px; font-size: 22px; font-weight: 600; }
.auth-card p.lead { margin: 0 0 18px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.auth-card label { display: block; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }
.auth-card input { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; font-size: 14px; }
.auth-card button.primary-button { width: 100%; margin-top: 20px; padding: 12px; font-size: 14px; }
.auth-card .links { margin-top: 16px; font-size: 13px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.auth-card a { color: var(--blue); }
.form-error { margin-top: 14px; color: var(--red); font-size: 13px; }
.form-note { margin-top: 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* App shell */
.shell-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 22px; flex-wrap: wrap; }
.shell-nav button { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 13px; padding: 10px 14px; border-bottom: 2px solid transparent; cursor: pointer; }
.shell-nav button.active { color: var(--text); border-bottom-color: var(--red); font-weight: 600; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 4px; font-size: 16px; }
.hint, .panel p.hint { margin: 0 0 16px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.form-grid input, .form-grid textarea, .form-grid select, .inline-form input, .inline-form select {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--text); font: inherit; font-size: 13px; }
.form-grid textarea { min-height: 70px; resize: vertical; }
.actions { display: flex; gap: 10px; align-items: center; margin-top: 16px; flex-wrap: wrap; }
.saved { color: #247a36; font-size: 12px; }
.inline-form { display: grid; grid-template-columns: 1fr 150px auto; gap: 10px; align-items: end; }
.file-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.file-row:first-of-type { border-top: 0; }
.file-row small { color: var(--muted); display: block; margin-top: 2px; }
.badge { display: inline-block; padding: 3px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 11px; }
.table-wrap { overflow-x: auto; }
.link-box { margin-top: 12px; padding: 10px 12px; background: var(--soft); border-radius: 8px; font-size: 12px; word-break: break-all; }
.who { font-size: 12px; color: var(--muted); }
.top-actions { display: flex; gap: 8px; align-items: center; justify-self: end; flex-wrap: wrap; }
.company-switch { max-width: 220px; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } .inline-form { grid-template-columns: 1fr; } .topbar { height: auto; padding: 12px 16px; grid-template-columns: 1fr; } .top-actions { justify-self: start; } }
.modal-overlay { position: fixed; inset: 0; background: rgba(8,15,22,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { width: 100%; max-width: 420px; background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 22px; box-shadow: 0 20px 70px rgba(0,0,0,.3); }
.modal-card h2 { margin: 0 0 12px; font-size: 17px; }

/* Stage 2: dashboard, projects, contractors, project workspace */
.modal-card.wide { max-width: 760px; max-height: 90vh; overflow: auto; }
.metrics { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.metric span { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.metric strong { display: block; font-size: 20px; margin-top: 6px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; margin-right: 6px; }
.dot.needed { background: #c0392b; } .dot.requested { background: #2e8b57; } .dot.not_required { background: #b8c2cc; }
.state-retainage td:first-child { box-shadow: inset 3px 0 0 #d9a400; } .state-complete td:first-child { box-shadow: inset 3px 0 0 #2e8b57; }
.project-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.project-head h2 { margin: 0 0 6px; font-size: 20px; }
.facts { display: flex; flex-wrap: wrap; gap: 6px 18px; font-size: 12px; color: var(--muted); }
.facts b { color: var(--text); font-weight: 600; }
.recon { margin-top: 14px; padding: 10px 12px; border-radius: 8px; font-size: 12px; background: var(--soft); display: flex; gap: 18px; flex-wrap: wrap; }
.recon.ok { background: #e6f4ea; color: #1e5b2f; } .recon.off { background: #fdecea; color: #8b1e24; }
.subtabs { display: flex; gap: 6px; margin: 18px 0 12px; flex-wrap: wrap; }
.subtabs button { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 999px; padding: 7px 14px; font: inherit; font-size: 12px; cursor: pointer; }
.subtabs button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.sov-table input { width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); font: inherit; font-size: 12px; }
.sov-table td { padding: 6px 8px; vertical-align: middle; }
.sov-table .val input { text-align: right; }
.row-actions { display: flex; gap: 10px; justify-content: flex-end; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: var(--soft); color: var(--muted); }
.pill.Approved { background: #e6f4ea; color: #1e5b2f; } .pill.Rejected { background: #fdecea; color: #8b1e24; } .pill.Pending { background: #fff4d6; color: #7a5a00; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.check input { width: auto; }
@media (max-width: 900px) { .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* The original dashboard stylesheet hides table columns 3 & 5 under 800px and every secondary button under 480px.
   v2 tables and toolbars need all of them. */
@media (max-width: 800px) {
  th:nth-child(3), td:nth-child(3), th:nth-child(5), td:nth-child(5) { display: table-cell; }
}
@media (max-width: 480px) {
  .secondary-button { display: inline-block; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .sov-table input { min-width: 0; }
  .sov-table th:first-child { width: 60px !important; }
}

/* ---------- stage 3: contract reader and documents ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 28px; border: 2px dashed var(--line); border-radius: 12px;
  background: var(--soft); cursor: pointer; text-align: center; color: var(--muted); font-size: 12px; }
.dropzone b { color: var(--blue); font-size: 15px; }
.dropzone.over { border-color: var(--blue); background: var(--blue-soft); }
.file-list { margin-top: 12px; border: 1px solid var(--line); border-radius: 10px; }
.file-list > div { display: flex; gap: 10px; align-items: center; padding: 8px 12px; font-size: 13px; }
.file-list > div + div { border-top: 1px solid var(--line); }
.file-list span { flex: 1; overflow-wrap: anywhere; } .file-list small { color: var(--muted); }
.choices { display: grid; gap: 8px; margin-bottom: 10px; }
.check.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.check.choice:has(input:checked) { border-color: var(--blue); background: var(--blue-soft); }
.check.choice span { display: flex; flex-direction: column; gap: 2px; font-size: 13px; }
.check.choice small { color: var(--muted); font-size: 12px; }
.progress-panel { text-align: center; padding: 40px 20px; }
.spinner { width: 34px; height: 34px; margin: 0 auto 14px; border: 4px solid var(--soft); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.warnings { background: #fff4d6; color: #5c4400; border-radius: 10px; padding: 10px 14px; font-size: 13px; }
.warnings ul { margin: 6px 0 0; padding-left: 18px; }
.notice { background: var(--blue-soft); border-radius: 10px; padding: 10px 14px; font-size: 13px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice select { flex: 1; min-width: 220px; }
#rvForm h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
#rvForm h3:first-of-type { margin-top: 4px; }
.review-field label { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.evidence { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; line-height: 1.4; overflow-wrap: anywhere; }
.pill.ai { background: var(--blue-soft); color: var(--blue); } .pill.basic { background: #e6f4ea; color: #1e5b2f; }
.pill.default { background: var(--soft); } .pill.missing { background: #fdecea; color: #8b1e24; }
tr.piece td:nth-child(3) { padding-left: 22px; }
td select { width: 100%; min-width: 170px; }
.doc-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.doc-summary > div { background: var(--soft); border-radius: 10px; padding: 10px 12px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.doc-summary span { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.search-form { display: flex; gap: 6px; }
.search-form input { min-width: 220px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; background: var(--panel); color: var(--text); }
#pBody a, .doc-summary a { color: var(--blue); text-decoration: none; } #pBody a:hover, .doc-summary a:hover { text-decoration: underline; }
#pBody .panel { box-shadow: none; }
.hits { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; font-size: 12px; max-height: 320px; overflow: auto; }
.hits > div { padding: 6px 0; border-top: 1px solid var(--line); } .hits > div span { font-weight: 600; margin-right: 6px; }
mark { background: #ffe58a; color: inherit; }
@media (max-width: 480px) { .search-form, .search-form input { width: 100%; min-width: 0; } }
table.cmp td { vertical-align: top; overflow-wrap: anywhere; font-size: 12px; }
table.cmp th small { font-weight: 400; color: var(--muted); margin-left: 6px; }
table.cmp tr.diff td { background: #fff4d6; }

/* ---------- stage 4: pay applications ---------- */
.pa-state { margin-top: 12px; padding: 9px 12px; border-radius: 10px; font-size: 13px; }
.pa-state.draft { background: var(--blue-soft); } .pa-state.locked { background: #e6f4ea; color: #1e5b2f; }
.pa-actions { margin-top: 12px; }
.secondary-button.danger { color: #8b1e24; }
a.primary-button, a.secondary-button { text-decoration: none; display: inline-flex; align-items: center; }
.pa-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.pa-summary { max-width: 560px; }
.summary-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.summary-table td { padding: 7px 4px; border-bottom: 1px solid var(--line); }
.summary-table tr.due td { font-weight: 700; background: #e6f4ea; }
.ws-mode { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.ws-mode select, .ws-table select { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; background: var(--panel); color: var(--text); }
.ws-table { font-size: 13px; }
.ws-table td.val input { width: 100px; text-align: right; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font: inherit; font-size: 13px; background: var(--panel); color: var(--text); }
.ws-table td.val input:disabled { background: var(--soft); color: var(--muted); }
.ws-table input.bad, .ws-table tr.over input:not(:disabled) { border-color: #c0392b; background: #fdecea; }
.ws-table td:nth-child(2) { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-totals { margin-top: 10px; font-size: 13px; color: var(--muted); }
.pill.st-Signed, .pill.st-Paid { background: #e6f4ea; color: #1e5b2f; } .pill.st-Submitted, .pill.st-Finalized { background: var(--blue-soft); color: var(--blue); }


.ws-table select { width: auto; min-width: 0; }
.ws-table td, .ws-table th { padding-left: 8px; padding-right: 8px; }
.ws-table td.val input { width: 92px; }
.pa-grid > * { min-width: 0; }
.pa-sheet .table-wrap { overflow-x: auto; }

/* ---------- stage 5: waiver and print package ---------- */
.section-title { margin: 26px 0 10px; font-size: 18px; }
.doc-checks { display: grid; gap: 8px; }
.doc-checks .check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; }
.doc-checks .check span { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#pkWaiver { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; background: var(--panel); color: var(--text); max-width: 100%; }
