.popup-overlay[data-factory-popup] {
  z-index: 10002;
  padding: max(12px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: rgba(18,19,22,.48);
}
[data-factory-popup] .factory-dialog {
  width: min(720px,100%);
  min-width: 0;
  max-width: 720px;
  max-height: 90vh;
  max-height: min(90dvh, calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom) - 24px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 20px 64px #1114;
}
.factory-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: none;
  padding: 12px 18px;
  border-bottom: 1px solid #ebe7e0;
}
[data-factory-popup] .factory-dialog-head h3 {
  border: 0;
  padding: 0;
  margin: 0;
  font-size: 20px;
  line-height: 1.25;
  letter-spacing: 0;
}
.factory-close,.factory-remove {
  display: grid;
  place-items: center;
  flex: none;
  border: 0;
  border-radius: 50%;
  background: #f1efeb;
  color: #23262b;
  font: 24px/1 system-ui,sans-serif;
}
.factory-close { width: 44px; height: 44px; }
.factory-remove { width: 34px; height: 34px; justify-self: end; }
.factory-remove:disabled { opacity: .28; }
.factory-content { padding: 14px 18px; min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; }
.factory-content-form { display: flex; overflow: hidden; padding: 0; }
.factory-form { display: flex; flex-direction: column; width: 100%; min-width: 0; min-height: 0; }
.factory-form-scroll { padding: 14px 18px; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.factory-fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
.factory-fields > *, .factory-line > * { min-width: 0; }
.factory-fields .wide { grid-column: 1/-1; }
.factory-fields .popup-row { display: grid; gap: 4px; margin: 0; font-size: 13px; color: #525359; }
.factory-fields .popup-input {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  min-height: 44px;
  padding: 7px 8px;
  box-sizing: border-box;
  font-size: 16px;
  color: #202228;
  background: #f7f6f3;
  border: 1px solid #e5e0d8;
}
.factory-fields input[type=date] { display: block; -webkit-appearance: none; appearance: none; }
.factory-fields input[type=date]::-webkit-date-and-time-value { margin: 0; text-align: start; }
.factory-fields .factory-check { display: flex; align-items: center; gap: 7px; align-self: end; min-height: 44px; font-size: 13px; }
.factory-check input { accent-color: #916b38; }
.factory-block { padding: 12px; border: 1px solid #ebe7e0; border-radius: 12px; }
.factory-block h4 { margin: 0 0 8px; font-size: 15px; color: #181a20; }
.factory-section-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.factory-section-head h4 { margin-bottom: 0; }
.factory-link {
  color: #79592e;
  background: transparent;
  border: 0;
  min-height: 40px;
  padding: 0 3px;
  font-size: 13px;
  font-weight: 650;
}
.factory-help { color: #68665f; font-size: 12px; margin: 8px 0 0; }
.factory-line,.factory-line-head {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,72px) minmax(0,72px) 34px;
  gap: 6px;
  align-items: center;
}
.factory-line { padding: 6px 0; border-top: 1px solid #eeebe6; }
.factory-line-head { padding: 5px 0; color: #68665f; font-size: 12px; }
.factory-line-head span:not(:first-child),.factory-line input { text-align: center; }
.factory-line select { text-overflow: ellipsis; }
.factory-fields .factory-preferred-width { border-color: #ad8652; }
.factory-form-footer { flex: none; padding: 10px 18px; border-top: 1px solid #ebe7e0; }
.factory-form-footer [data-error] { color: #962e26; margin: 0 0 8px; font-size: 13px; }
.factory-form-footer [data-error]:empty { display: none; }
.factory-form-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.factory-form-actions output { white-space: nowrap; font-size: 13px; color: #57534c; font-variant-numeric: tabular-nums; }
[data-factory-popup] button.factory-primary {
  padding: 9px 14px;
  background: #1b1d21;
  color: #fff;
  border: 0;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 650;
  min-height: 44px;
}
.factory-primary:disabled { opacity: .55; }
.factory-optional { margin-top: 7px; }
.factory-optional summary { padding: 8px 0; color: #605b53; font-size: 13px; cursor: pointer; }
.factory-empty { text-align: center; margin: 4px 0 8px; padding: 24px 12px; border-radius: 12px; background: #f7f6f3; }
.factory-empty p { color: #68665f; font-size: 13px; margin: 8px 0 14px; }
@media (max-width: 420px) {
  .factory-dialog-head,.factory-content,.factory-form-scroll,.factory-form-footer { padding-inline: 12px; }
  .factory-block { padding: 9px; }
  .factory-line,.factory-line-head { grid-template-columns: minmax(0,1fr) 54px 54px 30px; gap: 4px; }
  .factory-remove { width: 30px; height: 32px; }
}
