.portal-body {
  min-height: 100svh;
  background: #171713;
}

.portal-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.login-panel {
  width: min(520px, 100%);
  margin: 8vh auto;
  padding: clamp(28px, 5vw, 48px);
  background: #f7f4ed;
  color: #171713;
}

.login-panel h1,
.portal-topbar h1 {
  margin: 10px 0 8px;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1;
}

.portal-home {
  color: inherit;
  font-weight: 900;
  text-decoration: none;
}

.portal-alert,
.portal-notice {
  padding: 12px 14px;
  margin: 0 0 18px;
  background: #ffe9a8;
  color: #352400;
  font-weight: 800;
}

.portal-notice {
  background: #dff4dc;
  color: #173b17;
}

.portal-form {
  display: grid;
  gap: 18px;
  margin-top: 26px;
}

.portal-form.compact {
  gap: 12px;
  margin-top: 0;
}

.portal-form input,
.portal-form select,
.portal-form textarea,
.login-panel input,
.work-order-form input,
.work-order-form select,
.work-order-form textarea,
.accept-quote-form input,
.accept-quote-form textarea,
.invoice-create-form input,
.invoice-create-form textarea,
.profile-form input,
.admin-account-card input,
.admin-account-card select {
  border-color: #c9c1af;
  background: #fff;
  color: #171713;
}

.portal-form select option,
.work-order-form select option {
  color: #171713;
  background: #fff;
}

.portal-topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  color: #fff;
  margin-bottom: 30px;
}

.portal-topbar p {
  margin: 0;
  color: #dedbd1;
  font-weight: 800;
}

.portal-logout {
  color: #fff;
}

.portal-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 24px;
  padding: 10px;
  background: #262620;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.portal-body .portal-nav a,
.portal-body .portal-nav a:link,
.portal-body .portal-nav a:visited,
.portal-body .portal-nav a:focus {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  color: #f7f4ed !important;
  font-weight: 900;
  text-decoration: none;
  border: 1px solid transparent;
}

.portal-body .portal-nav a:not(.active):hover,
.portal-body .portal-nav a:not(.active):focus {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff !important;
  border-color: rgba(255, 255, 255, 0.28);
}

.portal-body .portal-nav a.active {
  background: #e9b51b;
  color: #171713 !important;
  border-color: #e9b51b;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 28px;
  background: rgba(255, 255, 255, 0.2);
}

.metric-strip article {
  padding: 24px;
  background: #f7f4ed;
}

.metric-strip span {
  display: block;
  font-size: clamp(1.55rem, 2.7vw, 2.5rem);
  font-weight: 900;
  line-height: 1;
}

.metric-strip p {
  margin: 8px 0 0;
  color: #5d5b53;
  font-weight: 800;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.portal-panel {
  min-width: 0;
  padding: 24px;
  background: #fff;
  color: #171713;
}

.portal-panel.wide {
  grid-column: 1 / -1;
}

.portal-panel h2 {
  margin: 0 0 18px;
  font-size: 1.45rem;
}

.portal-panel h3 {
  margin: 0 0 8px;
}

.portal-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.portal-panel-head a {
  font-weight: 900;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 10px;
  border-bottom: 1px solid #ded8ca;
  text-align: left;
  vertical-align: top;
}

td span {
  display: block;
  margin-top: 4px;
  color: #5d5b53;
  font-size: 0.92rem;
}

th {
  color: #5d5b53;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.portal-list {
  display: grid;
  gap: 12px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.portal-list li {
  display: grid;
  gap: 4px;
  padding-bottom: 12px;
  border-bottom: 1px solid #ded8ca;
}

.portal-list span {
  color: #5d5b53;
}

.account-list {
  margin-top: 22px;
}

.portal-kicker {
  margin: 0 0 8px;
  color: #8a6100;
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.work-order-list {
  display: grid;
  gap: 18px;
}

.work-order-card {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1fr);
  gap: 20px;
  padding: 20px;
  border: 1px solid #ded8ca;
}

.work-order-card p {
  margin: 0 0 7px;
  color: #5d5b53;
}

.work-order-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.crew-work-panel {
  display: grid;
  gap: 14px;
}

.crew-work-actions,
.crew-finish-form {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid #ded8ca;
  background: #fbfaf6;
}

.crew-work-actions button,
.crew-finish-form button {
  min-height: 54px;
  width: 100%;
}

.crew-work-actions input,
.crew-finish-form input,
.crew-finish-form textarea {
  border-color: #c9c1af;
  background: #fff;
  color: #171713;
}

.crew-work-actions .button.secondary {
  border-color: #171713;
  color: #171713;
}

.work-order-checklist,
.invoice-edit-card {
  grid-column: 1 / -1;
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid #ded8ca;
  background: #fbfaf6;
}

.work-order-checklist h4,
.invoice-edit-card h3 {
  margin: 0;
}

.checklist-edit-form,
.checklist-add-form,
.invoice-card-list,
.invoice-edit-form,
.invoice-add-line-form {
  display: grid;
  gap: 12px;
}

.checklist-row,
.invoice-line-editor-row,
.invoice-add-line-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 130px auto;
  gap: 10px;
  align-items: center;
}

.invoice-line-editor-row {
  grid-template-columns: 90px minmax(220px, 1fr) 130px 110px;
}

.invoice-add-line-form {
  grid-template-columns: 90px minmax(220px, 1fr) 130px auto;
}

.invoice-edit-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.invoice-edit-form label:nth-of-type(4),
.invoice-lines-editor,
.invoice-edit-form button {
  grid-column: 1 / -1;
}

.work-order-checklist input,
.work-order-checklist select,
.invoice-edit-card input,
.invoice-edit-card textarea {
  border-color: #c9c1af;
  background: #fff;
  color: #171713;
}

.work-order-form label:nth-child(n + 5) {
  grid-column: 1 / -1;
}

.work-order-form button {
  grid-column: 1 / -1;
  width: fit-content;
}

.photo-strip {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding-top: 4px;
}

.photo-strip figure {
  margin: 0;
  border: 1px solid #ded8ca;
  background: #fbfaf6;
}

.photo-strip img {
  width: 100%;
  aspect-ratio: 4 / 3;
  height: auto;
  object-fit: cover;
  display: block;
}

.photo-strip figcaption {
  display: grid;
  gap: 3px;
  padding: 8px;
  color: #5d5b53;
  font-size: 0.85rem;
}

.photo-strip figcaption strong {
  color: #171713;
}

.quote-review-table table {
  min-width: 980px;
}

.accept-quote-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(110px, 1fr));
  gap: 8px;
  min-width: 340px;
}

