:root {
  --portal-logo-width: clamp(180px, 24vw, 300px);
  --partner-logo-size: clamp(70px, 7vw, 100px);
  --brand-indigo: #3a3a6d;
  --brand-indigo-dark: #2e2e57;
  --pastel-lavender: #eeeef7;
  --pastel-blue: #edf4f8;
  --pastel-cream: #faf5e9;
  --page-background: #edf4f8;
  --surface: #fff;
  --text: #292936;
  --border: #b9b9cc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--page-background);
}

main {
  width: min(100% - 32px, 1000px);
  margin: 0 auto;
  padding: 32px 0;
}

h1 {
  margin: 0 0 8px;
  font-size: 2rem;
  color: var(--brand-indigo);
}

.portal-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  width: 100%;
  gap: 16px;
}

.portal-logo {
  display: block;
  grid-column: 1;
  justify-self: start;
  width: min(var(--portal-logo-width), 40vw);
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.portal-logo:not([src]) {
  display: none;
}

.partner-logos {
  display: grid;
  grid-column: 3;
  grid-template-columns: repeat(2, var(--partner-logo-size));
  justify-self: end;
  gap: clamp(6px, 1vw, 10px);
  padding: clamp(6px, 1vw, 10px);
  border-radius: 10px;
}

.partner-logo-slot {
  display: grid;
  width: var(--partner-logo-size);
  height: var(--partner-logo-size);
  place-items: center;
  overflow: hidden;
  color: var(--brand-indigo);
  border-radius: 10px;
}

.partner-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.partner-logo:not([src]) {
  display: none;
}

.partner-logo[src] + span {
  display: none;
}

.portal-title span {
  display: block;
}

.portal-title {
  grid-column: 2;
  justify-self: center;
  min-width: 0;
  margin: 0;
  text-align: center;
}

.portal-title span:last-child {
  margin-top: 2px;
}

h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

p {
  margin-top: 0;
}

.workspace {
  margin-top: 24px;
}

.box {
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.success-view {
  max-width: 600px;
  margin-top: 24px;
}

[hidden] {
  display: none !important;
}

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

.attribute-checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
}

.field--checkbox {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 0 10px;
  min-height: 44px;
}

.field--checkbox label {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
}

.field--checkbox input[type="checkbox"] {
  grid-column: 1;
  grid-row: 1;
  margin: 0;
}

.field--checkbox .field-help {
  grid-column: 2;
}

.contents {
  display: contents;
}

.order-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.order-tabs {
  display: flex;
  flex: 1 1 auto;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.order-tab-group,
.product-actions,
.quantity-control {
  display: flex;
  align-items: stretch;
}

.order-tab-group {
  max-width: 100%;
}

.product-actions {
  gap: 4px;
}

#delete-product-button {
  display: grid;
  min-width: 42px;
  padding: 8px;
  place-items: center;
  background: #dcecf5;
}

#delete-product-button svg {
  width: 18px;
  height: 22px;
  fill: var(--brand-indigo);
}

#delete-product-button:hover:not(:disabled) {
  background: #cce3ef;
}

#delete-product-button:disabled {
  opacity: 1;
}

.quantity-button {
  min-width: 42px;
  padding: 8px;
}

