:root {
  color-scheme: light;
  --ink: #17233a;
  --muted: #6b7689;
  --line: #dfe5ec;
  --line-strong: #cbd5e1;
  --surface: #ffffff;
  --canvas: #f4f7fa;
  --navy: #173b64;
  --navy-dark: #102f52;
  --blue-soft: #edf5fc;
  --teal: #0e7c73;
  --teal-soft: #e9f7f4;
  --amber: #9a6700;
  --amber-soft: #fff8e8;
  --red: #b42318;
  --red-soft: #fff1f0;
  --shadow: 0 12px 30px rgba(23, 59, 100, 0.07);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1180px; color: var(--ink); background: var(--canvas); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
[hidden] { display: none !important; }

.auth-screen {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background:
    radial-gradient(circle at 16% 16%, rgba(60, 133, 193, .18), transparent 28%),
    linear-gradient(135deg, #eef4f9, #f9fbfd 62%, #e8f2f4);
}
.login-card { width: 390px; padding: 38px; border: 1px solid rgba(203, 213, 225, .9); border-radius: 20px; background: rgba(255,255,255,.94); box-shadow: 0 24px 70px rgba(16,47,82,.14); }
.login-card h1 { margin: 13px 0 8px; font-size: 29px; }
.login-copy { margin: 0 0 24px; color: var(--muted); }
#loginBtn { margin-top: 16px; }
.brand-mark { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 15px; color: white; background: var(--navy); font-weight: 750; letter-spacing: -.02em; }
.brand-mark.small { width: 42px; height: 42px; border-radius: 12px; }
.compact-status { min-height: 20px; margin-top: 12px; color: var(--red); font-size: 13px; }

.portal-shell { width: min(1480px, calc(100% - 72px)); margin: 0 auto; padding-bottom: 34px; }
.app-header { min-height: 92px; display: flex; align-items: center; justify-content: space-between; }
.brand-lockup { display: flex; gap: 14px; align-items: center; }
.eyebrow, .section-number { margin: 0 0 4px; color: var(--teal); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.app-header h1 { margin: 0; font-size: 23px; letter-spacing: -.02em; }
.header-actions { display: flex; gap: 8px; }

.workflow-rail { display: flex; align-items: center; padding: 15px 22px; margin-bottom: 18px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.82); }
.workflow-step { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 650; white-space: nowrap; }
.workflow-step b { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 11px; }
.workflow-step.active { color: var(--navy); }
.workflow-step.active b { color: white; border-color: var(--navy); background: var(--navy); }
.workflow-line { height: 1px; flex: 1; margin: 0 16px; background: var(--line); }

.layout { display: grid; gap: 18px; }
.panel { padding: 26px 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.compact-panel { display: block; }
.compact-panel .section-heading { margin-bottom: 12px; }
.applicant-field { width: min(560px, 100%); }
.section-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 20px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.015em; }
.section-note { margin: -10px 0 20px; color: var(--muted); font-size: 13px; }
.section-status, .ai-summary { padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #f8fafc; font-size: 11px; font-weight: 750; }
.section-status.ai, .ai-summary.ready { color: var(--teal); border-color: #bce4dd; background: var(--teal-soft); }
.ai-summary.warning { color: var(--amber); border-color: #ead49b; background: var(--amber-soft); }

label { display: grid; gap: 7px; color: #39465a; font-size: 12px; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid var(--line-strong); border-radius: 9px; color: var(--ink); background: white; outline: none; transition: border-color .16s, box-shadow .16s; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: #6aa4ce; box-shadow: 0 0 0 3px rgba(63,133,184,.12); }
input:disabled { color: #8c97a8; background: #f4f6f8; }
.required-star { color: var(--red); }
.grid { display: grid; gap: 15px; }
.extracted-grid { grid-template-columns: minmax(260px, 1.2fr) minmax(360px, 1.65fr) 180px 165px; align-items: end; }
.vendor-purpose-grid { grid-template-columns: 1fr 1.35fr; margin-top: 15px; }
.grid.four { grid-template-columns: 1fr 1fr 1fr .8fr; }
.total-output { min-height: 42px; display: flex; align-items: center; padding: 9px 12px; border: 1px solid #b8dcd5; border-radius: 9px; color: var(--teal); background: var(--teal-soft); font-weight: 800; }

.attachment-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.attachment-slot { min-width: 0; padding: 15px; border: 1px dashed var(--line-strong); border-radius: 12px; background: #fbfcfd; transition: border-color .16s, background .16s; }
.attachment-slot.is-filled { border-style: solid; border-color: #90c9bf; background: #f4fbf9; }
.attachment-slot.is-dragging { border-style: solid; border-color: #4d98c5; background: var(--blue-soft); }
.attachment-slot.is-required { border-left: 3px solid var(--navy); }
.attachment-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.attachment-title { display: flex; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; font-weight: 750; }
.tick { width: 19px; height: 19px; display: grid; place-items: center; border: 1px solid var(--line-strong); border-radius: 5px; color: white; background: white; font-size: 10px; }
.is-filled .tick { border-color: var(--teal); background: var(--teal); }
.attachment-help { margin-top: 5px; color: var(--muted); font-size: 11px; font-weight: 450; }
.attachment-actions, .uploaded-file-actions { display: flex; gap: 6px; align-items: center; }
.attachment-file-input { display: none; }
.uploaded-file-list { display: grid; gap: 5px; margin: 11px 0 0; padding: 0; list-style: none; }
.uploaded-file-list li { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-width: 0; padding: 7px 9px; border-radius: 7px; color: #4b596d; background: rgba(255,255,255,.8); font-size: 11px; font-weight: 500; }
.uploaded-file-list li > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uploaded-file-list .empty-file-list { padding-left: 0; color: #98a2b3; background: transparent; }
.char-count { color: var(--muted); font-size: 10px; text-align: right; }

.subsection { margin-top: 22px; padding: 20px; border: 1px solid var(--line); border-radius: 13px; background: #fafbfd; }
.subsection-title, .line-items-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.subsection-title { margin-bottom: 16px; }
.subsection-title h3, .line-items-header h3 { margin: 0; font-size: 15px; }
.subsection-title span, .line-items-header p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.payee-top-row { display: flex; align-items: flex-end; justify-content: flex-start; gap: 40px; margin-bottom: 15px; }
.bank-option-field { display: block; max-width: 720px; margin-bottom: 15px; }
.bank-option-field[hidden] { display: none; }
.budget-subsection { padding-top: 17px; padding-bottom: 17px; }
.budget-row { display: flex; align-items: flex-end; gap: 28px; }
.budget-project-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); gap: 14px; flex: 1; }
.budget-project-fields #projectNameField[hidden] + label { grid-column: 1 / -1; }
.field-label { margin-bottom: 7px; color: #39465a; font-size: 12px; font-weight: 700; }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 9px; background: white; }
.segmented label { display: flex; grid-template-columns: auto auto; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 6px; cursor: pointer; }
.segmented input { width: auto; min-height: auto; margin: 0; }
.preferred-date-field { width: 230px; }
.date-input-wrap { position: relative; display: block; }
.date-input-wrap #preferredDateInput { padding-right: 42px; }
.date-picker-button { position: absolute; top: 4px; right: 4px; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 7px; color: var(--navy); background: var(--blue-soft); font-weight: 800; }
.date-input-wrap:hover .date-picker-button { background: #dfeef9; }
.native-date-picker { position: absolute; z-index: 2; top: 4px; right: 4px; width: 34px; height: 34px; min-height: 34px; padding: 0; border: 0; opacity: 0; cursor: pointer; }
.line-items-header { margin: 22px 0 11px; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 10px 11px; color: #596579; background: #f5f7fa; font-size: 10px; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
td { padding: 9px 11px; border-top: 1px solid var(--line); vertical-align: top; }
.line-table-wrap table { table-layout: fixed; }
.line-table-wrap th:nth-child(1) { width: 54%; }
.line-table-wrap th:nth-child(2) { width: 9%; }
.line-table-wrap th:nth-child(3), .line-table-wrap th:nth-child(4) { width: 15%; }
.line-table-wrap th:nth-child(5) { width: 7%; }
.line-table-wrap input { min-height: 36px; }
.calculated-amount { display: block; padding-top: 10px; font-weight: 750; text-align: left; }
.line-table-wrap .remove { width: 100%; min-height: 30px; padding: 0; font-size: 10px; text-align: center; white-space: nowrap; }
.line-total-row td { padding-top: 11px; padding-bottom: 11px; border-top: 2px solid var(--line-strong); background: #f8fafc; }
.line-total-cell { color: var(--teal); }
.line-total-cell span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.line-total-cell output { display: block; font-size: 14px; font-weight: 800; }

.action-panel { border-top: 3px solid var(--navy); }
.review-layout { display: grid; grid-template-columns: 1fr 420px; gap: 30px; align-items: start; }
.flags { display: grid; gap: 7px; }
.flag { padding: 9px 11px; border-left: 3px solid var(--red); border-radius: 7px; color: #7d251f; background: var(--red-soft); font-size: 12px; }
.flag.warning { color: #72520c; border-left-color: #d7a326; background: var(--amber-soft); }
.flag.ok { color: #17675f; border-left-color: var(--teal); background: var(--teal-soft); }
.summary-details { margin-top: 13px; color: var(--muted); font-size: 12px; }
.summary-details summary, .reference-section > summary { cursor: pointer; color: var(--navy); font-weight: 750; }
dl { display: grid; grid-template-columns: 150px 1fr; margin: 16px 0 0; }
dt, dd { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--line); }
dt { color: var(--muted); }
.generate-card { padding: 18px; border: 1px solid var(--line); border-radius: 13px; background: #f8fafc; }
.generate-button { width: 100%; min-height: 48px; }
.output-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.output-links a { padding: 10px; border: 1px solid #8bc3bb; border-radius: 8px; color: var(--teal); background: white; font-size: 11px; font-weight: 750; text-align: center; text-decoration: none; }

.reference-section > summary { list-style: none; }
.reference-section > summary::-webkit-details-marker { display: none; }
.reference-section > summary::before { content: "+"; display: inline-grid; place-items: center; width: 22px; height: 22px; margin-right: 9px; border-radius: 6px; background: var(--blue-soft); }
.reference-section[open] > summary::before { content: "−"; }
.reference-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; margin-top: 20px; }
.reference-grid h3 { margin: 0 0 10px; font-size: 14px; }
.schedule-reference { display: grid; gap: 10px; }
.schedule-card { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: #fafbfd; font-size: 11px; }
.schedule-card + .schedule-card { margin-top: 10px; }
.schedule-section { margin-top: 8px; color: var(--ink); font-weight: 700; }
.schedule-line { margin-top: 4px; padding-left: 13px; color: var(--muted); position: relative; }
.schedule-line::before { content: "–"; position: absolute; left: 1px; color: var(--ink); }
.schedule-note { margin-top: 6px; color: var(--muted); font-style: italic; }
.app-footer { padding: 20px 8px 0; color: var(--muted); font-size: 11px; text-align: center; }

.primary-button, .secondary-button, .upload-files-btn, .ghost-button, .remove, .remove-file-btn { min-height: 34px; padding: 7px 11px; border-radius: 8px; font-weight: 700; }
.primary-button { border: 1px solid var(--navy); color: white; background: var(--navy); }
.primary-button:hover { background: var(--navy-dark); }
.secondary-button, .upload-files-btn { border: 1px solid var(--line-strong); color: var(--navy); background: white; }
.ghost-button, .remove-file-btn, .remove { border: 1px solid transparent; color: #647084; background: transparent; }
.ghost-button:hover, .remove-file-btn:hover, .remove:hover { color: var(--navy); background: var(--blue-soft); }

.status-box { margin-top: 14px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; }
.status-box.muted { color: var(--muted); background: #f8fafc; }
.status-box.loading { color: var(--navy); border-color: #b8d2e7; background: var(--blue-soft); }
.status-box.ok { color: #17675f; border-color: #a8d8d1; background: var(--teal-soft); }
.status-box.error { color: #8c2f28; border-color: #edc1bd; background: var(--red-soft); }
.is-invalid, label.is-invalid input, label.is-invalid select, label.is-invalid textarea { border-color: #d96b62 !important; }
[data-ai-field].ai-low { position: relative; }
[data-ai-field].ai-low > input, [data-ai-field].ai-low > select, [data-ai-field].ai-low > textarea, .table-wrap.ai-low { border-color: #d7a326; background: #fffdf7; }
.ai-hint { color: var(--amber); font-size: 10px; font-weight: 650; }

@media (max-width: 1279px) {
  .portal-shell { width: calc(100% - 40px); }
  .panel { padding: 22px; }
  .extracted-grid { grid-template-columns: minmax(250px, 1.15fr) minmax(340px, 1.55fr) 170px 155px; }
  .review-layout { grid-template-columns: 1fr 370px; }
  .budget-project-fields { grid-template-columns: minmax(0, 1fr) minmax(0, 3fr); }
}