.accept-quote-form textarea,
.accept-quote-form button {
  grid-column: 1 / -1;
}

.accept-quote-form input,
.accept-quote-form textarea {
  min-height: 42px;
  padding: 10px 11px;
}

.quote-action-stack {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.quote-work-order-link {
  min-height: 40px;
  background: #e9b51b;
  color: #171713 !important;
}

.quote-action-stack form {
  margin: 0;
}

.danger-inline-form {
  margin: 8px 0 0;
}

.quote-action-stack button {
  border: 1px solid #171713;
  background: #fff;
  color: #171713;
  padding: 8px 11px;
  font-weight: 900;
  cursor: pointer;
}

.danger-inline-form button {
  border: 1px solid #8f1d1d;
  background: #fff5f2;
  color: #8f1d1d;
  padding: 8px 11px;
  font-weight: 900;
  cursor: pointer;
}

.stage-board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 1px;
  background: #ded8ca;
}

.stage-board article {
  display: grid;
  gap: 6px;
  min-height: 110px;
  padding: 16px;
  background: #f7f4ed;
}

.stage-board strong {
  color: #8a6100;
  text-transform: uppercase;
}

.stage-board span,
.portal-panel-head span {
  color: #5d5b53;
  font-weight: 800;
}

.profile-panel {
  display: grid;
  grid-template-columns: minmax(240px, 0.65fr) minmax(320px, 1fr);
  gap: 24px;
  align-items: start;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
}

.profile-card h2 {
  margin-bottom: 6px;
}

.profile-card p {
  margin: 0;
  color: #5d5b53;
  font-weight: 800;
}

.profile-photo {
  display: grid;
  width: 86px;
  height: 86px;
  flex: 0 0 86px;
  place-items: center;
  overflow: hidden;
  border: 3px solid #e9b51b;
  background: #171713;
  color: #fff;
  font-size: 2rem;
  font-weight: 900;
}

.profile-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-photo.small {
  width: 58px;
  height: 58px;
  flex-basis: 58px;
  font-size: 1.35rem;
}

.profile-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.profile-form button {
  grid-column: 1 / -1;
  width: fit-content;
}

.admin-account-grid {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.admin-account-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  border: 1px solid #ded8ca;
  background: #fbfaf6;
}

.admin-account-head,
.admin-account-card label:nth-last-of-type(1),
.admin-account-card button {
  grid-column: 1 / -1;
}

.admin-account-head {
  display: flex;
  align-items: center;
  gap: 12px;
}

.admin-account-head span {
  display: block;
  color: #5d5b53;
  font-weight: 800;
}

.admin-account-card button {
  width: fit-content;
}

.gallery-admin-form,
.gallery-admin-grid,
.gallery-admin-edit {
  display: grid;
  gap: 12px;
}

.gallery-admin-form {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 18px;
}

.gallery-admin-form label:nth-of-type(4),
.gallery-admin-form label:nth-of-type(5),
.gallery-admin-form button {
  grid-column: 1 / -1;
}

.gallery-admin-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 24px;
}

.gallery-admin-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid #ded8ca;
  background: #fbfaf6;
}

