* {
  box-sizing: border-box;
}

body {
  background: #fff;
  color: #20221d;
  font-family: Arial Black, Arial, sans-serif;
  line-height: 1.5;
  margin: 0;
  overflow-x: hidden;
}

main {
  margin: 0 auto;
  max-width: 1120px;
  padding: 24px 24px 64px;
}

a {
  color: #20221d;
  font-weight: 900;
  text-decoration-thickness: 3px;
  text-underline-offset: 4px;
}

.app-nav {
  --border-width: 15px;

  align-items: center;
  background: #fdfdfb;
  border: var(--border-width) solid #20221d;
  border-radius: 24px;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  display: flex;
  flex-direction: column;
  gap: 18px;
  justify-content: center;
  padding: 72px;
  /* padding-block-start: 96px; */
  text-align: center;
  margin-left: calc(var(--border-width) * -1);
  margin-block-start: calc(var(--border-width) * -1);
  width: calc(100% + var(--border-width) * 2);
}

.app-nav__brand {
  align-items: center;
  display: inline-flex;
  justify-content: center;
  text-decoration: none;
}

.app-nav__logo {
  display: block;
  height: auto;
  max-width: min(250px, 82vw);
  width: 250px;
}

h1,
h2,
h3 {
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.05;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.75rem);
}

h2 {
  font-size: 1.5rem;
}

h3 {
  font-size: 1.15rem;
}

p {
  margin-top: 0;
}

section {
  margin-top: 28px;
}

table {
  background: #fdfdfb;
  border-collapse: collapse;
  border: 4px solid #20221d;
  width: 100%;
}

th,
td {
  border: 3px solid #20221d;
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

th {
  background: #20221d;
  color: #fdfdfb;
  font-size: 0.85rem;
  font-weight: 900;
  text-transform: uppercase;
}

input[type="number"],
input[type="text"] {
  background: #fff;
  border: 3px solid #20221d;
  border-radius: 0;
  color: #20221d;
  font: inherit;
  font-weight: 900;
  padding: 9px 10px;
  width: 100%;
}

input[type="checkbox"],
input[type="radio"] {
  appearance: none;
  background: #fdfdfb;
  border: 3px solid #20221d;
  color: #20221d;
  display: inline-grid;
  flex: 0 0 auto;
  height: 26px;
  margin: 0;
  place-content: center;
  width: 26px;
}

input[type="checkbox"]::before,
input[type="radio"]::before {
  background: #20221d;
  content: "";
  display: block;
  transform: scale(0);
  transition: transform 80ms ease-in-out;
}

input[type="checkbox"]::before {
  height: 14px;
  transform-origin: center;
  width: 14px;
}

input[type="radio"],
input[type="radio"]::before {
  border-radius: 50%;
}

input[type="radio"]::before {
  height: 12px;
  width: 12px;
}

input[type="checkbox"]:checked::before,
input[type="radio"]:checked::before {
  transform: scale(1);
}

input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 4px solid #fff2a8;
  outline-offset: 3px;
}

.input.radio_buttons,
.input.boolean {
  align-items: center;
  display: flex;
  gap: 8px;
  padding-top: 28px;

  label {
    margin-bottom: 0;
    display: flex;
    gap: 12px;
    text-wrap: nowrap;
  }
}

.part-quantity-field {
  max-width: 84px;
}

.parts-table .grain-group {
  background: #e7efe4;
}

.parts-table th.grain-group {
  background: #20221d;
}

