:root {
  --ink: #142d3a;
  --muted: #526a76;
  --brand: #146a78;
  --brand-dark: #0c4e59;
  --accent: #f2ae3e;
  --surface: #ffffff;
  --surface-soft: #f2f7f8;
  --line: #cbd9dd;
  --danger: #a52b2b;
  --warning: #fff5d8;
  --shadow: 0 16px 44px rgba(19, 54, 68, 0.1);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

body {
  margin: 0;
  background: #eaf1f3;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--brand-dark);
}

.skip-link {
  position: fixed;
  z-index: 20;
  top: 8px;
  left: 8px;
  padding: 12px 16px;
  transform: translateY(-150%);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

.portal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 12px clamp(20px, 5vw, 72px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  background: #12384c;
  color: #fff;
}

.portal-header p {
  margin: 0;
  color: #d8e8ec;
  font-size: 0.9rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 11px;
  background: var(--accent);
  color: #183440;
  font-size: 1.35rem;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand small {
  color: #bcd5db;
}

.session-warning {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 12px 20px;
  background: var(--warning);
  border-bottom: 1px solid #d9b65c;
}

.session-warning p {
  margin: 0;
}

.portal-shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.portal-title {
  max-width: 760px;
  margin-bottom: 28px;
}

.portal-title h1,
.policy-page h1 {
  margin: 4px 0 8px;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.portal-title > p:last-child,
.policy-page > p {
  color: var(--muted);
  font-size: 1.06rem;
}

.eyebrow {
  margin: 0;
  color: var(--brand-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.progress {
  margin-bottom: 24px;
}

.progress ol {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.progress li {
  display: flex;
  align-items: center;
  min-height: 52px;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 4px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.progress li span {
  display: grid;
  width: 28px;
  height: 28px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: #d9e5e8;
}

.progress li.is-complete,
.progress li[aria-current="step"] {
  border-color: var(--brand);
  color: var(--ink);
}

.progress li.is-complete span,
.progress li[aria-current="step"] span {
  background: var(--brand);
  color: #fff;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: start;
  gap: 24px;
}

#business-portal-form,
.live-summary,
.policy-page {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

#business-portal-form {
  min-height: 540px;
  padding: clamp(22px, 4vw, 42px);
}

.step-heading {
  margin-bottom: 30px;
}

.step-heading > p:first-child {
  margin: 0 0 4px;
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
}

.step-heading h2 {
  margin: 0 0 6px;
  font-size: clamp(1.6rem, 3vw, 2.25rem);
  line-height: 1.15;
}

.step-heading > p:last-child {
  margin: 0;
  color: var(--muted);
}

.field {
  min-width: 0;
  margin-bottom: 20px;
}

.field label,
.field-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 750;
}

.field label span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

input,
select {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid #91a8af;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
}

[aria-invalid="true"] {
  border-color: var(--danger);
}

.money-input {
  display: flex;
  align-items: center;
  min-height: 48px;
  border: 1px solid #91a8af;
  border-radius: 8px;
  background: #fff;
}

.money-input:focus-within {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
}

.money-input span {
  padding-left: 12px;
  color: var(--muted);
  font-weight: 700;
}

.money-input input {
  min-height: 46px;
  border: 0;
  outline: 0;
}

.field-prominent {
  max-width: 560px;
  padding: 20px;
  border: 2px solid #b7cdd2;
  border-radius: 12px;
  background: var(--surface-soft);
}

.field-prominent > label {
  font-size: 1.1rem;
}

.compact-field {
  max-width: 320px;
  margin-top: 12px;
}

.field-hint,
.field-error {
  margin: 6px 0 0;
  font-size: 0.86rem;
}

.field-hint {
  color: var(--muted);
}

.field-error {
  color: var(--danger);
  font-weight: 650;
}

.field-grid-error {
  grid-column: 1 / -1;
}

.step-error {
  margin-bottom: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 18px;
}

.section-divider {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin: 30px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.section-divider h3,
.section-divider p {
  margin: 0;
}

.section-divider p {
  color: var(--muted);
}

.entry-list {
  display: grid;
  gap: 14px;
}

.add-another {
  margin-top: 14px;
}

.entry-card {
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fbfdfe;
}

.entry-card legend {
  padding: 0 8px;
  font-weight: 800;
}

.inline-fields {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-fields input {
  width: 88px;
}

.primary-button,
.secondary-button,
.danger-button,
.text-button,
.icon-button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 750;
  text-decoration: none;
}

.primary-button,
.secondary-button,
.danger-button {
  padding: 10px 18px;
}

.primary-button {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
}

.primary-button:hover {
  background: var(--brand-dark);
}

.primary-button:disabled {
  cursor: not-allowed;
  border-color: #a9b5b9;
  background: #d8dfe1;
  color: #5f7077;
}

.secondary-button {
  border: 1px solid #8aa1a8;
  background: #fff;
  color: var(--ink);
}

.danger-button {
  border: 1px solid var(--danger);
  background: var(--danger);
  color: #fff;
}

.text-button {
  padding: 8px 2px;
  border: 0;
  background: transparent;
  color: var(--brand-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.remove-row {
  color: var(--danger);
}

.icon-button {
  width: 44px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--danger);
  font-size: 1.4rem;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.quick-note,
.estimated-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #e9f6f4;
}

.quick-note strong,
.estimated-warning strong {
  flex: none;
}

.category-list {
  display: grid;
  gap: 10px;
}

.category-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(150px, 220px) 44px;
  align-items: center;
  gap: 10px;
}

.category-row .field-error {
  grid-column: 2 / -1;
}

.select-action {
  margin-left: auto;
}

.select-action select {
  min-width: 150px;
}

.live-summary {
  position: sticky;
  top: 20px;
  padding: 22px;
}

.live-summary h2 {
  margin: 0 0 14px;
  font-size: 1.12rem;
}

.live-summary dl,
.monthly-summary dl,
.reconciliation {
  margin: 0;
}

.live-summary dl div,
.monthly-summary dl div,
.reconciliation div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.live-summary dt,
.live-summary dd,
.monthly-summary dt,
.monthly-summary dd,
.reconciliation dt,
.reconciliation dd {
  margin: 0;
}

.live-summary dd,
.monthly-summary dd,
.reconciliation dd {
  font-variant-numeric: tabular-nums;
  font-weight: 750;
}

.live-summary .total,
.monthly-summary .total {
  margin-top: 5px;
  border-bottom: 0;
  font-size: 1.1rem;
  font-weight: 850;
}

.live-summary > p {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metric-grid article {
  min-height: 120px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
}

.metric-grid h3 {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.86rem;
}

.metric-grid strong,
.metric-grid span {
  display: block;
}

.metric-grid strong {
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
}

.metric-grid span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.84rem;
}

.monthly-summary,
.projection-details {
  margin-top: 18px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.monthly-summary h3 {
  margin: 0 0 10px;
}

.projection-details summary {
  min-height: 44px;
  cursor: pointer;
  font-weight: 800;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

.transfer-status {
  color: var(--muted);
  font-size: 0.88rem;
}

.inline-confirmation {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 20px;
  padding: 16px;
  border: 2px solid #d8a4a4;
  border-radius: 10px;
  background: #fff6f6;
}

.inline-confirmation div {
  flex: 1 1 300px;
}

.inline-confirmation p {
  margin: 3px 0 0;
}

.step-errors {
  margin-top: 12px;
  color: var(--danger);
  font-weight: 700;
}

.portal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 26px clamp(20px, 5vw, 72px);
  background: #12384c;
  color: #d9e7ea;
  font-size: 0.9rem;
}

.portal-footer p {
  margin: 0;
}

.portal-footer nav {
  display: flex;
  gap: 18px;
}

.portal-footer a {
  color: #fff;
}

.policy-page {
  width: min(780px, calc(100% - 32px));
  margin: 50px auto;
  padding: clamp(24px, 5vw, 50px);
}

.policy-page h2 {
  margin-top: 30px;
}

.inline-button {
  margin-top: 18px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .live-summary {
    position: static;
    grid-row: 1;
  }

  .portal-header p {
    display: none;
  }
}

@media (max-width: 680px) {
  .portal-shell {
    width: min(100% - 20px, 1240px);
    padding-top: 24px;
  }

  .progress ol {
    grid-template-columns: repeat(5, minmax(52px, 1fr));
    overflow-x: auto;
  }

  .progress li {
    justify-content: center;
    padding-inline: 4px;
    font-size: 0;
  }

  .progress li span {
    font-size: 0.9rem;
  }

  #business-portal-form {
    padding: 20px 16px;
  }

  .field-grid,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .section-divider {
    align-items: stretch;
    flex-direction: column;
  }

  .category-row {
    grid-template-columns: 1fr 44px;
  }

  .category-row label {
    grid-column: 1 / -1;
  }

  .category-row .field-error {
    grid-column: 1 / -1;
  }

  .form-actions,
  .portal-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions button {
    flex: 1;
  }

  .portal-footer nav {
    flex-wrap: wrap;
  }
}