.quantity-value {
  display: grid;
  min-width: 42px;
  place-items: center;
  background: var(--pastel-blue);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.order-tab[aria-selected="true"] {
  color: #fff;
  background: var(--brand-indigo);
  border-color: var(--brand-indigo);
}

.order-name-field {
  max-width: 480px;
  margin: 16px 0;
}

.field,
.field--full {
  min-width: 0;
}

.field--full {
  grid-column: 1 / -1;
}

label {
  display: block;
  margin-bottom: 5px;
  font-weight: 700;
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 8px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

input[type="checkbox"] {
  width: 24px;
  min-height: 24px;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.field-help {
  margin: 5px 0 0;
  font-size: 0.875rem;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid var(--brand-indigo);
  outline-offset: 2px;
}

input:disabled,
select:disabled,
button:disabled {
  opacity: 0.55;
}

.attribute-heading {
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.attribute-heading p,
.attribute-message {
  margin-bottom: 0;
}

.attribute-message {
  grid-column: 1 / -1;
  padding: 12px;
  background: var(--pastel-blue);
  border: 1px dashed var(--border);
  border-radius: 6px;
}

.product-overview {
  min-height: 50px;
  padding: 12px;
  overflow-wrap: anywhere;
  background: var(--pastel-lavender);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.door-stack-section {
  padding: 16px;
  background: var(--pastel-blue);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.door-stack-question {
  margin: 0;
  padding: 0;
  border: 0;
}

.door-stack-question legend {
  margin-bottom: 8px;
  font-weight: 700;
}

.door-stack-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.door-stack-choice {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 90px;
  margin: 0;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.door-stack-choice input[type="radio"] {
  width: 20px;
  min-height: 20px;
  margin: 0;
}

.door-stack-builder {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.door-stack-panels {
  display: flex;
  gap: 12px;
  min-width: 0;
  padding-bottom: 4px;
  overflow-x: auto;
}

.door-stack-panel {
  flex: 1 0 180px;
  min-width: 0;
}

.door-stack-graphic {
  position: relative;
  width: min(100%, 180px);
  aspect-ratio: 3 / 4;
  margin: 0 auto 10px;
  overflow: hidden;
  background: var(--surface);
  border: 4px solid var(--brand-indigo);
}

.door-stack-graphic::before,
.door-stack-graphic::after {
  position: absolute;
  content: "";
}

.door-stack-graphic--fixed::before,
.door-stack-graphic--fixed::after {
  top: 50%;
  left: 50%;
  width: 140%;
  height: 2px;
  background: var(--border);
  transform-origin: center;
}

.door-stack-graphic--fixed::before {
  transform: translate(-50%, -50%) rotate(53deg);
}

.door-stack-graphic--fixed::after {
  transform: translate(-50%, -50%) rotate(-53deg);
}

.door-stack-graphic--sliding::before {
  top: 12px;
  right: 12px;
  bottom: 12px;
  left: 12px;
  border: 2px solid var(--border);
}

.door-stack-graphic--sliding::after {
  right: 18px;
  bottom: 16px;
  width: 32px;
  height: 8px;
  border-right: 2px solid var(--brand-indigo);
  border-bottom: 2px solid var(--brand-indigo);
  transform: rotate(-45deg);
}

.door-stack-handle {
  position: absolute;
  z-index: 1;
  top: 48%;
  width: 5px;
  height: 22px;
  background: var(--brand-indigo);
  border-radius: 3px;
}

.door-stack-handle--left {
  left: 12px;
}

.door-stack-handle--right {
  right: 12px;
}

.door-stack-handle--none {
  display: none;
}

.door-stack-field + .door-stack-field {
  margin-top: 8px;
}

.door-stack-field label {
  font-size: 0.875rem;
}

.door-stack-add {
  width: 44px;
  min-width: 44px;
  padding: 0;
  color: #fff;
  background: var(--brand-indigo);
  border-color: var(--brand-indigo);
  font-size: 1.5rem;
  line-height: 1;
}

.door-stack-add:hover:not(:disabled) {
  background: var(--brand-indigo-dark);
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

button {
  min-height: 44px;
  padding: 8px 14px;
  color: var(--text);
  background: var(--pastel-lavender);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: #e2e2f1;
}

#submit-button,
#new-order-button {
  color: #fff;
  background: var(--brand-indigo);
  border-color: var(--brand-indigo);
}

#submit-button:hover:not(:disabled),
#new-order-button:hover:not(:disabled) {
  background: var(--brand-indigo-dark);
}

#add-order-button {
  background: var(--pastel-blue);
}

button:disabled {
  cursor: not-allowed;
}

.form-status:not(:empty) {
  margin-top: 16px;
  padding: 10px;
  color: #a12622;
  background: var(--pastel-cream);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 700;
}

@media (max-width: 900px) {
  .portal-header {
    --portal-logo-width: clamp(170px, 34vw, 260px);
    --partner-logo-size: clamp(60px, 10vw, 82px);
    grid-template-areas:
      "logo partners"
      "title title";
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .portal-logo {
    grid-area: logo;
  }

  .portal-title {
    grid-area: title;
  }

  .partner-logos {
    grid-area: partners;
  }
}

@media (max-width: 760px) {
  main {
    width: calc(100% - 20px);
    padding: 20px 0;
  }

  .portal-title {
    font-size: 1.65rem;
    line-height: 1.25;
  }

  .box {
    padding: 14px;
  }

  .form-grid,
  .attribute-grid {
    grid-template-columns: 1fr;
  }

  .field--full {
    grid-column: auto;
  }

  .order-toolbar {
    flex-wrap: wrap;
  }

  .order-tabs,
  .product-actions {
    width: 100%;
  }

  .order-tab-group {
    flex: 1 1 220px;
  }

  .order-tab,
  #add-order-button {
    flex: 1;
    min-width: 0;
  }

  .order-tab {
    overflow-wrap: anywhere;
  }

  .order-name-field {
    max-width: none;
  }

  .form-actions button {
    flex: 1 1 100%;
  }
}

@media (max-width: 520px) {
  .portal-header {
    --portal-logo-width: clamp(170px, 58vw, 230px);
    --partner-logo-size: clamp(54px, 17vw, 72px);
    grid-template-areas:
      "logo"
      "title"
      "partners";
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 12px;
  }

  .portal-logo,
  .portal-title,
  .partner-logos {
    grid-column: 1;
    justify-self: center;
  }

  .door-stack-section {
    padding: 12px;
  }

  .door-stack-builder {
    grid-template-columns: 40px minmax(0, 1fr) 40px;
    gap: 6px;
  }

  .door-stack-add {
    width: 40px;
    min-width: 40px;
  }

  .door-stack-panel {
    flex-basis: 150px;
  }
}

@media (max-width: 420px) {
  main {
    width: calc(100% - 16px);
  }

  .box {
    padding: 12px;
  }
}

@media (orientation: landscape) and (max-width: 950px) and (max-height: 500px) {
  main {
    width: calc(100% - 20px);
    padding: 12px 0;
  }

  .portal-title {
    grid-area: auto;
    grid-column: 2;
    font-size: 1.5rem;
    line-height: 1.2;
  }

  .portal-header {
    --portal-logo-width: clamp(140px, 24vw, 220px);
    --partner-logo-size: clamp(48px, 7vw, 68px);
    grid-template-areas: none;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  }

  .portal-logo {
    grid-area: auto;
    grid-column: 1;
  }

  .partner-logos {
    grid-area: auto;
    grid-column: 3;
  }

  .workspace {
    margin-top: 12px;
  }

  .box {
    padding: 12px;
  }

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

  .field--full {
    grid-column: 1 / -1;
  }

  .order-toolbar {
    flex-wrap: wrap;
  }

  .order-tabs {
    width: auto;
    flex: 1 1 400px;
  }

  .product-actions {
    width: auto;
    flex: 0 0 auto;
  }

  .order-name-field {
    max-width: 480px;
  }

  .form-actions button {
    flex: 0 1 auto;
  }
}