label {
  display: block;
  font-weight: 900;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.actions,
.page-header {
  align-items: center;
  display: flex;
  gap: 12px;
}

.page-header {
  border-bottom: 5px solid #20221d;
  display: grid;
  gap: 40px 20px;
  grid-template-columns: minmax(0, 1fr) max-content;
  margin-top: 0;
  padding-bottom: 18px;
}

.page-header h1 {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.page-header__description {
  align-self: end;
  grid-column: 1;
  margin-bottom: 0;
  min-width: 0;
}

.page-header__actions {
  align-self: end;
  grid-column: 2;
  justify-self: end;
  white-space: nowrap;
}

.page-header:not(:has(.page-header__actions)) {
  grid-template-columns: minmax(0, 1fr);
}

.page-header:not(:has(.page-header__actions)) .page-header__description {
  grid-column: 1 / -1;
}

.button {
  background: #fdfdfb;
  border: 4px solid #20221d;
  border-radius: 0;
  color: #20221d;
  cursor: pointer;
  display: inline-block;
  font: inherit;
  font-weight: 900;
  padding: 9px 14px;
  text-decoration: none;
  text-transform: uppercase;
}

.button.primary {
  background: #20221d;
  border-color: #20221d;
  color: #fdfdfb;
}

.unsaved-indicator {
  background: #fff2a8;
  border: 4px solid #20221d;
  border-radius: 0;
  color: #20221d;
  font-weight: 900;
  padding: 8px 10px;
  text-transform: uppercase;
}

.field-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.job-form > .actions {
  margin-top: 28px;
}

.form-errors {
  background: #ffe5e5;
  border: 4px solid #20221d;
  border-radius: 0;
  color: #20221d;
  padding: 16px;
}

.job-list {
  display: grid;
  gap: 12px;
}

.job-list-item {
  align-items: center;
  background: #fdfdfb;
  border: 4px solid #20221d;
  border-radius: 0;
  display: flex;
  justify-content: space-between;
  padding: 16px;
}

.job-list-item__meta {
  align-items: center;
  display: flex;
  gap: 14px;
}

.kebab-menu {
  position: relative;
}

.kebab-menu summary {
  align-items: center;
  background: #fdfdfb;
  border: 3px solid #20221d;
  border-radius: 0;
  cursor: pointer;
  display: inline-flex;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  list-style: none;
  width: 34px;
}

.kebab-menu summary::-webkit-details-marker {
  display: none;
}

.kebab-menu__panel {
  background: #fdfdfb;
  border: 4px solid #20221d;
  border-radius: 0;
  box-shadow: 6px 6px 0 #20221d;
  padding: 6px;
  position: absolute;
  right: 0;
  top: 40px;
  z-index: 10;
}

.kebab-menu__item {
  background: transparent;
  border: 0;
  color: #20221d;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
  padding: 8px 12px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.export-menu {
  position: relative;
}

.export-menu__toggle {
  align-items: center;
  display: inline-flex;
  gap: 8px;
  list-style: none;
}

.export-menu__toggle::-webkit-details-marker {
  display: none;
}

.export-menu__panel {
  background: #fdfdfb;
  border: 4px solid #20221d;
  border-radius: 0;
  box-shadow: 6px 6px 0 #20221d;
  display: grid;
  min-width: 140px;
  padding: 6px;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 10;
}

.export-menu__item {
  color: #20221d;
  font-weight: 900;
  padding: 8px 12px;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.grain-control {
  display: inline-block;
}

.grain-control__button {
  align-items: center;
  background: transparent;
  border: 3px solid #20221d;
  border-radius: 0;
  cursor: pointer;
  display: inline-flex;
  height: 38px;
  justify-content: center;
  padding: 0;
  width: 38px;
}

.grain-control__button[data-value="width"],
.grain-control__button[data-value="length"] {
  background: transparent;
  border-color: #20221d;
  box-shadow: inset 0 0 0 2px #20221d;
}

.grain-control--sheet .grain-control__button {
  border-color: #20221d;
}

.grain-control--part .grain-control__button[data-value="none"] .grain-icon {
  color: #757575;
}

.grain-control--part .grain-control__button[data-value="width"] .grain-icon,
.grain-control--part .grain-control__button[data-value="length"] .grain-icon {
  color: #20221d;
}

.grain-control--sheet .grain-icon {
  color: #20221d;
}

.grain-display {
  align-items: center;
  background: transparent;
  border: 3px solid #20221d;
  color: #20221d;
  display: inline-flex;
  height: 30px;
  justify-content: center;
  width: 30px;
}

.grain-display--none {
  background: transparent;
  color: #757575;
}

.grain-display .grain-icon {
  color: inherit;
}

.grain-icon {
  color: #20221d;
  display: grid;
  gap: 3px;
  height: 22px;
  place-content: center;
  width: 22px;
}

.grain-icon[data-active="false"] {
  display: none;
}

.grain-icon--length {
  transform: rotate(90deg);
}

.grain-icon__line {
  background: currentColor;
  border-radius: 999px;
  display: block;
  height: 3px;
  width: 20px;
}

.grain-icon__none {
  border: 3px solid currentColor;
  border-radius: 999px;
  display: grid;
  height: 20px;
  place-items: center;
  width: 20px;
}

.grain-icon__none::after {
  background: currentColor;
  border-radius: 999px;
  content: "";
  display: block;
  height: 3px;
  transform: rotate(-45deg);
  width: 74%;
}

.notice,
.alert {
  background: #fdfdfb;
  border: 4px solid #20221d;
  border-radius: 0;
  font-weight: 900;
  padding: 10px 12px;
}

.alert {
  background: #ffe5e5;
  color: #20221d;
}

.layout-diagrams {
  align-items: flex-start;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
}

.layout-sheet {
  background: #fdfdfb;
  border: 4px solid #20221d;
  border-radius: 0;
  flex: 0 1 auto;
  max-width: 100%;
  padding: 16px;
  width: fit-content;
}

.layout-sheet h3 {
  text-align: center;
}

.sheet-diagram {
  display: block;
  height: auto;
  margin: 0 auto;
  max-height: min(720px, 75vh);
  max-width: 100%;
  width: min(100%, calc((min(720px, 75vh) * var(--sheet-width)) / var(--sheet-length)));
}

.sheet-diagram__sheet {
  fill: #fff;
  stroke: #20221d;
  stroke-width: 0.25;
}

.sheet-diagram__waste {
  fill: #e5e7eb;
  stroke: #cbd5df;
  stroke-width: 0.1;
}

.sheet-diagram__part {
  fill: #bfdbfe;
  stroke: #1d4ed8;
  stroke-width: 0.18;
}

.sheet-diagram__label,
.sheet-diagram__dimension {
  fill: #20221d;
  font-family: Arial, sans-serif;
  pointer-events: none;
  visibility: hidden;
}

.sheet-diagram__label {
  dominant-baseline: central;
  font-size: 2.2px;
  font-weight: 700;
  text-anchor: middle;
}

.sheet-diagram__dimension {
  font-size: 2px;
  text-anchor: middle;
}

.layout-tooltip {
  background: #20221d;
  border: 4px solid #20221d;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  line-height: 1.25;
  max-width: 240px;
  padding: 6px 8px;
  pointer-events: none;
  position: fixed;
  white-space: pre-line;
  z-index: 20;
}

@media (max-width: 720px) {
  main {
    padding-inline: 16px;
  }

  .actions,
  .job-list-item,
  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .page-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-header__actions,
  .page-header__description {
    grid-column: 1 / -1;
  }

  .page-header__actions {
    justify-self: stretch;
    white-space: normal;
  }

  .actions {
    width: 100%;
  }

  .button {
    text-align: center;
  }

  .export-menu__panel {
    left: 0;
    right: 0;
  }

  .export-menu__toggle {
    justify-content: center;
    width: 100%;
  }

  table {
    display: block;
    overflow-x: auto;
  }
}