.gallery-admin-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.gallery-admin-form input,
.gallery-admin-form textarea,
.gallery-admin-edit input,
.gallery-admin-edit textarea {
  border-color: #c9c1af;
  background: #fff;
  color: #171713;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inline-check input {
  width: auto;
}

.invoice-link-row,
.invoice-create-form {
  grid-column: 1 / -1;
}

.invoice-link-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: #f7f4ed;
  border: 1px solid #ded8ca;
}

.invoice-link-row .button.secondary {
  border-color: #171713;
  color: #171713;
}

.invoice-create-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
  border: 1px solid #ded8ca;
  background: #fbfaf6;
}

.invoice-create-form h4,
.invoice-create-form label:nth-last-of-type(-n + 2),
.invoice-create-form button {
  grid-column: 1 / -1;
}

.invoice-create-form h4 {
  margin: 0;
}

.invoice-actions-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.invoice-actions-cell form {
  margin: 0;
}

.invoice-actions-cell button,
.invoice-actions button {
  border: 1px solid #171713;
  background: #fff;
  color: #171713;
  padding: 8px 11px;
  font-weight: 900;
  cursor: pointer;
}

.invoice-body {
  margin: 0;
  background: #4b4b4b;
  color: #050505;
  font-family: Arial, Helvetica, sans-serif;
}

.invoice-page {
  width: min(960px, 100%);
  min-height: 1220px;
  margin: 0 auto;
  padding: 70px 76px;
  background:
    linear-gradient(170deg, #f6ead4 0 31%, transparent 31.2%),
    linear-gradient(174deg, transparent 0 84%, #f6ead4 84.2%),
    #fff;
}

.invoice-hero {
  display: grid;
  grid-template-columns: 1fr 310px;
  gap: 40px;
  min-height: 330px;
}

.invoice-hero h1 {
  margin: 0 0 50px;
  font-size: 2.4rem;
  letter-spacing: 0;
}

.invoice-meta {
  display: grid;
  grid-template-columns: repeat(2, 180px);
  gap: 70px;
  margin-bottom: 72px;
}

.invoice-meta div,
.invoice-summary div,
.invoice-totals div {
  display: grid;
  gap: 10px;
}

.invoice-meta strong,
.invoice-summary strong,
.invoice-lines th {
  color: #a96500;
  font-size: 1.05rem;
  text-transform: uppercase;
}

.invoice-hero address {
  display: grid;
  gap: 8px;
  font-style: normal;
}

.invoice-brand {
  display: grid;
  justify-items: center;
  align-content: start;
  gap: 8px;
  padding-top: 72px;
  font-weight: 900;
}

.invoice-logo {
  width: 230px;
  max-width: 100%;
  height: auto;
}

.invoice-summary {
  display: grid;
  grid-template-columns: 1fr 1.1fr 1.25fr 0.85fr;
  margin-bottom: 90px;
  border: 1px solid #c8c8c8;
}

.invoice-summary div {
  padding: 8px 10px;
  border-right: 1px solid #c8c8c8;
}

.invoice-summary div:last-child {
  border-right: 0;
}

.invoice-lines th,
.invoice-lines td {
  border-bottom: 1px solid #111;
  padding: 11px 10px;
}

.invoice-lines th:nth-child(2),
.invoice-lines td:nth-child(2) {
  width: 42%;
}

.invoice-totals {
  display: grid;
  justify-content: end;
  gap: 0;
  margin-top: 110px;
}

.invoice-totals div {
  grid-template-columns: 110px 170px;
  gap: 0;
  align-items: center;
}

.invoice-totals strong {
  border: 1px solid #c8c8c8;
  padding: 3px 8px;
  text-align: right;
}

.invoice-totals span {
  padding-right: 8px;
  text-align: right;
}

.invoice-note {
  margin-top: 24px;
  font-size: 0.82rem;
  font-weight: 700;
}

.invoice-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
}

.invoice-actions a {
  color: #171713;
  font-weight: 900;
}

@media (max-width: 820px) {
  .portal-topbar,
  .portal-grid {
    grid-template-columns: 1fr;
  }

  .metric-strip,
  .stage-board {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-grid {
    display: grid;
  }

  .portal-topbar {
    display: grid;
  }

  .work-order-card,
  .work-order-form,
  .invoice-create-form,
  .profile-panel,
  .profile-form,
  .admin-account-card,
  .gallery-admin-form,
  .gallery-admin-grid {
    grid-template-columns: 1fr;
  }

  .invoice-page {
    padding: 40px 24px;
  }

  .invoice-hero,
  .invoice-summary {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .metric-strip {
    grid-template-columns: 1fr;
  }
}

@media print {
  .invoice-body {
    background: #fff;
  }

  .invoice-page {
    width: 100%;
    min-height: 100vh;
    margin: 0;
  }

  .invoice-actions {
    display: none;
  }
}
